2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
26 #include "GUIShader.h"
27 #include "MatrixGLES.h"
28 #include "utils/log.h"
30 CGUIShader::CGUIShader( const char *shader ) : CGLSLShaderProgram("guishader_vert.glsl", shader)
47 void CGUIShader::OnCompiledAndLinked()
49 // This is called after CompileAndLink()
51 // Variables passed directly to the Fragment shader
52 m_hTex0 = glGetUniformLocation(ProgramHandle(), "m_samp0");
53 m_hTex1 = glGetUniformLocation(ProgramHandle(), "m_samp1");
54 m_hUniCol = glGetUniformLocation(ProgramHandle(), "m_unicol");
56 // Variables passed directly to the Vertex shader
57 m_hProj = glGetUniformLocation(ProgramHandle(), "m_proj");
58 m_hModel = glGetUniformLocation(ProgramHandle(), "m_model");
59 m_hPos = glGetAttribLocation(ProgramHandle(), "m_attrpos");
60 m_hCol = glGetAttribLocation(ProgramHandle(), "m_attrcol");
61 m_hCord0 = glGetAttribLocation(ProgramHandle(), "m_attrcord0");
62 m_hCord1 = glGetAttribLocation(ProgramHandle(), "m_attrcord1");
64 // It's okay to do this only one time. Textures units never change.
65 glUseProgram( ProgramHandle() );
66 glUniform1i(m_hTex0, 0);
67 glUniform1i(m_hTex1, 1);
68 glUniform4f(m_hUniCol, 1.0, 1.0, 1.0, 1.0);
72 bool CGUIShader::OnEnabled()
74 // This is called after glUseProgram()
76 glUniformMatrix4fv(m_hProj, 1, GL_FALSE, g_matrices.GetMatrix(MM_PROJECTION));
77 glUniformMatrix4fv(m_hModel, 1, GL_FALSE, g_matrices.GetMatrix(MM_MODELVIEW));
82 void CGUIShader::Free()
85 CGLSLShaderProgram::Free();