Browse Source

ref: gl: turn magic skybox numbers into defined macros

pull/2/head
Alibek Omarov 1 year ago
parent
commit
1d62df0e2d
  1. 9
      ref/gl/gl_local.h
  2. 16
      ref/gl/gl_warp.c

9
ref/gl/gl_local.h

@ -105,6 +105,9 @@ extern poolhandle_t r_temppool; @@ -105,6 +105,9 @@ extern poolhandle_t r_temppool;
#define HACKS_RELATED_HLMODS // some HL-mods works differently under Xash and can't be fixed without some hacks at least at current time
#define SKYBOX_BASE_NUM 5800 // set skybox base (to let some mods load hi-res skyboxes)
#define SKYBOX_MAX_SIDES 6 // box can only have 6 sides
typedef struct gltexture_s
{
char name[256]; // game path, including extension (can be store image programs)
@ -181,8 +184,8 @@ typedef struct @@ -181,8 +184,8 @@ typedef struct
int cached_contents; // in water
int cached_waterlevel; // was in water
float skyMins[2][6];
float skyMaxs[2][6];
float skyMins[2][SKYBOX_MAX_SIDES];
float skyMaxs[2][SKYBOX_MAX_SIDES];
matrix4x4 objectMatrix; // currententity matrix
matrix4x4 worldviewMatrix; // modelview for world
@ -217,7 +220,7 @@ typedef struct @@ -217,7 +220,7 @@ typedef struct
int alphaskyTexture; // quake1 alpha-sky layer
int lightmapTextures[MAX_LIGHTMAPS];
int dlightTexture; // custom dlight texture
int skyboxTextures[6]; // skybox sides
int skyboxTextures[SKYBOX_MAX_SIDES]; // skybox sides
int cinTexture; // cinematic texture
int skytexturenum; // this not a gl_texturenum!

16
ref/gl/gl_warp.c

@ -71,7 +71,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) @@ -71,7 +71,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] )
{
// check HL-style skyboxes
num_checked_sides = 0;
for( j = 0; j < 6; j++ )
for( j = 0; j < SKYBOX_MAX_SIDES; j++ )
{
// build side name
Q_snprintf( sidename, sizeof( sidename ), "%s%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] );
@ -87,7 +87,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] ) @@ -87,7 +87,7 @@ static qboolean CheckSkybox( const char *name, char out[6][MAX_STRING] )
// check Q1-style skyboxes
num_checked_sides = 0;
for( j = 0; j < 6; j++ )
for( j = 0; j < SKYBOX_MAX_SIDES; j++ )
{
// build side name
Q_snprintf( sidename, sizeof( sidename ), "%s_%s.%s", name, r_skyBoxSuffix[j], skybox_ext[i] );
@ -294,7 +294,7 @@ void R_ClearSkyBox( void ) @@ -294,7 +294,7 @@ void R_ClearSkyBox( void )
{
int i;
for( i = 0; i < 6; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
RI.skyMins[0][i] = RI.skyMins[1][i] = 9999999.0f;
RI.skyMaxs[0][i] = RI.skyMaxs[1][i] = -9999999.0f;
@ -348,13 +348,13 @@ void R_UnloadSkybox( void ) @@ -348,13 +348,13 @@ void R_UnloadSkybox( void )
int i;
// release old skybox
for( i = 0; i < 6; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( !tr.skyboxTextures[i] ) continue;
GL_FreeTexture( tr.skyboxTextures[i] );
}
tr.skyboxbasenum = 5800; // set skybox base (to let some mods load hi-res skyboxes)
tr.skyboxbasenum = SKYBOX_BASE_NUM; // set skybox base (to let some mods load hi-res skyboxes)
memset( tr.skyboxTextures, 0, sizeof( tr.skyboxTextures ));
tr.fCustomSkybox = false;
@ -381,7 +381,7 @@ void R_DrawSkyBox( void ) @@ -381,7 +381,7 @@ void R_DrawSkyBox( void )
pglDisable( GL_ALPHA_TEST );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
for( i = 0; i < 6; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
continue;
@ -447,7 +447,7 @@ void R_SetupSky( const char *skyboxname ) @@ -447,7 +447,7 @@ void R_SetupSky( const char *skyboxname )
R_UnloadSkybox();
gEngfuncs.Con_DPrintf( "SKY: " );
for( i = 0; i < 6; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
tr.skyboxTextures[i] = GL_LoadTexture( sidenames[i], NULL, 0, TF_CLAMP|TF_SKY );
@ -632,7 +632,7 @@ void R_DrawClouds( void ) @@ -632,7 +632,7 @@ void R_DrawClouds( void )
pglDepthFunc( GL_GEQUAL );
pglDepthMask( GL_FALSE );
for( i = 0; i < 6; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
continue;

Loading…
Cancel
Save