diff options
-rw-r--r-- | guilib/GUIShader.cpp | 4 | ||||
-rw-r--r-- | guilib/GUITextureGLES.cpp | 59 | ||||
-rw-r--r-- | system/shaders/guishader_frag_fonts.glsl | 2 | ||||
-rw-r--r-- | xbmc/RenderSystemGLES.cpp | 4 | ||||
-rw-r--r-- | xbmc/RenderSystemGLES.h | 3 |
5 files changed, 45 insertions, 27 deletions
diff --git a/guilib/GUIShader.cpp b/guilib/GUIShader.cpp index eb69d8c0be..bd70e5a8f0 100644 --- a/guilib/GUIShader.cpp +++ b/guilib/GUIShader.cpp @@ -59,9 +59,11 @@ void CGUIShader::OnCompiledAndLinked() m_hCord0 = glGetAttribLocation(ProgramHandle(), "m_attrcord0"); m_hCord1 = glGetAttribLocation(ProgramHandle(), "m_attrcord1"); - // it's okay to do this only one time. Textures units never change + // It's okay to do this only one time. Textures units never change. + glUseProgram( ProgramHandle() ); glUniform1i(m_hTex0, 0); glUniform1i(m_hTex1, 1); + glUseProgram( 0 ); } bool CGUIShader::OnEnabled() diff --git a/guilib/GUITextureGLES.cpp b/guilib/GUITextureGLES.cpp index 8c4bbbef57..971a136941 100644 --- a/guilib/GUITextureGLES.cpp +++ b/guilib/GUITextureGLES.cpp @@ -45,15 +45,13 @@ void CGUITextureGLES::Begin(color_t color) glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); glEnable(GL_TEXTURE_2D); - if (m_diffuse.size()) - { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject()); - glEnable(GL_TEXTURE_2D); - } - else + // Setup Colors + for (int i = 0; i < 4; i++) { - g_Windowing.EnableGUIShader(SM_TEXTURE); + m_col[i][0] = (GLubyte)GET_R(color); + m_col[i][1] = (GLubyte)GET_G(color); + m_col[i][2] = (GLubyte)GET_B(color); + m_col[i][3] = (GLubyte)GET_A(color); } GLint posLoc = g_Windowing.GUIShaderGetPos(); @@ -68,39 +66,54 @@ void CGUITextureGLES::Begin(color_t color) glEnableVertexAttribArray(colLoc); glEnableVertexAttribArray(tex0Loc); - // Setup Colors - for (int i = 0; i < 4; i++) - { - m_col[i][0] = (GLubyte)GET_R(color); - m_col[i][1] = (GLubyte)GET_G(color); - m_col[i][2] = (GLubyte)GET_B(color); - m_col[i][3] = (GLubyte)GET_A(color); - } + bool hasAlpha = m_texture.m_textures[m_currentFrame]->HasAlpha() || m_col[0][3] < 255; if (m_diffuse.size()) { + if (m_col[0][0] == 255 && m_col[0][1] == 255 && m_col[0][2] == 255 && m_col[0][3] == 255 ) + { + g_Windowing.EnableGUIShader(SM_MULTI); + } + else + { + g_Windowing.EnableGUIShader(SM_MULTI_BLENDCOLOR); + } + + hasAlpha |= m_diffuse.m_textures[0]->HasAlpha(); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject()); + glEnable(GL_TEXTURE_2D); + GLint tex1Loc = g_Windowing.GUIShaderGetCoord1(); glVertexAttribPointer(tex1Loc, 2, GL_FLOAT, 0, 0, m_tex1); glEnableVertexAttribArray(tex1Loc); - glEnable( GL_BLEND ); - g_Windowing.EnableGUIShader(SM_MULTI); + + hasAlpha = true; } else { - CBaseTexture* textureObject = m_texture.m_textures[m_currentFrame]; - if (textureObject->HasAlpha() || m_col[0][3] < 255 ) + if ( hasAlpha ) { - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); // Turn Blending On g_Windowing.EnableGUIShader(SM_TEXTURE); } else { - glDisable(GL_BLEND); g_Windowing.EnableGUIShader(SM_TEXTURE_NOBLEND); } } + + if ( hasAlpha ) + { + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glEnable( GL_BLEND ); + } + else + { + glDisable(GL_BLEND); + } + } void CGUITextureGLES::End() diff --git a/system/shaders/guishader_frag_fonts.glsl b/system/shaders/guishader_frag_fonts.glsl index 24e356a303..150f33ec18 100644 --- a/system/shaders/guishader_frag_fonts.glsl +++ b/system/shaders/guishader_frag_fonts.glsl @@ -30,5 +30,5 @@ void main () gl_FragColor.r = m_colour.r; gl_FragColor.g = m_colour.g; gl_FragColor.b = m_colour.b; - gl_FragColor.a = texture2D(m_samp0, m_cord0.xy).a; + gl_FragColor.a = m_colour.a * texture2D(m_samp0, m_cord0.xy).a; } diff --git a/xbmc/RenderSystemGLES.cpp b/xbmc/RenderSystemGLES.cpp index 6a8fa9e159..be108413a6 100644 --- a/xbmc/RenderSystemGLES.cpp +++ b/xbmc/RenderSystemGLES.cpp @@ -37,7 +37,9 @@ static const char* ShaderNames[SM_ESHADERCOUNT] = "guishader_frag_texture.glsl", "guishader_frag_multi.glsl", "guishader_frag_fonts.glsl", - "guishader_frag_texture_noblend.glsl"}; + "guishader_frag_texture_noblend.glsl", + "guishader_frag_multi_blendcolor.glsl" + }; CRenderSystemGLES::CRenderSystemGLES() : CRenderSystemBase() diff --git a/xbmc/RenderSystemGLES.h b/xbmc/RenderSystemGLES.h index 0bff1c5298..f2a5fdd96a 100644 --- a/xbmc/RenderSystemGLES.h +++ b/xbmc/RenderSystemGLES.h @@ -34,7 +34,8 @@ enum ESHADERMETHOD SM_MULTI, SM_FONTS, SM_TEXTURE_NOBLEND, - SM_ESHADERCOUNT + SM_MULTI_BLENDCOLOR, + SM_ESHADERCOUNT, }; class CRenderSystemGLES : public CRenderSystemBase |