]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cleaned up R_RenderView setup code a bit, and shuffled SCR_CalcRefdef stuff to SCR_Up...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 21 Feb 2004 21:05:21 +0000 (21:05 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 21 Feb 2004 21:05:21 +0000 (21:05 +0000)
scissor is now on during all of R_RenderView (including rtlight portions), and GL_Scissor is used to set it instead of direct qglScissor calls, also GL_ScissorTest is used
r_farclip is now calculated without need for... just about anything, this allowed shuffling the setup code around a bit
various cleanups to allow multiple view renders per frame
added scr_zoomwindow cvars to do a (silly) zoomed view picture-in-picture overlay, it works but turned out useless in playtesting unless you want to stare at a shambler's chest... ugh
R_AnimateLight and R_BuildLightList merged to become R_UpdateLights
some setup code from R_RenderView became a new function R_UpdateWorld
GL_SetupView_ViewPort calls replaced by qglViewport calls, as it was a mostly useless wrapper

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3919 d7cf8633-e32d-0410-b094-e92efae38249

13 files changed:
cl_main.c
cl_screen.c
gl_backend.c
gl_backend.h
gl_draw.c
gl_rmain.c
host.c
r_light.c
r_light.h
r_shadow.c
render.h
screen.h
todo

index 42b01de1846b8194feaa63155b5202635d077190..e45180f064f2edc27f33344c7ce7df265e5b808a 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1133,6 +1133,7 @@ int CL_ReadFromServer(void)
 
                // move particles
                CL_MoveParticles();
+               R_MoveExplosions();
 
                // link stuff
                CL_RelinkWorld();
index b8038ba79cd22f6b3e7fad775fd17556d7bf5560..9384f3e2e5f66fbb44cdac27139826465d46b780 100644 (file)
@@ -5,7 +5,7 @@
 #include "cl_collision.h"
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100"};
-cvar_t scr_fov = {CVAR_SAVE, "fov","90"};      // 10 - 170
+cvar_t scr_fov = {CVAR_SAVE, "fov","90"};      // 1 - 170
 cvar_t scr_conspeed = {CVAR_SAVE, "scr_conspeed","900"}; // LordHavoc: quake used 300
 cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1"};
 cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "0.2"};
@@ -645,97 +645,6 @@ void DrawQ_ResetClipArea(void)
        r_refdef.drawqueuesize += dq->size;
 }
 
-/*
-====================
-CalcFov
-====================
-*/
-float CalcFov (float fov_x, float width, float height)
-{
-       // calculate vision size and alter by aspect, then convert back to angle
-       return atan (height / (width / tan(fov_x/360*M_PI))) * 360 / M_PI;
-}
-
-/*
-=================
-SCR_CalcRefdef
-
-Must be called whenever vid changes
-Internal use only
-=================
-*/
-static void SCR_CalcRefdef (void)
-{
-       float size;
-       int contents;
-
-//========================================
-
-// bound viewsize
-       if (scr_viewsize.value < 30)
-               Cvar_Set ("viewsize","30");
-       if (scr_viewsize.value > 120)
-               Cvar_Set ("viewsize","120");
-
-// bound field of view
-       if (scr_fov.value < 10)
-               Cvar_Set ("fov","10");
-       if (scr_fov.value > 170)
-               Cvar_Set ("fov","170");
-
-// intermission is always full screen
-       if (cl.intermission)
-       {
-               size = 1;
-               sb_lines = 0;
-       }
-       else
-       {
-               if (scr_viewsize.value >= 120)
-                       sb_lines = 0;           // no status bar at all
-               else if (scr_viewsize.value >= 110)
-                       sb_lines = 24;          // no inventory
-               else
-                       sb_lines = 24+16+8;
-               size = scr_viewsize.value * (1.0 / 100.0);
-       }
-
-       if (size >= 1)
-       {
-               r_refdef.width = vid.realwidth;
-               r_refdef.height = vid.realheight;
-               r_refdef.x = 0;
-               r_refdef.y = 0;
-       }
-       else
-       {
-               r_refdef.width = vid.realwidth * size;
-               r_refdef.height = vid.realheight * size;
-               r_refdef.x = (vid.realwidth - r_refdef.width)/2;
-               r_refdef.y = (vid.realheight - r_refdef.height)/2;
-       }
-
-       r_refdef.width = bound(0, r_refdef.width, vid.realwidth);
-       r_refdef.height = bound(0, r_refdef.height, vid.realheight);
-       r_refdef.x = bound(0, r_refdef.x, vid.realwidth - r_refdef.width) + vid.realx;
-       r_refdef.y = bound(0, r_refdef.y, vid.realheight - r_refdef.height) + vid.realy;
-
-       // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
-       r_refdef.fov_x = scr_fov.value * cl.viewzoom;
-       r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.width, r_refdef.height);
-
-       if (cl.worldmodel)
-       {
-               Mod_CheckLoaded(cl.worldmodel);
-               contents = CL_PointSuperContents(r_vieworigin);
-               if (contents & SUPERCONTENTS_LIQUIDSMASK)
-               {
-                       r_refdef.fov_x *= (sin(cl.time * 4.7) * 0.015 + 0.985);
-                       r_refdef.fov_y *= (sin(cl.time * 3.0) * 0.015 + 0.985);
-               }
-       }
-}
-
 /*
 ==================
 SCR_ScreenShot_f
@@ -974,9 +883,6 @@ void CL_SetupScreenSize(void)
                vid.conheight = 240;*/
 
        SCR_SetUpToDrawConsole();
