Browse Source

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

pull/2/head
Alibek Omarov 1 year ago
parent
commit
a3ab04e0cb
  1. 1
      ref/gl/gl_backend.c
  2. 2
      ref/gl/gl_image.c
  3. 1
      ref/gl/gl_local.h
  4. 2
      ref/gl/gl_rsurf.c

1
ref/gl/gl_backend.c

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

2
ref/gl/gl_image.c

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

1
ref/gl/gl_local.h

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

2
ref/gl/gl_rsurf.c

@ -803,7 +803,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale ) @@ -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;
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;
flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0;

Loading…
Cancel
Save