X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=gl_rmain.c;h=c4a257d239f4016a08b00ae0b56c65e1730a3361;hb=e4b3858e7aca0ead91be1d8f675db084d025abad;hp=c2836b8718e08983da0b8e498443a099ac395eb7;hpb=9ba80c169d244d56e90f437c512f827953cc1208;p=xonotic%2Fdarkplaces.git diff --git a/gl_rmain.c b/gl_rmain.c index c2836b87..c4a257d2 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -33,7 +33,7 @@ int r_framecount; // used for dlight push checking mplane_t frustum[4]; -int c_brush_polys, c_alias_polys, c_light_polys, c_nodes, c_leafs; +int c_brush_polys, c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights; qboolean envmap; // true during envmap command capture @@ -73,16 +73,15 @@ cvar_t r_speeds = {"r_speeds","0"}; cvar_t r_speeds2 = {"r_speeds2","0"}; cvar_t r_fullbright = {"r_fullbright","0"}; //cvar_t r_lightmap = {"r_lightmap","0"}; -cvar_t r_shadows = {"r_shadows","0"}; cvar_t r_wateralpha = {"r_wateralpha","1"}; cvar_t r_dynamic = {"r_dynamic","1"}; cvar_t r_novis = {"r_novis","0"}; cvar_t r_waterripple = {"r_waterripple","0"}; cvar_t r_fullbrights = {"r_fullbrights", "1"}; -cvar_t contrast = {"contrast", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction -cvar_t brightness = {"brightness", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction -cvar_t gl_lightmode = {"gl_lightmode", "1", TRUE}; // LordHavoc: overbright lighting +cvar_t contrast = {"contrast", "1.0", true}; // LordHavoc: a method of operating system independent color correction +cvar_t brightness = {"brightness", "1.0", true}; // LordHavoc: a method of operating system independent color correction +cvar_t gl_lightmode = {"gl_lightmode", "1", true}; // LordHavoc: overbright lighting //cvar_t r_dynamicbothsides = {"r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right... cvar_t r_farclip = {"r_farclip", "6144"}; @@ -223,6 +222,9 @@ void glmain_shutdown() void GL_Main_Init() { FOG_registercvars(); + Cvar_RegisterVariable (&r_drawentities); + Cvar_RegisterVariable (&r_drawviewmodel); + Cvar_RegisterVariable (&r_speeds); Cvar_RegisterVariable (&r_speeds2); Cvar_RegisterVariable (&contrast); Cvar_RegisterVariable (&brightness); @@ -230,6 +232,10 @@ void GL_Main_Init() // Cvar_RegisterVariable (&r_dynamicwater); // Cvar_RegisterVariable (&r_dynamicbothsides); Cvar_RegisterVariable (&r_fullbrights); + Cvar_RegisterVariable (&r_wateralpha); + Cvar_RegisterVariable (&r_dynamic); + Cvar_RegisterVariable (&r_novis); + Cvar_RegisterVariable (&r_waterripple); // LordHavoc: added waterripple if (nehahra) Cvar_SetValue("r_fullbrights", 0); // if (gl_vendor && strstr(gl_vendor, "3Dfx")) @@ -248,6 +254,8 @@ extern void GL_Misc_Init(); extern void R_Crosshairs_Init(); extern void R_Light_Init(); extern void R_Particles_Init(); +extern void R_Explosion_Init(); +extern void CL_Effects_Init(); void Render_Init() { @@ -262,6 +270,8 @@ void Render_Init() R_Crosshairs_Init(); R_Light_Init(); R_Particles_Init(); + R_Explosion_Init(); + CL_Effects_Init(); R_StartModules(); } @@ -270,7 +280,7 @@ void Render_Init() GL_Init =============== */ -extern char *QSG_EXTENSIONS; +extern char *ENGINE_EXTENSIONS; void GL_Init (void) { gl_vendor = glGetString (GL_VENDOR); @@ -285,11 +295,11 @@ void GL_Init (void) // Con_Printf ("%s %s\n", gl_renderer, gl_version); - VID_CheckMultiTexture(); - VID_CheckVertexArrays(); + VID_CheckMultitexture(); + VID_CheckCVA(); // LordHavoc: report supported extensions - Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS); + Con_Printf ("\nengine extensions: %s\n", ENGINE_EXTENSIONS); glCullFace(GL_FRONT); glEnable(GL_TEXTURE_2D); @@ -315,13 +325,6 @@ void R_RotateForEntity (entity_t *e) } */ -// LordHavoc: if not for the fact BRIGHTFIELD particles require this, it would be removed... -#define NUMVERTEXNORMALS 162 - -float r_avertexnormals[NUMVERTEXNORMALS][3] = { -#include "anorms.h" -}; - // LordHavoc: shading stuff vec3_t shadevector; vec3_t shadecolor; @@ -331,7 +334,49 @@ float modelalpha; //================================================================================== void R_DrawBrushModel (entity_t *e); -void R_DrawSpriteModel (entity_t *e); +void R_DrawSpriteModel (entity_t *e, frameblend_t *blend); + +void R_LerpUpdate(entity_t *ent) +{ + int frame; + frame = ent->frame; + if (ent->model && ent->frame >= ent->model->numframes) + { + Con_Printf("R_LerpUpdate: no such frame%6i in \"%s\"\n", ent->frame, ent->model->name); + frame = 0; + } + + if (ent->lerp_model != ent->model) + { + // reset all interpolation information + ent->lerp_model = ent->model; + ent->frame1 = ent->frame2 = frame; + ent->frame1start = ent->frame2start = cl.time; + ent->framelerp = 1; + ent->lerp_starttime = 0; + } + else if (ent->frame2 != frame) + { + // transition to new frame + ent->frame1 = ent->frame2; + ent->frame1start = ent->frame2start; + ent->frame2 = frame; + ent->frame2start = cl.time; + ent->framelerp = 0; + ent->lerp_starttime = cl.time; + } + else + { + // lerp_starttime < 0 is used to prevent changing of framelerp + if (ent->lerp_starttime >= 0) + { + // update transition + ent->framelerp = (cl.time - ent->lerp_starttime) * 10; + ent->framelerp = bound(0, ent->framelerp, 1); + } + } +} + /* ============= @@ -360,6 +405,7 @@ void R_DrawEntitiesOnList1 (void) void R_DrawEntitiesOnList2 (void) { int i; + frameblend_t blend[4]; if (!r_drawentities.value) return; @@ -372,11 +418,18 @@ void R_DrawEntitiesOnList2 (void) switch (currententity->model->type) { case mod_alias: - R_DrawAliasModel (currententity, true, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->effects, currententity->model->flags, currententity->colormap); + if (!strcmp(currententity->model->name, "progs/flame2.mdl")) + blend[0].frame = 0; + + R_LerpUpdate(currententity); + R_LerpAnimation(currententity->model, currententity->frame1, currententity->frame2, currententity->frame1start, currententity->frame2start, currententity->framelerp, blend); + R_DrawAliasModel (currententity, true, modelalpha, currententity->model, blend, currententity->skinnum, currententity->origin, currententity->angles, currententity->scale, currententity->effects, currententity->model->flags, currententity->colormap); break; case mod_sprite: - R_DrawSpriteModel (currententity); + R_LerpUpdate(currententity); + R_LerpAnimation(currententity->model, currententity->frame1, currententity->frame2, currententity->frame1start, currententity->frame2start, currententity->framelerp, blend); + R_DrawSpriteModel (currententity, blend); break; default: @@ -392,6 +445,8 @@ R_DrawViewModel */ void R_DrawViewModel (void) { + frameblend_t blend[4]; + if (!r_drawviewmodel.value || chase_active.value || envmap || !r_drawentities.value || cl.items & IT_INVISIBILITY || cl.stats[STAT_HEALTH] <= 0 || !cl.viewent.model) return; @@ -401,9 +456,12 @@ void R_DrawViewModel (void) currententity->scale = 1; VectorCopy(cl_entities[cl.viewentity].colormod, currententity->colormod); + R_LerpUpdate(currententity); + R_LerpAnimation(currententity->model, currententity->frame1, currententity->frame2, currententity->frame1start, currententity->frame2start, currententity->framelerp, blend); + // hack the depth range to prevent view model from poking into walls glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); - R_DrawAliasModel (currententity, FALSE, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->effects, currententity->model->flags, currententity->colormap); + R_DrawAliasModel (currententity, false, modelalpha, currententity->model, blend, currententity->skinnum, currententity->origin, currententity->angles, currententity->scale, currententity->effects, currententity->model->flags, currententity->colormap); glDepthRange (gldepthmin, gldepthmax); } @@ -484,9 +542,14 @@ void R_SetupFrame (void) c_brush_polys = 0; c_alias_polys = 0; c_light_polys = 0; + c_faces = 0; c_nodes = 0; c_leafs = 0; - + c_models = 0; + c_bmodels = 0; + c_sprites = 0; + c_particles = 0; +// c_dlights = 0; } @@ -586,10 +649,6 @@ void R_SetupGL (void) glShadeModel(GL_SMOOTH); } -void R_DrawWorld (void); -//void R_RenderDlights (void); -void R_DrawParticles (void); - /* ============= R_Clear @@ -680,6 +739,7 @@ void GL_BlendView() glEnable(GL_TEXTURE_2D); } +/* #define TIMEREPORT(DESC) \ if (r_speeds2.value)\ {\ @@ -688,6 +748,16 @@ void GL_BlendView() temptime += currtime;\ Con_Printf(DESC " %.4fms ", temptime * 1000.0);\ } +*/ +#define TIMEREPORT(VAR) \ + if (r_speeds2.value)\ + {\ + temptime = currtime;\ + currtime = Sys_FloatTime();\ + VAR = (int) ((currtime - temptime) * 1000000.0);\ + }\ + else\ + VAR = 0; /* ================ @@ -700,8 +770,11 @@ extern qboolean intimerefresh; extern qboolean skyisvisible; extern void R_Sky(); extern void UploadLightmaps(); +char r_speeds2_string1[81], r_speeds2_string2[81], r_speeds2_string3[81], r_speeds2_string4[81], r_speeds2_string5[81], r_speeds2_string6[81]; void R_RenderView (void) { + double starttime, currtime, temptime; + int time_clear, time_setup, time_world, time_bmodels, time_upload, time_sky, time_wall, time_models, time_moveparticles, time_drawparticles, time_moveexplosions, time_drawexplosions, time_transpoly, time_blend, time_total; // double currtime, temptime; // if (r_norefresh.value) // return; @@ -713,13 +786,16 @@ void R_RenderView (void) FOG_framebegin(); -// if (r_speeds2.value) -// { -// currtime = Sys_FloatTime(); + if (r_speeds2.value) + { + starttime = currtime = Sys_FloatTime(); // Con_Printf("render time: "); -// } + } + else + starttime = currtime = 0; R_Clear(); -// TIMEREPORT("R_Clear") + skyisvisible = false; + TIMEREPORT(time_clear) // render normal view @@ -730,30 +806,59 @@ void R_RenderView (void) skypolyclear(); wallpolyclear(); transpolyclear(); - skyisvisible = false; + + TIMEREPORT(time_setup) R_MarkLeaves (); // done here so we know if we're in water R_DrawWorld (); // adds static entities to the list - if (!intimerefresh) - S_ExtraUpdate (); // don't let sound get messed up if going slow + TIMEREPORT(time_world) R_DrawEntitiesOnList1 (); // BSP models + TIMEREPORT(time_bmodels) + + UploadLightmaps(); + TIMEREPORT(time_upload) skypolyrender(); // fogged sky polys, affects depth + if (skyname[0] && skyisvisible && !fogenabled) R_Sky(); // does not affect depth, draws over the sky polys + TIMEREPORT(time_sky) - UploadLightmaps(); wallpolyrender(); + TIMEREPORT(time_wall) + + if (!intimerefresh && !r_speeds2.value) + S_ExtraUpdate (); // don't let sound get messed up if going slow R_DrawEntitiesOnList2 (); // other models // R_RenderDlights (); R_DrawViewModel (); + TIMEREPORT(time_models) + R_MoveParticles (); + TIMEREPORT(time_moveparticles) R_DrawParticles (); + TIMEREPORT(time_drawparticles) + R_MoveExplosions(); + TIMEREPORT(time_moveexplosions) + R_DrawExplosions(); + TIMEREPORT(time_drawexplosions) transpolyrender(); + TIMEREPORT(time_transpoly) FOG_frameend(); + GL_BlendView(); -// if (r_speeds2.value) + TIMEREPORT(time_blend) + if (r_speeds2.value) + { + time_total = (int) ((Sys_FloatTime() - starttime) * 1000000.0); // Con_Printf("\n"); + sprintf(r_speeds2_string1, "%6i walls %6i dlitwalls %7i modeltris %7i transpoly\n", c_brush_polys, c_light_polys, c_alias_polys, currenttranspoly); + sprintf(r_speeds2_string2, "BSP: %6i faces %6i nodes %6i leafs\n", c_faces, c_nodes, c_leafs); + sprintf(r_speeds2_string3, "%4i models %4i bmodels %4i sprites %5i particles %3i dlights\n", c_models, c_bmodels, c_sprites, c_particles, c_dlights); + sprintf(r_speeds2_string4, "%6ius clear %6ius setup %6ius world %6ius bmodel %6ius upload", time_clear, time_setup, time_world, time_bmodels, time_upload); + sprintf(r_speeds2_string5, "%6ius sky %6ius wall %6ius models %6ius mpart %6ius dpart ", time_sky, time_wall, time_models, time_moveparticles, time_drawparticles); + sprintf(r_speeds2_string6, "%6ius trans %6ius blend %6ius total %6ius permdl", time_transpoly, time_blend, time_total, time_models / max(c_models, 1)); + } }