-
-       // determine size of refresh window
-       SCR_CalcRefdef();
 }
 
 extern void R_Shadow_EditLights_DrawSelectedLightProperties(void);
index 869e338b4a6b609ad5a9e37018136b2a432f1fc8..9f970fe63e4ed91a434ce542d3f688b17478af0a 100644 (file)
@@ -2,6 +2,7 @@
 #include "quakedef.h"
 #include "image.h"
 #include "jpeg.h"
+#include "cl_collision.h"
 
 cvar_t gl_mesh_drawrangeelements = {0, "gl_mesh_drawrangeelements", "1"};
 cvar_t gl_mesh_testarrayelement = {0, "gl_mesh_testarrayelement", "0"};
@@ -186,6 +187,11 @@ static void gl_backend_newmap(void)
 {
 }
 
+cvar_t scr_zoomwindow = {CVAR_SAVE, "scr_zoomwindow", "0"};
+cvar_t scr_zoomwindow_viewsizex = {CVAR_SAVE, "scr_zoomwindow_viewsizex", "20"};
+cvar_t scr_zoomwindow_viewsizey = {CVAR_SAVE, "scr_zoomwindow_viewsizey", "20"};
+cvar_t scr_zoomwindow_fov = {CVAR_SAVE, "scr_zoomwindow_fov", "20"};
+
 void gl_backend_init(void)
 {
        int i;
@@ -210,17 +216,13 @@ void gl_backend_init(void)
        Cvar_RegisterVariable(&gl_mesh_drawrangeelements);
        Cvar_RegisterVariable(&gl_mesh_testarrayelement);
        Cvar_RegisterVariable(&gl_mesh_testmanualfeeding);
-       R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
-}
 
-void GL_SetupView_ViewPort (int x, int y, int width, int height)
-{
-       if (!r_render.integer)
-               return;
+       Cvar_RegisterVariable(&scr_zoomwindow);
+       Cvar_RegisterVariable(&scr_zoomwindow_viewsizex);
+       Cvar_RegisterVariable(&scr_zoomwindow_viewsizey);
+       Cvar_RegisterVariable(&scr_zoomwindow_fov);
 
-       // y is weird beause OpenGL is bottom to top, we use top to bottom
-       qglViewport(x, vid.realheight - (y + height), width, height);
-       CHECKGLERROR
+       R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
 }
 
 void GL_SetupView_Orientation_Identity (void)
@@ -1075,6 +1077,17 @@ void R_ClearScreen(void)
        }
 }
 
