mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-03-06 01:22:06 +00:00
Füge Multitexturing ein. Dies funktioniert (natürlich) nicht mir Mesa3D
This commit is contained in:
parent
beb16e08f4
commit
6847b33cb5
6 changed files with 477 additions and 75 deletions
|
@ -75,6 +75,7 @@ typedef struct
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *strlwr ( char *s );
|
char *strlwr ( char *s );
|
||||||
|
|
||||||
extern viddef_t vid;
|
extern viddef_t vid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -246,6 +247,8 @@ void R_TranslatePlayerSkin ( int playernum );
|
||||||
void R_Bind ( int texnum );
|
void R_Bind ( int texnum );
|
||||||
void R_MBind ( GLenum target, int texnum );
|
void R_MBind ( GLenum target, int texnum );
|
||||||
void R_TexEnv ( GLenum value );
|
void R_TexEnv ( GLenum value );
|
||||||
|
void R_EnableMultitexture ( qboolean enable );
|
||||||
|
void R_SelectTexture ( GLenum );
|
||||||
|
|
||||||
void R_LightPoint ( vec3_t p, vec3_t color );
|
void R_LightPoint ( vec3_t p, vec3_t color );
|
||||||
void R_PushDlights ( void );
|
void R_PushDlights ( void );
|
||||||
|
@ -370,7 +373,7 @@ typedef struct
|
||||||
int allocated [ BLOCK_WIDTH ];
|
int allocated [ BLOCK_WIDTH ];
|
||||||
|
|
||||||
/* the lightmap texture data needs to be kept in
|
/* the lightmap texture data needs to be kept in
|
||||||
main memory so texsubimage can update properly */
|
* main memory so texsubimage can update properly */
|
||||||
byte lightmap_buffer [ 4 * BLOCK_WIDTH * BLOCK_HEIGHT ];
|
byte lightmap_buffer [ 4 * BLOCK_WIDTH * BLOCK_HEIGHT ];
|
||||||
} gllightmapstate_t;
|
} gllightmapstate_t;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
|
|
||||||
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
|
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
|
||||||
|
|
||||||
|
#define GL_TEXTURE0_SGIS 0x835E
|
||||||
|
#define GL_TEXTURE1_SGIS 0x835F
|
||||||
|
|
||||||
qboolean QGL_Init ( const char *dllname );
|
qboolean QGL_Init ( const char *dllname );
|
||||||
void QGL_Shutdown ( void );
|
void QGL_Shutdown ( void );
|
||||||
|
|
||||||
|
@ -391,12 +394,19 @@ extern void ( APIENTRY *qglPointParameterfvEXT )( GLenum param, const GLfloat *v
|
||||||
extern void ( APIENTRY *qglColorTableEXT )( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * );
|
extern void ( APIENTRY *qglColorTableEXT )( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * );
|
||||||
|
|
||||||
extern void ( APIENTRY *qglLockArraysEXT )( int, int );
|
extern void ( APIENTRY *qglLockArraysEXT )( int, int );
|
||||||
|
|
||||||
extern void ( APIENTRY *qglUnlockArraysEXT )( void );
|
extern void ( APIENTRY *qglUnlockArraysEXT )( void );
|
||||||
|
extern void ( APIENTRY *qglMTexCoord2fSGIS )( GLenum, GLfloat, GLfloat );
|
||||||
|
extern void ( APIENTRY *qglSelectTextureSGIS )( GLenum );
|
||||||
|
|
||||||
|
extern void ( APIENTRY *qglActiveTextureARB )( GLenum );
|
||||||
|
extern void ( APIENTRY *qglClientActiveTextureARB )( GLenum );
|
||||||
|
|
||||||
/* local function in dll */
|
/* local function in dll */
|
||||||
extern void *qwglGetProcAddress ( char *symbol );
|
extern void *qwglGetProcAddress ( char *symbol );
|
||||||
|
|
||||||
void Fake_glColorTableEXT ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table );
|
void Fake_glColorTableEXT ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table );
|
||||||
|
|
||||||
extern int QGL_TEXTURE0, QGL_TEXTURE1;
|
extern int QGL_TEXTURE0, QGL_TEXTURE1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,6 +127,68 @@ typedef struct
|
||||||
int upload_width, upload_height;
|
int upload_width, upload_height;
|
||||||
qboolean uploaded_paletted;
|
qboolean uploaded_paletted;
|
||||||
|
|
||||||
|
void
|
||||||
|
R_EnableMultitexture ( qboolean enable )
|
||||||
|
{
|
||||||
|
if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( enable )
|
||||||
|
{
|
||||||
|
R_SelectTexture( QGL_TEXTURE1 );
|
||||||
|
qglEnable( GL_TEXTURE_2D );
|
||||||
|
R_TexEnv( GL_REPLACE );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
R_SelectTexture( QGL_TEXTURE1 );
|
||||||
|
qglDisable( GL_TEXTURE_2D );
|
||||||
|
R_TexEnv( GL_REPLACE );
|
||||||
|
}
|
||||||
|
|
||||||
|
R_SelectTexture( QGL_TEXTURE0 );
|
||||||
|
R_TexEnv( GL_REPLACE );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_SelectTexture ( GLenum texture )
|
||||||
|
{
|
||||||
|
int tmu;
|
||||||
|
|
||||||
|
if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( texture == QGL_TEXTURE0 )
|
||||||
|
{
|
||||||
|
tmu = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmu = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( tmu == gl_state.currenttmu )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_state.currenttmu = tmu;
|
||||||
|
|
||||||
|
if ( qglSelectTextureSGIS )
|
||||||
|
{
|
||||||
|
qglSelectTextureSGIS( texture );
|
||||||
|
}
|
||||||
|
else if ( qglActiveTextureARB )
|
||||||
|
{
|
||||||
|
qglActiveTextureARB( texture );
|
||||||
|
qglClientActiveTextureARB( texture );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_TexEnv ( GLenum mode )
|
R_TexEnv ( GLenum mode )
|
||||||
{
|
{
|
||||||
|
@ -161,6 +223,8 @@ R_Bind ( int texnum )
|
||||||
void
|
void
|
||||||
R_MBind ( GLenum target, int texnum )
|
R_MBind ( GLenum target, int texnum )
|
||||||
{
|
{
|
||||||
|
R_SelectTexture( target );
|
||||||
|
|
||||||
if ( target == QGL_TEXTURE0 )
|
if ( target == QGL_TEXTURE0 )
|
||||||
{
|
{
|
||||||
if ( gl_state.currenttextures [ 0 ] == texnum )
|
if ( gl_state.currenttextures [ 0 ] == texnum )
|
||||||
|
@ -693,7 +757,7 @@ R_Upload8 ( byte *data, int width, int height, qboolean mipmap, qboolean is_sky
|
||||||
trans [ i ] = d_8to24table [ p ];
|
trans [ i ] = d_8to24table [ p ];
|
||||||
|
|
||||||
/* transparent, so scan around for another color
|
/* transparent, so scan around for another color
|
||||||
to avoid alpha fringes */
|
* to avoid alpha fringes */
|
||||||
if ( p == 255 )
|
if ( p == 255 )
|
||||||
{
|
{
|
||||||
if ( ( i > width ) && ( data [ i - width ] != 255 ) )
|
if ( ( i > width ) && ( data [ i - width ] != 255 ) )
|
||||||
|
|
|
@ -257,8 +257,11 @@ LM_BeginBuildingLightmaps ( model_t *m )
|
||||||
|
|
||||||
r_framecount = 1; /* no dlightcache */
|
r_framecount = 1; /* no dlightcache */
|
||||||
|
|
||||||
|
R_EnableMultitexture( true );
|
||||||
|
R_SelectTexture( QGL_TEXTURE1 );
|
||||||
|
|
||||||
/* setup the base lightstyles so the lightmaps won't have to be regenerated
|
/* setup the base lightstyles so the lightmaps won't have to be regenerated
|
||||||
the first time they're seen */
|
* the first time they're seen */
|
||||||
for ( i = 0; i < MAX_LIGHTSTYLES; i++ )
|
for ( i = 0; i < MAX_LIGHTSTYLES; i++ )
|
||||||
{
|
{
|
||||||
lightstyles [ i ].rgb [ 0 ] = 1;
|
lightstyles [ i ].rgb [ 0 ] = 1;
|
||||||
|
@ -295,5 +298,6 @@ void
|
||||||
LM_EndBuildingLightmaps ( void )
|
LM_EndBuildingLightmaps ( void )
|
||||||
{
|
{
|
||||||
LM_UploadBlock( false );
|
LM_UploadBlock( false );
|
||||||
|
R_EnableMultitexture( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ cvar_t *gl_particle_att_b;
|
||||||
cvar_t *gl_particle_att_c;
|
cvar_t *gl_particle_att_c;
|
||||||
|
|
||||||
cvar_t *gl_ext_swapinterval;
|
cvar_t *gl_ext_swapinterval;
|
||||||
|
cvar_t *gl_ext_multitexture;
|
||||||
cvar_t *gl_ext_pointparameters;
|
cvar_t *gl_ext_pointparameters;
|
||||||
cvar_t *gl_ext_compiled_vertex_array;
|
cvar_t *gl_ext_compiled_vertex_array;
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ R_DrawSpriteModel ( entity_t *e )
|
||||||
dsprite_t *psprite;
|
dsprite_t *psprite;
|
||||||
|
|
||||||
/* don't even bother culling, because it's just a single
|
/* don't even bother culling, because it's just a single
|
||||||
polygon without a surface cache */
|
* polygon without a surface cache */
|
||||||
psprite = (dsprite_t *) currentmodel->extradata;
|
psprite = (dsprite_t *) currentmodel->extradata;
|
||||||
|
|
||||||
e->frame %= psprite->numframes;
|
e->frame %= psprite->numframes;
|
||||||
|
@ -370,8 +371,8 @@ R_DrawEntitiesOnList ( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw transparent entities
|
/* draw transparent entities
|
||||||
we could sort these if it ever
|
* we could sort these if it ever
|
||||||
becomes a problem... */
|
* becomes a problem... */
|
||||||
qglDepthMask( 0 ); /* no z writes */
|
qglDepthMask( 0 ); /* no z writes */
|
||||||
|
|
||||||
for ( i = 0; i < r_newrefdef.num_entities; i++ )
|
for ( i = 0; i < r_newrefdef.num_entities; i++ )
|
||||||
|
@ -892,7 +893,7 @@ R_SetLightLevel ( void )
|
||||||
R_LightPoint( r_newrefdef.vieworg, shadelight );
|
R_LightPoint( r_newrefdef.vieworg, shadelight );
|
||||||
|
|
||||||
/* pick the greatest component, which should be the same
|
/* pick the greatest component, which should be the same
|
||||||
as the mono value returned by software */
|
* as the mono value returned by software */
|
||||||
if ( shadelight [ 0 ] > shadelight [ 1 ] )
|
if ( shadelight [ 0 ] > shadelight [ 1 ] )
|
||||||
{
|
{
|
||||||
if ( shadelight [ 0 ] > shadelight [ 2 ] )
|
if ( shadelight [ 0 ] > shadelight [ 2 ] )
|
||||||
|
@ -979,6 +980,7 @@ R_Register ( void )
|
||||||
gl_vertex_arrays = ri.Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
|
gl_vertex_arrays = ri.Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
|
||||||
|
|
||||||
gl_ext_swapinterval = ri.Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
|
gl_ext_swapinterval = ri.Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
|
||||||
|
gl_ext_multitexture = ri.Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE );
|
||||||
gl_ext_pointparameters = ri.Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
|
gl_ext_pointparameters = ri.Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
|
||||||
gl_ext_compiled_vertex_array = ri.Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
|
gl_ext_compiled_vertex_array = ri.Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
|
||||||
|
|
||||||
|
@ -1012,7 +1014,7 @@ R_SetMode ( void )
|
||||||
gl_mode->modified = false;
|
gl_mode->modified = false;
|
||||||
|
|
||||||
/* a bit hackish approach to enable custom resolutions:
|
/* a bit hackish approach to enable custom resolutions:
|
||||||
Glimp_SetMode needs these values set for mode -1 */
|
* Glimp_SetMode needs these values set for mode -1 */
|
||||||
vid.width = gl_customwidth->value;
|
vid.width = gl_customwidth->value;
|
||||||
vid.height = gl_customheight->value;
|
vid.height = gl_customheight->value;
|
||||||
|
|
||||||
|
@ -1146,8 +1148,7 @@ R_Init ( void *hinstance, void *hWnd )
|
||||||
if ( gl_ext_pointparameters->value )
|
if ( gl_ext_pointparameters->value )
|
||||||
{
|
{
|
||||||
qglPointParameterfEXT = ( void (APIENTRY *) ( GLenum, GLfloat ) )qwglGetProcAddress( "glPointParameterfEXT" );
|
qglPointParameterfEXT = ( void (APIENTRY *) ( GLenum, GLfloat ) )qwglGetProcAddress( "glPointParameterfEXT" );
|
||||||
qglPointParameterfvEXT = ( void (APIENTRY *) ( GLenum, const GLfloat * ) )qwglGetProcAddress(
|
qglPointParameterfvEXT = ( void (APIENTRY *) ( GLenum, const GLfloat * ) )qwglGetProcAddress( "glPointParameterfvEXT" );
|
||||||
"glPointParameterfvEXT" );
|
|
||||||
ri.Con_Printf( PRINT_ALL, "...using GL_EXT_point_parameters\n" );
|
ri.Con_Printf( PRINT_ALL, "...using GL_EXT_point_parameters\n" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1160,6 +1161,51 @@ R_Init ( void *hinstance, void *hWnd )
|
||||||
ri.Con_Printf( PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
|
ri.Con_Printf( PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( strstr( gl_config.extensions_string, "GL_ARB_multitexture" ) )
|
||||||
|
{
|
||||||
|
if ( gl_ext_multitexture->value )
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...using GL_ARB_multitexture\n" );
|
||||||
|
qglMTexCoord2fSGIS = (void *) qwglGetProcAddress( "glMultiTexCoord2fARB" );
|
||||||
|
qglActiveTextureARB = (void *) qwglGetProcAddress( "glActiveTextureARB" );
|
||||||
|
qglClientActiveTextureARB = (void *) qwglGetProcAddress( "glClientActiveTextureARB" );
|
||||||
|
QGL_TEXTURE0 = GL_TEXTURE0_ARB;
|
||||||
|
QGL_TEXTURE1 = GL_TEXTURE1_ARB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...ignoring GL_ARB_multitexture\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...GL_ARB_multitexture not found\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( strstr( gl_config.extensions_string, "GL_SGIS_multitexture" ) )
|
||||||
|
{
|
||||||
|
if ( qglActiveTextureARB )
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...GL_SGIS_multitexture deprecated in favor of ARB_multitexture\n" );
|
||||||
|
}
|
||||||
|
else if ( gl_ext_multitexture->value )
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...using GL_SGIS_multitexture\n" );
|
||||||
|
qglMTexCoord2fSGIS = (void *) qwglGetProcAddress( "glMTexCoord2fSGIS" );
|
||||||
|
qglSelectTextureSGIS = (void *) qwglGetProcAddress( "glSelectTextureSGIS" );
|
||||||
|
QGL_TEXTURE0 = GL_TEXTURE0_SGIS;
|
||||||
|
QGL_TEXTURE1 = GL_TEXTURE1_SGIS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...ignoring GL_SGIS_multitexture\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ri.Con_Printf( PRINT_ALL, "...GL_SGIS_multitexture not found\n" );
|
||||||
|
}
|
||||||
|
|
||||||
R_SetDefaultState();
|
R_SetDefaultState();
|
||||||
|
|
||||||
R_InitImages();
|
R_InitImages();
|
||||||
|
|
|
@ -229,7 +229,7 @@ R_BlendLightmaps ( void )
|
||||||
qglDepthMask( 0 );
|
qglDepthMask( 0 );
|
||||||
|
|
||||||
/* set the appropriate blending mode unless
|
/* set the appropriate blending mode unless
|
||||||
we're only looking at the lightmaps. */
|
* we're only looking at the lightmaps. */
|
||||||
if ( !gl_lightmap->value )
|
if ( !gl_lightmap->value )
|
||||||
{
|
{
|
||||||
qglEnable( GL_BLEND );
|
qglEnable( GL_BLEND );
|
||||||
|
@ -478,7 +478,7 @@ R_DrawAlphaSurfaces ( void )
|
||||||
R_TexEnv( GL_MODULATE );
|
R_TexEnv( GL_MODULATE );
|
||||||
|
|
||||||
/* the textures are prescaled up for a better lighting range,
|
/* the textures are prescaled up for a better lighting range,
|
||||||
so scale it back down */
|
* so scale it back down */
|
||||||
intens = gl_state.inverse_intensity;
|
intens = gl_state.inverse_intensity;
|
||||||
|
|
||||||
for ( s = r_alpha_surfaces; s; s = s->texturechain )
|
for ( s = r_alpha_surfaces; s; s = s->texturechain )
|
||||||
|
@ -529,6 +529,8 @@ R_DrawTextureChains ( void )
|
||||||
|
|
||||||
c_visible_textures = 0;
|
c_visible_textures = 0;
|
||||||
|
|
||||||
|
if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
|
||||||
|
{
|
||||||
for ( i = 0, image = gltextures; i < numgltextures; i++, image++ )
|
for ( i = 0, image = gltextures; i < numgltextures; i++, image++ )
|
||||||
{
|
{
|
||||||
if ( !image->registration_sequence )
|
if ( !image->registration_sequence )
|
||||||
|
@ -552,10 +554,238 @@ R_DrawTextureChains ( void )
|
||||||
|
|
||||||
image->texturechain = NULL;
|
image->texturechain = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( i = 0, image = gltextures; i < numgltextures; i++, image++ )
|
||||||
|
{
|
||||||
|
if ( !image->registration_sequence )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !image->texturechain )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
c_visible_textures++;
|
||||||
|
|
||||||
|
for ( s = image->texturechain; s; s = s->texturechain )
|
||||||
|
{
|
||||||
|
if ( !( s->flags & SURF_DRAWTURB ) )
|
||||||
|
{
|
||||||
|
R_RenderBrushPoly( s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
R_EnableMultitexture( false );
|
||||||
|
|
||||||
|
for ( i = 0, image = gltextures; i < numgltextures; i++, image++ )
|
||||||
|
{
|
||||||
|
if ( !image->registration_sequence )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = image->texturechain;
|
||||||
|
|
||||||
|
if ( !s )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ; s; s = s->texturechain )
|
||||||
|
{
|
||||||
|
if ( s->flags & SURF_DRAWTURB )
|
||||||
|
{
|
||||||
|
R_RenderBrushPoly( s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image->texturechain = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
R_TexEnv( GL_REPLACE );
|
R_TexEnv( GL_REPLACE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
R_RenderLightmappedPoly ( msurface_t *surf )
|
||||||
|
{
|
||||||
|
int i, nv = surf->polys->numverts;
|
||||||
|
int map;
|
||||||
|
float *v;
|
||||||
|
image_t *image = R_TextureAnimation( surf->texinfo );
|
||||||
|
qboolean is_dynamic = false;
|
||||||
|
unsigned lmtex = surf->lightmaptexturenum;
|
||||||
|
glpoly_t *p;
|
||||||
|
|
||||||
|
for ( map = 0; map < MAXLIGHTMAPS && surf->styles [ map ] != 255; map++ )
|
||||||
|
{
|
||||||
|
if ( r_newrefdef.lightstyles [ surf->styles [ map ] ].white != surf->cached_light [ map ] )
|
||||||
|
{
|
||||||
|
goto dynamic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( surf->dlightframe == r_framecount ) )
|
||||||
|
{
|
||||||
|
dynamic:
|
||||||
|
|
||||||
|
if ( gl_dynamic->value )
|
||||||
|
{
|
||||||
|
if ( !( surf->texinfo->flags & ( SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP ) ) )
|
||||||
|
{
|
||||||
|
is_dynamic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_dynamic )
|
||||||
|
{
|
||||||
|
unsigned temp [ 128 * 128 ];
|
||||||
|
int smax, tmax;
|
||||||
|
|
||||||
|
if ( ( ( surf->styles [ map ] >= 32 ) || ( surf->styles [ map ] == 0 ) ) && ( surf->dlightframe != r_framecount ) )
|
||||||
|
{
|
||||||
|
smax = ( surf->extents [ 0 ] >> 4 ) + 1;
|
||||||
|
tmax = ( surf->extents [ 1 ] >> 4 ) + 1;
|
||||||
|
|
||||||
|
R_BuildLightMap( surf, (void *) temp, smax * 4 );
|
||||||
|
R_SetCacheState( surf );
|
||||||
|
|
||||||
|
R_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + surf->lightmaptexturenum );
|
||||||
|
|
||||||
|
lmtex = surf->lightmaptexturenum;
|
||||||
|
|
||||||
|
qglTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||||
|
surf->light_s, surf->light_t,
|
||||||
|
smax, tmax,
|
||||||
|
GL_LIGHTMAP_FORMAT,
|
||||||
|
GL_UNSIGNED_BYTE, temp );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
smax = ( surf->extents [ 0 ] >> 4 ) + 1;
|
||||||
|
tmax = ( surf->extents [ 1 ] >> 4 ) + 1;
|
||||||
|
|
||||||
|
R_BuildLightMap( surf, (void *) temp, smax * 4 );
|
||||||
|
|
||||||
|
R_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + 0 );
|
||||||
|
|
||||||
|
lmtex = 0;
|
||||||
|
|
||||||
|
qglTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||||
|
surf->light_s, surf->light_t,
|
||||||
|
smax, tmax,
|
||||||
|
GL_LIGHTMAP_FORMAT,
|
||||||
|
GL_UNSIGNED_BYTE, temp );
|
||||||
|
}
|
||||||
|
|
||||||
|
c_brush_polys++;
|
||||||
|
|
||||||
|
R_MBind( QGL_TEXTURE0, image->texnum );
|
||||||
|
R_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex );
|
||||||
|
|
||||||
|
if ( surf->texinfo->flags & SURF_FLOWING )
|
||||||
|
{
|
||||||
|
float scroll;
|
||||||
|
|
||||||
|
scroll = -64 * ( ( r_newrefdef.time / 40.0 ) - (int) ( r_newrefdef.time / 40.0 ) );
|
||||||
|
|
||||||
|
if ( scroll == 0.0 )
|
||||||
|
{
|
||||||
|
scroll = -64.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( p = surf->polys; p; p = p->chain )
|
||||||
|
{
|
||||||
|
v = p->verts [ 0 ];
|
||||||
|
qglBegin( GL_POLYGON );
|
||||||
|
|
||||||
|
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
|
||||||
|
{
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE0, ( v [ 3 ] + scroll ), v [ 4 ] );
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE1, v [ 5 ], v [ 6 ] );
|
||||||
|
qglVertex3fv( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
qglEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( p = surf->polys; p; p = p->chain )
|
||||||
|
{
|
||||||
|
v = p->verts [ 0 ];
|
||||||
|
qglBegin( GL_POLYGON );
|
||||||
|
|
||||||
|
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
|
||||||
|
{
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE0, v [ 3 ], v [ 4 ] );
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE1, v [ 5 ], v [ 6 ] );
|
||||||
|
qglVertex3fv( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
qglEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c_brush_polys++;
|
||||||
|
|
||||||
|
R_MBind( QGL_TEXTURE0, image->texnum );
|
||||||
|
R_MBind( QGL_TEXTURE1, gl_state.lightmap_textures + lmtex );
|
||||||
|
|
||||||
|
if ( surf->texinfo->flags & SURF_FLOWING )
|
||||||
|
{
|
||||||
|
float scroll;
|
||||||
|
|
||||||
|
scroll = -64 * ( ( r_newrefdef.time / 40.0 ) - (int) ( r_newrefdef.time / 40.0 ) );
|
||||||
|
|
||||||
|
if ( scroll == 0.0 )
|
||||||
|
{
|
||||||
|
scroll = -64.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( p = surf->polys; p; p = p->chain )
|
||||||
|
{
|
||||||
|
v = p->verts [ 0 ];
|
||||||
|
qglBegin( GL_POLYGON );
|
||||||
|
|
||||||
|
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
|
||||||
|
{
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE0, ( v [ 3 ] + scroll ), v [ 4 ] );
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE1, v [ 5 ], v [ 6 ] );
|
||||||
|
qglVertex3fv( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
qglEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( p = surf->polys; p; p = p->chain )
|
||||||
|
{
|
||||||
|
v = p->verts [ 0 ];
|
||||||
|
qglBegin( GL_POLYGON );
|
||||||
|
|
||||||
|
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
|
||||||
|
{
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE0, v [ 3 ], v [ 4 ] );
|
||||||
|
qglMTexCoord2fSGIS( QGL_TEXTURE1, v [ 5 ], v [ 6 ] );
|
||||||
|
qglVertex3fv( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
qglEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_DrawInlineBModel ( void )
|
R_DrawInlineBModel ( void )
|
||||||
{
|
{
|
||||||
|
@ -603,17 +833,26 @@ R_DrawInlineBModel ( void )
|
||||||
psurf->texturechain = r_alpha_surfaces;
|
psurf->texturechain = r_alpha_surfaces;
|
||||||
r_alpha_surfaces = psurf;
|
r_alpha_surfaces = psurf;
|
||||||
}
|
}
|
||||||
|
else if ( qglMTexCoord2fSGIS && !( psurf->flags & SURF_DRAWTURB ) )
|
||||||
|
{
|
||||||
|
R_RenderLightmappedPoly( psurf );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
R_EnableMultitexture( false );
|
||||||
R_RenderBrushPoly( psurf );
|
R_RenderBrushPoly( psurf );
|
||||||
|
R_EnableMultitexture( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !( currententity->flags & RF_TRANSLUCENT ) )
|
if ( !( currententity->flags & RF_TRANSLUCENT ) )
|
||||||
|
{
|
||||||
|
if ( !qglMTexCoord2fSGIS )
|
||||||
{
|
{
|
||||||
R_BlendLightmaps();
|
R_BlendLightmaps();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qglDisable( GL_BLEND );
|
qglDisable( GL_BLEND );
|
||||||
|
@ -683,10 +922,14 @@ R_DrawBrushModel ( entity_t *e )
|
||||||
e->angles [ 0 ] = -e->angles [ 0 ];
|
e->angles [ 0 ] = -e->angles [ 0 ];
|
||||||
e->angles [ 2 ] = -e->angles [ 2 ];
|
e->angles [ 2 ] = -e->angles [ 2 ];
|
||||||
|
|
||||||
|
R_EnableMultitexture( true );
|
||||||
|
R_SelectTexture( QGL_TEXTURE0 );
|
||||||
R_TexEnv( GL_REPLACE );
|
R_TexEnv( GL_REPLACE );
|
||||||
|
R_SelectTexture( QGL_TEXTURE1 );
|
||||||
R_TexEnv( GL_MODULATE );
|
R_TexEnv( GL_MODULATE );
|
||||||
|
|
||||||
R_DrawInlineBModel();
|
R_DrawInlineBModel();
|
||||||
|
R_EnableMultitexture( false );
|
||||||
|
|
||||||
qglPopMatrix();
|
qglPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -747,7 +990,7 @@ R_RecursiveWorldNode ( mnode_t *node )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* node is just a decision point, so go down the apropriate sides
|
/* node is just a decision point, so go down the apropriate sides
|
||||||
find which side of the node we are on */
|
* find which side of the node we are on */
|
||||||
plane = node->plane;
|
plane = node->plane;
|
||||||
|
|
||||||
switch ( plane->type )
|
switch ( plane->type )
|
||||||
|
@ -806,12 +1049,19 @@ R_RecursiveWorldNode ( mnode_t *node )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* the polygon is visible, so add it to the texture */
|
if ( qglMTexCoord2fSGIS && !( surf->flags & SURF_DRAWTURB ) )
|
||||||
|
{
|
||||||
|
R_RenderLightmappedPoly( surf );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* the polygon is visible, so add it to the texture sorted chain */
|
||||||
image = R_TextureAnimation( surf->texinfo );
|
image = R_TextureAnimation( surf->texinfo );
|
||||||
surf->texturechain = image->texturechain;
|
surf->texturechain = image->texturechain;
|
||||||
image->texturechain = surf;
|
image->texturechain = surf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* recurse down the back side */
|
/* recurse down the back side */
|
||||||
R_RecursiveWorldNode( node->children [ !side ] );
|
R_RecursiveWorldNode( node->children [ !side ] );
|
||||||
|
@ -846,8 +1096,33 @@ R_DrawWorld ( void )
|
||||||
qglColor3f( 1, 1, 1 );
|
qglColor3f( 1, 1, 1 );
|
||||||
memset( gl_lms.lightmap_surfaces, 0, sizeof ( gl_lms.lightmap_surfaces ) );
|
memset( gl_lms.lightmap_surfaces, 0, sizeof ( gl_lms.lightmap_surfaces ) );
|
||||||
R_ClearSkyBox();
|
R_ClearSkyBox();
|
||||||
|
|
||||||
|
if ( qglMTexCoord2fSGIS )
|
||||||
|
{
|
||||||
|
R_EnableMultitexture( true );
|
||||||
|
|
||||||
|
R_SelectTexture( QGL_TEXTURE0 );
|
||||||
|
R_TexEnv( GL_REPLACE );
|
||||||
|
R_SelectTexture( QGL_TEXTURE1 );
|
||||||
|
|
||||||
|
if ( gl_lightmap->value )
|
||||||
|
{
|
||||||
|
R_TexEnv( GL_REPLACE );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
R_TexEnv( GL_MODULATE );
|
||||||
|
}
|
||||||
|
|
||||||
R_RecursiveWorldNode( r_worldmodel->nodes );
|
R_RecursiveWorldNode( r_worldmodel->nodes );
|
||||||
|
|
||||||
|
R_EnableMultitexture( false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
R_RecursiveWorldNode( r_worldmodel->nodes );
|
||||||
|
}
|
||||||
|
|
||||||
R_DrawTextureChains();
|
R_DrawTextureChains();
|
||||||
R_BlendLightmaps();
|
R_BlendLightmaps();
|
||||||
|
|
||||||
|
@ -877,7 +1152,7 @@ R_MarkLeaves ( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* development aid to let you run around and see exactly where
|
/* development aid to let you run around and see exactly where
|
||||||
the pvs ends */
|
* the pvs ends */
|
||||||
if ( gl_lockpvs->value )
|
if ( gl_lockpvs->value )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue