ref: gl: track current bound texture index in gl_textures array in separate glState field

This commit is contained in:
Alibek Omarov 2023-05-16 23:44:52 +03:00
parent 7d2bf93c72
commit a3ab04e0cb
4 changed files with 5 additions and 1 deletions

View File

@ -220,6 +220,7 @@ void GL_CleanUpTextureUnits( int last )
pglDisable( glState.currentTextureTargets[i] ); pglDisable( glState.currentTextureTargets[i] );
glState.currentTextureTargets[i] = GL_NONE; glState.currentTextureTargets[i] = GL_NONE;
glState.currentTextures[i] = -1; // unbind texture glState.currentTextures[i] = -1; // unbind texture
glState.currentTexturesIndex[i] = 0;
} }
GL_SetTexCoordArrayMode( GL_NONE ); GL_SetTexCoordArrayMode( GL_NONE );

View File

@ -116,6 +116,7 @@ void GL_Bind( GLint tmu, GLenum texnum )
pglBindTexture( texture->target, texture->texnum ); pglBindTexture( texture->target, texture->texnum );
glState.currentTextures[tmu] = texture->texnum; glState.currentTextures[tmu] = texture->texnum;
glState.currentTexturesIndex[tmu] = texnum;
} }
/* /*
@ -1208,6 +1209,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
// uploading texture into video memory, change the binding // uploading texture into video memory, change the binding
glState.currentTextures[glState.activeTMU] = tex->texnum; glState.currentTextures[glState.activeTMU] = tex->texnum;
glState.currentTexturesIndex[glState.activeTMU] = tex - gl_textures;
pglBindTexture( tex->target, tex->texnum ); pglBindTexture( tex->target, tex->texnum );
for( i = 0; i < numSides; i++ ) for( i = 0; i < numSides; i++ )

View File

@ -677,6 +677,7 @@ typedef struct
int width, height; int width, height;
int activeTMU; int activeTMU;
GLint currentTextures[MAX_TEXTURE_UNITS]; GLint currentTextures[MAX_TEXTURE_UNITS];
GLint currentTexturesIndex[MAX_TEXTURE_UNITS];
GLuint currentTextureTargets[MAX_TEXTURE_UNITS]; GLuint currentTextureTargets[MAX_TEXTURE_UNITS];
GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS]; GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS];
GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R

View File

@ -803,7 +803,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
flConveyorSpeed = (e->curstate.rendercolor.g<<8|e->curstate.rendercolor.b) / 16.0f; flConveyorSpeed = (e->curstate.rendercolor.g<<8|e->curstate.rendercolor.b) / 16.0f;
if( e->curstate.rendercolor.r ) flConveyorSpeed = -flConveyorSpeed; if( e->curstate.rendercolor.r ) flConveyorSpeed = -flConveyorSpeed;
} }
texture = R_GetTexture( glState.currentTextures[glState.activeTMU] ); texture = R_GetTexture( glState.currentTexturesIndex[glState.activeTMU] );
flRate = fabs( flConveyorSpeed ) / (float)texture->srcWidth; flRate = fabs( flConveyorSpeed ) / (float)texture->srcWidth;
flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0; flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0;