From 25e2c0df70708cf9ae4d950deeb2634d585cdc10 Mon Sep 17 00:00:00 2001 From: Alex Foster <123afoster@gmail.com> Date: Tue, 15 Nov 2022 22:16:26 -0800 Subject: [PATCH] move bindslottex() to renderstate for #241 --- src/engine/render/renderva.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/engine/render/renderva.cpp b/src/engine/render/renderva.cpp index f123aba47..ed00ac0c2 100644 --- a/src/engine/render/renderva.cpp +++ b/src/engine/render/renderva.cpp @@ -629,8 +629,7 @@ namespace GLuint vbuf; bool vattribs, vquery; float alphascale; - int globals, tmu; - GLuint textures[7]; + int globals; int texgenorient, texgenmillis; void disablevquery(); @@ -653,6 +652,8 @@ namespace } } private: + int tmu; + GLuint textures[7]; vec colorscale; Slot *slot; VSlot *vslot; @@ -665,6 +666,7 @@ namespace void changetexgen(int orient, Slot &slot, VSlot &vslot); void changebatchtmus(); void changeslottmus(int pass, Slot &newslot, VSlot &newvslot); + void bindslottex(int type, Texture *tex, GLenum target = GL_TEXTURE_2D); }; void renderstate::disablevbuf() @@ -971,16 +973,16 @@ namespace } } - void bindslottex(renderstate &cur, int type, Texture *tex, GLenum target = GL_TEXTURE_2D) + void renderstate::bindslottex(int type, Texture *tex, GLenum target) { - if(cur.textures[type] != tex->id) + if(textures[type] != tex->id) { - if(cur.tmu != type) + if(tmu != type) { - cur.tmu = type; + tmu = type; glActiveTexture(GL_TEXTURE0 + type); } - glBindTexture(target, cur.textures[type] = tex->id); + glBindTexture(target, textures[type] = tex->id); } } @@ -989,7 +991,7 @@ namespace Texture *diffuse = newslot.sts.empty() ? notexture : newslot.sts[0].t; if(pass==RenderPass_GBuffer || pass==RenderPass_ReflectiveShadowMap) { - bindslottex(*this, Tex_Diffuse, diffuse); + bindslottex(Tex_Diffuse, diffuse); if(pass == RenderPass_GBuffer) { @@ -1051,7 +1053,7 @@ namespace case Tex_Normal: case Tex_Glow: { - bindslottex(*this, t.type, t.t); + bindslottex(t.type, t.t); break; } }