27 Jul 2009

This commit is contained in:
g-cont 2009-07-27 00:00:00 +04:00 committed by Alibek Omarov
parent 691fa794cf
commit 64e5378a74
17 changed files with 72 additions and 57 deletions

View File

@ -213,7 +213,7 @@ void CL_SetSky_f( void )
Msg( "Usage: sky <shadername>\n" );
return;
}
re->RegisterShader( Cmd_Argv(1), SHADER_SKYBOX );
re->RegisterShader( Cmd_Argv(1), SHADER_SKY );
}
/*

View File

@ -366,7 +366,7 @@ void CL_ParseConfigString( sizebuf_t *msg )
// do something apropriate
if( i == CS_SKYNAME && cl.video_prepped )
{
re->RegisterShader( cl.configstrings[CS_SKYNAME], SHADER_SKYBOX );
re->RegisterShader( cl.configstrings[CS_SKYNAME], SHADER_SKY );
}
else if( i > CS_BACKGROUND_TRACK && i < CS_MODELS )
{

View File

@ -8,10 +8,10 @@
#include "ref_params.h"
// shader types used for shader loading
#define SHADER_SKYBOX 0 // sky box shader
#define SHADER_FONT 1 // special case for displayed fonts
#define SHADER_NOMIP 2 // 2d images
#define SHADER_GENERIC 3 // generic shader
#define SHADER_SKY 1 // sky box shader
#define SHADER_FONT 2 // special case for displayed fonts
#define SHADER_NOMIP 3 // 2d images
#define SHADER_GENERIC 4 // generic shader
typedef struct
{

View File

@ -65,18 +65,18 @@ typedef struct
bool new_frame;
int s_rate;
int s_width;
int s_channels;
int s_rate;
int s_width;
int s_channels;
int width;
int height;
int width;
int height;
file_t *file;
int headerlen;
file_t *file;
int headerlen;
unsigned int time; // Sys_Milliseconds for first cinematic frame
unsigned int frame;
float time; // Sys_Milliseconds for first cinematic frame
uint frame;
byte *pic;
byte *pic_pending;

View File

@ -1090,7 +1090,7 @@ static bool R_VertexTCBase( const shaderpass_t *pass, int unit, mat4x4_t matrix
// distance to fog
dist = RI.fog_dist_to_eye[r_texFog-r_worldbrushmodel->fogs];
if( r_currentShader->flags & SHADER_SKY )
if( r_currentShader->flags & SHADER_SKYPARMS )
{
if( dist > 0 )
VectorMA( RI.viewOrigin, -dist, fogPlane->normal, viewtofog );
@ -1640,7 +1640,7 @@ void R_ModifyColor( const shaderpass_t *pass )
fogShaderDistScale = 1.0 / (r_colorFog->shader->fog_dist - r_colorFog->shader->fog_clearDist);
dist = RI.fog_dist_to_eye[r_colorFog-r_worldbrushmodel->fogs];
if( r_currentShader->flags & SHADER_SKY )
if( r_currentShader->flags & SHADER_SKYPARMS )
{
if( dist > 0 )
VectorScale( fogPlane->normal, -dist, viewtofog );
@ -2572,7 +2572,7 @@ void R_RenderMeshBuffer( const meshbuffer_t *mb )
// can we fog the geometry with alpha texture?
r_texFog = ( fog && ( ( r_currentShader->sort <= SHADER_SORT_ALPHATEST &&
( r_currentShader->flags & ( SHADER_DEPTHWRITE|SHADER_SKY ) ) ) || r_currentShader->fog_dist ) ) ? fog : NULL;
( r_currentShader->flags & ( SHADER_DEPTHWRITE|SHADER_SKYPARMS ) ) ) || r_currentShader->fog_dist ) ) ? fog : NULL;
// check if the fog volume is present but we can't use alpha texture
r_colorFog = ( fog && !r_texFog ) ? fog : NULL;
@ -2697,7 +2697,7 @@ void R_RenderMeshBuffer( const meshbuffer_t *mb )
if( r_texFog && r_texFog->shader )
{
r_fogPass.anim_frames[0] = r_fogtexture;
if( !r_currentShader->numpasses || r_currentShader->fog_dist || ( r_currentShader->flags & SHADER_SKY ) )
if( !r_currentShader->numpasses || r_currentShader->fog_dist || ( r_currentShader->flags & SHADER_SKYPARMS ) )
r_fogPass.flags &= ~GLSTATE_DEPTHFUNC_EQ;
else
r_fogPass.flags |= GLSTATE_DEPTHFUNC_EQ;

View File

@ -79,13 +79,13 @@ R_RunRoQ
*/
static void R_RunRoQ( cinematics_t *cin )
{
unsigned int frame;
uint frame;
frame = (Sys_Milliseconds () - cin->time) * (float)(RoQ_FRAMERATE) / 1000;
frame = (RI.refdef.time - cin->time) * (float)(RoQ_FRAMERATE);
if( frame <= cin->frame )
return;
if( frame > cin->frame + 1 )
cin->time = Sys_Milliseconds () - cin->frame * 1000 / RoQ_FRAMERATE;
cin->time = RI.refdef.time - cin->frame / RoQ_FRAMERATE;
cin->pic = cin->pic_pending;
cin->pic_pending = R_ReadNextRoQFrame( cin );
@ -95,7 +95,7 @@ static void R_RunRoQ( cinematics_t *cin )
FS_Seek( cin->file, cin->headerlen, SEEK_SET );
cin->frame = 0;
cin->pic_pending = R_ReadNextRoQFrame( cin );
cin->time = Sys_Milliseconds ();
cin->time = RI.refdef.time;
}
cin->new_frame = true;
@ -163,7 +163,7 @@ static cinematics_t *R_OpenCinematics( char *filename )
cin->headerlen = FS_Tell( cin->file );
cin->frame = 0;
cin->pic = cin->pic_pending = R_ReadNextRoQFrame( cin );
cin->time = Sys_Milliseconds ();
cin->time = RI.refdef.time;
cin->new_frame = true;
return cin;
@ -192,7 +192,7 @@ static texture_t *R_ResampleCinematicFrame( r_cinhandle_t *handle )
r_cin.flags = 0;
r_cin.palette = NULL;
r_cin.buffer = cin->pic;
r_cin.numMips = 1;
r_cin.numMips = r_cin.depth = 1;
handle->image = R_LoadTexture( handle->name, &r_cin, 3, TF_CINEMATIC );
cin->new_frame = false;
}
@ -205,8 +205,8 @@ static texture_t *R_ResampleCinematicFrame( r_cinhandle_t *handle )
image = handle->image;
GL_Bind( 0, image );
if( image->srcWidth != cin->width || image->srcHeight != cin->height )
R_Upload32( &cin->pic, image->srcWidth, image->srcHeight, TF_CINEMATIC, &(image->width), &(image->height), &(image->samples), false );
else R_Upload32( &cin->pic, image->srcWidth, image->srcHeight, TF_CINEMATIC, &(image->width), &(image->height), &(image->samples), true );
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, image->srcWidth, image->srcHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, cin->pic );
else pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, image->srcWidth, image->srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, cin->pic );
image->srcWidth = cin->width;
image->srcHeight = cin->height;

