Skip to content

Commit

Permalink
Move currenttextures to trGlobals_t
Browse files Browse the repository at this point in the history
Move it to tr so we can keep memset for glState
  • Loading branch information
VReaperV committed May 18, 2024
1 parent e6acaca commit 40ed394
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void GL_Bind( image_t *image )
texnum = tr.blackImage->texnum;
}

if ( glState.currenttextures[ glState.currenttmu ] != texnum )
if ( tr.currenttextures[ glState.currenttmu ] != texnum )
{
image->frameUsed = tr.frameCount;
glState.currenttextures[ glState.currenttmu ] = texnum;
tr.currenttextures[ glState.currenttmu ] = texnum;
glBindTexture( image->type, texnum );
}
}
Expand All @@ -69,7 +69,7 @@ void GL_Unbind( image_t *image )
{
GLimp_LogComment( "--- GL_Unbind() ---\n" );

glState.currenttextures[ glState.currenttmu ] = 0;
tr.currenttextures[ glState.currenttmu ] = 0;
glBindTexture( image->type, 0 );
}

Expand Down Expand Up @@ -180,7 +180,7 @@ void GL_BindToTMU( int unit, image_t *image )
Sys::Drop( "GL_BindToTMU: unit %i is out of range\n", unit );
}

if ( glState.currenttextures[ unit ] == texnum )
if ( tr.currenttextures[ unit ] == texnum )
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2993,7 +2993,7 @@ void R_ShutdownImages()
glDeleteTextures( 1, &image->texnum );
}

glState.currenttextures.clear();
tr.currenttextures.clear();

tr.images.clear();
tr.lightmaps.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p

GL_CheckErrors();

glState.currenttextures.resize( glConfig2.maxTextureUnits );
tr.currenttextures.resize( glConfig2.maxTextureUnits );

// initialize downstream texture units if we're running
// in a multitexture environment
Expand Down
5 changes: 3 additions & 2 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2477,8 +2477,6 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
float polygonOffsetFactor, polygonOffsetUnits;
vec2_t tileStep;

// Maximum reported is 192, see https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
std::vector<int> currenttextures;
int currenttmu;

int stackIndex;
Expand Down Expand Up @@ -2644,6 +2642,9 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };

const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load

// Maximum reported is 192, see https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
std::vector<int> currenttextures;

image_t *defaultImage;
image_t *cinematicImage[ MAX_IN_GAME_VIDEOS ];
image_t *fogImage;
Expand Down

0 comments on commit 40ed394

Please sign in to comment.