+/*
+====================
+CalcFov
+====================
+*/
+float CalcFov (float fov_x, float width, float height)
+{
+       // calculate vision size and alter by aspect, then convert back to angle
+       return atan (height / (width / tan(fov_x/360*M_PI))) * 360 / M_PI;
+}
+
 /*
 ==================
 SCR_UpdateScreen
@@ -1107,8 +1120,77 @@ void SCR_UpdateScreen (void)
        R_TimeReport("clear");
 
        if (scr_conlines < vid.conheight && cls.signon == SIGNONS)
+       {
+               float size;
+               int contents;
+
+               // bound viewsize
+               if (scr_viewsize.value < 30)
+                       Cvar_Set ("viewsize","30");
+               if (scr_viewsize.value > 120)
+                       Cvar_Set ("viewsize","120");
+               
+               // bound field of view
+               if (scr_fov.value < 1)
+                       Cvar_Set ("fov","1");
+               if (scr_fov.value > 170)
+                       Cvar_Set ("fov","170");
+       
+               // intermission is always full screen
+               if (cl.intermission)
+               {
+                       size = 1;
+                       sb_lines = 0;
+               }
+               else
+               {
+                       if (scr_viewsize.value >= 120)
+                               sb_lines = 0;           // no status bar at all
+                       else if (scr_viewsize.value >= 110)
+                               sb_lines = 24;          // no inventory
+                       else
+                               sb_lines = 24+16+8;
+                       size = scr_viewsize.value * (1.0 / 100.0);
+                       size = min(size, 1);
+               }
+       
+               r_refdef.width = vid.realwidth * size;
+               r_refdef.height = vid.realheight * size;
+               r_refdef.x = (vid.realwidth - r_refdef.width)/2;
+               r_refdef.y = (vid.realheight - r_refdef.height)/2;
+       
+               // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
+               r_refdef.fov_x = scr_fov.value * cl.viewzoom;
+               r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.width, r_refdef.height);
+       
+               if (cl.worldmodel)
+               {
+                       Mod_CheckLoaded(cl.worldmodel);
+                       contents = CL_PointSuperContents(r_vieworigin);
+                       if (contents & SUPERCONTENTS_LIQUIDSMASK)
+                       {
+                               r_refdef.fov_x *= (sin(cl.time * 4.7) * 0.015 + 0.985);
+                               r_refdef.fov_y *= (sin(cl.time * 3.0) * 0.015 + 0.985);
+                       }
+               }
+
                R_RenderView();
 
+               if (scr_zoomwindow.integer)
+               {
+                       float sizex = bound(10, scr_zoomwindow_viewsizex.value, 100) / 100.0;
+                       float sizey = bound(10, scr_zoomwindow_viewsizey.value, 100) / 100.0;
+                       r_refdef.width = vid.realwidth * sizex;
+                       r_refdef.height = vid.realheight * sizey;
+                       r_refdef.x = (vid.realwidth - r_refdef.width)/2;
+                       r_refdef.y = 0;
+                       r_refdef.fov_x = scr_zoomwindow_fov.value;
+                       r_refdef.fov_y = CalcFov(r_refdef.fov_x, r_refdef.width, r_refdef.height);
+
+                       R_RenderView();
+               }
+       }
+
        // draw 2D stuff
        R_DrawQueue();
 
index dd43b40b27d16e3ae027b2b3f14bf26aab48be0a..cf828683c9848c68cddf2353d2249c44141b233b 100644 (file)
@@ -7,7 +7,6 @@
 #define POLYGONELEMENTS_MAXPOINTS 258
 extern int polygonelements[768];
 
-void GL_SetupView_ViewPort(int x, int y, int width, int height);
 void GL_SetupView_Orientation_Identity(void);
 void GL_SetupView_Orientation_FromEntity(matrix4x4_t *matrix);
 void GL_SetupView_Mode_Perspective(double fovx, double fovy, double zNear, double zFar);
index 8407edf2b438fe768f9cd5be29caaf3a6f3b5cd7..e143ad3ea2277e8f3b570af032c5354e466d620c 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -418,7 +418,7 @@ void R_DrawQueue(void)
                        quadelements[pos++] = num + 3;
                }
        }
-       GL_SetupView_ViewPort(vid.realx, vid.realy, vid.realwidth, vid.realheight);
+       qglViewport(0, 0, vid.realwidth, vid.realheight);
        GL_SetupView_Mode_Ortho(0, 0, vid.conwidth, vid.conheight, -10, 100);
        qglDepthFunc(GL_LEQUAL);
        R_Mesh_Start();
index 375f4d566674e0fc20abad256543ea2819d9a6b0..fef43b34fcfb7e1053f04a49844ae515cd67ce4d 100644 (file)
@@ -142,7 +142,7 @@ vec_t fogdensity;
 float fog_density, fog_red, fog_green, fog_blue;
 qboolean fogenabled;
 qboolean oldgl_fogenable;
-void R_SetupFog(void)
+void R_UpdateFog(void)
 {
        if (gamemode == GAME_NEHAHRA)
        {
@@ -267,28 +267,16 @@ void GL_Main_Init(void)
        R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
 }
 
-vec3_t r_farclip_origin;
-vec3_t r_farclip_direction;
-vec_t r_farclip_directiondist;
-vec_t r_farclip_meshfarclip;
-int r_farclip_directionbit0;
-int r_farclip_directionbit1;
-int r_farclip_directionbit2;
-
-// start a farclip measuring session
-void R_FarClip_Start(vec3_t origin, vec3_t direction, vec_t startfarclip)
-{
-       VectorCopy(origin, r_farclip_origin);
-       VectorCopy(direction, r_farclip_direction);
-       r_farclip_directiondist = DotProduct(r_farclip_origin, r_farclip_direction);
-       r_farclip_directionbit0 = r_farclip_direction[0] < 0;
-       r_farclip_directionbit1 = r_farclip_direction[1] < 0;
-       r_farclip_directionbit2 = r_farclip_direction[2] < 0;
-       r_farclip_meshfarclip = r_farclip_directiondist + startfarclip;
-}
+static vec3_t r_farclip_origin;
+static vec3_t r_farclip_direction;
+static vec_t r_farclip_directiondist;
+static vec_t r_farclip_meshfarclip;
+static int r_farclip_directionbit0;
+static int r_farclip_directionbit1;
+static int r_farclip_directionbit2;
 
 // enlarge farclip to accomodate box
-void R_FarClip_Box(vec3_t mins, vec3_t maxs)
+static void R_FarClip_Box(vec3_t mins, vec3_t maxs)
 {
        float d;
        d = (r_farclip_directionbit0 ? mins[0] : maxs[0]) * r_farclip_direction[0]
@@ -299,8 +287,23 @@ void R_FarClip_Box(vec3_t mins, vec3_t maxs)
 }
 
 // return farclip value
-float R_FarClip_Finish(void)
+static float R_FarClip(vec3_t origin, vec3_t direction, vec_t startfarclip)
 {
+       int i;
+
+       VectorCopy(origin, r_farclip_origin);
+       VectorCopy(direction, r_farclip_direction);
+       r_farclip_directiondist = DotProduct(r_farclip_origin, r_farclip_direction);
+       r_farclip_directionbit0 = r_farclip_direction[0] < 0;
+       r_farclip_directionbit1 = r_farclip_direction[1] < 0;
+       r_farclip_directionbit2 = r_farclip_direction[2] < 0;
+       r_farclip_meshfarclip = r_farclip_directiondist + startfarclip;
+
+       if (cl.worldmodel)
+               R_FarClip_Box(cl.worldmodel->normalmins, cl.worldmodel->normalmaxs);
+       for (i = 0;i < r_refdef.numentities;i++)
+               R_FarClip_Box(r_refdef.entities[i]->mins, r_refdef.entities[i]->maxs);
+       
        return r_farclip_meshfarclip - r_farclip_directiondist;
 }
 
@@ -417,9 +420,6 @@ static void R_MarkEntities (void)
        Matrix4x4_CreateIdentity(&ent->matrix);
        Matrix4x4_CreateIdentity(&ent->inversematrix);
 
-       if (cl.worldmodel)
-               R_FarClip_Box(cl.worldmodel->normalmins, cl.worldmodel->normalmaxs);
-
        if (!r_drawentities.integer)
                return;
 
@@ -436,10 +436,7 @@ static void R_MarkEntities (void)
                if ((chase_active.integer || !(ent->flags & RENDER_EXTERIORMODEL))
                 && !VIS_CullBox(ent->mins, ent->maxs)
                 && (!envmap || !(ent->flags & (RENDER_VIEWMODEL | RENDER_EXTERIORMODEL))))
-               {
                        ent->visframe = r_framecount;
-                       R_FarClip_Box(ent->mins, ent->maxs);
-               }
        }
 }
 
@@ -718,14 +715,18 @@ void R_ShadowVolumeLighting(int visiblevolumes)
        if (visiblevolumes)
        {
                qglEnable(GL_CULL_FACE);
-               qglDisable(GL_SCISSOR_TEST);
+               GL_Scissor(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
        }
        else
                R_Shadow_Stage_End();
 }
 
-static void R_SetFrustum (void)
+static void R_SetFrustum(void)
 {
+       // break apart the viewentity matrix into vectors for various purposes
+       Matrix4x4_ToVectors(&r_refdef.viewentitymatrix, r_viewforward, r_viewleft, r_viewup, r_vieworigin);
+       VectorNegate(r_viewleft, r_viewright);
+
        // LordHavoc: note to all quake engine coders, the special case for 90
        // degrees assumed a square view (wrong), so I removed it, Quake2 has it
        // disabled as well.
@@ -751,34 +752,6 @@ static void R_SetFrustum (void)
        PlaneClassify(&frustum[3]);
 }
 
-/*
-===============
-R_SetupFrame
-===============
-*/
-static void R_SetupFrame (void)
-{
-// don't allow cheats in multiplayer
-       if (!cl.islocalgame)
-       {
-               if (r_fullbright.integer != 0)
-                       Cvar_Set ("r_fullbright", "0");
-               if (r_ambient.value != 0)
-                       Cvar_Set ("r_ambient", "0");
-       }
-
-       r_framecount++;
-
-       // break apart the viewentity matrix into vectors for various purposes
-       Matrix4x4_ToVectors(&r_refdef.viewentitymatrix, r_viewforward, r_viewleft, r_viewup, r_vieworigin);
-       VectorNegate(r_viewleft, r_viewright);
-
-       GL_SetupView_ViewPort(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
-
-       R_AnimateLight();
-}
-
-
 static void R_BlendView(void)
 {
        rmeshstate_t m;
@@ -811,69 +784,111 @@ static void R_BlendView(void)
        R_Mesh_Draw(3, 1, polygonelements);
 }
 
+void R_UpdateWorld(void)
+{
+       if (!r_refdef.entities/* || !cl.worldmodel*/)
+               return; //Host_Error ("R_RenderView: NULL worldmodel");
+
+       if (r_shadow_realtime_world.integer && !gl_stencil)
+       {
+               Con_Printf("Realtime world lighting requires 32bit color; turning off r_shadow_realtime_world, please type vid_bitsperpixel 32;vid_restart and try again\n");
+               Cvar_SetValueQuick(&r_shadow_realtime_world, 0);
+       }
+
+       // don't allow cheats in multiplayer
+       if (!cl.islocalgame)
+       {
+               if (r_fullbright.integer != 0)
+                       Cvar_Set ("r_fullbright", "0");
+               if (r_ambient.value != 0)
+                       Cvar_Set ("r_ambient", "0");
+       }
+
+       R_Textures_Frame();
+       R_UpdateFog();
+       R_UpdateLights();
+}
+
+void R_RenderScene(void);
+
 /*
 ================
 R_RenderView
-
-r_refdef must be set before the first call
 ================
 */
-extern void R_DrawLightningBeams (void);
-void R_RenderView (void)
+void R_RenderView(void)
 {
-       entity_render_t *world;
        if (!r_refdef.entities/* || !cl.worldmodel*/)
                return; //Host_Error ("R_RenderView: NULL worldmodel");
+       
+       r_refdef.width = bound(0, r_refdef.width, vid.realwidth);
+       r_refdef.height = bound(0, r_refdef.height, vid.realheight);
+       r_refdef.x = bound(0, r_refdef.x, vid.realwidth - r_refdef.width);
+       r_refdef.y = bound(0, r_refdef.y, vid.realheight - r_refdef.height);
+       r_refdef.fov_x = bound(1, r_refdef.fov_x, 170);
+       r_refdef.fov_y = bound(1, r_refdef.fov_y, 170);
+
+       // GL is weird because it's bottom to top, r_refdef.y is top to bottom
+       qglViewport(r_refdef.x, vid.realheight - (r_refdef.y + r_refdef.height), r_refdef.width, r_refdef.height);
+       GL_Scissor(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
+       GL_ScissorTest(true);
+       R_ClearScreen();
 
-       if (r_shadow_realtime_world.integer)
-       {
-               if (!gl_stencil)
-               {
-                       Con_Printf("Realtime world lighting requires 32bit color turning off r_shadow_realtime_world, please type vid_bitsperpixel 32;vid_restart and try again\n");
-                       Cvar_SetValueQuick(&r_shadow_realtime_world, 0);
-               }
-       }
+       R_SetFrustum();
+       r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
 
-       world = &cl_entities[0].render;
+       if (gl_stencil && ((r_shadow_realtime_world.integer && r_shadow_worldshadows.integer) || ((r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && r_shadow_dlightshadows.integer)))
+               GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.fov_x, r_refdef.fov_y, 1.0f);
+       else
+               GL_SetupView_Mode_Perspective(r_refdef.fov_x, r_refdef.fov_y, 1.0f, r_farclip);
 
-       // FIXME: move to client
-       R_MoveExplosions();
-       R_TimeReport("mexplosion");
+       GL_SetupView_Orientation_FromEntity(&r_refdef.viewentitymatrix);
+       R_TimeReport("setup");
 
-       qglPolygonOffset(0, 0);
-       qglEnable(GL_POLYGON_OFFSET_FILL);
+       R_RenderScene();
+
+       R_BlendView();
+       R_TimeReport("blendview");
+       
+       GL_Scissor(0, 0, vid.realwidth, vid.realheight);
+       GL_ScissorTest(false);
+}
+
+extern void R_DrawLightningBeams (void);
+void R_RenderScene(void)
+{
+       entity_render_t *world;
+
+       // don't let sound skip if going slow
+       if (!intimerefresh && !r_speeds.integer)
+               S_ExtraUpdate ();
+
+       r_framecount++;
 
-       R_Textures_Frame();
-       R_SetupFrame();
-       R_SetFrustum();
-       R_SetupFog();
        R_SkyStartFrame();
-       R_BuildLightList();
-       R_TimeReport("setup");
 
        if (cl.worldmodel && cl.worldmodel->brush.FatPVS)
                cl.worldmodel->brush.FatPVS(cl.worldmodel, r_vieworigin, 2, r_pvsbits, sizeof(r_pvsbits));
-
+       world = &cl_entities[0].render;
        R_WorldVisibility(world);
        R_TimeReport("worldvis");
 
-       R_FarClip_Start(r_vieworigin, r_viewforward, 768.0f);
        R_MarkEntities();
-       r_farclip = R_FarClip_Finish() + 256.0f;
-       if (gl_stencil && ((r_shadow_realtime_world.integer && r_shadow_worldshadows.integer) || ((r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && r_shadow_dlightshadows.integer)))
-               GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.fov_x, r_refdef.fov_y, 1.0f);
-       else
-               GL_SetupView_Mode_Perspective(r_refdef.fov_x, r_refdef.fov_y, 1.0f, r_farclip);
-       GL_SetupView_Orientation_FromEntity(&r_refdef.viewentitymatrix);
        R_TimeReport("markentity");
 
        qglDepthFunc(GL_LEQUAL);
+       qglPolygonOffset(0, 0);
+       qglEnable(GL_POLYGON_OFFSET_FILL);
 
        R_Mesh_Start();
        R_MeshQueue_BeginScene();
 
        R_Shadow_UpdateWorldLightSelection();
 
+       // don't let sound skip if going slow
+       if (!intimerefresh && !r_speeds.integer)
+               S_ExtraUpdate ();
+
        if (R_DrawBrushModelsSky())
                R_TimeReport("bmodelsky");
 
@@ -888,9 +903,17 @@ void R_RenderView (void)
        R_DrawModels();
        R_TimeReport("models");
 
+       // don't let sound skip if going slow
+       if (!intimerefresh && !r_speeds.integer)
+               S_ExtraUpdate ();
+
        R_ShadowVolumeLighting(false);
        R_TimeReport("rtlights");
 
+       // don't let sound skip if going slow
+       if (!intimerefresh && !r_speeds.integer)
+               S_ExtraUpdate ();
+
        R_DrawLightningBeams();
        R_TimeReport("lightning");
 
@@ -909,9 +932,6 @@ void R_RenderView (void)
        R_DrawWorldCrosshair();
        R_TimeReport("crosshair");
 
-       R_BlendView();
-       R_TimeReport("blendview");
-
        R_MeshQueue_Render();
        R_MeshQueue_EndScene();
 
@@ -926,6 +946,10 @@ void R_RenderView (void)
 
        qglPolygonOffset(0, 0);
        qglDisable(GL_POLYGON_OFFSET_FILL);
+
+       // don't let sound skip if going slow
+       if (!intimerefresh && !r_speeds.integer)
+               S_ExtraUpdate ();
 }
 
 /*
diff --git a/host.c b/host.c
index fbb6615a5102821ef211292df56f83b32dd76c28..299ecad647d35f18df6ac0686fade1dcb23977de 100644 (file)
--- a/host.c
+++ b/host.c
@@ -757,6 +757,7 @@ void _Host_Frame (float time)
        if (host_speeds.integer)
                time1 = Sys_DoubleTime();
 
+       R_UpdateWorld();
        CL_UpdateScreen();
 
        if (host_speeds.integer)
index 2facc1ffe279ccc1910b95fc060e8efb5e890234..3734eea9eaa67206e2c8c2627f2569c173487e7b 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -81,14 +81,15 @@ void R_Light_Init(void)
 
 /*
 ==================
-R_AnimateLight
+R_UpdateLights
 ==================
 */
-void R_AnimateLight (void)
+void R_UpdateLights(void)
 {
        int i, j, k;
+       dlight_t *cd;
+       rdlight_t *rd;
 
-//
 // light animations
 // 'm' is normal light, 'a' is no light, 'z' is double bright
        i = (int)(cl.time * 10);
@@ -104,14 +105,6 @@ void R_AnimateLight (void)
                k = k*22;
                d_lightstylevalue[j] = k;
        }
-}
-
-
-void R_BuildLightList(void)
-{
-       int i;
-       dlight_t *cd;
-       rdlight_t *rd;
 
        r_numdlights = 0;
        c_dlights = 0;
index a3c7066e26fbe81c9177f3b8d948109f2fc57ca8..5c7c116b74148adef7e245dcec516b07bcf4836b 100644 (file)
--- a/r_light.h
+++ b/r_light.h
@@ -27,8 +27,7 @@ rdlight_t;
 extern int r_numdlights;
 extern rdlight_t r_dlight[MAX_DLIGHTS];
 
-void R_BuildLightList(void);
-void R_AnimateLight(void);
+void R_UpdateLights(void);
 void R_MarkLights(entity_render_t *ent);
 void R_DrawCoronas(void);
 void R_CompleteLightPoint(vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal, const vec3_t p, int dynamic, const mleaf_t *leaf);
index 060ab75280bbaa92edea79d48d06587d7d620881..ce3cc8dcbd1a598efd35246b746a75dcfbff56c0 100644 (file)
@@ -863,7 +863,7 @@ void R_Shadow_Stage_Begin(void)
        R_Mesh_State_Texture(&m);
        GL_Color(0, 0, 0, 1);
        qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-       qglDisable(GL_SCISSOR_TEST);
+       GL_Scissor(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
        r_shadowstage = SHADOWSTAGE_NONE;
 
        c_rt_lights = c_rt_clears = c_rt_scissored = 0;
@@ -978,7 +978,7 @@ void R_Shadow_Stage_End(void)
        //qglDisable(GL_POLYGON_OFFSET_FILL);
        GL_Color(1, 1, 1, 1);
        qglColorMask(1, 1, 1, 1);
-       qglDisable(GL_SCISSOR_TEST);
+       GL_Scissor(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
        qglDepthFunc(GL_LEQUAL);
        qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
        qglDisable(GL_STENCIL_TEST);
@@ -1000,7 +1000,7 @@ int R_Shadow_ScissorForBBox(const float *mins, const float *maxs)
        // (?!?  seems like a driver bug) so abort if gl_stencil is false
        if (!gl_stencil || BoxesOverlap(r_vieworigin, r_vieworigin, mins, maxs))
        {
-               qglDisable(GL_SCISSOR_TEST);
+               GL_Scissor(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
                return false;
        }
        for (i = 0;i < 3;i++)
@@ -1153,8 +1153,9 @@ int R_Shadow_ScissorForBBox(const float *mins, const float *maxs)
        if (ix2 <= ix1 || iy2 <= iy1)
                return true;
        // set up the scissor rectangle
-       qglScissor(ix1, iy1, ix2 - ix1, iy2 - iy1);
-       qglEnable(GL_SCISSOR_TEST);
+       GL_Scissor(ix1, iy1, ix2 - ix1, iy2 - iy1);
+       //qglScissor(ix1, iy1, ix2 - ix1, iy2 - iy1);
+       //qglEnable(GL_SCISSOR_TEST);
        c_rt_scissored++;
        return false;
 }
index 33d3acd70cdb74f51723eea1add94c0a9829bf06..a85e6604c1d6d962066eaa2f1a87c6d62d37f60b 100644 (file)
--- a/render.h
+++ b/render.h
@@ -109,8 +109,9 @@ extern cvar_t r_wateralpha;
 extern cvar_t r_dynamic;
 extern cvar_t r_drawcollisionbrushes;
 
-void R_Init (void);
-void R_RenderView (void); // must set r_refdef first
+void R_Init(void);
+void R_UpdateWorld(void); // needs no r_refdef
+void R_RenderView(void); // must call R_UpdateWorld and set r_refdef first
 
 
 void R_InitSky (qbyte *src, int bytesperpixel); // called at level load
@@ -133,17 +134,6 @@ extern vec_t fogdensity;
 #define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_vieworigin[0])*((v)[0] - r_vieworigin[0])+((v)[1] - r_vieworigin[1])*((v)[1] - r_vieworigin[1])+((v)[2] - r_vieworigin[2])*((v)[2] - r_vieworigin[2])))))
 #define calcfogbyte(v) ((qbyte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))
 
-// start a farclip measuring session
-void R_FarClip_Start(vec3_t origin, vec3_t direction, vec_t startfarclip);
-// enlarge farclip to accomodate box
-void R_FarClip_Box(vec3_t mins, vec3_t maxs);
-// return farclip value
-float R_FarClip_Finish(void);
-
-// updates farclip distance so it is large enough for the specified box
-// (*important*)
-void R_Mesh_EnlargeFarClipBBox(vec3_t mins, vec3_t maxs);
-
 #include "r_modules.h"
 
 #include "meshqueue.h"
index 2627d18d0d951b1234cc8c9bb4d27f388a2f4da9..a4b1b9315a0c27af42007b2b2cdd2c64efcbb123 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -38,6 +38,7 @@ extern qboolean       scr_disabled_for_loading;
 extern qboolean        scr_skipupdate;
 
 extern cvar_t scr_viewsize;
+extern cvar_t scr_fov;
 extern cvar_t showfps;
 
 extern cvar_t crosshair;
diff --git a/todo b/todo
index 652fc8750d7dfd7680554fead5ec5a1c76615705..b171af1e4bd4e3e96796c7422e66fdbc5935336f 100644 (file)
--- a/todo
+++ b/todo
@@ -34,6 +34,8 @@
 -n darkplaces: segfault reading memory in windows when starting a new server from menu (yummyluv)
 -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv)
 -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv)
+d darkplaces: added silly scr_zoomwindow as an experiment, turned out mostly useless
+0 dpmod: revert back to id1 weapons
 -n dpmod: make grapple off-hand (joe hill)
 d darkplaces: change cl_fakelocalping_min and _max to only lag by half each way, as currently it results in 2x ping
 d darkplaces: make MAX_PACKETFRAGMENT a property of each net connection, so memory loopbacks could use huge limits (Sajt)