From 8998901335bd46b1200bd941093590668a03bcdb Mon Sep 17 00:00:00 2001 From: John Jordan Date: Fri, 25 Nov 2011 16:46:43 +0000 Subject: [PATCH] Workaround for shader texture bug (issue #711) --- src/LmrModel.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/LmrModel.cpp b/src/LmrModel.cpp index b498126572c..da9cf1a9b8d 100644 --- a/src/LmrModel.cpp +++ b/src/LmrModel.cpp @@ -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); } } @@ -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);