-
-extern char skyname[];
-
-/*
-=============
-R_SetupGL
-=============
-*/
-void R_SetupGL (void)
-{
- float screenaspect;
- extern int glwidth, glheight;
- int x, x2, y2, y, w, h;
-
- //
- // set up viewpoint
- //
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity ();
- x = r_refdef.vrect.x * glwidth/vid.width;
- x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * glwidth/vid.width;
- y = (vid.height-r_refdef.vrect.y) * glheight/vid.height;
- y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height)) * glheight/vid.height;
-
- // fudge around because of frac screen scale
- if (x > 0)
- x--;
- if (x2 < glwidth)
- x2++;
- if (y2 < 0)
- y2--;
- if (y < glheight)
- y++;
-
- w = x2 - x;
- h = y - y2;
-
- if (envmap)
- {
- x = y2 = 0;
- w = h = 256;
- }
-
- glViewport (glx + x, gly + y2, w, h);
- screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
-// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
-// if (skyname[0]) // skybox enabled?
-// MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_skyboxsize.value*1.732050807569 + 256); // this is size*sqrt(3) + 256
-// else
- MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_farclip.value);
-
- glCullFace(GL_FRONT);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity ();
-
- glRotatef (-90, 1, 0, 0); // put Z going up
- glRotatef (90, 0, 0, 1); // put Z going up
- glRotatef (-r_refdef.viewangles[2], 1, 0, 0);
- glRotatef (-r_refdef.viewangles[0], 0, 1, 0);
- glRotatef (-r_refdef.viewangles[1], 0, 0, 1);
- glTranslatef (-r_refdef.vieworg[0], -r_refdef.vieworg[1], -r_refdef.vieworg[2]);
-
- glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
-
- //
- // set drawing parms
- //
-// if (gl_cull.value)
- glEnable(GL_CULL_FACE);
-// else
-// glDisable(GL_CULL_FACE);
-
- glEnable(GL_BLEND); // was Disable
- glDisable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.5);
- glEnable(GL_DEPTH_TEST);
- glDepthMask(1);
- glShadeModel(GL_SMOOTH);
-}
-
-void R_DrawWorld (void);
-//void R_RenderDlights (void);
-void R_DrawParticles (void);
-
-/*
-=============
-R_Clear
-=============
-*/
-void R_Clear (void)
-{
-// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: moved to SCR_UpdateScreen
- gldepthmin = 0;
- gldepthmax = 1;
- glDepthFunc (GL_LEQUAL);
-
- glDepthRange (gldepthmin, gldepthmax);
-}
-
-// LordHavoc: my trick to *FIX* GLQuake lighting once and for all :)
-void GL_Brighten()
-{
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity ();
- glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity ();
- glDisable (GL_DEPTH_TEST);
- glDisable (GL_CULL_FACE);
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- glBlendFunc (GL_DST_COLOR, GL_ONE);
- glBegin (GL_TRIANGLES);
- glColor3f (1, 1, 1);
- glVertex2f (-5000, -5000);
- glVertex2f (10000, -5000);
- glVertex2f (-5000, 10000);
- glEnd ();
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glEnable (GL_DEPTH_TEST);
- glEnable (GL_CULL_FACE);
-}
-
-extern cvar_t contrast;
-extern cvar_t brightness;
-extern cvar_t gl_lightmode;
-
-void GL_BlendView()
-{
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity ();
- glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity ();
- glDisable (GL_DEPTH_TEST);
- glDisable (GL_CULL_FACE);
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- if (lighthalf)
- {
- glBlendFunc (GL_DST_COLOR, GL_ONE);
- glBegin (GL_TRIANGLES);
- glColor3f (1, 1, 1);
- glVertex2f (-5000, -5000);
- glVertex2f (10000, -5000);
- glVertex2f (-5000, 10000);
- glEnd ();
- }
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- contrast.value = bound(0.2, contrast.value, 1.0);
- if (/*gl_polyblend.value && */v_blend[3])
- {
- glBegin (GL_TRIANGLES);
- glColor4fv (v_blend);
- glVertex2f (-5000, -5000);
- glVertex2f (10000, -5000);
- glVertex2f (-5000, 10000);
- glEnd ();
- }
-
- glEnable (GL_CULL_FACE);
- glEnable (GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
-}
-
-#define TIMEREPORT(DESC) \
- if (r_speeds2.value)\
- {\
- temptime = -currtime;\
- currtime = Sys_FloatTime();\
- temptime += currtime;\
- Con_Printf(DESC " %.4fms ", temptime * 1000.0);\
- }
-