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
//int particletexture; // little dot for particles
//int playertextures; // up to 16 color translated skins
-extern qboolean isG200, isRagePro; // LordHavoc: special card hacks
-
//
// view origin
//
cvar_t gl_fogend = {"gl_fogend","0"};
cvar_t glfog = {"glfog", "0"};
-extern qboolean isRagePro;
-
qboolean lighthalf;
vec3_t fogcolor;
fog_blue = 0;
}
}
+ if (fog_density)
+ {
+ fogcolor[0] = fog_red = bound(0.0f, fog_red , 1.0f);
+ fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
+ fogcolor[2] = fog_blue = bound(0.0f, fog_blue , 1.0f);
+ if (lighthalf)
+ {
+ fogcolor[0] *= 0.5f;
+ fogcolor[1] *= 0.5f;
+ fogcolor[2] *= 0.5f;
+ }
+ }
if (glfog.value)
{
+ if (!r_render.value)
+ return;
if(fog_density)
{
// LordHavoc: Borland C++ 5.0 was choking on this line, stupid compiler...
{
fogenabled = true;
fogdensity = -4000.0f / (fog_density * fog_density);
- fogcolor[0] = fog_red = bound(0.0f, fog_red , 1.0f);
- fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
- fogcolor[2] = fog_blue = bound(0.0f, fog_blue , 1.0f);
- if (lighthalf)
- {
- fogcolor[0] *= 0.5f;
- fogcolor[1] *= 0.5f;
- fogcolor[2] *= 0.5f;
- }
+ // fog color was already set
}
else
fogenabled = false;
void GL_Main_Init()
{
FOG_registercvars();
+ Cvar_RegisterVariable (&r_drawentities);
+ Cvar_RegisterVariable (&r_drawviewmodel);
+ Cvar_RegisterVariable (&r_shadows);
+ Cvar_RegisterVariable (&r_speeds);
Cvar_RegisterVariable (&r_speeds2);
Cvar_RegisterVariable (&contrast);
Cvar_RegisterVariable (&brightness);
// 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"))
R_StartModules();
}
+/*
+===============
+GL_Init
+===============
+*/
+extern char *QSG_EXTENSIONS;
+void GL_Init (void)
+{
+ gl_vendor = glGetString (GL_VENDOR);
+ Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
+ gl_renderer = glGetString (GL_RENDERER);
+ Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
+
+ gl_version = glGetString (GL_VERSION);
+ Con_Printf ("GL_VERSION: %s\n", gl_version);
+ gl_extensions = glGetString (GL_EXTENSIONS);
+ Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
+
+// Con_Printf ("%s %s\n", gl_renderer, gl_version);
+
+ VID_CheckMultitexture();
+ VID_CheckVertexArrays();
+
+ // LordHavoc: report supported extensions
+ Con_Printf ("\nQSG extensions: %s\n", QSG_EXTENSIONS);
+
+ glCullFace(GL_FRONT);
+ glEnable(GL_TEXTURE_2D);
+// glDisable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.5);
+
+// glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+
+ Palette_Init();
+}
+
+
/*
void R_RotateForEntity (entity_t *e)
{
#include "anorms.h"
};
-// LordHavoc: moved this shading stuff up because the sprites need shading stuff
+// LordHavoc: shading stuff
vec3_t shadevector;
vec3_t shadecolor;
float modelalpha;
-extern void R_LightPoint (vec3_t color, vec3_t p);
-extern void R_DynamicLightPoint(vec3_t color, vec3_t org, int *dlightbits);
-extern void R_DynamicLightPointNoMask(vec3_t color, vec3_t org);
-
-/*
-=============================================================
-
- SPRITE MODELS
-
-=============================================================
-*/
-
-/*
-================
-R_GetSpriteFrame
-================
-*/
-void R_GetSpriteFrame (entity_t *currententity, mspriteframe_t **oldframe, mspriteframe_t **newframe, float *framelerp)
-{
- msprite_t *psprite;
- mspritegroup_t *pspritegroup;
- int i, j, numframes, frame;
- float *pintervals, fullinterval, targettime, time, jtime, jinterval;
-
- psprite = currententity->model->cache.data;
- frame = currententity->frame;
-
- if ((frame >= psprite->numframes) || (frame < 0))
- {
- Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
- frame = 0;
- }
-
- if (psprite->frames[frame].type == SPR_SINGLE)
- {
- if (currententity->draw_lastmodel == currententity->model && currententity->draw_lerpstart < cl.time)
- {
- if (frame != currententity->draw_pose)
- {
- currententity->draw_lastpose = currententity->draw_pose;
- currententity->draw_pose = frame;
- currententity->draw_lerpstart = cl.time;
- *framelerp = 0;
- }
- else
- *framelerp = (cl.time - currententity->draw_lerpstart) * 10.0;
- }
- else // uninitialized
- {
- currententity->draw_lastmodel = currententity->model;
- currententity->draw_lastpose = currententity->draw_pose = frame;
- currententity->draw_lerpstart = cl.time;
- *framelerp = 0;
- }
- *oldframe = psprite->frames[currententity->draw_lastpose].frameptr;
- *newframe = psprite->frames[frame].frameptr;
- }
- else
- {
- pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
- pintervals = pspritegroup->intervals;
- numframes = pspritegroup->numframes;
- fullinterval = pintervals[numframes-1];
-
- time = cl.time + currententity->syncbase;
-
- // when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
- // are positive, so we don't have to worry about division by 0
- targettime = time - ((int)(time / fullinterval)) * fullinterval;
-
- // LordHavoc: since I can't measure the time properly when it loops from numframes-1 to 0,
- // I instead measure the time of the first frame, hoping it is consistent
- j = numframes-1;jtime = 0;jinterval = pintervals[1] - pintervals[0];
- for (i=0 ; i<(numframes-1) ; i++)
- {
- if (pintervals[i] > targettime)
- break;
- j = i;jinterval = pintervals[i] - jtime;jtime = pintervals[i];
- }
- *framelerp = (targettime - jtime) / jinterval;
-
- *oldframe = pspritegroup->frames[j];
- *newframe = pspritegroup->frames[i];
- }
-}
-
-void GL_DrawSpriteImage (mspriteframe_t *frame, vec3_t origin, vec3_t up, vec3_t right, int red, int green, int blue, int alpha)
-{
- // LordHavoc: rewrote this to use the transparent poly system
- transpolybegin(frame->gl_texturenum, 0, frame->gl_fogtexturenum, currententity->effects & EF_ADDITIVE ? TPOLYTYPE_ADD : TPOLYTYPE_ALPHA);
- transpolyvert(origin[0] + frame->down * up[0] + frame->left * right[0], origin[1] + frame->down * up[1] + frame->left * right[1], origin[2] + frame->down * up[2] + frame->left * right[2], 0, 1, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->up * up[0] + frame->left * right[0], origin[1] + frame->up * up[1] + frame->left * right[1], origin[2] + frame->up * up[2] + frame->left * right[2], 0, 0, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->up * up[0] + frame->right * right[0], origin[1] + frame->up * up[1] + frame->right * right[1], origin[2] + frame->up * up[2] + frame->right * right[2], 1, 0, red, green, blue, alpha);
- transpolyvert(origin[0] + frame->down * up[0] + frame->right * right[0], origin[1] + frame->down * up[1] + frame->right * right[1], origin[2] + frame->down * up[2] + frame->right * right[2], 1, 1, red, green, blue, alpha);
- transpolyend();
-}
-
-extern qboolean isG200, isRagePro, lighthalf;
-
-/*
-=================
-R_DrawSpriteModel
-
-=================
-*/
-void R_DrawSpriteModel (entity_t *e)
-{
- mspriteframe_t *oldframe, *newframe;
- float *up, *right, lerp, ilerp;
- vec3_t v_forward, v_right, v_up, org;
- msprite_t *psprite;
-
- // don't even bother culling, because it's just a single
- // polygon without a surface cache
- R_GetSpriteFrame (e, &oldframe, &newframe, &lerp);
- if (lerp < 0) lerp = 0;
- if (lerp > 1) lerp = 1;
- if (isRagePro) // LordHavoc: no alpha scaling supported on per pixel alpha images on ATI Rage Pro... ACK!
- lerp = 1;
- ilerp = 1.0 - lerp;
- psprite = e->model->cache.data;
-
- if (psprite->type == SPR_ORIENTED)
- { // bullet marks on walls
- AngleVectors (e->angles, v_forward, v_right, v_up);
- up = v_up;
- right = v_right;
- VectorSubtract(e->origin, vpn, org);
- }
- else
- { // normal sprite
- up = vup;
- right = vright;
- VectorCopy(e->origin, org);
- }
- if (e->scale != 1)
- {
- VectorScale(up, e->scale, up);
- VectorScale(right, e->scale, right);
- }
-
- if (e->model->flags & EF_FULLBRIGHT || e->effects & EF_FULLBRIGHT)
- {
- shadecolor[0] = e->colormod[0] * 255;
- shadecolor[1] = e->colormod[1] * 255;
- shadecolor[2] = e->colormod[2] * 255;
- }
- else
- {
- R_LightPoint (shadecolor, e->origin);
- R_DynamicLightPointNoMask(shadecolor, e->origin);
- }
-
- // LordHavoc: interpolated sprite rendering
- if (ilerp != 0)
- GL_DrawSpriteImage(oldframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*ilerp);
- if (lerp != 0)
- GL_DrawSpriteImage(newframe, org, up, right, shadecolor[0],shadecolor[1],shadecolor[2],e->alpha*255*lerp);
-}
-
//==================================================================================
void R_DrawBrushModel (entity_t *e);
+void R_DrawSpriteModel (entity_t *e);
/*
=============
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;
}
extern int glwidth, glheight;
int x, x2, y2, y, w, h;
+ if (!r_render.value)
+ return;
//
// set up viewpoint
//
glShadeModel(GL_SMOOTH);
}
-void R_DrawWorld (void);
-//void R_RenderDlights (void);
-void R_DrawParticles (void);
-
/*
=============
R_Clear
*/
void R_Clear (void)
{
+ if (!r_render.value)
+ return;
// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: moved to SCR_UpdateScreen
gldepthmin = 0;
gldepthmax = 1;
// LordHavoc: my trick to *FIX* GLQuake lighting once and for all :)
void GL_Brighten()
{
+ if (!r_render.value)
+ return;
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
void GL_BlendView()
{
+ if (!r_render.value)
+ return;
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
glEnable(GL_TEXTURE_2D);
}
+/*
#define TIMEREPORT(DESC) \
if (r_speeds2.value)\
{\
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);\
+ }
/*
================
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_transpoly, time_blend, time_total;
// double currtime, temptime;
// if (r_norefresh.value)
// return;
FOG_framebegin();
-// if (r_speeds2.value)
-// {
-// currtime = Sys_FloatTime();
+ if (r_speeds2.value)
+ {
+ starttime = currtime = Sys_FloatTime();
// Con_Printf("render time: ");
-// }
+ }
R_Clear();
-// TIMEREPORT("R_Clear")
+ skypolyclear();
+ wallpolyclear();
+ transpolyclear();
+ skyisvisible = false;
+ TIMEREPORT(time_clear)
// render normal view
R_SetupFrame ();
R_SetFrustum ();
R_SetupGL ();
-
- 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)
+// 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)
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));
+ }
}