Skip to content

Commit

Permalink
ref: restore missing PARM_TEX_MEMORY RenderAPI parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Oct 6, 2023
1 parent 34fa1b5 commit a738b2a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ref/gl/gl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ static int GL_RefGetParm( int parm, int arg )
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_TEX_MEMORY:
return GL_TexMemory();
case PARM_ACTIVE_TMU:
return glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
Expand Down
19 changes: 18 additions & 1 deletion ref/gl/gl_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ int GL_LoadTextureArray( const char **names, int flags )

len += ret;
}

COM_FileBase( names[i], basename, sizeof( basename ));
ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s[%i]", basename, numLayers );

Expand Down Expand Up @@ -1943,6 +1943,23 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
gEngfuncs.FS_FreeImage( pic );
}

/*
================
GL_TexMemory
return size of all uploaded textures
================
*/
int GL_TexMemory( void )
{
int i, total = 0;

for( i = 0; i < gl_numTextures; i++ )
total += gl_textures[i].size;

return total;
}

/*
==============================================================================
Expand Down
1 change: 1 addition & 0 deletions ref/gl/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ void R_InitDlightTexture( void );
void R_TextureList_f( void );
void R_InitImages( void );
void R_ShutdownImages( void );
int GL_TexMemory( void );

//
// gl_rlight.c
Expand Down
2 changes: 2 additions & 0 deletions ref/soft/r_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ static int GL_RefGetParm( int parm, int arg )
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_TEX_MEMORY:
return R_TexMemory();
case PARM_ACTIVE_TMU:
return 0; //glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
Expand Down
17 changes: 17 additions & 0 deletions ref/soft/r_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,23 @@ void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int b
gEngfuncs.FS_FreeImage( pic );
}

/*
================
R_TexMemory
return size of all uploaded textures
================
*/
int R_TexMemory( void )
{
int i, total = 0;

for( i = 0; i < r_numImages; i++ )
total += r_images[i].size;

return total;
}

/*
==============================================================================
Expand Down
2 changes: 2 additions & 0 deletions ref/soft/r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ void R_InitDlightTexture( void );
void R_TextureList_f( void );
void R_InitImages( void );
void R_ShutdownImages( void );
int R_TexMemory( void );

#if 1
//
// gl_rlight.c
Expand Down

0 comments on commit a738b2a

Please sign in to comment.