Browse Source

ref_soft: Update ref interface

pull/2/head
mittorn 6 years ago
parent
commit
37ee9752e1
  1. 4
      r_beams.c
  2. 74
      r_context.c
  3. 8
      r_image.c
  4. 1
      r_local.h
  5. 125
      r_main.c
  6. 4
      r_studio.c

4
r_beams.c

@ -1082,7 +1082,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime ) @@ -1082,7 +1082,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
// XASH SPECIFIC: get brightness from head entity
pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity );
if( pStart && pStart->curstate.rendermode != kRenderNormal )
pbeam->brightness = gEngfuncs.CL_FxBlend( pStart ) / 255.0f;
pbeam->brightness = CL_FxBlend( pStart ) / 255.0f;
}
if( FBitSet( pbeam->flags, FBEAM_FADEIN ))
@ -1202,7 +1202,7 @@ void R_BeamDrawCustomEntity( cl_entity_t *ent ) @@ -1202,7 +1202,7 @@ void R_BeamDrawCustomEntity( cl_entity_t *ent )
{
BEAM beam;
float amp = ent->curstate.body / 100.0f;
float blend = gEngfuncs.CL_FxBlend( ent ) / 255.0f;
float blend = CL_FxBlend( ent ) / 255.0f;
float r, g, b;
int beamFlags;

74
r_context.c

@ -59,45 +59,6 @@ static const byte * GAME_EXPORT R_GetTextureOriginalBuffer( unsigned int idx ) @@ -59,45 +59,6 @@ static const byte * GAME_EXPORT R_GetTextureOriginalBuffer( unsigned int idx )
return NULL;
}
static int GAME_EXPORT R_GetBuiltinTexture( enum ref_shared_texture_e type )
{
switch( type )
{
case REF_DEFAULT_TEXTURE: return tr.defaultTexture;
case REF_GRAY_TEXTURE: return tr.grayTexture;
case REF_WHITE_TEXTURE: return tr.whiteTexture;
case REF_SOLIDSKY_TEXTURE: return tr.solidskyTexture;
case REF_ALPHASKY_TEXTURE: return tr.alphaskyTexture;
default: gEngfuncs.Host_Error( "R_GetBuiltinTexture: unsupported type %d\n", type );
}
return 0;
}
static void GAME_EXPORT R_FreeSharedTexture( enum ref_shared_texture_e type )
{
int num = 0;
switch( type )
{
case REF_SOLIDSKY_TEXTURE:
num = tr.solidskyTexture;
tr.solidskyTexture = 0;
break;
case REF_ALPHASKY_TEXTURE:
num = tr.alphaskyTexture;
tr.alphaskyTexture = 0;
break;
case REF_DEFAULT_TEXTURE:
case REF_GRAY_TEXTURE:
case REF_WHITE_TEXTURE:
gEngfuncs.Host_Error( "R_FreeSharedTexture: invalid type %d\n", type );
default: gEngfuncs.Host_Error( "R_FreeSharedTexture: unsupported type %d\n", type );
}
GL_FreeTexture( num );
}
/*
=============
CL_FillRGBA
@ -161,7 +122,8 @@ qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create, const @@ -161,7 +122,8 @@ qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create, const
return loaded;
}
static int GAME_EXPORT GL_RenderGetParm( int parm, int arg )
static int GL_RefGetParm( int parm, int arg )
{
image_t *glt;
@ -179,6 +141,12 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg ) @@ -179,6 +141,12 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg )
case PARM_TEX_SRC_HEIGHT:
glt = R_GetTexture( arg );
return glt->srcHeight;
case PARM_TEX_GLFORMAT:
glt = R_GetTexture( arg );
return 0; //glt->format;
case PARM_TEX_ENCODE:
glt = R_GetTexture( arg );
return 0; //glt->encode;
case PARM_TEX_MIPCOUNT:
glt = R_GetTexture( arg );
return glt->numMips;
@ -189,7 +157,7 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg ) @@ -189,7 +157,7 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg )
Assert( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
case PARM_TEX_SKYTEXNUM:
return 0;
return 0; //tr.skytexturenum;
case PARM_TEX_LIGHTMAP:
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
return tr.lightmapTextures[arg];
@ -201,20 +169,34 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg ) @@ -201,20 +169,34 @@ static int GAME_EXPORT GL_RenderGetParm( int parm, int arg )
return gpGlobals->width;
case PARM_SCREEN_HEIGHT:
return gpGlobals->height;
case PARM_TEX_TARGET:
glt = R_GetTexture( arg );
return 0; //glt->target;
case PARM_TEX_TEXNUM:
glt = R_GetTexture( arg );
return 0; //glt->texnum;
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_ACTIVE_TMU:
return 0; //glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
return tr.lightstylevalue[arg];
case PARM_MAX_IMAGE_UNITS:
return 1;
return 0; //GL_MaxTextureUnits();
case PARM_REBUILD_GAMMA:
return 0; //glConfig.softwareGammaUpdate;
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < WORLDMODEL->numsurfaces )
return gEngfuncs.Mod_SampleSizeForFace( &WORLDMODEL->surfaces[arg] );
return LM_SAMPLE_SIZE;
case PARM_GL_CONTEXT_TYPE:
return 0; //glConfig.context;
case PARM_GLES_WRAPPER:
return 0; //glConfig.wrapper;
case PARM_STENCIL_ACTIVE:
return 0; //glState.stencilEnabled;
case PARM_SKY_SPHERE:
return ENGINE_GET_PARM_( parm, arg ) && !tr.fCustomSkybox;
default:
@ -495,16 +477,11 @@ ref_interface_t gReffuncs = @@ -495,16 +477,11 @@ ref_interface_t gReffuncs =
CL_AddCustomBeam,
R_ProcessEntData,
IsNormalPass,
R_ShowTextures,
R_ShowTree,
R_IncrementSpeedsCounter,
R_GetTextureOriginalBuffer,
GL_LoadTextureFromBuffer,
R_GetBuiltinTexture,
R_FreeSharedTexture,
GL_ProcessTexture,
R_SetupSky,
@ -545,7 +522,7 @@ ref_interface_t gReffuncs = @@ -545,7 +522,7 @@ ref_interface_t gReffuncs =
CL_DrawBeams,
R_BeamCull,
GL_RenderGetParm,
GL_RefGetParm,
R_GetDetailScaleForTexture,
R_GetExtraParmsForTexture,
R_GetFrameTime,
@ -585,7 +562,6 @@ ref_interface_t gReffuncs = @@ -585,7 +562,6 @@ ref_interface_t gReffuncs =
R_StudioGetTexture,
R_RenderFrame,
GL_BuildLightmaps,
Mod_SetOrthoBounds,
R_SpeedsMessage,
Mod_GetCurrentVis,

8
r_image.c

@ -1281,7 +1281,7 @@ static void GL_CreateInternalTextures( void ) @@ -1281,7 +1281,7 @@ static void GL_CreateInternalTextures( void )
}
}
tr.defaultTexture = GL_LoadTextureInternal( "*default", pic, TF_COLORMAP );
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
// particle texture from quake1
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA );
@ -1305,19 +1305,19 @@ static void GL_CreateInternalTextures( void ) @@ -1305,19 +1305,19 @@ static void GL_CreateInternalTextures( void )
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFFFFFFFF;
tr.whiteTexture = GL_LoadTextureInternal( "*white", pic, TF_COLORMAP );
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
// gray texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF7F7F7F;
tr.grayTexture = GL_LoadTextureInternal( "*gray", pic, TF_COLORMAP );
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
// black texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF000000;
tr.blackTexture = GL_LoadTextureInternal( "*black", pic, TF_COLORMAP );
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
// cinematic dummy
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );

1
r_local.h

@ -1279,6 +1279,7 @@ void R_RenderTriangle( finalvert_t *fv1 , finalvert_t *fv2, finalvert_t *fv3 ); @@ -1279,6 +1279,7 @@ void R_RenderTriangle( finalvert_t *fv1 , finalvert_t *fv2, finalvert_t *fv3 );
void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, int s, int t );
void RotatedBBox (vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs);
int R_BmodelCheckBBox (float *minmaxs);
int CL_FxBlend( cl_entity_t *e );
void R_SetUpWorldTransform (void);

125
r_main.c

@ -367,7 +367,7 @@ qboolean GAME_EXPORT R_AddEntity( struct cl_entity_s *clent, int type ) @@ -367,7 +367,7 @@ qboolean GAME_EXPORT R_AddEntity( struct cl_entity_s *clent, int type )
if( FBitSet( clent->curstate.effects, EF_NODRAW ))
return false; // done
if( !R_ModelOpaque( clent->curstate.rendermode ) && gEngfuncs.CL_FxBlend( clent ) <= 0 )
if( !R_ModelOpaque( clent->curstate.rendermode ) && CL_FxBlend( clent ) <= 0 )
return true; // invisible
if( type == ET_FRAGMENTED )
@ -909,7 +909,7 @@ void R_DrawEntitiesOnList( void ) @@ -909,7 +909,7 @@ void R_DrawEntitiesOnList( void )
// handle studiomodels with custom rendermodes on texture
if( RI.currententity->curstate.rendermode != kRenderNormal )
tr.blend = gEngfuncs.CL_FxBlend( RI.currententity ) / 255.0f;
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
else tr.blend = 1.0f; // draw as solid but sorted by distance
if( tr.blend <= 0.0f ) continue;
@ -2004,3 +2004,124 @@ void GAME_EXPORT R_Shutdown() @@ -2004,3 +2004,124 @@ void GAME_EXPORT R_Shutdown()
gEngfuncs.R_Free_Video();
}
/*
===============
CL_FxBlend
===============
*/
int CL_FxBlend( cl_entity_t *e )
{
int blend = 0;
float offset, dist;
vec3_t tmp;
offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gpGlobals->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gpGlobals->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gpGlobals->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( gpGlobals->time * 2 ) + sin( gpGlobals->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( gpGlobals->time * 16 ) + sin( gpGlobals->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
dist = DotProduct( tmp, RI.vforward );
// turn off distance fade
if( e->curstate.renderfx == kRenderFxDistort )
dist = 1;
if( dist <= 0 )
{
blend = 0;
}
else
{
e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt;
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += gEngfuncs.COM_RandomLong( -32, 31 );
}
break;
default:
blend = e->curstate.renderamt;
break;
}
blend = bound( 0, blend, 255 );
return blend;
}

4
r_studio.c

@ -1862,7 +1862,7 @@ void R_StudioSetRenderamt( int iRenderamt ) @@ -1862,7 +1862,7 @@ void R_StudioSetRenderamt( int iRenderamt )
if( !RI.currententity ) return;
RI.currententity->curstate.renderamt = iRenderamt;
tr.blend = gEngfuncs.CL_FxBlend( RI.currententity ) / 255.0f;
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
}
/*
@ -3466,7 +3466,7 @@ void R_DrawViewModel( void ) @@ -3466,7 +3466,7 @@ void R_DrawViewModel( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
tr.blend = gEngfuncs.CL_FxBlend( view ) / 255.0f;
tr.blend = CL_FxBlend( view ) / 255.0f;
if( !R_ModelOpaque( view->curstate.rendermode ) && tr.blend <= 0.0f )
return; // invisible ?

Loading…
Cancel
Save