View File

@ -70,16 +70,23 @@ void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, f
R_DrawStretchRaw
=============
*/
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, byte *data, bool redraw )
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, bool redraw )
{
int samples = 3;
GL_Bind( 0, r_cintexture );
R_Upload32( &data, cols, rows, TF_CINEMATIC, NULL, NULL, &samples, ( cols == r_cintexture->srcWidth && rows == r_cintexture->srcHeight ) );
r_cintexture->srcWidth = cols;
r_cintexture->srcHeight = rows;
if( cols == r_cintexture->width && rows == r_cintexture->height )
{
pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data );
}
else
{
r_cintexture->width = cols;
r_cintexture->height = rows;
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
}
R_CheckForErrors();
pglBegin( GL_QUADS );
pglTexCoord2f( 0, 0 );

View File

@ -3381,12 +3381,20 @@ void R_InitShadowmapTexture( texture_t **texture, int id, int screenWidth, int s
R_InitCinematicTexture
==================
*/
static void R_InitCinematicTexture( void )
static rgbdata_t *R_InitCinematicTexture( int *flags, int *samples )
{
// reserve a dummy texture slot
r_cintexture = &r_textures[r_numTextures++];
pglGenTextures( 1, &r_cintexture->texnum );
r_cintexture->depth = 1;
// light corona texture
r_image.width = r_image.height = 256;
r_image.numMips = r_image.depth = 1;
r_image.buffer = data2D;
r_image.flags = IMAGE_HAS_COLOR;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
*flags = TF_STATIC|TF_NOMIPMAP|TF_NOPICMIP|TF_UNCOMPRESSED|TF_CLAMP;
*samples = 4;
return &r_image;
}
/*
@ -3418,6 +3426,7 @@ static void R_InitBuiltinTextures( void )
{ "***r_particletexture***", &r_particletexture, R_InitParticleTexture },
{ "***r_fogtexture***", &r_fogtexture, R_InitFogTexture },
{ "***r_coronatexture***", &r_coronatexture, R_InitCoronaTexture },
{ "***r_cintexture***", &r_cintexture, R_InitCinematicTexture },
{ NULL, NULL, NULL }
};
size_t i, num_builtin_textures = sizeof( textures ) / sizeof( textures[0] ) - 1;
@ -3553,7 +3562,6 @@ void R_InitImages( void )
// set texture parameters
R_SetTextureParameters();
R_InitCinematicTexture();
R_InitBuiltinTextures();
R_InitBloomTextures();
}

View File

@ -46,7 +46,7 @@ bool R_SurfPotentiallyLit( msurface_t *surf )
return false;
shader = surf->shader;
if( ( shader->flags & ( SHADER_SKY|SHADER_FLARE ) ) || !shader->numpasses )
if( ( shader->flags & ( SHADER_SKYPARMS|SHADER_FLARE ) ) || !shader->numpasses )
return false;
return ( surf->mesh && ( surf->facetype != MST_FLARE ) /* && (surf->facetype != MST_TRISURF)*/ );

