From f91d66a0e070760d0a824f84e4608ecb241d6f62 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Wed, 25 May 2022 01:05:52 +0200 Subject: [PATCH] bind texture only when we're really about to render --- BBGE/RenderObject.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index bd96dd1..e56bfa7 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -560,27 +560,27 @@ void RenderObject::renderCall(const RenderState& rs) const (*i)->render(rs); } - if (texture) - { - if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat) - { - texture->apply(repeatTexture); - lastTextureRepeat = repeatTexture; - lastTextureApplied = texture->textures[0]; - } - } - else - { - if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat) - { - glBindTexture(GL_TEXTURE_2D, 0); - lastTextureApplied = 0; - lastTextureRepeat = repeatTexture; - } - } - if (rs.pass == RENDER_ALL || rs.pass == renderPass) { + if (texture) + { + if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat) + { + texture->apply(repeatTexture); + lastTextureRepeat = repeatTexture; + lastTextureApplied = texture->textures[0]; + } + } + else + { + if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat) + { + glBindTexture(GL_TEXTURE_2D, 0); + lastTextureApplied = 0; + lastTextureRepeat = repeatTexture; + } + } + // RenderState color applies to everything in the scene graph, // so that needs to be multiplied in unconditionally {