int cl_max_lightstyle;
int cl_max_brushmodel_entities;
int cl_activedlights;
+int cl_activeeffects;
+int cl_activebeams;
entity_t *cl_entities;
entity_t *cl_csqcentities; //[515]: csqc
cl_max_lightstyle = MAX_LIGHTSTYLES;
cl_max_brushmodel_entities = MAX_EDICTS;
cl_activedlights = 0;
+ cl_activeeffects = 0;
+ cl_activebeams = 0;
cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
cl_csqcentities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_csqcentities * sizeof(entity_t)); //[515]: csqc
e->frame = 0;
e->frame1time = cl.time;
e->frame2time = cl.time;
+ cl_activeeffects = max(cl_activeeffects, i + 1);
break;
}
}
entity_t *ent;
float frame;
- for (i = 0, e = cl_effects;i < cl_max_effects;i++, e++)
+ for (i = 0, e = cl_effects;i < cl_activeeffects;i++, e++)
{
if (e->active)
{
if (intframe < 0 || intframe >= e->endframe)
{
memset(e, 0, sizeof(*e));
+ while (cl_activeeffects > 0 && !cl_effects[cl_activeeffects - 1].active)
+ cl_activeeffects--;
continue;
}
float forward;
matrix4x4_t tempmatrix;
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ while (cl_activebeams > 0 && !cl_beams[cl_activebeams - 1].model)
+ cl_activeeffects--;
+ for (i = 0, b = cl_beams;i < cl_activebeams;i++, b++)
{
- if (!b->model || b->endtime < cl.time)
+ if (!b->model)
+ continue;
+ if (b->endtime < cl.time)
+ {
+ b->model = NULL;
continue;
+ }
// if coming from the player, update the start position
//if (b->entity == cl.viewentity)
}
}
-void R_TimeReport_Start(void)
+void R_TimeReport_Frame(void)
{
- r_timereport_active = r_speeds.integer && cls.signon == SIGNONS && cls.state == ca_connected;
- r_speeds_string[0] = 0;
- if (r_timereport_active)
+ int i, j, lines, y;
+
+ if (r_speeds_string[0])
+ {
+ if (r_timereport_active)
+ R_TimeReport("total");
+
+ r_timereport_current = r_timereport_start;
+ j = (int)strlen(r_speeds_string);
+ if (r_timereport_active && j > 0)
+ {
+ if (r_speeds_string[j-1] == '\n')
+ r_speeds_string[j-1] = 0;
+ lines = 1;
+ for (i = 0;r_speeds_string[i];i++)
+ if (r_speeds_string[i] == '\n')
+ lines++;
+ y = vid_conheight.integer - sb_lines - lines * 8;
+ i = j = 0;
+ DrawQ_Fill(0, y, vid_conwidth.integer, lines * 8, 0, 0, 0, 0.5, 0);
+ while (r_speeds_string[i])
+ {
+ j = i;
+ while (r_speeds_string[i] && r_speeds_string[i] != '\n')
+ i++;
+ if (i - j > 0)
+ DrawQ_String(0, y, r_speeds_string + j, i - j, 8, 8, 1, 1, 1, 1, 0);
+ if (r_speeds_string[i] == '\n')
+ i++;
+ y += 8;
+ }
+ }
+ r_speeds_string[0] = 0;
+ r_timereport_active = false;
+ }
+ if (r_speeds.integer && cls.signon == SIGNONS && cls.state == ca_connected)
{
speedstringcount = 0;
sprintf(r_speeds_string + strlen(r_speeds_string), "org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_vieworigin[0], r_vieworigin[1], r_vieworigin[2], r_viewforward[0], r_viewforward[1], r_viewforward[2]);
else
sprintf(r_speeds_string + strlen(r_speeds_string), "rendered%6i meshes%8i triangles\n", renderstats.meshes, renderstats.meshes_elements / 3);
- r_timereport_start = Sys_DoubleTime();
- }
-
- memset(&renderstats, 0, sizeof(renderstats));
-}
-
-void R_TimeReport_End(void)
-{
- int i, j, lines, y;
-
- r_timereport_current = r_timereport_start;
- R_TimeReport("total");
+ memset(&renderstats, 0, sizeof(renderstats));
- j = (int)strlen(r_speeds_string);
- if (r_timereport_active && j > 0)
- {
- if (r_speeds_string[j-1] == '\n')
- r_speeds_string[j-1] = 0;
- lines = 1;
- for (i = 0;r_speeds_string[i];i++)
- if (r_speeds_string[i] == '\n')
- lines++;
- y = vid_conheight.integer - sb_lines - lines * 8;
- i = j = 0;
- DrawQ_Fill(0, y, vid_conwidth.integer, lines * 8, 0, 0, 0, 0.5, 0);
- while (r_speeds_string[i])
+ if (r_speeds.integer >= 2)
{
- j = i;
- while (r_speeds_string[i] && r_speeds_string[i] != '\n')
- i++;
- if (i - j > 0)
- DrawQ_String(0, y, r_speeds_string + j, i - j, 8, 8, 1, 1, 1, 1, 0);
- if (r_speeds_string[i] == '\n')
- i++;
- y += 8;
+ r_timereport_active = true;
+ r_timereport_start = Sys_DoubleTime();
}
}
}
SCR_CaptureVideo();
- if (cls.signon == SIGNONS)
+ if (r_timereport_active)
R_TimeReport("other");
CL_SetupScreenSize();
DrawQ_Clear();
- if (cls.signon == SIGNONS)
+ if (r_timereport_active)
R_TimeReport("setup");
//FIXME: force menu if nothing else to look at?
//ui_draw();
if (cls.signon == SIGNONS)
{
- R_TimeReport("2d");
- R_TimeReport_End();
- R_TimeReport_Start();
+ if (r_timereport_active)
+ R_TimeReport("2d");
+ R_TimeReport_Frame();
}
R_Shadow_EditLights_DrawSelectedLightProperties();
static int cl_videogmask;
static int cl_videobytesperpixel;
+static int cl_activevideos;
static clvideo_t videoarray[ MAXCLVIDEOS ];
static rtexturepool_t *cl_videotexturepool;
-static clvideo_t *FindUnusedVid( void )
-{
- int i;
- for( i = 1 ; i < MAXCLVIDEOS ; i++ )
- if( videoarray[ i ].state == CLVIDEO_UNUSED )
- return &videoarray[ i ];
- return NULL;
-}
-
static qboolean OpenStream( clvideo_t * video )
{
char *errorstring;
return true;
}
-static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char *name, int owner )
+clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, qboolean cinematic )
{
+ int i;
+ clvideo_t *video;
+
+ if (cinematic)
+ {
+ video = videoarray;
+ i = 0;
+ }
+ else
+ {
+ for (i = 1, video = videoarray; i < cl_activevideos;i++, video++)
+ if (videoarray[i].state == CLVIDEO_UNUSED)
+ break;
+ if (i == MAXCLVIDEOS)
+ {
+ Con_Printf( "unable to open video \"%s\" - video limit reached\n", filename );
+ return NULL;
+ }
+ }
+
strncpy( video->filename, filename, MAX_QPATH );
video->ownertag = owner;
+
if( strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) )
return NULL;
+
strncpy( video->cpif.name, name, MAX_QPATH );
if( !OpenStream( video ) )
video->cpif.width = dpvsimpledecode_getwidth( video->stream );
video->cpif.height = dpvsimpledecode_getheight( video->stream );
- video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+ video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name, video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
- video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ // expand the active range to include the new entry
+ cl_activevideos = max(cl_activevideos, i + 1);
return video;
}
-clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner )
-{
- clvideo_t *video;
-
- video = FindUnusedVid();
- if( !video ) {
- Con_Printf( "unable to open video \"%s\" - video limit reached\n", filename );
- return NULL;
- }
- return OpenVideo( video, filename, name, owner );
-}
-
clvideo_t* CL_GetVideo( const char *name )
{
int i;
clvideo_t *video;
- for( i = 0 ; i < MAXCLVIDEOS ; i++ )
+ for( i = 0 ; i < cl_activevideos ; i++ )
if( videoarray[ i ].state != CLVIDEO_UNUSED
&& !strcmp( videoarray[ i ].cpif.name , name ) )
break;
- if( i == MAXCLVIDEOS )
+ if( i == cl_activevideos )
return NULL;
video = &videoarray[ i ];
int i;
clvideo_t *video;
- for( video = videoarray, i = 0 ; i < MAXCLVIDEOS ; video++, i++ )
+ for( video = videoarray, i = 0 ; i < cl_activevideos ; video++, i++ )
if( video->state != CLVIDEO_UNUSED && !video->suspended )
{
if( realtime - video->lasttime > CLTHRESHOLD )
if( videoarray->state == CLVIDEO_FIRSTFRAME )
CL_VideoStop();
+
+ // reduce range to exclude unnecessary entries
+ while (cl_activevideos > 0 && videoarray[cl_activevideos-1].state == CLVIDEO_UNUSED)
+ cl_activevideos--;
}
void CL_Video_Shutdown( void )
{
int i;
- for( i = 0 ; i < MAXCLVIDEOS ; i++ )
+ for( i = 0 ; i < cl_activevideos ; i++ )
CL_CloseVideo( &videoarray[ i ] );
}
void CL_PurgeOwner( int owner )
{
int i;
- for( i = 0 ; i < MAXCLVIDEOS ; i++ )
+ for( i = 0 ; i < cl_activevideos ; i++ )
if( videoarray[ i ].ownertag == owner )
CL_CloseVideo( &videoarray[ i ] );
}
if( videoarray->state != CLVIDEO_UNUSED )
CL_CloseVideo( videoarray );
- if( !OpenVideo( videoarray, filename, va( CLVIDEOPREFIX "%s", filename ), 0 ) )
+ if( !CL_OpenVideo( filename, va( CLVIDEOPREFIX "%s", filename ), 0, true ) )
return;
cl_videoplaying = true;
cl_videotexturepool = R_AllocTexturePool();
- for( video = videoarray, i = 0 ; i < MAXCLVIDEOS ; i++, video++ )
+ for( video = videoarray, i = 0 ; i < cl_activevideos ; i++, video++ )
if( video->state != CLVIDEO_UNUSED && !video->suspended )
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
void CL_Video_Init( void )
{
+ cl_activevideos = 0;
cl_videobytesperpixel = 4;
cl_videormask = BigLong(0xFF000000);
cl_videogmask = BigLong(0x00FF0000);
char filename[MAX_QPATH];
} clvideo_t;
-clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner );
+clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, qboolean cinematic );
clvideo_t* CL_GetVideo( const char *name );
void CL_SetVideoState( clvideo_t *video, clvideostate_t state );
void CL_RestartVideo( clvideo_t *video );
extern int cl_max_lightstyle;
extern int cl_max_brushmodel_entities;
extern int cl_activedlights;
+extern int cl_activeeffects;
+extern int cl_activebeams;
extern entity_t *cl_entities;
extern entity_t *cl_csqcentities; //[515]: csqc
{
R_Mesh_Start();
- R_TimeReport("setup");
+ if (r_timereport_active)
+ R_TimeReport("setup");
if (cls.signon == SIGNONS)
{
R_Mesh_Finish();
- R_TimeReport("meshfinish");
+ if (r_timereport_active)
+ R_TimeReport("meshfinish");
}
void SCR_UpdateLoadingScreen (void)
qglClear(GL_COLOR_BUFFER_BIT);
CHECKGLERROR
- R_TimeReport("clear");
+ if (r_timereport_active)
+ R_TimeReport("clear");
if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
{
SCR_DrawScreen();
VID_Finish();
- R_TimeReport("finish");
+ if (r_timereport_active)
+ R_TimeReport("finish");
}
R_ClearScreen();
R_Textures_Frame();
R_UpdateFog();
- R_TimeReport("setup");
+ if (r_timereport_active)
+ R_TimeReport("setup");
qglDepthFunc(GL_LEQUAL);
qglPolygonOffset(0, 0);
qglDisable(GL_POLYGON_OFFSET_FILL);
R_BlendView();
- R_TimeReport("blendview");
+ if (r_timereport_active)
+ R_TimeReport("blendview");
GL_Scissor(0, 0, vid.width, vid.height);
GL_ScissorTest(false);
R_ClearScreen();
R_Textures_Frame();
R_UpdateFog();
- R_TimeReport("setup");
+ if (r_timereport_active)
+ R_TimeReport("setup");
}
//[515]: csqc
qglDisable(GL_POLYGON_OFFSET_FILL);
R_BlendView();
- R_TimeReport("blendview");
+ if (r_timereport_active)
+ R_TimeReport("blendview");
GL_Scissor(0, 0, vid.width, vid.height);
GL_ScissorTest(false);
R_SkyStartFrame();
R_WorldVisibility();
- R_TimeReport("worldvis");
+ if (r_timereport_active)
+ R_TimeReport("worldvis");
R_MarkEntities();
- R_TimeReport("markentity");
+ if (r_timereport_active)
+ R_TimeReport("markentity");
R_Shadow_UpdateWorldLightSelection();
if (r_refdef.extraupdate)
S_ExtraUpdate ();
- GL_ShowTrisColor(0.025, 0.025, 0, 1);
+ if (r_showtrispass)
+ GL_ShowTrisColor(0.025, 0.025, 0, 1);
if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky)
{
r_refdef.worldmodel->DrawSky(r_refdef.worldentity);
- R_TimeReport("worldsky");
+ if (r_timereport_active)
+ R_TimeReport("worldsky");
}
- if (R_DrawBrushModelsSky())
+ if (R_DrawBrushModelsSky() && r_timereport_active)
R_TimeReport("bmodelsky");
- GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+ if (r_showtrispass)
+ GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
if (r_refdef.worldmodel && r_refdef.worldmodel->Draw)
{
r_refdef.worldmodel->Draw(r_refdef.worldentity);
- R_TimeReport("world");
+ if (r_timereport_active)
+ R_TimeReport("world");
}
}
if (r_refdef.extraupdate)
S_ExtraUpdate ();
- GL_ShowTrisColor(0, 0.015, 0, 1);
+ if (r_showtrispass)
+ GL_ShowTrisColor(0, 0.015, 0, 1);
R_DrawModels();
- R_TimeReport("models");
+ if (r_timereport_active)
+ R_TimeReport("models");
// don't let sound skip if going slow
if (r_refdef.extraupdate)
S_ExtraUpdate ();
- GL_ShowTrisColor(0, 0, 0.033, 1);
+ if (r_showtrispass)
+ GL_ShowTrisColor(0, 0, 0.033, 1);
R_ShadowVolumeLighting(false);
- R_TimeReport("rtlights");
+ if (r_timereport_active)
+ R_TimeReport("rtlights");
// don't let sound skip if going slow
if (r_refdef.extraupdate)
S_ExtraUpdate ();
- GL_ShowTrisColor(0.1, 0, 0, 1);
+ if (r_showtrispass)
+ GL_ShowTrisColor(0.1, 0, 0, 1);
if (cl.csqc_vidvars.drawworld)
{
R_DrawLightningBeams();
- R_TimeReport("lightning");
+ if (r_timereport_active)
+ R_TimeReport("lightning");
R_DrawParticles();
- R_TimeReport("particles");
+ if (r_timereport_active)
+ R_TimeReport("particles");
R_DrawExplosions();
- R_TimeReport("explosions");
+ if (r_timereport_active)
+ R_TimeReport("explosions");
}
R_MeshQueue_RenderTransparent();
- R_TimeReport("drawtrans");
+ if (r_timereport_active)
+ R_TimeReport("drawtrans");
if (cl.csqc_vidvars.drawworld)
{
R_DrawCoronas();
- R_TimeReport("coronas");
+ if (r_timereport_active)
+ R_TimeReport("coronas");
}
if(cl.csqc_vidvars.drawcrosshair)
{
R_DrawWorldCrosshair();
- R_TimeReport("crosshair");
+ if (r_timereport_active)
+ R_TimeReport("crosshair");
}
VM_AddPolygonsToMeshQueue();
VM_CheckEmptyString( file );
VM_CheckEmptyString( name );
- if( CL_OpenVideo( file, name, MENUOWNER ) )
+ if( CL_OpenVideo( file, name, MENUOWNER, false ) )
PRVM_G_FLOAT( OFS_RETURN ) = 1;
else
PRVM_G_FLOAT( OFS_RETURN ) = 0;
return;
beamrepeatscale = 1.0f / r_lightningbeam_repeatdistance.value;
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ for (i = 0, b = cl_beams;i < cl_activebeams;i++, b++)
{
if (b->model && b->endtime >= r_refdef.time && b->lightning)
{
// render profiling stuff
extern char r_speeds_string[1024];
+extern int r_timereport_active;
// lighting stuff
extern cvar_t r_ambient;
extern rtexture_t *r_texture_fogintensity;
void R_TimeReport(char *name);
-void R_TimeReport_Start(void);
-void R_TimeReport_End(void);
// r_stain
void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2);