2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-23 02:15:55 +01:00

ref_gl: fixes for MSVC

This commit is contained in:
Alibek Omarov 2019-03-20 01:20:58 +03:00
parent 7aa7f4dbbd
commit 7e08104631
3 changed files with 50 additions and 50 deletions

View File

@ -164,6 +164,43 @@ static void Mod_LoadModel( modtype_t desiredType, model_t *mod, const byte *buf,
} }
} }
void Mod_BrushUnloadTextures( model_t *mod )
{
int i;
for( i = 0; i < mod->numtextures; i++ )
{
texture_t *tx = mod->textures[i];
if( !tx || tx->gl_texturenum == tr.defaultTexture )
continue; // free slot
GL_FreeTexture( tx->gl_texturenum ); // main texture
GL_FreeTexture( tx->fb_texturenum ); // luma texture
}
}
void Mod_UnloadTextures( model_t *mod )
{
Assert( mod != NULL );
switch( mod->type )
{
case mod_studio:
Mod_StudioUnloadTextures( mod->cache.data );
break;
case mod_alias:
Mod_AliasUnloadTextures( mod->cache.data );
break;
case mod_brush:
Mod_BrushUnloadTextures( mod );
break;
case mod_sprite:
Mod_SpriteUnloadTextures( mod->cache.data );
break;
default: gEngfuncs.Host_Error( "Mod_UnloadModel: unsupported type %d\n", mod->type );
}
}
qboolean Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf ) qboolean Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf )
{ {
qboolean loaded = true; qboolean loaded = true;
@ -336,45 +373,6 @@ const byte *GL_TextureData( unsigned int texnum )
return NULL; return NULL;
} }
void Mod_BrushUnloadTextures( model_t *mod )
{
int i;
for( i = 0; i < mod->numtextures; i++ )
{
texture_t *tx = mod->textures[i];
if( !tx || tx->gl_texturenum == tr.defaultTexture )
continue; // free slot
GL_FreeTexture( tx->gl_texturenum ); // main texture
GL_FreeTexture( tx->fb_texturenum ); // luma texture
}
}
void Mod_UnloadTextures( model_t *mod )
{
int i, j;
Assert( mod != NULL );
switch( mod->type )
{
case mod_studio:
Mod_StudioUnloadTextures( mod->cache.data );
break;
case mod_alias:
Mod_AliasUnloadTextures( mod->cache.data );
break;
case mod_brush:
Mod_BrushUnloadTextures( mod );
break;
case mod_sprite:
Mod_SpriteUnloadTextures( mod->cache.data );
break;
default: gEngfuncs.Host_Error( "Mod_UnloadModel: unsupported type %d\n", mod->type );
}
}
void R_ProcessEntData( qboolean allocate ) void R_ProcessEntData( qboolean allocate )
{ {
if( !allocate ) if( !allocate )

View File

@ -34,7 +34,9 @@ GNU General Public License for more details.
#include "pm_movevars.h" #include "pm_movevars.h"
//#include "cvar.h" //#include "cvar.h"
#ifndef offsetof
#define offsetof(s,m) (size_t)&(((s *)0)->m) #define offsetof(s,m) (size_t)&(((s *)0)->m)
#endif // offsetof
#define ASSERT(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define ASSERT(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#define Assert(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define Assert(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )

View File

@ -144,9 +144,9 @@ load sprite model
*/ */
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags ) void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags )
{ {
dsprite_t *pin; const dsprite_t *pin;
short *numi = NULL; const short *numi = NULL;
dframetype_t *pframetype; const dframetype_t *pframetype;
msprite_t *psprite; msprite_t *psprite;
int i; int i;
@ -156,7 +156,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 ) if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 )
numi = NULL; numi = NULL;
else if( pin->version == SPRITE_VERSION_HL ) else if( pin->version == SPRITE_VERSION_HL )
numi = (short *)(buffer + sizeof( dsprite_hl_t )); numi = (const short *)((const byte*)buffer + sizeof( dsprite_hl_t ));
r_texFlags = texFlags; r_texFlags = texFlags;
sprite_version = pin->version; sprite_version = pin->version;
@ -168,21 +168,21 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
rgbdata_t *pal; rgbdata_t *pal;
pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 ); pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 );
pframetype = (dframetype_t *)(buffer + sizeof( dsprite_q1_t )); // pinq1 + 1 pframetype = (const dframetype_t *)((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
} }
else if( *numi == 256 ) else if( *numi == 256 )
{ {
byte *src = (byte *)(numi+1); const byte *src = (const byte *)(numi+1);
rgbdata_t *pal; rgbdata_t *pal;
// install palette // install palette
switch( psprite->texFormat ) switch( psprite->texFormat )
{ {
case SPR_INDEXALPHA: case SPR_INDEXALPHA:
pal = gEngfuncs.FS_LoadImage( "#gradient.pal", src, 768 ); pal = gEngfuncs.FS_LoadImage( "#gradient.pal", src, 768 );
break; break;
case SPR_ALPHTEST: case SPR_ALPHTEST:
pal = gEngfuncs.FS_LoadImage( "#masked.pal", src, 768 ); pal = gEngfuncs.FS_LoadImage( "#masked.pal", src, 768 );
break; break;
default: default:
@ -190,7 +190,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
break; break;
} }
pframetype = (dframetype_t *)(src + 768); pframetype = (const dframetype_t *)(src + 768);
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
} }
else else
@ -298,7 +298,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
temp.width = w; temp.width = w;
temp.height = h; temp.height = h;
temp.type = pix->type; temp.type = pix->type;
temp.flags = pix->flags; temp.flags = pix->flags;
temp.size = w * h * gEngfuncs.Image_GetPFDesc(temp.type)->bpp; temp.size = w * h * gEngfuncs.Image_GetPFDesc(temp.type)->bpp;
temp.buffer = Mem_Malloc( r_temppool, temp.size ); temp.buffer = Mem_Malloc( r_temppool, temp.size );
temp.palette = NULL; temp.palette = NULL;