diff --git a/src/video/Basic.fsh b/src/video/Basic.fsh index d59c6957..4f66497c 100644 --- a/src/video/Basic.fsh +++ b/src/video/Basic.fsh @@ -21,26 +21,7 @@ varying vec2 varTexcoord; // global alpha value uniform float aValue; -// texture switch -uniform int tex2Use; - -// Framebuffer -uniform sampler2D framebufferTexture; - -// Floating message -uniform sampler2D messageTexture; - -// Joystick axis -uniform sampler2D axisTexture; - -// Joystick buttons -uniform sampler2D buttonTexture; - -// Keyboard -uniform sampler2D kbdTexture; - -// HUD Sprouting Menus -uniform sampler2D topMenuTexture; +uniform sampler2D texture; #if __VERSION__ >= 140 #define OUTPUT_TEXTURE(TEX) \ @@ -55,19 +36,6 @@ uniform sampler2D topMenuTexture; void main(void) { - if (tex2Use == 0) { - OUTPUT_TEXTURE(framebufferTexture); - } else if (tex2Use == 1) { - OUTPUT_TEXTURE(messageTexture); - } else if (tex2Use == 2) { - OUTPUT_TEXTURE(axisTexture); - } else if (tex2Use == 3) { - OUTPUT_TEXTURE(buttonTexture); - } else if (tex2Use == 4) { - OUTPUT_TEXTURE(kbdTexture); - } else if (tex2Use == 5) { - OUTPUT_TEXTURE(topMenuTexture); - } else { - //OUTPUT_RED(); -- WTF is this failing? - } + OUTPUT_TEXTURE(texture); + //OUTPUT_RED(); -- WTF is this failing? } diff --git a/src/video/glalert.c b/src/video/glalert.c index 8d6155d8..07df9dd8 100644 --- a/src/video/glalert.c +++ b/src/video/glalert.c @@ -184,7 +184,7 @@ static void alert_render(void) { messageModel->texDirty = false; glTexImage2D(GL_TEXTURE_2D, /*level*/0, TEX_FORMAT_INTERNAL, messageModel->texWidth, messageModel->texHeight, /*border*/0, TEX_FORMAT, TEX_TYPE, messageModel->texPixels); } - glUniform1i(uniformTex2Use, TEXTURE_ID_MESSAGE); + glUniform1i(texSamplerLoc, TEXTURE_ID_MESSAGE); glhud_renderDefault(messageModel); } diff --git a/src/video/gltouchjoy.c b/src/video/gltouchjoy.c index 1c7ac596..54271d5d 100644 --- a/src/video/gltouchjoy.c +++ b/src/video/gltouchjoy.c @@ -301,7 +301,7 @@ static void gltouchjoy_render(void) { glBindBuffer(GL_ARRAY_BUFFER, axes.model->posBufferName); glBufferData(GL_ARRAY_BUFFER, axes.model->positionArraySize, axes.model->positions, GL_DYNAMIC_DRAW); } - glUniform1i(uniformTex2Use, TEXTURE_ID_TOUCHJOY_AXIS); + glUniform1i(texSamplerLoc, TEXTURE_ID_TOUCHJOY_AXIS); glhud_renderDefault(axes.model); } @@ -322,7 +322,7 @@ static void gltouchjoy_render(void) { glBindBuffer(GL_ARRAY_BUFFER, buttons.model->posBufferName); glBufferData(GL_ARRAY_BUFFER, buttons.model->positionArraySize, buttons.model->positions, GL_DYNAMIC_DRAW); } - glUniform1i(uniformTex2Use, TEXTURE_ID_TOUCHJOY_BUTTON); + glUniform1i(texSamplerLoc, TEXTURE_ID_TOUCHJOY_BUTTON); glhud_renderDefault(buttons.model); } } diff --git a/src/video/gltouchkbd.c b/src/video/gltouchkbd.c index 42d83e0a..992381fc 100644 --- a/src/video/gltouchkbd.c +++ b/src/video/gltouchkbd.c @@ -531,7 +531,7 @@ static void gltouchkbd_render(void) { glBindBuffer(GL_ARRAY_BUFFER, kbd.model->posBufferName); glBufferData(GL_ARRAY_BUFFER, kbd.model->positionArraySize, kbd.model->positions, GL_DYNAMIC_DRAW); } - glUniform1i(uniformTex2Use, TEXTURE_ID_TOUCHKBD); + glUniform1i(texSamplerLoc, TEXTURE_ID_TOUCHKBD); glhud_renderDefault(kbd.model); } } diff --git a/src/video/gltouchmenu.c b/src/video/gltouchmenu.c index 5d075301..7adba21d 100644 --- a/src/video/gltouchmenu.c +++ b/src/video/gltouchmenu.c @@ -432,7 +432,7 @@ static void gltouchmenu_render(void) { menu.model->texDirty = false; glTexImage2D(GL_TEXTURE_2D, /*level*/0, TEX_FORMAT_INTERNAL, menu.model->texWidth, menu.model->texHeight, /*border*/0, TEX_FORMAT, TEX_TYPE, menu.model->texPixels); } - glUniform1i(uniformTex2Use, TEXTURE_ID_TOUCHMENU); + glUniform1i(texSamplerLoc, TEXTURE_ID_TOUCHMENU); glhud_renderDefault(menu.model); GL_ERRLOG("gltouchmenu_render"); diff --git a/src/video/glvideo.c b/src/video/glvideo.c index 2b3f3a58..10e4aebd 100644 --- a/src/video/glvideo.c +++ b/src/video/glvideo.c @@ -32,7 +32,7 @@ static int viewportHeight = SCANHEIGHT*1.5; static int adjustedHeight = 0; #endif -GLint uniformTex2Use = UNINITIALIZED_GL; +GLint texSamplerLoc = UNINITIALIZED_GL; GLint alphaValue = UNINITIALIZED_GL; static GLint uniformMVPIdx = UNINITIALIZED_GL; static GLenum crtElementType = UNINITIALIZED_GL; @@ -436,18 +436,11 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc // Setup common program input points // /////////////////////////////////////// - GLint fbSamplerLoc = glGetUniformLocation(prgName, "framebufferTexture"); - if (fbSamplerLoc < 0) { - LOG("OOPS, no framebufferTexture shader : %d", fbSamplerLoc); + texSamplerLoc = glGetUniformLocation(prgName, "texture"); + if (texSamplerLoc < 0) { + LOG("OOPS, no framebufferTexture shader : %d", texSamplerLoc); } else { - glUniform1i(fbSamplerLoc, TEXTURE_ID_FRAMEBUFFER); - } - - GLint messageSamplerLoc = glGetUniformLocation(prgName, "messageTexture"); - if (messageSamplerLoc < 0) { - LOG("OOPS, no messageSamplerLoc shader : %d", messageSamplerLoc); - } else { - glUniform1i(messageSamplerLoc, TEXTURE_ID_MESSAGE); + glUniform1i(texSamplerLoc, TEXTURE_ID_FRAMEBUFFER); } GLint maxTextureUnits = -1; @@ -460,46 +453,11 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc LOG("GL_MAX_TEXTURE_IMAGE_UNITS : %d", maxTextureUnits); } -#if INTERFACE_TOUCH - GLint axisSamplerLoc = glGetUniformLocation(prgName, "axisTexture"); - if (axisSamplerLoc < 0) { - LOG("OOPS, no axisSamplerLoc shader : %d", axisSamplerLoc); - } else { - glUniform1i(axisSamplerLoc, TEXTURE_ID_TOUCHJOY_AXIS); - } - - GLint buttonSamplerLoc = glGetUniformLocation(prgName, "buttonTexture"); - if (buttonSamplerLoc < 0) { - LOG("OOPS, no buttonSamplerLoc shader : %d", buttonSamplerLoc); - } else { - glUniform1i(buttonSamplerLoc, TEXTURE_ID_TOUCHJOY_BUTTON); - } - - GLint kbdSamplerLoc = glGetUniformLocation(prgName, "kbdTexture"); - if (kbdSamplerLoc < 0) { - LOG("OOPS, no kbdSamplerLoc shader : %d", kbdSamplerLoc); - } else { - glUniform1i(kbdSamplerLoc, TEXTURE_ID_TOUCHKBD); - } - - GLint topMenuSamplerLoc = glGetUniformLocation(prgName, "topMenuTexture"); - if (topMenuSamplerLoc < 0) { - LOG("OOPS, no topMenuSamplerLoc shader : %d", topMenuSamplerLoc); - } else { - glUniform1i(topMenuSamplerLoc, TEXTURE_ID_TOUCHMENU); - } -#endif - uniformMVPIdx = glGetUniformLocation(prgName, "modelViewProjectionMatrix"); if (uniformMVPIdx < 0) { LOG("OOPS, no modelViewProjectionMatrix in shader : %d", uniformMVPIdx); } - uniformTex2Use = glGetUniformLocation(prgName, "tex2Use"); - if (uniformTex2Use < 0) { - LOG("OOPS, no texture selector in shader : %d", uniformTex2Use); - } - alphaValue = glGetUniformLocation(prgName, "aValue"); if (alphaValue < 0) { LOG("OOPS, no texture selector in shader : %d", alphaValue); @@ -743,7 +701,7 @@ static void gldriver_render(void) { glActiveTexture(TEXTURE_ACTIVE_FRAMEBUFFER); glBindTexture(GL_TEXTURE_2D, a2TextureName); - glUniform1i(uniformTex2Use, TEXTURE_ID_FRAMEBUFFER); + glUniform1i(texSamplerLoc, TEXTURE_ID_FRAMEBUFFER); if (wasDirty) { glTexImage2D(GL_TEXTURE_2D, /*level*/0, TEX_FORMAT_INTERNAL, SCANWIDTH, SCANHEIGHT, /*border*/0, TEX_FORMAT, TEX_TYPE, (GLvoid *)&pixels[0]); } diff --git a/src/video/glvideo.h b/src/video/glvideo.h index dfcf670b..181877c3 100644 --- a/src/video/glvideo.h +++ b/src/video/glvideo.h @@ -43,7 +43,7 @@ enum { TEXTURE_ACTIVE_MAX, }; -extern GLint uniformTex2Use; +extern GLint texSamplerLoc; extern GLint alphaValue; #endif