From c1d9bbe13a1d1b1769f1690d94f3b49b9f16f840 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 21 Feb 2004 21:05:21 +0000 Subject: [PATCH] cleaned up R_RenderView setup code a bit, and shuffled SCR_CalcRefdef stuff to SCR_UpdateScreen 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 --- cl_main.c | 1 + cl_screen.c | 96 +---------------------- gl_backend.c | 100 +++++++++++++++++++++--- gl_backend.h | 1 - gl_draw.c | 2 +- gl_rmain.c | 212 ++++++++++++++++++++++++++++----------------------- host.c | 1 + r_light.c | 15 +--- r_light.h | 3 +- r_shadow.c | 11 +-- render.h | 16 +--- screen.h | 1 + todo | 2 + 13 files changed, 230 insertions(+), 231 deletions(-) diff --git a/cl_main.c b/cl_main.c index 42b01de1..e45180f0 100644 --- 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(); diff --git a/cl_screen.c b/cl_screen.c index b8038ba7..9384f3e2 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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); diff --git a/gl_backend.c b/gl_backend.c index 869e338b..9f970fe6 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -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(); diff --git a/gl_backend.h b/gl_backend.h index dd43b40b..cf828683 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -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); diff --git a/gl_draw.c b/gl_draw.c index 8407edf2..e143ad3e 100644 --- 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(); diff --git a/gl_rmain.c b/gl_rmain.c index 375f4d56..fef43b34 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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 fbb6615a..299ecad6 100644 --- 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) diff --git a/r_light.c b/r_light.c index 2facc1ff..3734eea9 100644 --- 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; diff --git a/r_light.h b/r_light.h index a3c7066e..5c7c116b 100644 --- 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); diff --git a/r_shadow.c b/r_shadow.c index 060ab752..ce3cc8dc 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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; } diff --git a/render.h b/render.h index 33d3acd7..a85e6604 100644 --- 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" diff --git a/screen.h b/screen.h index 2627d18d..a4b1b931 100644 --- 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 652fc875..b171af1e 100644 --- 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) -- 2.39.2