View File

@ -491,7 +491,7 @@ void R_ShutdownOcclusionQueries( void );
extern meshbuffer_t pic_mbuffer;
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, shader_t shadernum );
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, byte *data, bool redraw );
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, bool redraw );
void R_DrawSetParms( shader_t handle, kRenderMode_t rendermode, int frame );
void R_DrawGetParms( int *w, int *h, int *f, int frame, shader_t shader );
void R_DrawFill( float x, float y, float w, float h );

View File

@ -2147,7 +2147,7 @@ shader_t Mod_RegisterShader( const char *name, int shaderType )
case SHADER_NOMIP:
src = R_RegisterPic( name );
break;
case SHADER_SKYBOX:
case SHADER_SKY:
case SHADER_GENERIC:
src = R_RegisterShader( name );
break;

View File

@ -316,7 +316,7 @@ static void R_BatchMeshBuffer( const meshbuffer_t *mb, const meshbuffer_t *nextm
case mod_brush:
MB_NUM2SHADER( mb->shaderkey, shader );
if( shader->flags & SHADER_SKY )
if( shader->flags & SHADER_SKYPARMS )
{ // draw sky
if( !( RI.params & RP_NOSKY ) )
R_DrawSky( shader );
@ -516,7 +516,7 @@ void R_DrawPortals( void )
{
MB_NUM2SHADER( mb->shaderkey, shader );
if( shader->flags & SHADER_SKY )
if( shader->flags & SHADER_SKYPARMS )
{
R_DrawSky( shader );
RI.params |= RP_NOSKY;

View File

@ -1904,7 +1904,7 @@ static void Mod_Finish( const lump_t *faces, const lump_t *light, vec3_t gridSiz
{
if( globalFog && surf->mesh && surf->fog != testFog )
{
if( !( surf->shader->flags & SHADER_SKY ) && !surf->shader->fog_dist )
if( !( surf->shader->flags & SHADER_SKYPARMS ) && !surf->shader->fog_dist )
globalFog = false;
}
@ -1929,7 +1929,7 @@ static void Mod_Finish( const lump_t *faces, const lump_t *light, vec3_t gridSiz
{
if( globalFog && surf->mesh && surf->fog != testFog )
{
if( !( surf->shader->flags & SHADER_SKY ) && !surf->shader->fog_dist )
if( !( surf->shader->flags & SHADER_SKYPARMS ) && !surf->shader->fog_dist )
globalFog = false;
}

View File

@ -193,7 +193,7 @@ void R_AddLightToScene( const vec3_t org, float intensity, float r, float g, fl
bool R_AddPolyToScene( const poly_t *poly );
void R_AddLightStyleToScene( int style, float r, float g, float b );
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, shader_t shader );
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, byte *data, int frame );
void R_DrawStretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, bool redraw );
void R_SetCustomColor( int num, int r, int g, int b );
void R_LightForOrigin( const vec3_t origin, vec3_t dir, vec4_t ambient, vec4_t diffuse, float radius );

View File

@ -687,7 +687,7 @@ static int Shader_SetImageFlags( ref_shader_t *shader )
{
int flags = 0;
if( shader->flags & SHADER_SKY )
if( shader->flags & SHADER_SKYPARMS )
flags |= TF_SKYSIDE;
if( r_shaderNoMipMaps )
flags |= TF_NOMIPMAP;
@ -856,7 +856,7 @@ static void Shader_SkyParms( ref_shader_t *shader, shaderpass_t *pass, const cha
Shader_ParseSkySides( ptr, nearboxShaders, false );
r_skydomes[shaderNum] = R_CreateSkydome( skyheight, farboxShaders, nearboxShaders );
shader->flags |= SHADER_SKY;
shader->flags |= SHADER_SKYPARMS;
shader->sort = SHADER_SORT_SKY;
}
@ -1920,7 +1920,7 @@ void Shader_FreeShader( ref_shader_t *shader )
shaderpass_t *pass;
shaderNum = shader - r_shaders;
if( ( shader->flags & SHADER_SKY ) && r_skydomes[shaderNum] )
if( ( shader->flags & SHADER_SKYPARMS ) && r_skydomes[shaderNum] )
{
R_FreeSkydome( r_skydomes[shaderNum] );
r_skydomes[shaderNum] = NULL;
@ -2079,7 +2079,7 @@ static void Shader_Readpass( ref_shader_t *shader, const char **ptr )
break;
}
if( ( shader->flags & SHADER_SKY ) && ( shader->flags & SHADER_DEPTHWRITE ) )
if( ( shader->flags & SHADER_SKYPARMS ) && ( shader->flags & SHADER_DEPTHWRITE ) )
{
if( pass->flags & GLSTATE_DEPTHWRITE )
pass->flags &= ~GLSTATE_DEPTHWRITE;
@ -2368,7 +2368,7 @@ void Shader_Finish( ref_shader_t *s )
}
}
if( !( s->flags & SHADER_SKY ) && !s->sort )
if( !( s->flags & SHADER_SKYPARMS ) && !s->sort )
{
if( s->flags & SHADER_DEPTHWRITE || ( opaque != -1 && s->passes[opaque].flags & GLSTATE_ALPHAFUNC ) )
s->sort = SHADER_SORT_ALPHATEST;
@ -2407,7 +2407,7 @@ void Shader_Finish( ref_shader_t *s )
s->sort = SHADER_SORT_ALPHATEST;
}
if( !( pass->flags & GLSTATE_DEPTHWRITE ) && !( s->flags & SHADER_SKY ) )
if( !( pass->flags & GLSTATE_DEPTHWRITE ) && !( s->flags & SHADER_SKYPARMS ) )
{
pass->flags |= GLSTATE_DEPTHWRITE;
s->flags |= SHADER_DEPTHWRITE;
@ -2417,7 +2417,7 @@ void Shader_Finish( ref_shader_t *s )
if( !s->sort )
s->sort = SHADER_SORT_OPAQUE;
if( ( s->flags & SHADER_SKY ) && ( s->flags & SHADER_DEPTHWRITE ) )
if( ( s->flags & SHADER_SKYPARMS ) && ( s->flags & SHADER_DEPTHWRITE ) )
s->flags &= ~SHADER_DEPTHWRITE;
Shader_SetFeatures( s );
@ -2638,7 +2638,7 @@ ref_shader_t *R_LoadShader( const char *name, int type, bool forceDefault, int a
s->type = SHADER_FARBOX;
s->features = MF_STCOORDS;
s->sort = SHADER_SORT_SKY;
s->flags = SHADER_SKY;
s->flags = SHADER_SKYPARMS;
s->numpasses = 1;
s->name = Shader_Malloc( length + 1 + sizeof( shaderpass_t ) * s->numpasses );
strcpy( s->name, shortname );
@ -2655,7 +2655,7 @@ ref_shader_t *R_LoadShader( const char *name, int type, bool forceDefault, int a
s->features = MF_STCOORDS;
s->sort = SHADER_SORT_SKY;
s->numpasses = 1;
s->flags = SHADER_SKY;
s->flags = SHADER_SKYPARMS;
s->name = Shader_Malloc( length + 1 + sizeof( shaderpass_t ) * s->numpasses );
strcpy( s->name, shortname );
s->passes = ( shaderpass_t * )( ( byte * )s->name + length + 1 );

View File

@ -49,7 +49,7 @@ enum
enum
{
SHADER_DEPTHWRITE = 1 << 0,
SHADER_SKY = 1 << 1,
SHADER_SKYPARMS = 1 << 1,
SHADER_POLYGONOFFSET = 1 << 2,
SHADER_CULL_FRONT = 1 << 3,
SHADER_CULL_BACK = 1 << 4,

View File

@ -139,7 +139,7 @@ static meshbuffer_t *R_AddSurfaceToList( msurface_t *surf, unsigned int clipflag
return NULL;
shader = ((r_drawworld->integer == 2) ? R_OcclusionShader() : surf->shader);
if( shader->flags & SHADER_SKY )
if( shader->flags & SHADER_SKYPARMS )
{
bool vis = R_AddSkySurface( surf );
if( ( RI.params & RP_NOSKY ) && vis )