Skip to content

Commit

Permalink
Workaround for shader texture bug (issue pioneerspacesim#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Jordan committed Nov 25, 2011
1 parent a7783c5 commit 8998901
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/LmrModel.cpp
Expand Up @@ -270,9 +270,9 @@ void LmrModelClearStatsTris() { s_numTrisRendered = 0; }
void UseProgram(LmrShader *shader, bool Textured = false, bool Glowmap = false) {
if (Render::AreShadersEnabled()) {
Render::State::UseProgram(shader);
if (Textured) shader->set_tex(0);
if (Textured) shader->set_tex(1);
shader->set_usetex(Textured ? 1 : 0);
if (Glowmap) shader->set_texGlow(1);
if (Glowmap) shader->set_texGlow(2);
shader->set_useglow(Glowmap ? 1 : 0);
}
}
Expand Down Expand Up @@ -360,13 +360,18 @@ class LmrGeomBuffer {
switch (op.type) {
case OP_DRAW_ELEMENTS:
if (op.elems.texture != 0 ) {
UseProgram(curShader, true, op.elems.glowmap != 0);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
op.elems.texture->BindTexture();
if (op.elems.glowmap != 0) {
if (Render::AreShadersEnabled()) {
UseProgram(curShader, true, op.elems.glowmap != 0);
// use units 1 & 2 because of weird driver bugs
glActiveTexture(GL_TEXTURE1);
op.elems.glowmap->BindTexture();
op.elems.texture->BindTexture();
glActiveTexture(GL_TEXTURE2);
if (op.elems.glowmap != 0) op.elems.glowmap->BindTexture();
}
else {
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
op.elems.texture->BindTexture();
}
} else {
UseProgram(curShader, false);
Expand Down

0 comments on commit 8998901

Please sign in to comment.