diff --git a/ref/gl/gl_context.c b/ref/gl/gl_context.c index cd71ce43c..5e35659ca 100644 --- a/ref/gl/gl_context.c +++ b/ref/gl/gl_context.c @@ -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: diff --git a/ref/gl/gl_image.c b/ref/gl/gl_image.c index 737ba49f2..ffe9411df 100644 --- a/ref/gl/gl_image.c +++ b/ref/gl/gl_image.c @@ -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 ); @@ -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; +} + /* ============================================================================== diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index f53f4561f..bddfc307b 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -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 diff --git a/ref/soft/r_context.c b/ref/soft/r_context.c index 6ab73ae2c..ece7fb649 100644 --- a/ref/soft/r_context.c +++ b/ref/soft/r_context.c @@ -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: diff --git a/ref/soft/r_image.c b/ref/soft/r_image.c index b02437c94..933e8cf7c 100644 --- a/ref/soft/r_image.c +++ b/ref/soft/r_image.c @@ -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; +} + /* ============================================================================== diff --git a/ref/soft/r_local.h b/ref/soft/r_local.h index 7a465db12..d4e132dfa 100644 --- a/ref/soft/r_local.h +++ b/ref/soft/r_local.h @@ -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