]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Revert everything..
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Jan 2008 01:03:54 +0000 (01:03 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Jan 2008 01:03:54 +0000 (01:03 +0000)
git-svn-id: svn://svn.icculus.org/twilight/branches/dp-mqc-render/darkplaces@7906 d7cf8633-e32d-0410-b094-e92efae38249

25 files changed:
cl_input.c
cl_main.c
cl_particles.c
cl_screen.c
client.h
clvm_cmds.c
clvm_cmds.h
csprogs.c
gl_backend.c
gl_draw.c
gl_rmain.c
gl_rsurf.c
host.c
image.c
menu.c
meshqueue.c
mvm_cmds.c
r_explosion.c
r_lightning.c
r_shadow.c
r_sky.c
r_sprites.c
render.h
snd_coreaudio.c
view.c

index fe3e67cfa13cfdca21e49083c443adae960e54fb..da986f25e7d62745ae5ebd884dd75ac57743f2d4 100644 (file)
@@ -665,10 +665,10 @@ void CL_UpdatePrydonCursor(void)
        cl.cmd.cursor_screen[2] = 1;
 
        // calculate current view matrix
-       Matrix4x4_OriginFromMatrix(&r_view.matrix, cl.cmd.cursor_start);
+       Matrix4x4_OriginFromMatrix(&r_refdef.view.matrix, cl.cmd.cursor_start);
        // calculate direction vector of cursor in viewspace by using frustum slopes
-       VectorSet(temp, cl.cmd.cursor_screen[2] * 1000000, (v_flipped.integer ? -1 : 1) * cl.cmd.cursor_screen[0] * -r_view.frustum_x * 1000000, cl.cmd.cursor_screen[1] * -r_view.frustum_y * 1000000);
-       Matrix4x4_Transform(&r_view.matrix, temp, cl.cmd.cursor_end);
+       VectorSet(temp, cl.cmd.cursor_screen[2] * 1000000, (v_flipped.integer ? -1 : 1) * cl.cmd.cursor_screen[0] * -r_refdef.view.frustum_x * 1000000, cl.cmd.cursor_screen[1] * -r_refdef.view.frustum_y * 1000000);
+       Matrix4x4_Transform(&r_refdef.view.matrix, temp, cl.cmd.cursor_end);
        // trace from view origin to the cursor
        cl.cmd.cursor_fraction = CL_SelectTraceLine(cl.cmd.cursor_start, cl.cmd.cursor_end, cl.cmd.cursor_impact, cl.cmd.cursor_normal, &cl.cmd.cursor_entitynumber, (chase_active.integer || cl.intermission) ? &cl.entities[cl.playerentity].render : NULL);
 }
index 0198841286500cfe62f2120fe1b0be5ffa2ed1dc..02f0bd0e7bf10aada03b84007932073fa5ead93c 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -607,17 +607,17 @@ void CL_ClearTempEntities (void)
        cl.num_temp_entities = 0;
 }
 
-entity_t *CL_NewTempEntity(renderscene_t* scene)
+entity_t *CL_NewTempEntity(void)
 {
        entity_t *ent;
 
-       if (scene->refdef.numentities >= r_refdef.maxentities)
+       if (r_refdef.numentities >= r_refdef.maxentities)
                return NULL;
        if (cl.num_temp_entities >= cl.max_temp_entities)
                return NULL;
        ent = &cl.temp_entities[cl.num_temp_entities++];
        memset (ent, 0, sizeof(*ent));
-       scene->refdef.entities[scene->refdef.numentities++] = &ent->render;
+       r_refdef.entities[r_refdef.numentities++] = &ent->render;
 
        ent->render.alpha = 1;
        VectorSet(ent->render.colormod, 1, 1, 1);
@@ -845,7 +845,7 @@ void CL_AddQWCTFFlagModel(entity_t *player, int skin)
        }
        // end of code taken from QuakeWorld
 
-       flag = CL_NewTempEntity(&client_scene);
+       flag = CL_NewTempEntity();
        if (!flag)
                return;
 
@@ -955,7 +955,7 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat
        {
                // view-relative entity (guns and such)
                if (e->render.effects & EF_NOGUNBOB)
-                       matrix = &r_view.matrix; // really attached to view
+                       matrix = &r_refdef.view.matrix; // really attached to view
                else
                        matrix = &viewmodelmatrix; // attached to gun bob matrix
        }
@@ -1552,7 +1552,7 @@ static void CL_RelinkEffects(void)
 
                        // if we're drawing effects, get a new temp entity
                        // (NewTempEntity adds it to the render entities list for us)
-                       if (r_draweffects.integer && (ent = CL_NewTempEntity(&client_scene)))
+                       if (r_draweffects.integer && (ent = CL_NewTempEntity()))
                        {
                                // interpolation stuff
                                ent->render.frame1 = intframe;
@@ -1606,7 +1606,7 @@ void CL_Beam_CalculatePositions(const beam_t *b, vec3_t start, vec3_t end)
                        len = VectorLength(dir);
                        VectorNormalize(dir);
                        VectorSet(localend, len, 0, 0);
-                       Matrix4x4_Transform(&r_view.matrix, localend, end);
+                       Matrix4x4_Transform(&r_refdef.view.matrix, localend, end);
                }
        }
 }
@@ -1676,7 +1676,7 @@ void CL_RelinkBeams(void)
                d = VectorNormalizeLength(dist);
                while (d > 0)
                {
-                       ent = CL_NewTempEntity (&client_scene);
+                       ent = CL_NewTempEntity ();
                        if (!ent)
                                return;
                        //VectorCopy (org, ent->render.origin);
@@ -1708,7 +1708,7 @@ static void CL_RelinkQWNails(void)
 
                // if we're drawing effects, get a new temp entity
                // (NewTempEntity adds it to the render entities list for us)
-               if (!(ent = CL_NewTempEntity(&client_scene)))
+               if (!(ent = CL_NewTempEntity()))
                        continue;
 
                // normal stuff
@@ -1781,7 +1781,7 @@ void CL_UpdateWorld(void)
        r_refdef.extraupdate = !r_speeds.integer;
        r_refdef.numentities = 0;
        r_refdef.numlights = 0;
-       r_view.matrix = identitymatrix;
+       r_refdef.view.matrix = identitymatrix;
 
        cl.num_brushmodel_entities = 0;
 
@@ -1884,7 +1884,7 @@ static void CL_TimeRefresh_f (void)
        timestart = Sys_DoubleTime();
        for (i = 0;i < 128;i++)
        {
-               Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, r_view.origin[0], r_view.origin[1], r_view.origin[2], 0, i / 128.0 * 360.0, 0, 1);
+               Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], 0, i / 128.0 * 360.0, 0, 1);
                CL_UpdateScreen();
        }
        timedelta = Sys_DoubleTime() - timestart;
@@ -1991,7 +1991,7 @@ void CL_Locs_Add_f(void)
 void CL_Locs_RemoveNearest_f(void)
 {
        cl_locnode_t *loc;
-       loc = CL_Locs_FindNearest(r_view.origin);
+       loc = CL_Locs_FindNearest(r_refdef.view.origin);
        if (loc)
                CL_Locs_FreeNode(loc);
        else
@@ -2236,20 +2236,15 @@ void CL_Shutdown (void)
 CL_Init
 =================
 */
-void CL_InitScene (renderscene_t* scene, mempool_t* pool)
-{
-       memset(&scene->refdef, 0, sizeof(scene->refdef));
-       // max entities sent to renderer per frame
-       scene->refdef.maxentities = MAX_EDICTS + 256 + 512;
-       scene->refdef.entities = (entity_render_t **)Mem_Alloc(pool, sizeof(entity_render_t *) * scene->refdef.maxentities);
-}
-
 void CL_Init (void)
 {
        cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
        cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
 
-        CL_InitScene (&client_scene, cls.permanentmempool);
+       memset(&r_refdef, 0, sizeof(r_refdef));
+       // max entities sent to renderer per frame
+       r_refdef.maxentities = MAX_EDICTS + 256 + 512;
+       r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.maxentities);
 
        CL_InitInput ();
 
index 9d6c538e3d5a2cf3f45e910d0a7156c9847a2760..72a280ed2e41eda07abf0abe63e8dab09c1c149e 100644 (file)
@@ -2229,9 +2229,9 @@ void R_DrawDecal_TransparentCallback(const entity_render_t *ent, const rtlight_t
 
                //blendmode = particletype[d->typeindex].blendmode;
 
-               cr = d->color[0] * (1.0f / 255.0f) * r_view.colorscale;
-               cg = d->color[1] * (1.0f / 255.0f) * r_view.colorscale;
-               cb = d->color[2] * (1.0f / 255.0f) * r_view.colorscale;
+               cr = d->color[0] * (1.0f / 255.0f) * r_refdef.view.colorscale;
+               cg = d->color[1] * (1.0f / 255.0f) * r_refdef.view.colorscale;
+               cb = d->color[2] * (1.0f / 255.0f) * r_refdef.view.colorscale;
                ca = d->alpha * (1.0f / 255.0f);
                //if (blendmode == PBLEND_MOD)
                {
@@ -2364,9 +2364,9 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh
 
                blendmode = particletype[p->typeindex].blendmode;
 
-               cr = p->color[0] * (1.0f / 255.0f) * r_view.colorscale;
-               cg = p->color[1] * (1.0f / 255.0f) * r_view.colorscale;
-               cb = p->color[2] * (1.0f / 255.0f) * r_view.colorscale;
+               cr = p->color[0] * (1.0f / 255.0f) * r_refdef.view.colorscale;
+               cg = p->color[1] * (1.0f / 255.0f) * r_refdef.view.colorscale;
+               cb = p->color[2] * (1.0f / 255.0f) * r_refdef.view.colorscale;
                ca = p->alpha * (1.0f / 255.0f);
                if (blendmode == PBLEND_MOD)
                {
@@ -2412,8 +2412,8 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh
                switch(particletype[p->typeindex].orientation)
                {
                case PARTICLE_BILLBOARD:
-                       VectorScale(r_view.left, -size, right);
-                       VectorScale(r_view.up, size, up);
+                       VectorScale(r_refdef.view.left, -size, right);
+                       VectorScale(r_refdef.view.up, size, up);
                        v3f[ 0] = org[0] - right[0] - up[0];
                        v3f[ 1] = org[1] - right[1] - up[1];
                        v3f[ 2] = org[2] - right[2] - up[2];
@@ -2548,10 +2548,10 @@ void R_DrawParticles (void)
        if ((!cl.num_particles) || (!r_drawparticles.integer))
                return;
 
-       minparticledist = DotProduct(r_view.origin, r_view.forward) + 4.0f;
+       minparticledist = DotProduct(r_refdef.view.origin, r_refdef.view.forward) + 4.0f;
 
        // LordHavoc: only render if not too close
        for (i = 0, p = cl.particles;i < cl.num_particles;i++, p++)
-               if (p->typeindex && !p->delayedspawn && (DotProduct(p->org, r_view.forward) >= minparticledist || particletype[p->typeindex].orientation == PARTICLE_BEAM))
+               if (p->typeindex && !p->delayedspawn && (DotProduct(p->org, r_refdef.view.forward) >= minparticledist || particletype[p->typeindex].orientation == PARTICLE_BEAM))
                        R_MeshQueue_AddTransparent(p->org, R_DrawParticle_TransparentCallback, NULL, i, NULL);
 }
index 94eaf837faab2208aed034fee3c90d73b678861d..1cacf7691aceaaa6ff8308c067faeef4e56691ad 100644 (file)
@@ -696,7 +696,7 @@ void R_TimeReport_EndFrame(void)
                loc = CL_Locs_FindNearest(cl.movement_origin);
                if (loc)
                        sprintf(string + strlen(string), "Location: %s\n", loc->name);
-               sprintf(string + strlen(string), "org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_view.origin[0], r_view.origin[1], r_view.origin[2], r_view.forward[0], r_view.forward[1], r_view.forward[2]);
+               sprintf(string + strlen(string), "org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2]);
                sprintf(string + strlen(string), "%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n", r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles);
                sprintf(string + strlen(string), "%5i leafs%5i portals%6i particles%6i decals\n", r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles, r_refdef.stats.decals);
                sprintf(string + strlen(string), "%7i lightmap updates (%7i pixels)\n", r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels);
@@ -1710,18 +1710,18 @@ static void R_Envmap_f (void)
 
        r_refdef.envmap = true;
 
-       R_UpdateVariables (&client_scene);
+       R_UpdateVariables();
 
-       r_view.x = 0;
-       r_view.y = 0;
-       r_view.z = 0;
-       r_view.width = size;
-       r_view.height = size;
-       r_view.depth = 1;
-       r_view.useperspective = true;
+       r_refdef.view.x = 0;
+       r_refdef.view.y = 0;
+       r_refdef.view.z = 0;
+       r_refdef.view.width = size;
+       r_refdef.view.height = size;
+       r_refdef.view.depth = 1;
+       r_refdef.view.useperspective = true;
 
-       r_view.frustum_x = tan(90 * M_PI / 360.0);
-       r_view.frustum_y = tan(90 * M_PI / 360.0);
+       r_refdef.view.frustum_x = tan(90 * M_PI / 360.0);
+       r_refdef.view.frustum_y = tan(90 * M_PI / 360.0);
 
        buffer1 = (unsigned char *)Mem_Alloc(tempmempool, size * size * 3);
        buffer2 = (unsigned char *)Mem_Alloc(tempmempool, size * size * 3);
@@ -1730,12 +1730,12 @@ static void R_Envmap_f (void)
        for (j = 0;j < 12;j++)
        {
                sprintf(filename, "env/%s%s.tga", basename, envmapinfo[j].name);
-               Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, r_view.origin[0], r_view.origin[1], r_view.origin[2], envmapinfo[j].angles[0], envmapinfo[j].angles[1], envmapinfo[j].angles[2], 1);
-               r_view.clear = true;
+               Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], envmapinfo[j].angles[0], envmapinfo[j].angles[1], envmapinfo[j].angles[2], 1);
+               r_refdef.view.clear = true;
                R_Mesh_Start();
-               R_RenderView(&client_scene);
+               R_RenderView();
                R_Mesh_Finish();
-               SCR_ScreenShot(filename, buffer1, buffer2, buffer3, 0, vid.height - (r_view.y + r_view.height), size, size, envmapinfo[j].flipx, envmapinfo[j].flipy, envmapinfo[j].flipdiagonaly, false, false);
+               SCR_ScreenShot(filename, buffer1, buffer2, buffer3, 0, vid.height - (r_refdef.view.y + r_refdef.view.height), size, size, envmapinfo[j].flipx, envmapinfo[j].flipy, envmapinfo[j].flipdiagonaly, false, false);
        }
 
        Mem_Free (buffer1);
@@ -1900,11 +1900,11 @@ void SCR_DrawScreen (void)
 
        R_TimeReport_BeginFrame();
 
-       R_UpdateVariables (&client_scene);
+       R_UpdateVariables();
 
        // Quake uses clockwise winding, so these are swapped
-       r_view.cullface_front = GL_BACK;
-       r_view.cullface_back = GL_FRONT;
+       r_refdef.view.cullface_front = GL_BACK;
+       r_refdef.view.cullface_back = GL_FRONT;
 
        if (cls.signon == SIGNONS)
        {
@@ -1915,23 +1915,23 @@ void SCR_DrawScreen (void)
 
                if (r_stereo_sidebyside.integer)
                {
-                       r_view.width = (int)(vid.width * size / 2.5);
-                       r_view.height = (int)(vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100));
-                       r_view.depth = 1;
-                       r_view.x = (int)((vid.width - r_view.width * 2.5) * 0.5);
-                       r_view.y = (int)((vid.height - r_view.height)/2);
-                       r_view.z = 0;
+                       r_refdef.view.width = (int)(vid.width * size / 2.5);
+                       r_refdef.view.height = (int)(vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100));
+                       r_refdef.view.depth = 1;
+                       r_refdef.view.x = (int)((vid.width - r_refdef.view.width * 2.5) * 0.5);
+                       r_refdef.view.y = (int)((vid.height - r_refdef.view.height)/2);
+                       r_refdef.view.z = 0;
                        if (r_stereo_side)
-                               r_view.x += (int)(r_view.width * 1.5);
+                               r_refdef.view.x += (int)(r_refdef.view.width * 1.5);
                }
                else
                {
-                       r_view.width = (int)(vid.width * size);
-                       r_view.height = (int)(vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100));
-                       r_view.depth = 1;
-                       r_view.x = (int)((vid.width - r_view.width)/2);
-                       r_view.y = (int)((vid.height - r_view.height)/2);
-                       r_view.z = 0;
+                       r_refdef.view.width = (int)(vid.width * size);
+                       r_refdef.view.height = (int)(vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100));
+                       r_refdef.view.depth = 1;
+                       r_refdef.view.x = (int)((vid.width - r_refdef.view.width)/2);
+                       r_refdef.view.y = (int)((vid.height - r_refdef.view.height)/2);
+                       r_refdef.view.z = 0;
                }
 
                // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
@@ -1940,48 +1940,48 @@ void SCR_DrawScreen (void)
                // this it simply assumes the requested fov is the vertical fov
                // for a 4x3 display, if the ratio is not 4x3 this makes the fov
                // higher/lower according to the ratio
-               r_view.useperspective = true;
-               r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
-               r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
+               r_refdef.view.useperspective = true;
+               r_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+               r_refdef.view.frustum_x = r_refdef.view.frustum_y * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
 
-               r_view.frustum_x *= r_refdef.frustumscale_x;
-               r_view.frustum_y *= r_refdef.frustumscale_y;
+               r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
+               r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
 
                if(!CL_VM_UpdateView())
-                       R_RenderView(&client_scene);
+                       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_view.width = (int)(vid.width * sizex);
-                       r_view.height = (int)(vid.height * sizey);
-                       r_view.depth = 1;
-                       r_view.x = (int)((vid.width - r_view.width)/2);
-                       r_view.y = 0;
-                       r_view.z = 0;
+                       r_refdef.view.width = (int)(vid.width * sizex);
+                       r_refdef.view.height = (int)(vid.height * sizey);
+                       r_refdef.view.depth = 1;
+                       r_refdef.view.x = (int)((vid.width - r_refdef.view.width)/2);
+                       r_refdef.view.y = 0;
+                       r_refdef.view.z = 0;
 
-                       r_view.useperspective = true;
-                       r_view.frustum_y = tan(scr_zoomwindow_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
-                       r_view.frustum_x = r_view.frustum_y * vid_pixelheight.value * (float)r_view.width / (float)r_view.height;
+                       r_refdef.view.useperspective = true;
+                       r_refdef.view.frustum_y = tan(scr_zoomwindow_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+                       r_refdef.view.frustum_x = r_refdef.view.frustum_y * vid_pixelheight.value * (float)r_refdef.view.width / (float)r_refdef.view.height;
 
-                       r_view.frustum_x *= r_refdef.frustumscale_x;
-                       r_view.frustum_y *= r_refdef.frustumscale_y;
+                       r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
+                       r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
 
                        if(!CL_VM_UpdateView())
-                               R_RenderView(&client_scene);
+                               R_RenderView();
                }
        }
 
        if (!r_stereo_sidebyside.integer)
        {
-               r_view.width = vid.width;
-               r_view.height = vid.height;
-               r_view.depth = 1;
-               r_view.x = 0;
-               r_view.y = 0;
-               r_view.z = 0;
-               r_view.useperspective = false;
+               r_refdef.view.width = vid.width;
+               r_refdef.view.height = vid.height;
+               r_refdef.view.depth = 1;
+               r_refdef.view.x = 0;
+               r_refdef.view.y = 0;
+               r_refdef.view.z = 0;
+               r_refdef.view.useperspective = false;
        }
 
        // draw 2D stuff
@@ -2144,9 +2144,9 @@ void CL_UpdateScreen(void)
                        sb_lines = 24+16+8;
        }
 
-       r_view.colormask[0] = 1;
-       r_view.colormask[1] = 1;
-       r_view.colormask[2] = 1;
+       r_refdef.view.colormask[0] = 1;
+       r_refdef.view.colormask[1] = 1;
+       r_refdef.view.colormask[2] = 1;
 
        SCR_SetUpToDrawConsole();
 
@@ -2158,7 +2158,7 @@ void CL_UpdateScreen(void)
        qglColorMask(1,1,1,1);CHECKGLERROR
        qglClearColor(0,0,0,0);CHECKGLERROR
        R_ClearScreen(false);
-       r_view.clear = false;
+       r_refdef.view.clear = false;
 
        if(scr_stipple.integer)
        {
@@ -2184,19 +2184,19 @@ void CL_UpdateScreen(void)
 
        if (vid.stereobuffer || r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
        {
-               matrix4x4_t originalmatrix = r_view.matrix;
+               matrix4x4_t originalmatrix = r_refdef.view.matrix;
                matrix4x4_t offsetmatrix;
                Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * 0.5f, 0, 0, r_stereo_angle.value * 0.5f, 0, 1);
-               Matrix4x4_Concat(&r_view.matrix, &originalmatrix, &offsetmatrix);
+               Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 0;
 
                if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer)
                {
-                       r_view.colormask[0] = 1;
-                       r_view.colormask[1] = 0;
-                       r_view.colormask[2] = 0;
+                       r_refdef.view.colormask[0] = 1;
+                       r_refdef.view.colormask[1] = 0;
+                       r_refdef.view.colormask[2] = 0;
                }
 
                if (vid.stereobuffer)
@@ -2205,16 +2205,16 @@ void CL_UpdateScreen(void)
                SCR_DrawScreen();
 
                Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * -0.5f, 0, 0, r_stereo_angle.value * -0.5f, 0, 1);
-               Matrix4x4_Concat(&r_view.matrix, &originalmatrix, &offsetmatrix);
+               Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 1;
 
                if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer)
                {
-                       r_view.colormask[0] = 0;
-                       r_view.colormask[1] = r_stereo_redcyan.integer || r_stereo_redgreen.integer;
-                       r_view.colormask[2] = r_stereo_redcyan.integer || r_stereo_redblue.integer;
+                       r_refdef.view.colormask[0] = 0;
+                       r_refdef.view.colormask[1] = r_stereo_redcyan.integer || r_stereo_redgreen.integer;
+                       r_refdef.view.colormask[2] = r_stereo_redcyan.integer || r_stereo_redblue.integer;
                }
 
                if (vid.stereobuffer)
@@ -2222,7 +2222,7 @@ void CL_UpdateScreen(void)
 
                SCR_DrawScreen();
 
-               r_view.matrix = originalmatrix;
+               r_refdef.view.matrix = originalmatrix;
        }
        else
                SCR_DrawScreen();
index 1aa559891dbdfa11b587a5d4aaa6cacae6596597..bc1952fcae990114cc7413f9e29c2e214c67b47b 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1168,8 +1168,7 @@ void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
 void CL_ClientMovement_Replay(void);
 
 void CL_ClearTempEntities (void);
-struct renderscene_s;
-entity_t *CL_NewTempEntity (struct renderscene_s* scene);
+entity_t *CL_NewTempEntity (void);
 
 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
 
@@ -1348,6 +1347,83 @@ typedef struct r_refdef_stats_s
 }
 r_refdef_stats_t;
 
+typedef struct r_refdef_view_s
+{
+       // view information (changes multiple times per frame)
+       // if any of these variables change then r_refdef.viewcache must be regenerated
+       // by calling R_View_Update
+       // (which also updates viewport, scissor, colormask)
+
+       // it is safe and expected to copy this into a structure on the stack and
+       // call the renderer recursively, then restore from the stack afterward
+       // (as long as R_View_Update is called)
+
+       // eye position information
+       matrix4x4_t matrix, inverse_matrix;
+       vec3_t origin;
+       vec3_t forward;
+       vec3_t left;
+       vec3_t right;
+       vec3_t up;
+       int numfrustumplanes;
+       mplane_t frustum[6];
+       qboolean useclipplane;
+       qboolean usecustompvs; // uses r_refdef.viewcache.pvsbits as-is rather than computing it
+       mplane_t clipplane;
+       float frustum_x, frustum_y;
+       vec3_t frustumcorner[4];
+       // if turned off it renders an ortho view
+       int useperspective;
+       float ortho_x, ortho_y;
+
+       // screen area to render in
+       int x;
+       int y;
+       int z;
+       int width;
+       int height;
+       int depth;
+
+       // which color components to allow (for anaglyph glasses)
+       int colormask[4];
+
+       // global RGB color multiplier for rendering, this is required by HDR
+       float colorscale;
+
+       // whether to call R_ClearScreen before rendering stuff
+       qboolean clear;
+
+       // whether to draw r_showtris and such, this is only true for the main
+       // view render, all secondary renders (HDR, mirrors, portals, cameras,
+       // distortion effects, etc) omit such debugging information
+       qboolean showdebug;
+
+       // these define which values to use in GL_CullFace calls to request frontface or backface culling
+       int cullface_front;
+       int cullface_back;
+}
+r_refdef_view_t;
+
+typedef struct r_refdef_viewcache_s
+{
+       // these properties are generated by R_View_Update()
+
+       // which entities are currently visible for this viewpoint
+       // (the used range is 0...r_refdef.numentities)
+       unsigned char entityvisible[MAX_EDICTS];
+       // flag arrays used for visibility checking on world model
+       // (all other entities have no per-surface/per-leaf visibility checks)
+       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
+       unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps
+       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
+       unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps
+       // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
+       unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps
+       // if true, the view is currently in a leaf without pvs data
+       qboolean world_novis;
+}
+r_refdef_viewcache_t;
+
 typedef struct r_refdef_s
 {
        // these fields define the basic rendering information for the world
@@ -1358,6 +1434,10 @@ typedef struct r_refdef_s
        // frustum_x/frustum_y are calculated
        float frustumscale_x, frustumscale_y;
 
+       // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
+       r_refdef_view_t view;
+       r_refdef_viewcache_t viewcache;
+
        // minimum visible distance (pixels closer than this disappear)
        double nearclip;
        // maximum visible distance (pixels further than this disappear in 16bpp modes,
@@ -1435,100 +1515,7 @@ typedef struct r_refdef_s
 }
 r_refdef_t;
 
-typedef struct r_view_s
-{
-       // view information (changes multiple times per frame)
-       // if any of these variables change then r_viewcache must be regenerated
-       // by calling R_View_Update
-       // (which also updates viewport, scissor, colormask)
-
-       // it is safe and expected to copy this into a structure on the stack and
-       // call the renderer recursively, then restore from the stack afterward
-       // (as long as R_View_Update is called)
-
-       // eye position information
-       matrix4x4_t matrix, inverse_matrix;
-       vec3_t origin;
-       vec3_t forward;
-       vec3_t left;
-       vec3_t right;
-       vec3_t up;
-       int numfrustumplanes;
-       mplane_t frustum[6];
-       qboolean useclipplane;
-       qboolean usecustompvs; // uses r_viewcache.pvsbits as-is rather than computing it
-       mplane_t clipplane;
-       float frustum_x, frustum_y;
-       vec3_t frustumcorner[4];
-       // if turned off it renders an ortho view
-       int useperspective;
-       float ortho_x, ortho_y;
-
-       // screen area to render in
-       int x;
-       int y;
-       int z;
-       int width;
-       int height;
-       int depth;
-
-       // which color components to allow (for anaglyph glasses)
-       int colormask[4];
-
-       // global RGB color multiplier for rendering, this is required by HDR
-       float colorscale;
-
-       // whether to call R_ClearScreen before rendering stuff
-       qboolean clear;
-
-       // whether to draw r_showtris and such, this is only true for the main
-       // view render, all secondary renders (HDR, mirrors, portals, cameras,
-       // distortion effects, etc) omit such debugging information
-       qboolean showdebug;
-
-       // these define which values to use in GL_CullFace calls to request frontface or backface culling
-       int cullface_front;
-       int cullface_back;
-}
-r_view_t;
-
-typedef struct r_viewcache_s
-{
-       // these properties are generated by R_View_Update()
-
-       // which entities are currently visible for this viewpoint
-       // (the used range is 0...r_refdef.numentities)
-       unsigned char entityvisible[MAX_EDICTS];
-       // flag arrays used for visibility checking on world model
-       // (all other entities have no per-surface/per-leaf visibility checks)
-       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
-       unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps
-       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
-       unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps
-       // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
-       unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps
-       // if true, the view is currently in a leaf without pvs data
-       qboolean world_novis;
-}
-r_viewcache_t;
-
-typedef struct renderscene_s
-{
-  //
-  // screen size info
-  //
-  r_refdef_t refdef;
-  r_view_t view;
-  r_viewcache_t viewcache;
-} renderscene_t;
-
-void CL_InitScene (renderscene_t* scene, mempool_t* pool);
-
-extern renderscene_t client_scene;
-/* Convenience */
-#define r_refdef    (client_scene.refdef)
-#define r_view      (client_scene.view)
-#define r_viewcache (client_scene.viewcache)
+extern r_refdef_t r_refdef;
 
 #endif
 
index c39b82c3120e380ab4cf8aeb898292b4c707158a..c077f2877328412ff7327be8c06bd2bf8f9a4638 100644 (file)
@@ -5,10 +5,6 @@
 #include "cl_collision.h"
 #include "r_shadow.h"
 
-/* Per-VM scenes */
-renderscene_t* renderscenes[PRVM_MAXPROGS];
-#define RENDERSCENE     (*renderscenes[prognum])
-
 //============================================================================
 // Client
 //[515]: unsolved PROBLEMS
@@ -43,7 +39,7 @@ static void VM_CL_makevectors (void)
 }
 
 // #2 void(entity e, vector o) setorigin
-void VM_CL_setorigin (void)
+static void VM_CL_setorigin (void)
 {
        prvm_edict_t    *e;
        float   *org;
@@ -66,7 +62,7 @@ void VM_CL_setorigin (void)
 }
 
 // #3 void(entity e, string m) setmodel
-void VM_CL_setmodel (void)
+static void VM_CL_setmodel (void)
 {
        prvm_edict_t    *e;
        const char              *m;
@@ -343,7 +339,7 @@ static void VM_CL_tracetoss (void)
 
 
 // #20 void(string s) precache_model
-void VM_CL_precache_model (void)
+static void VM_CL_precache_model (void)
 {
        const char      *name;
        int                     i;
@@ -640,41 +636,38 @@ static void VM_CL_getlight (void)
 
 //============================================================================
 //[515]: SCENE MANAGER builtins
-extern qboolean CSQC_AddRenderEdict (renderscene_t* scene, prvm_edict_t *ed);//csprogs.c
+extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
 
 static void CSQC_R_RecalcView (void)
 {
        extern matrix4x4_t viewmodelmatrix;
-       const int prognum = PRVM_GetProgNr();
-       Matrix4x4_CreateFromQuakeEntity(&RENDERSCENE.view.matrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], 1);
+       Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], 1);
        Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], cl_viewmodel_scale.value);
 }
 
 void CL_RelinkLightFlashes(void);
 //#300 void() clearscene (EXT_CSQC)
-void VM_CL_R_ClearScene (void)
+static void VM_CL_R_ClearScene (void)
 {
-       const int prognum = PRVM_GetProgNr();
-       
        VM_SAFEPARMCOUNT(0, VM_CL_R_ClearScene);
        // clear renderable entity and light lists
-       RENDERSCENE.refdef.numentities = 0;
-       RENDERSCENE.refdef.numlights = 0;
+       r_refdef.numentities = 0;
+       r_refdef.numlights = 0;
        // FIXME: restore these to the values from VM_CL_UpdateView
-       RENDERSCENE.view.x = 0;
-       RENDERSCENE.view.y = 0;
-       RENDERSCENE.view.z = 0;
-       RENDERSCENE.view.width = vid.width;
-       RENDERSCENE.view.height = vid.height;
-       RENDERSCENE.view.depth = 1;
+       r_refdef.view.x = 0;
+       r_refdef.view.y = 0;
+       r_refdef.view.z = 0;
+       r_refdef.view.width = vid.width;
+       r_refdef.view.height = vid.height;
+       r_refdef.view.depth = 1;
        // FIXME: restore frustum_x/frustum_y
-       RENDERSCENE.view.useperspective = true;
-       RENDERSCENE.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
-       RENDERSCENE.view.frustum_x = RENDERSCENE.view.frustum_y * (float)RENDERSCENE.view.width / (float)RENDERSCENE.view.height / vid_pixelheight.value;
-       RENDERSCENE.view.frustum_x *= RENDERSCENE.refdef.frustumscale_x;
-       RENDERSCENE.view.frustum_y *= RENDERSCENE.refdef.frustumscale_y;
-       RENDERSCENE.view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)RENDERSCENE.view.width / (float)RENDERSCENE.view.height / vid_pixelheight.value;
-       RENDERSCENE.view.ortho_y = scr_fov.value * (3.0 / 4.0);
+       r_refdef.view.useperspective = true;
+       r_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+       r_refdef.view.frustum_x = r_refdef.view.frustum_y * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
+       r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
+       r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
+       r_refdef.view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
+       r_refdef.view.ortho_y = scr_fov.value * (3.0 / 4.0);
        // FIXME: restore cl.csqc_origin
        // FIXME: restore cl.csqc_angles
        cl.csqc_vidvars.drawworld = true;
@@ -685,12 +678,10 @@ void VM_CL_R_ClearScene (void)
 //#301 void(float mask) addentities (EXT_CSQC)
 extern void CSQC_Predraw (prvm_edict_t *ed);//csprogs.c
 extern void CSQC_Think (prvm_edict_t *ed);//csprogs.c
-void VM_CL_R_AddEntities (void)
+static void VM_CL_R_AddEntities (void)
 {
        int                     i, drawmask;
        prvm_edict_t *ed;
-       const int prognum = PRVM_GetProgNr();
-       
        VM_SAFEPARMCOUNT(1, VM_CL_R_AddEntities);
        drawmask = (int)PRVM_G_FLOAT(OFS_PARM0);
        CSQC_RelinkAllEntities(drawmask);
@@ -711,26 +702,23 @@ void VM_CL_R_AddEntities (void)
                        continue;
                if(!((int)ed->fields.client->drawmask & drawmask))
                        continue;
-               CSQC_AddRenderEdict(&RENDERSCENE, ed);
+               CSQC_AddRenderEdict(ed);
        }
 }
 
 //#302 void(entity ent) addentity (EXT_CSQC)
-void VM_CL_R_AddEntity (void)
+static void VM_CL_R_AddEntity (void)
 {
-       const int prognum = PRVM_GetProgNr();
-       
        VM_SAFEPARMCOUNT(1, VM_CL_R_AddEntity);
-       CSQC_AddRenderEdict(&RENDERSCENE, PRVM_G_EDICT(OFS_PARM0));
+       CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0));
 }
 
 //#303 float(float property, ...) setproperty (EXT_CSQC)
-void VM_CL_R_SetView (void)
+static void VM_CL_R_SetView (void)
 {
        int             c;
        float   *f;
        float   k;
-       const int prognum = PRVM_GetProgNr();
 
        VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_R_SetView);
 
@@ -741,41 +729,41 @@ void VM_CL_R_SetView (void)
        switch(c)
        {
        case VF_MIN:
-               RENDERSCENE.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
-               RENDERSCENE.view.y = (int)(f[1] * vid.height / vid_conheight.value);
+               r_refdef.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+               r_refdef.view.y = (int)(f[1] * vid.height / vid_conheight.value);
                break;
        case VF_MIN_X:
-               RENDERSCENE.view.x = (int)(k * vid.width / vid_conwidth.value);
+               r_refdef.view.x = (int)(k * vid.width / vid_conwidth.value);
                break;
        case VF_MIN_Y:
-               RENDERSCENE.view.y = (int)(k * vid.height / vid_conheight.value);
+               r_refdef.view.y = (int)(k * vid.height / vid_conheight.value);
                break;
        case VF_SIZE:
-               RENDERSCENE.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
-               RENDERSCENE.view.height = (int)(f[1] * vid.height / vid_conheight.value);
+               r_refdef.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+               r_refdef.view.height = (int)(f[1] * vid.height / vid_conheight.value);
                break;
        case VF_SIZE_Y:
-               RENDERSCENE.view.width = (int)(k * vid.width / vid_conwidth.value);
+               r_refdef.view.width = (int)(k * vid.width / vid_conwidth.value);
                break;
        case VF_SIZE_X:
-               RENDERSCENE.view.height = (int)(k * vid.height / vid_conheight.value);
+               r_refdef.view.height = (int)(k * vid.height / vid_conheight.value);
                break;
        case VF_VIEWPORT:
-               RENDERSCENE.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
-               RENDERSCENE.view.y = (int)(f[1] * vid.height / vid_conheight.value);
+               r_refdef.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+               r_refdef.view.y = (int)(f[1] * vid.height / vid_conheight.value);
                f = PRVM_G_VECTOR(OFS_PARM2);
-               RENDERSCENE.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
-               RENDERSCENE.view.height = (int)(f[1] * vid.height / vid_conheight.value);
+               r_refdef.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+               r_refdef.view.height = (int)(f[1] * vid.height / vid_conheight.value);
                break;
        case VF_FOV:
-               RENDERSCENE.view.frustum_x = tan(f[0] * M_PI / 360.0);RENDERSCENE.view.ortho_x = f[0];
-               RENDERSCENE.view.frustum_y = tan(f[1] * M_PI / 360.0);RENDERSCENE.view.ortho_y = f[1];
+               r_refdef.view.frustum_x = tan(f[0] * M_PI / 360.0);r_refdef.view.ortho_x = f[0];
+               r_refdef.view.frustum_y = tan(f[1] * M_PI / 360.0);r_refdef.view.ortho_y = f[1];
                break;
        case VF_FOVX:
-               RENDERSCENE.view.frustum_x = tan(k * M_PI / 360.0);RENDERSCENE.view.ortho_x = k;
+               r_refdef.view.frustum_x = tan(k * M_PI / 360.0);r_refdef.view.ortho_x = k;
                break;
        case VF_FOVY:
-               RENDERSCENE.view.frustum_y = tan(k * M_PI / 360.0);RENDERSCENE.view.ortho_y = k;
+               r_refdef.view.frustum_y = tan(k * M_PI / 360.0);r_refdef.view.ortho_y = k;
                break;
        case VF_ORIGIN:
                VectorCopy(f, cl.csqc_origin);
@@ -831,7 +819,7 @@ void VM_CL_R_SetView (void)
                cl.viewangles[2] = k;
                break;
        case VF_PERSPECTIVE:
-               RENDERSCENE.view.useperspective = k != 0;
+               r_refdef.view.useperspective = k != 0;
                break;
        default:
                PRVM_G_FLOAT(OFS_RETURN) = 0;
@@ -842,35 +830,31 @@ void VM_CL_R_SetView (void)
 }
 
 //#304 void() renderscene (EXT_CSQC)
-void VM_CL_R_RenderScene (void)
+static void VM_CL_R_RenderScene (void)
 {
-       const int prognum = PRVM_GetProgNr();
-       
        VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene);
-       // we need to update any RENDERENDERSCENE.viewMODEL entities at this point because
+       // we need to update any RENDER_VIEWMODEL entities at this point because
        // csqc supplies its own view matrix
        CL_UpdateViewEntities();
        // now draw stuff!
-       R_RenderView(&RENDERSCENE);
+       R_RenderView();
 }
 
 //#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
-void VM_CL_R_AddDynamicLight (void)
+static void VM_CL_R_AddDynamicLight (void)
 {
        float           *pos, *col;
        matrix4x4_t     matrix;
-       const int prognum = PRVM_GetProgNr();
-       
        VM_SAFEPARMCOUNTRANGE(3, 3, VM_CL_R_AddDynamicLight);
 
        // if we've run out of dlights, just return
-       if (RENDERSCENE.refdef.numlights >= MAX_DLIGHTS)
+       if (r_refdef.numlights >= MAX_DLIGHTS)
                return;
 
        pos = PRVM_G_VECTOR(OFS_PARM0);
        col = PRVM_G_VECTOR(OFS_PARM2);
        Matrix4x4_CreateFromQuakeEntity(&matrix, pos[0], pos[1], pos[2], 0, 0, 0, PRVM_G_FLOAT(OFS_PARM1));
-       R_RTLight_Update(&RENDERSCENE.refdef.lights[RENDERSCENE.refdef.numlights++], false, &matrix, col, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+       R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &matrix, col, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
 }
 
 //============================================================================
@@ -880,12 +864,11 @@ static void VM_CL_unproject (void)
 {
        float   *f;
        vec3_t  temp;
-       const int prognum = PRVM_GetProgNr();
 
        VM_SAFEPARMCOUNT(1, VM_CL_unproject);
        f = PRVM_G_VECTOR(OFS_PARM0);
-       VectorSet(temp, f[2], f[0] * f[2] * -RENDERSCENE.view.frustum_x * 2.0 / RENDERSCENE.view.width, f[1] * f[2] * -RENDERSCENE.view.frustum_y * 2.0 / RENDERSCENE.view.height);
-       Matrix4x4_Transform(&RENDERSCENE.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
+       VectorSet(temp, f[2], f[0] * f[2] * -r_refdef.view.frustum_x * 2.0 / r_refdef.view.width, f[1] * f[2] * -r_refdef.view.frustum_y * 2.0 / r_refdef.view.height);
+       Matrix4x4_Transform(&r_refdef.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
 }
 
 //#311 vector (vector v) cs_project (EXT_CSQC)
@@ -894,13 +877,12 @@ static void VM_CL_project (void)
        float   *f;
        vec3_t  v;
        matrix4x4_t m;
-       const int prognum = PRVM_GetProgNr();
 
        VM_SAFEPARMCOUNT(1, VM_CL_project);
        f = PRVM_G_VECTOR(OFS_PARM0);
-       Matrix4x4_Invert_Simple(&m, &RENDERSCENE.view.matrix);
+       Matrix4x4_Invert_Simple(&m, &r_refdef.view.matrix);
        Matrix4x4_Transform(&m, f, v);
-       VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-RENDERSCENE.view.frustum_x*0.5*RENDERSCENE.view.width, v[2]/v[0]/-RENDERSCENE.view.frustum_y*RENDERSCENE.view.height*0.5, v[0]);
+       VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-r_refdef.view.frustum_x*0.5*r_refdef.view.width, v[2]/v[0]/-r_refdef.view.frustum_y*r_refdef.view.height*0.5, v[0]);
 }
 
 //#330 float(float stnum) getstatf (EXT_CSQC)
@@ -2257,17 +2239,13 @@ typedef struct
        unsigned char                   flags;  //[515]: + VM_POLYGON_2D and VM_POLYGON_FL4V flags
 }vm_polygon_t;
 
-typedef struct vmpolygons_s
-{
-  //static float                       vm_polygon_linewidth = 1;
-  mempool_t            *pool;
-  unsigned char                current_vertices;
-  qboolean             initialized;
-  vm_polygon_t         *polygons;
-  unsigned long        polygons_num, drawpolygons_num; //[515]: ok long on 64bit ?
-  qboolean             polygonbegin;   //[515]: for "no-crap-on-the-screen" check
-} vmpolygons_t;
-vmpolygons_t vmpolygons[PRVM_MAXPROGS];
+//static float                 vm_polygon_linewidth = 1;
+static mempool_t               *vm_polygons_pool = NULL;
+static unsigned char                   vm_current_vertices = 0;
+static qboolean                        vm_polygons_initialized = false;
+static vm_polygon_t            *vm_polygons = NULL;
+static unsigned long   vm_polygons_num = 0, vm_drawpolygons_num = 0;   //[515]: ok long on 64bit ?
+static qboolean                        vm_polygonbegin = false;        //[515]: for "no-crap-on-the-screen" check
 #define VM_DEFPOLYNUM 64       //[515]: enough for default ?
 
 #define VM_POLYGON_FL3V                16      //more than 2 vertices (used only for lines)
@@ -2275,26 +2253,24 @@ vmpolygons_t vmpolygons[PRVM_MAXPROGS];
 #define VM_POLYGON_FL2D                64
 #define VM_POLYGON_FL4V                128     //4 vertices
 
-static void VM_InitPolygons (vmpolygons_t* polys)
+static void VM_InitPolygons (void)
 {
-       polys->pool = Mem_AllocPool("VMPOLY", 0, NULL);
-       polys->polygons = (vm_polygon_t *)Mem_Alloc(polys->pool, VM_DEFPOLYNUM*sizeof(vm_polygon_t));
-       memset(polys->polygons, 0, VM_DEFPOLYNUM*sizeof(vm_polygon_t));
-       polys->polygons_num = VM_DEFPOLYNUM;
-       polys->drawpolygons_num = 0;
-       polys->polygonbegin = false;
-       polys->initialized = true;
+       vm_polygons_pool = Mem_AllocPool("VMPOLY", 0, NULL);
+       vm_polygons = (vm_polygon_t *)Mem_Alloc(vm_polygons_pool, VM_DEFPOLYNUM*sizeof(vm_polygon_t));
+       memset(vm_polygons, 0, VM_DEFPOLYNUM*sizeof(vm_polygon_t));
+       vm_polygons_num = VM_DEFPOLYNUM;
+       vm_drawpolygons_num = 0;
+       vm_polygonbegin = false;
+       vm_polygons_initialized = true;
 }
 
 static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 {
        int surfacelistindex;
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
        // LordHavoc: FIXME: this is stupid code
        for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
        {
-               const vm_polygon_t      *p = &polys->polygons[surfacelist[surfacelistindex]];
+               const vm_polygon_t      *p = &vm_polygons[surfacelist[surfacelistindex]];
                int                                     flags = p->flags & 0x0f;
 
                if(flags == DRAWFLAG_ADDITIVE)
@@ -2369,6 +2345,7 @@ static void VM_CL_AddPolygonTo2DScene (vm_polygon_t *p)
 {
        drawqueuemesh_t mesh;
        static int              picelements[6] = {0, 1, 2, 0, 2, 3};
+
        mesh.texture = p->tex;
        mesh.data_element3i = picelements;
        mesh.data_vertex3f = p->data;
@@ -2393,51 +2370,47 @@ static void VM_CL_AddPolygonTo2DScene (vm_polygon_t *p)
 void VM_CL_AddPolygonsToMeshQueue (void)
 {
        int i;
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
-       if(!polys->drawpolygons_num)
+       if(!vm_drawpolygons_num)
                return;
        R_Mesh_Matrix(&identitymatrix);
        GL_CullFace(GL_NONE);
-       for(i = 0;i < (int)polys->drawpolygons_num;i++)
+       for(i = 0;i < (int)vm_drawpolygons_num;i++)
                VM_DrawPolygonCallback(NULL, NULL, 1, &i);
-       polys->drawpolygons_num = 0;
+       vm_drawpolygons_num = 0;
 }
 
 //void(string texturename, float flag[, float 2d[, float lines]]) R_BeginPolygon
-void VM_CL_R_PolygonBegin (void)
+static void VM_CL_R_PolygonBegin (void)
 {
        vm_polygon_t    *p;
        const char              *picname;
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
        VM_SAFEPARMCOUNTRANGE(2, 4, VM_CL_R_PolygonBegin);
 
-       if(!polys->initialized)
-               VM_InitPolygons(polys);
-       if(polys->polygonbegin)
+       if(!vm_polygons_initialized)
+               VM_InitPolygons();
+       if(vm_polygonbegin)
        {
                VM_Warning("VM_CL_R_PolygonBegin: called twice without VM_CL_R_PolygonEnd after first\n");
                return;
        }
-       if(polys->drawpolygons_num >= polys->polygons_num)
+       if(vm_drawpolygons_num >= vm_polygons_num)
        {
-               p = (vm_polygon_t *)Mem_Alloc(polys->pool, 2 * polys->polygons_num * sizeof(vm_polygon_t));
-               memset(p, 0, 2 * polys->polygons_num * sizeof(vm_polygon_t));
-               memcpy(p, polys->polygons, polys->polygons_num * sizeof(vm_polygon_t));
-               Mem_Free(polys->polygons);
-               polys->polygons = p;
-               polys->polygons_num *= 2;
+               p = (vm_polygon_t *)Mem_Alloc(vm_polygons_pool, 2 * vm_polygons_num * sizeof(vm_polygon_t));
+               memset(p, 0, 2 * vm_polygons_num * sizeof(vm_polygon_t));
+               memcpy(p, vm_polygons, vm_polygons_num * sizeof(vm_polygon_t));
+               Mem_Free(vm_polygons);
+               vm_polygons = p;
+               vm_polygons_num *= 2;
        }
-       p = &polys->polygons[polys->drawpolygons_num];
+       p = &vm_polygons[vm_drawpolygons_num];
        picname = PRVM_G_STRING(OFS_PARM0);
        if(picname[0])
                p->tex = Draw_CachePic(picname, true)->tex;
        else
                p->tex = r_texture_white;
        p->flags = (unsigned char)PRVM_G_FLOAT(OFS_PARM1);
-       polys->current_vertices = 0;
-       polys->polygonbegin = true;
+       vm_current_vertices = 0;
+       vm_polygonbegin = true;
        if(prog->argc >= 3)
        {
                if(PRVM_G_FLOAT(OFS_PARM2))
@@ -2451,15 +2424,13 @@ void VM_CL_R_PolygonBegin (void)
 }
 
 //void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
-void VM_CL_R_PolygonVertex (void)
+static void VM_CL_R_PolygonVertex (void)
 {
        float                   *coords, *tx, *rgb, alpha;
        vm_polygon_t    *p;
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
        VM_SAFEPARMCOUNT(4, VM_CL_R_PolygonVertex);
 
-       if(!polys->polygonbegin)
+       if(!vm_polygonbegin)
        {
                VM_Warning("VM_CL_R_PolygonVertex: VM_CL_R_PolygonBegin wasn't called\n");
                return;
@@ -2469,90 +2440,86 @@ void VM_CL_R_PolygonVertex (void)
        rgb             = PRVM_G_VECTOR(OFS_PARM2);
        alpha = PRVM_G_FLOAT(OFS_PARM3);
 
-       p = &polys->polygons[polys->drawpolygons_num];
-       if(polys->current_vertices > 4)
+       p = &vm_polygons[vm_drawpolygons_num];
+       if(vm_current_vertices > 4)
        {
                VM_Warning("VM_CL_R_PolygonVertex: may have 4 vertices max\n");
                return;
        }
 
-       p->data[polys->current_vertices*3]      = coords[0];
-       p->data[1+polys->current_vertices*3]    = coords[1];
-       p->data[2+polys->current_vertices*3]    = coords[2];
+       p->data[vm_current_vertices*3]          = coords[0];
+       p->data[1+vm_current_vertices*3]        = coords[1];
+       p->data[2+vm_current_vertices*3]        = coords[2];
 
-       p->data[12+polys->current_vertices*2]   = tx[0];
+       p->data[12+vm_current_vertices*2]       = tx[0];
        if(!(p->flags & VM_POLYGON_FLLINES))
-               p->data[13+polys->current_vertices*2]   = tx[1];
+               p->data[13+vm_current_vertices*2]       = tx[1];
 
-       p->data[20+polys->current_vertices*4]   = rgb[0];
-       p->data[21+polys->current_vertices*4]   = rgb[1];
-       p->data[22+polys->current_vertices*4]   = rgb[2];
-       p->data[23+polys->current_vertices*4]   = alpha;
+       p->data[20+vm_current_vertices*4]       = rgb[0];
+       p->data[21+vm_current_vertices*4]       = rgb[1];
+       p->data[22+vm_current_vertices*4]       = rgb[2];
+       p->data[23+vm_current_vertices*4]       = alpha;
 
-       polys->current_vertices++;
-       if(polys->current_vertices == 4)
+       vm_current_vertices++;
+       if(vm_current_vertices == 4)
                p->flags |= VM_POLYGON_FL4V;
        else
-               if(polys->current_vertices == 3)
+               if(vm_current_vertices == 3)
                        p->flags |= VM_POLYGON_FL3V;
 }
 
 //void() R_EndPolygon
-void VM_CL_R_PolygonEnd (void)
+static void VM_CL_R_PolygonEnd (void)
 {
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
        VM_SAFEPARMCOUNT(0, VM_CL_R_PolygonEnd);
-       if(!polys->polygonbegin)
+       if(!vm_polygonbegin)
        {
                VM_Warning("VM_CL_R_PolygonEnd: VM_CL_R_PolygonBegin wasn't called\n");
                return;
        }
-       polys->polygonbegin = false;
-       if(polys->current_vertices > 2 || (polys->current_vertices >= 2 && polys->polygons[polys->drawpolygons_num].flags & VM_POLYGON_FLLINES))
+       vm_polygonbegin = false;
+       if(vm_current_vertices > 2 || (vm_current_vertices >= 2 && vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FLLINES))
        {
-               if(polys->polygons[polys->drawpolygons_num].flags & VM_POLYGON_FL2D)    //[515]: don't use qcpolygons memory if 2D
-                       VM_CL_AddPolygonTo2DScene(&polys->polygons[polys->drawpolygons_num]);
+               if(vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FL2D)    //[515]: don't use qcpolygons memory if 2D
+                       VM_CL_AddPolygonTo2DScene(&vm_polygons[vm_drawpolygons_num]);
                else
-                       polys->drawpolygons_num++;
+                       vm_drawpolygons_num++;
        }
        else
-               VM_Warning("VM_CL_R_PolygonEnd: %i vertices isn't a good choice\n", polys->current_vertices);
+               VM_Warning("VM_CL_R_PolygonEnd: %i vertices isn't a good choice\n", vm_current_vertices);
 }
 
-static vmpolygons_t debugPolys;
-
 void Debug_PolygonBegin(const char *picname, int flags, qboolean draw2d, float linewidth)
 {
        vm_polygon_t    *p;
 
-       if(!debugPolys.initialized)
-               VM_InitPolygons(&debugPolys);
-       if(debugPolys.polygonbegin)
+       if(!vm_polygons_initialized)
+               VM_InitPolygons();
+       if(vm_polygonbegin)
        {
                Con_Printf("Debug_PolygonBegin: called twice without Debug_PolygonEnd after first\n");
                return;
        }
        // limit polygons to a vaguely sane amount, beyond this each one just
        // replaces the last one
-       debugPolys.drawpolygons_num = min(debugPolys.drawpolygons_num, (1<<20)-1);
-       if(debugPolys.drawpolygons_num >= debugPolys.polygons_num)
+       vm_drawpolygons_num = min(vm_drawpolygons_num, (1<<20)-1);
+       if(vm_drawpolygons_num >= vm_polygons_num)
        {
-               p = (vm_polygon_t *)Mem_Alloc(debugPolys.pool, 2 * debugPolys.polygons_num * sizeof(vm_polygon_t));
-               memset(p, 0, 2 * debugPolys.polygons_num * sizeof(vm_polygon_t));
-               memcpy(p, debugPolys.polygons, debugPolys.polygons_num * sizeof(vm_polygon_t));
-               Mem_Free(debugPolys.polygons);
-               debugPolys.polygons = p;
-               debugPolys.polygons_num *= 2;
+               p = (vm_polygon_t *)Mem_Alloc(vm_polygons_pool, 2 * vm_polygons_num * sizeof(vm_polygon_t));
+               memset(p, 0, 2 * vm_polygons_num * sizeof(vm_polygon_t));
+               memcpy(p, vm_polygons, vm_polygons_num * sizeof(vm_polygon_t));
+               Mem_Free(vm_polygons);
+               vm_polygons = p;
+               vm_polygons_num *= 2;
        }
-       p = &debugPolys.polygons[debugPolys.drawpolygons_num];
+       p = &vm_polygons[vm_drawpolygons_num];
        if(picname && picname[0])
                p->tex = Draw_CachePic(picname, true)->tex;
        else
                p->tex = r_texture_white;
        p->flags = flags;
-       debugPolys.current_vertices = 0;
-       debugPolys.polygonbegin = true;
+       vm_current_vertices = 0;
+       vm_polygonbegin = true;
        if(draw2d)
                p->flags |= VM_POLYGON_FL2D;
        if(linewidth)
@@ -2566,57 +2533,57 @@ void Debug_PolygonVertex(float x, float y, float z, float s, float t, float r, f
 {
        vm_polygon_t    *p;
 
-       if(!debugPolys.polygonbegin)
+       if(!vm_polygonbegin)
        {
                Con_Printf("Debug_PolygonVertex: Debug_PolygonBegin wasn't called\n");
                return;
        }
 
-       p = &debugPolys.polygons[debugPolys.drawpolygons_num];
-       if(debugPolys.current_vertices > 4)
+       p = &vm_polygons[vm_drawpolygons_num];
+       if(vm_current_vertices > 4)
        {
                Con_Printf("Debug_PolygonVertex: may have 4 vertices max\n");
                return;
        }
 
-       p->data[debugPolys.current_vertices*3]          = x;
-       p->data[1+debugPolys.current_vertices*3]        = y;
-       p->data[2+debugPolys.current_vertices*3]        = z;
+       p->data[vm_current_vertices*3]          = x;
+       p->data[1+vm_current_vertices*3]        = y;
+       p->data[2+vm_current_vertices*3]        = z;
 
-       p->data[12+debugPolys.current_vertices*2]       = s;
+       p->data[12+vm_current_vertices*2]       = s;
        if(!(p->flags & VM_POLYGON_FLLINES))
-               p->data[13+debugPolys.current_vertices*2]       = t;
+               p->data[13+vm_current_vertices*2]       = t;
 
-       p->data[20+debugPolys.current_vertices*4]       = r;
-       p->data[21+debugPolys.current_vertices*4]       = g;
-       p->data[22+debugPolys.current_vertices*4]       = b;
-       p->data[23+debugPolys.current_vertices*4]       = a;
+       p->data[20+vm_current_vertices*4]       = r;
+       p->data[21+vm_current_vertices*4]       = g;
+       p->data[22+vm_current_vertices*4]       = b;
+       p->data[23+vm_current_vertices*4]       = a;
 
-       debugPolys.current_vertices++;
-       if(debugPolys.current_vertices == 4)
+       vm_current_vertices++;
+       if(vm_current_vertices == 4)
                p->flags |= VM_POLYGON_FL4V;
        else
-               if(debugPolys.current_vertices == 3)
+               if(vm_current_vertices == 3)
                        p->flags |= VM_POLYGON_FL3V;
 }
 
 void Debug_PolygonEnd(void)
 {
-       if(!debugPolys.polygonbegin)
+       if(!vm_polygonbegin)
        {
                Con_Printf("Debug_PolygonEnd: Debug_PolygonBegin wasn't called\n");
                return;
        }
-       debugPolys.polygonbegin = false;
-       if(debugPolys.current_vertices > 2 || (debugPolys.current_vertices >= 2 && debugPolys.polygons[debugPolys.drawpolygons_num].flags & VM_POLYGON_FLLINES))
+       vm_polygonbegin = false;
+       if(vm_current_vertices > 2 || (vm_current_vertices >= 2 && vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FLLINES))
        {
-               if(debugPolys.polygons[debugPolys.drawpolygons_num].flags & VM_POLYGON_FL2D)    //[515]: don't use qcpolygons memory if 2D
-                       VM_CL_AddPolygonTo2DScene(&debugPolys.polygons[debugPolys.drawpolygons_num]);
+               if(vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FL2D)    //[515]: don't use qcpolygons memory if 2D
+                       VM_CL_AddPolygonTo2DScene(&vm_polygons[vm_drawpolygons_num]);
                else
-                       debugPolys.drawpolygons_num++;
+                       vm_drawpolygons_num++;
        }
        else
-               Con_Printf("Debug_PolygonEnd: %i vertices isn't a good choice\n", debugPolys.current_vertices);
+               Con_Printf("Debug_PolygonEnd: %i vertices isn't a good choice\n", vm_current_vertices);
 }
 
 /*
@@ -3196,7 +3163,7 @@ VM_CL_R_AddDynamicLight,          // #305 void(vector org, float radius, vector lightcol
 VM_CL_R_PolygonBegin,                  // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
 VM_CL_R_PolygonVertex,                 // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
 VM_CL_R_PolygonEnd,                            // #308 void() R_EndPolygon
-NULL /* R_LoadWorldModel in menu VM, should stay unassigned in client*/, // #309
+NULL,                                                  // #309
 VM_CL_unproject,                               // #310 vector (vector v) cs_unproject (EXT_CSQC)
 VM_CL_project,                                 // #311 vector (vector v) cs_project (EXT_CSQC)
 NULL,                                                  // #312
@@ -3400,28 +3367,24 @@ NULL,                                                   // #499
 
 const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
 
-void VM_Polygons_Reset(void)
+void VM_CL_Cmd_Init(void)
 {
-        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-        
+       VM_Cmd_Init();
        // TODO: replace vm_polygons stuff with a more general debugging polygon system, and make vm_polygons functions use that system
-       if(polys->initialized)
+       if(vm_polygons_initialized)
        {
-               Mem_FreePool(&polys->pool);
-               polys->initialized = false;
+               Mem_FreePool(&vm_polygons_pool);
+               vm_polygons_initialized = false;
        }
 }
 
-void VM_CL_Cmd_Init(void)
-{
-       VM_Cmd_Init();
-       VM_Polygons_Reset();
-       renderscenes[PRVM_CLIENTPROG] = &client_scene;
-}
-
 void VM_CL_Cmd_Reset(void)
 {
        VM_Cmd_Reset();
-       VM_Polygons_Reset();
+       if(vm_polygons_initialized)
+       {
+               Mem_FreePool(&vm_polygons_pool);
+               vm_polygons_initialized = false;
+       }
 }
 
index 2e5ca5cb5b84e2714c9d247bea8609692426e405..58928c2f938865e3bb742995d8f721797a26de83 100644 (file)
@@ -3,28 +3,4 @@
 
 int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex);
 
-/* These are VM built-ins that originate in the client-side programs support
-   but are reused by the other programs (usually the menu). */
-
-void VM_CL_setmodel (void);
-void VM_CL_precache_model (void);
-void VM_CL_setorigin (void);
-
-/* Per-VM scenes */
-extern renderscene_t* renderscenes[PRVM_MAXPROGS];
-
-void VM_CL_R_AddDynamicLight (void);
-void VM_CL_R_ClearScene (void);
-void VM_CL_R_AddEntities (void);
-void VM_CL_R_AddEntity (void);
-void VM_CL_R_SetView (void);
-void VM_CL_R_RenderScene (void);
-void VM_CL_R_LoadWorldModel (void);
-
-void VM_CL_R_PolygonBegin (void);
-void VM_CL_R_PolygonVertex (void);
-void VM_CL_R_PolygonEnd (void);
-/* VMs exposing the polygon calls must call this on Init/Reset */
-void VM_Polygons_Reset();
-
 #endif /* __CLVM_CMDS_H__ */
index 9809b5ead421b92824422daa824e8b2e462cf65e..995c0ed1a19d0d01701d5af58b34e49812ab38e2 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -123,7 +123,7 @@ void CSQC_Think (prvm_edict_t *ed)
 }
 
 extern cvar_t cl_noplayershadow;
-qboolean CSQC_AddRenderEdict(renderscene_t* scene, prvm_edict_t *ed)
+qboolean CSQC_AddRenderEdict(prvm_edict_t *ed)
 {
        int renderflags;
        int c;
@@ -137,7 +137,7 @@ qboolean CSQC_AddRenderEdict(renderscene_t* scene, prvm_edict_t *ed)
        if (!model)
                return false;
 
-       e = CL_NewTempEntity(scene);
+       e = CL_NewTempEntity();
        if (!e)
                return false;
 
@@ -233,9 +233,10 @@ qboolean CSQC_AddRenderEdict(renderscene_t* scene, prvm_edict_t *ed)
 qboolean CL_VM_InputEvent (qboolean down, int key, int ascii)
 {
        qboolean r;
-       prvm_eval_t* val;
+
        if(!cl.csqc_loaded)
                return false;
+
        CSQC_BEGIN
                if (!prog->funcoffsets.CSQC_InputEvent)
                        r = false;
index 09d479da20c33527bde8e12a39224ba6369d0299..25f0aa6e25c80313d4102b833f9394b54ffd8294 100644 (file)
@@ -903,9 +903,9 @@ void GL_TransformToScreen(const vec4_t in, vec4_t out)
        Matrix4x4_Transform4 (&backend_viewmatrix, in, temp);
        Matrix4x4_Transform4 (&backend_projectmatrix, temp, out);
        iw = 1.0f / out[3];
-       out[0] = r_view.x + (out[0] * iw + 1.0f) * r_view.width * 0.5f;
-       out[1] = r_view.y + r_view.height - (out[1] * iw + 1.0f) * r_view.height * 0.5f;
-       out[2] = r_view.z + (out[2] * iw + 1.0f) * r_view.depth * 0.5f;
+       out[0] = r_refdef.view.x + (out[0] * iw + 1.0f) * r_refdef.view.width * 0.5f;
+       out[1] = r_refdef.view.y + r_refdef.view.height - (out[1] * iw + 1.0f) * r_refdef.view.height * 0.5f;
+       out[2] = r_refdef.view.z + (out[2] * iw + 1.0f) * r_refdef.view.depth * 0.5f;
 }
 
 // called at beginning of frame
index f3241e561a2ebe373795293d2912cdcabc262bf3..9292c38cdc5fc24bd1dc66b442371081eb7745fb 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -737,8 +737,8 @@ static void _DrawQ_Setup(void)
                return;
        r_refdef.draw2dstage = true;
        CHECKGLERROR
-       qglViewport(r_view.x, vid.height - (r_view.y + r_view.height), r_view.width, r_view.height);CHECKGLERROR
-       GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 1);
+       qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
        qglDepthFunc(GL_LEQUAL);CHECKGLERROR
        qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
index 6c41e1173bb7a1985ae63535338020938660b2d7..ceb8e65c7e1b20ff9cb9c846a5738685089f59b1 100644 (file)
@@ -28,7 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 mempool_t *r_main_mempool;
 rtexturepool_t *r_main_texturepool;
 
-renderscene_t client_scene;
+//
+// screen size info
+//
+r_refdef_t r_refdef;
 
 cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "1", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
 cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
@@ -203,7 +206,7 @@ const static float r_screenvertex3f[12] =
        0, 1, 0
 };
 
-extern void R_DrawModelShadows(renderscene_t* scene);
+extern void R_DrawModelShadows(void);
 
 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b)
 {
@@ -260,7 +263,7 @@ float FogForDistance(vec_t dist)
 
 float FogPoint_World(const vec3_t p)
 {
-       return FogForDistance(VectorDistance((p), r_view.origin));
+       return FogForDistance(VectorDistance((p), r_refdef.view.origin));
 }
 
 float FogPoint_Model(const vec3_t p)
@@ -1453,10 +1456,10 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting, fl
                //   color.rgb = [[SceneBrightness * ContrastBoost]] * color.rgb / ([[ContrastBoost - 1]] * color.rgb + 1);
                // and do [[calculations]] here in the engine
                qglUniform1fARB(r_glsl_permutation->loc_ContrastBoostCoeff, r_glsl_contrastboost.value - 1);
-               if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_view.colorscale * r_glsl_contrastboost.value);
+               if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_refdef.view.colorscale * r_glsl_contrastboost.value);
        }
        else
-               if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_view.colorscale);
+               if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_refdef.view.colorscale);
        if (r_glsl_permutation->loc_FogColor >= 0)
        {
                // additive passes are only darkened by fog, not tinted
@@ -2096,12 +2099,12 @@ int R_CullBox(const vec3_t mins, const vec3_t maxs)
 {
        int i;
        mplane_t *p;
-       for (i = 0;i < r_view.numfrustumplanes;i++)
+       for (i = 0;i < r_refdef.view.numfrustumplanes;i++)
        {
                // skip nearclip plane, it often culls portals when you are very close, and is almost never useful
                if (i == 4)
                        continue;
-               p = r_view.frustum + i;
+               p = r_refdef.view.frustum + i;
                switch(p->signbits)
                {
                default:
@@ -2191,7 +2194,7 @@ int R_CullBoxCustomPlanes(const vec3_t mins, const vec3_t maxs, int numplanes, c
 
 //==================================================================================
 
-static void R_View_UpdateEntityVisible (renderscene_t* scene)
+static void R_View_UpdateEntityVisible (void)
 {
        int i, renderimask;
        entity_render_t *ent;
@@ -2199,27 +2202,27 @@ static void R_View_UpdateEntityVisible (renderscene_t* scene)
        if (!r_drawentities.integer)
                return;
 
-       renderimask = scene->refdef.envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : ((chase_active.integer || r_waterstate.renderingscene) ? RENDER_VIEWMODEL : RENDER_EXTERIORMODEL);
-       if (scene->refdef.worldmodel && scene->refdef.worldmodel->brush.BoxTouchingVisibleLeafs)
+       renderimask = r_refdef.envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : ((chase_active.integer || r_waterstate.renderingscene) ? RENDER_VIEWMODEL : RENDER_EXTERIORMODEL);
+       if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs)
        {
                // worldmodel can check visibility
-               for (i = 0;i < scene->refdef.numentities;i++)
+               for (i = 0;i < r_refdef.numentities;i++)
                {
-                       ent = scene->refdef.entities[i];
-                       scene->viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs)) && ((ent->effects & EF_NODEPTHTEST) || (ent->flags & RENDER_VIEWMODEL) || scene->refdef.worldmodel->brush.BoxTouchingVisibleLeafs(scene->refdef.worldmodel, scene->viewcache.world_leafvisible, ent->mins, ent->maxs));
+                       ent = r_refdef.entities[i];
+                       r_refdef.viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs)) && ((ent->effects & EF_NODEPTHTEST) || (ent->flags & RENDER_VIEWMODEL) || r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs));
 
                }
                if(r_cullentities_trace.integer && r_refdef.worldmodel->brush.TraceLineOfSight)
                {
-                       for (i = 0;i < scene->refdef.numentities;i++)
+                       for (i = 0;i < r_refdef.numentities;i++)
                        {
-                               ent = scene->refdef.entities[i];
-                               if(scene->viewcache.entityvisible[i] && !(ent->effects & EF_NODEPTHTEST) && !(ent->flags & RENDER_VIEWMODEL) && !(ent->model && (ent->model->name[0] == '*')))
+                               ent = r_refdef.entities[i];
+                               if(r_refdef.viewcache.entityvisible[i] && !(ent->effects & EF_NODEPTHTEST) && !(ent->flags & RENDER_VIEWMODEL) && !(ent->model && (ent->model->name[0] == '*')))
                                {
-                                       if(Mod_CanSeeBox_Trace(r_cullentities_trace_samples.integer, r_cullentities_trace_enlarge.value, scene->refdef.worldmodel, scene->view.origin, ent->mins, ent->maxs))
+                                       if(Mod_CanSeeBox_Trace(r_cullentities_trace_samples.integer, r_cullentities_trace_enlarge.value, r_refdef.worldmodel, r_refdef.view.origin, ent->mins, ent->maxs))
                                                ent->last_trace_visibility = realtime;
                                        if(ent->last_trace_visibility < realtime - r_cullentities_trace_delay.value)
-                                               scene->viewcache.entityvisible[i] = 0;
+                                               r_refdef.viewcache.entityvisible[i] = 0;
                                }
                        }
                }
@@ -2227,10 +2230,10 @@ static void R_View_UpdateEntityVisible (renderscene_t* scene)
        else
        {
                // no worldmodel or it can't check visibility
-               for (i = 0;i < scene->refdef.numentities;i++)
+               for (i = 0;i < r_refdef.numentities;i++)
                {
-                       ent = scene->refdef.entities[i];
-                       scene->viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs));
+                       ent = r_refdef.entities[i];
+                       r_refdef.viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs));
                }
        }
 }
@@ -2247,7 +2250,7 @@ int R_DrawBrushModelsSky (void)
        sky = false;
        for (i = 0;i < r_refdef.numentities;i++)
        {
-               if (!r_viewcache.entityvisible[i])
+               if (!r_refdef.viewcache.entityvisible[i])
                        continue;
                ent = r_refdef.entities[i];
                if (!ent->model || !ent->model->DrawSky)
@@ -2259,7 +2262,7 @@ int R_DrawBrushModelsSky (void)
 }
 
 static void R_DrawNoModel(entity_render_t *ent);
-static void R_DrawModels(renderscene_t* scene)
+static void R_DrawModels(void)
 {
        int i;
        entity_render_t *ent;
@@ -2267,12 +2270,12 @@ static void R_DrawModels(renderscene_t* scene)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < scene->refdef.numentities;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               if (!scene->viewcache.entityvisible[i])
+               if (!r_refdef.viewcache.entityvisible[i])
                        continue;
-               ent = scene->refdef.entities[i];
-               scene->refdef.stats.entities++;
+               ent = r_refdef.entities[i];
+               r_refdef.stats.entities++;
                if (ent->model && ent->model->Draw != NULL)
                        ent->model->Draw(ent);
                else
@@ -2280,7 +2283,7 @@ static void R_DrawModels(renderscene_t* scene)
        }
 }
 
-static void R_DrawModelsDepth(renderscene_t* scene)
+static void R_DrawModelsDepth(void)
 {
        int i;
        entity_render_t *ent;
@@ -2288,17 +2291,17 @@ static void R_DrawModelsDepth(renderscene_t* scene)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < scene->refdef.numentities;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               if (!scene->viewcache.entityvisible[i])
+               if (!r_refdef.viewcache.entityvisible[i])
                        continue;
-               ent = scene->refdef.entities[i];
+               ent = r_refdef.entities[i];
                if (ent->model && ent->model->DrawDepth != NULL)
                        ent->model->DrawDepth(ent);
        }
 }
 
-static void R_DrawModelsDebug(renderscene_t* scene)
+static void R_DrawModelsDebug(void)
 {
        int i;
        entity_render_t *ent;
@@ -2306,17 +2309,17 @@ static void R_DrawModelsDebug(renderscene_t* scene)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < scene->refdef.numentities;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               if (!scene->viewcache.entityvisible[i])
+               if (!r_refdef.viewcache.entityvisible[i])
                        continue;
-               ent = scene->refdef.entities[i];
+               ent = r_refdef.entities[i];
                if (ent->model && ent->model->DrawDebug != NULL)
                        ent->model->DrawDebug(ent);
        }
 }
 
-static void R_DrawModelsAddWaterPlanes(renderscene_t* scene)
+static void R_DrawModelsAddWaterPlanes(void)
 {
        int i;
        entity_render_t *ent;
@@ -2324,197 +2327,197 @@ static void R_DrawModelsAddWaterPlanes(renderscene_t* scene)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < scene->refdef.numentities;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               if (!scene->viewcache.entityvisible[i])
+               if (!r_refdef.viewcache.entityvisible[i])
                        continue;
-               ent = scene->refdef.entities[i];
+               ent = r_refdef.entities[i];
                if (ent->model && ent->model->DrawAddWaterPlanes != NULL)
                        ent->model->DrawAddWaterPlanes(ent);
        }
 }
 
-static void R_View_SetFrustum(renderscene_t* scene)
+static void R_View_SetFrustum(void)
 {
        int i;
        double slopex, slopey;
 
        // break apart the view matrix into vectors for various purposes
-       Matrix4x4_ToVectors(&scene->view.matrix, scene->view.forward, scene->view.left, scene->view.up, scene->view.origin);
-       VectorNegate(scene->view.left, scene->view.right);
+       Matrix4x4_ToVectors(&r_refdef.view.matrix, r_refdef.view.forward, r_refdef.view.left, r_refdef.view.up, r_refdef.view.origin);
+       VectorNegate(r_refdef.view.left, r_refdef.view.right);
 
 #if 0
-       r_view.frustum[0].normal[0] = 0 - 1.0 / r_view.frustum_x;
-       r_view.frustum[0].normal[1] = 0 - 0;
-       r_view.frustum[0].normal[2] = -1 - 0;
-       r_view.frustum[1].normal[0] = 0 + 1.0 / r_view.frustum_x;
-       r_view.frustum[1].normal[1] = 0 + 0;
-       r_view.frustum[1].normal[2] = -1 + 0;
-       r_view.frustum[2].normal[0] = 0 - 0;
-       r_view.frustum[2].normal[1] = 0 - 1.0 / r_view.frustum_y;
-       r_view.frustum[2].normal[2] = -1 - 0;
-       r_view.frustum[3].normal[0] = 0 + 0;
-       r_view.frustum[3].normal[1] = 0 + 1.0 / r_view.frustum_y;
-       r_view.frustum[3].normal[2] = -1 + 0;
+       r_refdef.view.frustum[0].normal[0] = 0 - 1.0 / r_refdef.view.frustum_x;
+       r_refdef.view.frustum[0].normal[1] = 0 - 0;
+       r_refdef.view.frustum[0].normal[2] = -1 - 0;
+       r_refdef.view.frustum[1].normal[0] = 0 + 1.0 / r_refdef.view.frustum_x;
+       r_refdef.view.frustum[1].normal[1] = 0 + 0;
+       r_refdef.view.frustum[1].normal[2] = -1 + 0;
+       r_refdef.view.frustum[2].normal[0] = 0 - 0;
+       r_refdef.view.frustum[2].normal[1] = 0 - 1.0 / r_refdef.view.frustum_y;
+       r_refdef.view.frustum[2].normal[2] = -1 - 0;
+       r_refdef.view.frustum[3].normal[0] = 0 + 0;
+       r_refdef.view.frustum[3].normal[1] = 0 + 1.0 / r_refdef.view.frustum_y;
+       r_refdef.view.frustum[3].normal[2] = -1 + 0;
 #endif
 
 #if 0
        zNear = r_refdef.nearclip;
        nudge = 1.0 - 1.0 / (1<<23);
-       r_view.frustum[4].normal[0] = 0 - 0;
-       r_view.frustum[4].normal[1] = 0 - 0;
-       r_view.frustum[4].normal[2] = -1 - -nudge;
-       r_view.frustum[4].dist = 0 - -2 * zNear * nudge;
-       r_view.frustum[5].normal[0] = 0 + 0;
-       r_view.frustum[5].normal[1] = 0 + 0;
-       r_view.frustum[5].normal[2] = -1 + -nudge;
-       r_view.frustum[5].dist = 0 + -2 * zNear * nudge;
+       r_refdef.view.frustum[4].normal[0] = 0 - 0;
+       r_refdef.view.frustum[4].normal[1] = 0 - 0;
+       r_refdef.view.frustum[4].normal[2] = -1 - -nudge;
+       r_refdef.view.frustum[4].dist = 0 - -2 * zNear * nudge;
+       r_refdef.view.frustum[5].normal[0] = 0 + 0;
+       r_refdef.view.frustum[5].normal[1] = 0 + 0;
+       r_refdef.view.frustum[5].normal[2] = -1 + -nudge;
+       r_refdef.view.frustum[5].dist = 0 + -2 * zNear * nudge;
 #endif
 
 
 
 #if 0
-       r_view.frustum[0].normal[0] = m[3] - m[0];
-       r_view.frustum[0].normal[1] = m[7] - m[4];
-       r_view.frustum[0].normal[2] = m[11] - m[8];
-       r_view.frustum[0].dist = m[15] - m[12];
-
-       r_view.frustum[1].normal[0] = m[3] + m[0];
-       r_view.frustum[1].normal[1] = m[7] + m[4];
-       r_view.frustum[1].normal[2] = m[11] + m[8];
-       r_view.frustum[1].dist = m[15] + m[12];
-
-       r_view.frustum[2].normal[0] = m[3] - m[1];
-       r_view.frustum[2].normal[1] = m[7] - m[5];
-       r_view.frustum[2].normal[2] = m[11] - m[9];
-       r_view.frustum[2].dist = m[15] - m[13];
-
-       r_view.frustum[3].normal[0] = m[3] + m[1];
-       r_view.frustum[3].normal[1] = m[7] + m[5];
-       r_view.frustum[3].normal[2] = m[11] + m[9];
-       r_view.frustum[3].dist = m[15] + m[13];
-
-       r_view.frustum[4].normal[0] = m[3] - m[2];
-       r_view.frustum[4].normal[1] = m[7] - m[6];
-       r_view.frustum[4].normal[2] = m[11] - m[10];
-       r_view.frustum[4].dist = m[15] - m[14];
-
-       r_view.frustum[5].normal[0] = m[3] + m[2];
-       r_view.frustum[5].normal[1] = m[7] + m[6];
-       r_view.frustum[5].normal[2] = m[11] + m[10];
-       r_view.frustum[5].dist = m[15] + m[14];
+       r_refdef.view.frustum[0].normal[0] = m[3] - m[0];
+       r_refdef.view.frustum[0].normal[1] = m[7] - m[4];
+       r_refdef.view.frustum[0].normal[2] = m[11] - m[8];
+       r_refdef.view.frustum[0].dist = m[15] - m[12];
+
+       r_refdef.view.frustum[1].normal[0] = m[3] + m[0];
+       r_refdef.view.frustum[1].normal[1] = m[7] + m[4];
+       r_refdef.view.frustum[1].normal[2] = m[11] + m[8];
+       r_refdef.view.frustum[1].dist = m[15] + m[12];
+
+       r_refdef.view.frustum[2].normal[0] = m[3] - m[1];
+       r_refdef.view.frustum[2].normal[1] = m[7] - m[5];
+       r_refdef.view.frustum[2].normal[2] = m[11] - m[9];
+       r_refdef.view.frustum[2].dist = m[15] - m[13];
+
+       r_refdef.view.frustum[3].normal[0] = m[3] + m[1];
+       r_refdef.view.frustum[3].normal[1] = m[7] + m[5];
+       r_refdef.view.frustum[3].normal[2] = m[11] + m[9];
+       r_refdef.view.frustum[3].dist = m[15] + m[13];
+
+       r_refdef.view.frustum[4].normal[0] = m[3] - m[2];
+       r_refdef.view.frustum[4].normal[1] = m[7] - m[6];
+       r_refdef.view.frustum[4].normal[2] = m[11] - m[10];
+       r_refdef.view.frustum[4].dist = m[15] - m[14];
+
+       r_refdef.view.frustum[5].normal[0] = m[3] + m[2];
+       r_refdef.view.frustum[5].normal[1] = m[7] + m[6];
+       r_refdef.view.frustum[5].normal[2] = m[11] + m[10];
+       r_refdef.view.frustum[5].dist = m[15] + m[14];
 #endif
 
-       if (scene->view.useperspective)
+       if (r_refdef.view.useperspective)
        {
-               slopex = 1.0 / scene->view.frustum_x;
-               slopey = 1.0 / scene->view.frustum_y;
-               VectorMA(scene->view.forward, -slopex, scene->view.left, scene->view.frustum[0].normal);
-               VectorMA(scene->view.forward,  slopex, scene->view.left, scene->view.frustum[1].normal);
-               VectorMA(scene->view.forward, -slopey, scene->view.up  , scene->view.frustum[2].normal);
-               VectorMA(scene->view.forward,  slopey, scene->view.up  , scene->view.frustum[3].normal);
-               VectorCopy(scene->view.forward, scene->view.frustum[4].normal);
+               slopex = 1.0 / r_refdef.view.frustum_x;
+               slopey = 1.0 / r_refdef.view.frustum_y;
+               VectorMA(r_refdef.view.forward, -slopex, r_refdef.view.left, r_refdef.view.frustum[0].normal);
+               VectorMA(r_refdef.view.forward,  slopex, r_refdef.view.left, r_refdef.view.frustum[1].normal);
+               VectorMA(r_refdef.view.forward, -slopey, r_refdef.view.up  , r_refdef.view.frustum[2].normal);
+               VectorMA(r_refdef.view.forward,  slopey, r_refdef.view.up  , r_refdef.view.frustum[3].normal);
+               VectorCopy(r_refdef.view.forward, r_refdef.view.frustum[4].normal);
 
                // Leaving those out was a mistake, those were in the old code, and they
                // fix a reproducable bug in this one: frustum culling got fucked up when viewmatrix was an identity matrix
                // I couldn't reproduce it after adding those normalizations. --blub
-               VectorNormalize(scene->view.frustum[0].normal);
-               VectorNormalize(scene->view.frustum[1].normal);
-               VectorNormalize(scene->view.frustum[2].normal);
-               VectorNormalize(scene->view.frustum[3].normal);
+               VectorNormalize(r_refdef.view.frustum[0].normal);
+               VectorNormalize(r_refdef.view.frustum[1].normal);
+               VectorNormalize(r_refdef.view.frustum[2].normal);
+               VectorNormalize(r_refdef.view.frustum[3].normal);
 
                // calculate frustum corners, which are used to calculate deformed frustum planes for shadow caster culling
-               VectorMAMAMAM(1, scene->view.origin, 1024, scene->view.forward, -1024 * slopex, scene->view.left, -1024 * slopey, scene->view.up, scene->view.frustumcorner[0]);
-               VectorMAMAMAM(1, scene->view.origin, 1024, scene->view.forward,  1024 * slopex, scene->view.left, -1024 * slopey, scene->view.up, scene->view.frustumcorner[1]);
-               VectorMAMAMAM(1, scene->view.origin, 1024, scene->view.forward, -1024 * slopex, scene->view.left,  1024 * slopey, scene->view.up, scene->view.frustumcorner[2]);
-               VectorMAMAMAM(1, scene->view.origin, 1024, scene->view.forward,  1024 * slopex, scene->view.left,  1024 * slopey, scene->view.up, scene->view.frustumcorner[3]);
+               VectorMAMAMAM(1, r_refdef.view.origin, 1024, r_refdef.view.forward, -1024 * slopex, r_refdef.view.left, -1024 * slopey, r_refdef.view.up, r_refdef.view.frustumcorner[0]);
+               VectorMAMAMAM(1, r_refdef.view.origin, 1024, r_refdef.view.forward,  1024 * slopex, r_refdef.view.left, -1024 * slopey, r_refdef.view.up, r_refdef.view.frustumcorner[1]);
+               VectorMAMAMAM(1, r_refdef.view.origin, 1024, r_refdef.view.forward, -1024 * slopex, r_refdef.view.left,  1024 * slopey, r_refdef.view.up, r_refdef.view.frustumcorner[2]);
+               VectorMAMAMAM(1, r_refdef.view.origin, 1024, r_refdef.view.forward,  1024 * slopex, r_refdef.view.left,  1024 * slopey, r_refdef.view.up, r_refdef.view.frustumcorner[3]);
 
-               scene->view.frustum[0].dist = DotProduct (scene->view.origin, scene->view.frustum[0].normal);
-               scene->view.frustum[1].dist = DotProduct (scene->view.origin, scene->view.frustum[1].normal);
-               scene->view.frustum[2].dist = DotProduct (scene->view.origin, scene->view.frustum[2].normal);
-               scene->view.frustum[3].dist = DotProduct (scene->view.origin, scene->view.frustum[3].normal);
-               scene->view.frustum[4].dist = DotProduct (scene->view.origin, scene->view.frustum[4].normal) + scene->refdef.nearclip;
+               r_refdef.view.frustum[0].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[0].normal);
+               r_refdef.view.frustum[1].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[1].normal);
+               r_refdef.view.frustum[2].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[2].normal);
+               r_refdef.view.frustum[3].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[3].normal);
+               r_refdef.view.frustum[4].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[4].normal) + r_refdef.nearclip;
        }
        else
        {
-               VectorScale(scene->view.left, -scene->view.ortho_x, scene->view.frustum[0].normal);
-               VectorScale(scene->view.left,  scene->view.ortho_x, scene->view.frustum[1].normal);
-               VectorScale(scene->view.up, -scene->view.ortho_y, scene->view.frustum[2].normal);
-               VectorScale(scene->view.up,  scene->view.ortho_y, scene->view.frustum[3].normal);
-               VectorCopy(scene->view.forward, scene->view.frustum[4].normal);
-               scene->view.frustum[0].dist = DotProduct (scene->view.origin, scene->view.frustum[0].normal) + scene->view.ortho_x;
-               scene->view.frustum[1].dist = DotProduct (scene->view.origin, scene->view.frustum[1].normal) + scene->view.ortho_x;
-               scene->view.frustum[2].dist = DotProduct (scene->view.origin, scene->view.frustum[2].normal) + scene->view.ortho_y;
-               scene->view.frustum[3].dist = DotProduct (scene->view.origin, scene->view.frustum[3].normal) + scene->view.ortho_y;
-               scene->view.frustum[4].dist = DotProduct (scene->view.origin, scene->view.frustum[4].normal) + r_refdef.nearclip;
+               VectorScale(r_refdef.view.left, -r_refdef.view.ortho_x, r_refdef.view.frustum[0].normal);
+               VectorScale(r_refdef.view.left,  r_refdef.view.ortho_x, r_refdef.view.frustum[1].normal);
+               VectorScale(r_refdef.view.up, -r_refdef.view.ortho_y, r_refdef.view.frustum[2].normal);
+               VectorScale(r_refdef.view.up,  r_refdef.view.ortho_y, r_refdef.view.frustum[3].normal);
+               VectorCopy(r_refdef.view.forward, r_refdef.view.frustum[4].normal);
+               r_refdef.view.frustum[0].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[0].normal) + r_refdef.view.ortho_x;
+               r_refdef.view.frustum[1].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[1].normal) + r_refdef.view.ortho_x;
+               r_refdef.view.frustum[2].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[2].normal) + r_refdef.view.ortho_y;
+               r_refdef.view.frustum[3].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[3].normal) + r_refdef.view.ortho_y;
+               r_refdef.view.frustum[4].dist = DotProduct (r_refdef.view.origin, r_refdef.view.frustum[4].normal) + r_refdef.nearclip;
        }
-       scene->view.numfrustumplanes = 5;
+       r_refdef.view.numfrustumplanes = 5;
 
-       if (scene->view.useclipplane)
+       if (r_refdef.view.useclipplane)
        {
-               scene->view.numfrustumplanes = 6;
-               scene->view.frustum[5] = scene->view.clipplane;
+               r_refdef.view.numfrustumplanes = 6;
+               r_refdef.view.frustum[5] = r_refdef.view.clipplane;
        }
 
-       for (i = 0;i < scene->view.numfrustumplanes;i++)
-               PlaneClassify(scene->view.frustum + i);
+       for (i = 0;i < r_refdef.view.numfrustumplanes;i++)
+               PlaneClassify(r_refdef.view.frustum + i);
 
        // LordHavoc: note to all quake engine coders, Quake had a special case
        // for 90 degrees which assumed a square view (wrong), so I removed it,
        // Quake2 has it disabled as well.
 
        // rotate R_VIEWFORWARD right by FOV_X/2 degrees
-       //RotatePointAroundVector( r_view.frustum[0].normal, r_view.up, r_view.forward, -(90 - r_refdef.fov_x / 2));
-       //r_view.frustum[0].dist = DotProduct (r_view.origin, frustum[0].normal);
+       //RotatePointAroundVector( r_refdef.view.frustum[0].normal, r_refdef.view.up, r_refdef.view.forward, -(90 - r_refdef.fov_x / 2));
+       //r_refdef.view.frustum[0].dist = DotProduct (r_refdef.view.origin, frustum[0].normal);
        //PlaneClassify(&frustum[0]);
 
        // rotate R_VIEWFORWARD left by FOV_X/2 degrees
-       //RotatePointAroundVector( r_view.frustum[1].normal, r_view.up, r_view.forward, (90 - r_refdef.fov_x / 2));
-       //r_view.frustum[1].dist = DotProduct (r_view.origin, frustum[1].normal);
+       //RotatePointAroundVector( r_refdef.view.frustum[1].normal, r_refdef.view.up, r_refdef.view.forward, (90 - r_refdef.fov_x / 2));
+       //r_refdef.view.frustum[1].dist = DotProduct (r_refdef.view.origin, frustum[1].normal);
        //PlaneClassify(&frustum[1]);
 
        // rotate R_VIEWFORWARD up by FOV_X/2 degrees
-       //RotatePointAroundVector( r_view.frustum[2].normal, r_view.left, r_view.forward, -(90 - r_refdef.fov_y / 2));
-       //r_view.frustum[2].dist = DotProduct (r_view.origin, frustum[2].normal);
+       //RotatePointAroundVector( r_refdef.view.frustum[2].normal, r_refdef.view.left, r_refdef.view.forward, -(90 - r_refdef.fov_y / 2));
+       //r_refdef.view.frustum[2].dist = DotProduct (r_refdef.view.origin, frustum[2].normal);
        //PlaneClassify(&frustum[2]);
 
        // rotate R_VIEWFORWARD down by FOV_X/2 degrees
-       //RotatePointAroundVector( r_view.frustum[3].normal, r_view.left, r_view.forward, (90 - r_refdef.fov_y / 2));
-       //r_view.frustum[3].dist = DotProduct (r_view.origin, frustum[3].normal);
+       //RotatePointAroundVector( r_refdef.view.frustum[3].normal, r_refdef.view.left, r_refdef.view.forward, (90 - r_refdef.fov_y / 2));
+       //r_refdef.view.frustum[3].dist = DotProduct (r_refdef.view.origin, frustum[3].normal);
        //PlaneClassify(&frustum[3]);
 
        // nearclip plane
-       //VectorCopy(r_view.forward, r_view.frustum[4].normal);
-       //r_view.frustum[4].dist = DotProduct (r_view.origin, frustum[4].normal) + r_nearclip.value;
+       //VectorCopy(r_refdef.view.forward, r_refdef.view.frustum[4].normal);
+       //r_refdef.view.frustum[4].dist = DotProduct (r_refdef.view.origin, frustum[4].normal) + r_nearclip.value;
        //PlaneClassify(&frustum[4]);
 }
 
-void R_View_Update(renderscene_t* scene)
+void R_View_Update(void)
 {
-       R_View_SetFrustum(scene);
-       R_View_WorldVisibility(scene->view.useclipplane);
-       R_View_UpdateEntityVisible(scene);
+       R_View_SetFrustum();
+       R_View_WorldVisibility(r_refdef.view.useclipplane);
+       R_View_UpdateEntityVisible();
 }
 
-void R_SetupView(renderscene_t* scene)
+void R_SetupView(void)
 {
-       if (!scene->view.useperspective)
-               GL_SetupView_Mode_Ortho(-scene->view.ortho_x, -scene->view.ortho_y, scene->view.ortho_x, scene->view.ortho_y, -scene->refdef.farclip, scene->refdef.farclip);
-       else if (scene->refdef.rtworldshadows || scene->refdef.rtdlightshadows)
-               GL_SetupView_Mode_PerspectiveInfiniteFarClip(scene->view.frustum_x, scene->view.frustum_y, scene->refdef.nearclip);
+       if (!r_refdef.view.useperspective)
+               GL_SetupView_Mode_Ortho(-r_refdef.view.ortho_x, -r_refdef.view.ortho_y, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip);
+       else if (r_refdef.rtworldshadows || r_refdef.rtdlightshadows)
+               GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip);
        else
-               GL_SetupView_Mode_Perspective(scene->view.frustum_x, scene->view.frustum_y, scene->refdef.nearclip, scene->refdef.farclip);
+               GL_SetupView_Mode_Perspective(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip);
 
-       GL_SetupView_Orientation_FromEntity(&scene->view.matrix);
+       GL_SetupView_Orientation_FromEntity(&r_refdef.view.matrix);
 
-       if (scene->view.useclipplane)
+       if (r_refdef.view.useclipplane)
        {
                // LordHavoc: couldn't figure out how to make this approach the
-               vec_t dist = scene->view.clipplane.dist - r_water_clippingplanebias.value;
-               vec_t viewdist = DotProduct(scene->view.origin, scene->view.clipplane.normal);
-               if (viewdist < scene->view.clipplane.dist + r_water_clippingplanebias.value)
-                       dist = scene->view.clipplane.dist;
-               GL_SetupView_ApplyCustomNearClipPlane(scene->view.clipplane.normal[0], scene->view.clipplane.normal[1], scene->view.clipplane.normal[2], dist);
+               vec_t dist = r_refdef.view.clipplane.dist - r_water_clippingplanebias.value;
+               vec_t viewdist = DotProduct(r_refdef.view.origin, r_refdef.view.clipplane.normal);
+               if (viewdist < r_refdef.view.clipplane.dist + r_water_clippingplanebias.value)
+                       dist = r_refdef.view.clipplane.dist;
+               GL_SetupView_ApplyCustomNearClipPlane(r_refdef.view.clipplane.normal[0], r_refdef.view.clipplane.normal[1], r_refdef.view.clipplane.normal[2], dist);
        }
 }
 
@@ -2527,12 +2530,12 @@ void R_ResetViewRendering2D(void)
 
        DrawQ_Finish();
 
-       // GL is weird because it's bottom to top, r_view.y is top to bottom
-       qglViewport(r_view.x, vid.height - (r_view.y + r_view.height), r_view.width, r_view.height);CHECKGLERROR
+       // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom
+       qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
        GL_SetupView_Mode_Ortho(0, 0, 1, 1, -10, 100);
-       GL_Scissor(r_view.x, r_view.y, r_view.width, r_view.height);
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
        GL_Color(1, 1, 1, 1);
-       GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 1);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_AlphaTest(false);
        GL_ScissorTest(false);
@@ -2551,7 +2554,7 @@ void R_ResetViewRendering2D(void)
        GL_CullFace(GL_FRONT); // quake is backwards, this culls back faces
 }
 
-void R_ResetViewRendering3D(renderscene_t* scene)
+void R_ResetViewRendering3D(void)
 {
        if (gl_support_fragment_shader)
        {
@@ -2560,12 +2563,12 @@ void R_ResetViewRendering3D(renderscene_t* scene)
 
        DrawQ_Finish();
 
-       // GL is weird because it's bottom to top, r_view.y is top to bottom
-       qglViewport(scene->view.x, vid.height - (scene->view.y + scene->view.height), scene->view.width, scene->view.height);CHECKGLERROR
-       R_SetupView(scene);
-       GL_Scissor(scene->view.x, scene->view.y, scene->view.width, scene->view.height);
+       // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom
+       qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
+       R_SetupView();
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
        GL_Color(1, 1, 1, 1);
-       GL_ColorMask(scene->view.colormask[0], scene->view.colormask[1], scene->view.colormask[2], 1);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_AlphaTest(false);
        GL_ScissorTest(true);
@@ -2574,14 +2577,14 @@ void R_ResetViewRendering3D(renderscene_t* scene)
        GL_DepthTest(true);
        R_Mesh_Matrix(&identitymatrix);
        R_Mesh_ResetTextureState();
-       GL_PolygonOffset(scene->refdef.polygonfactor, scene->refdef.polygonoffset);
+       GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
        qglEnable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
        qglDepthFunc(GL_LEQUAL);CHECKGLERROR
        qglDisable(GL_STENCIL_TEST);CHECKGLERROR
        qglStencilMask(~0);CHECKGLERROR
        qglStencilFunc(GL_ALWAYS, 128, ~0);CHECKGLERROR
        qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);CHECKGLERROR
-       GL_CullFace(scene->view.cullface_back);
+       GL_CullFace(r_refdef.view.cullface_back);
 }
 
 /*
@@ -2645,7 +2648,7 @@ void R_ResetViewRendering3D(renderscene_t* scene)
 "#endif // FRAGMENT_SHADER\n"
 */
 
-void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes);
+void R_RenderScene(qboolean addwaterplanes);
 
 static void R_Water_StartFrame(void)
 {
@@ -2655,8 +2658,8 @@ static void R_Water_StartFrame(void)
 
        // set waterwidth and waterheight to the water resolution that will be
        // used (often less than the screen resolution for faster rendering)
-       waterwidth = (int)bound(1, r_view.width * r_water_resolutionmultiplier.value, r_view.width);
-       waterheight = (int)bound(1, r_view.height * r_water_resolutionmultiplier.value, r_view.height);
+       waterwidth = (int)bound(1, r_refdef.view.width * r_water_resolutionmultiplier.value, r_refdef.view.width);
+       waterheight = (int)bound(1, r_refdef.view.height * r_water_resolutionmultiplier.value, r_refdef.view.height);
 
        // calculate desired texture sizes
        // can't use water if the card does not support the texture size
@@ -2745,7 +2748,7 @@ static void R_Water_AddWaterPlane(msurface_t *surface)
                p->plane.dist = DotProduct(vert[0], p->plane.normal);
                PlaneClassify(&p->plane);
                // flip the plane if it does not face the viewer
-               if (PlaneDiff(r_view.origin, &p->plane) < 0)
+               if (PlaneDiff(r_refdef.view.origin, &p->plane) < 0)
                {
                        VectorNegate(p->plane.normal, p->plane.normal);
                        p->plane.dist *= -1;
@@ -2767,13 +2770,13 @@ static void R_Water_AddWaterPlane(msurface_t *surface)
        }
 }
 
-static void R_Water_ProcessPlanes(renderscene_t* scene)
+static void R_Water_ProcessPlanes(void)
 {
-       r_view_t originalview;
+       r_refdef_view_t originalview;
        int planeindex;
        r_waterstate_waterplane_t *p;
 
-       originalview = scene->view;
+       originalview = r_refdef.view;
 
        // make sure enough textures are allocated
        for (planeindex = 0, p = r_waterstate.waterplanes;planeindex < r_waterstate.numwaterplanes;planeindex++, p++)
@@ -2798,72 +2801,72 @@ static void R_Water_ProcessPlanes(renderscene_t* scene)
        // render views
        for (planeindex = 0, p = r_waterstate.waterplanes;planeindex < r_waterstate.numwaterplanes;planeindex++, p++)
        {
-               scene->view.showdebug = false;
-               scene->view.width = r_waterstate.waterwidth;
-               scene->view.height = r_waterstate.waterheight;
-               scene->view.useclipplane = true;
+               r_refdef.view.showdebug = false;
+               r_refdef.view.width = r_waterstate.waterwidth;
+               r_refdef.view.height = r_waterstate.waterheight;
+               r_refdef.view.useclipplane = true;
                r_waterstate.renderingscene = true;
 
                // render the normal view scene and copy into texture
                // (except that a clipping plane should be used to hide everything on one side of the water, and the viewer's weapon model should be omitted)
                if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION))
                {
-                       scene->view.clipplane = p->plane;
-                       VectorNegate(scene->view.clipplane.normal, scene->view.clipplane.normal);
-                       scene->view.clipplane.dist = -scene->view.clipplane.dist;
-                       PlaneClassify(&scene->view.clipplane);
+                       r_refdef.view.clipplane = p->plane;
+                       VectorNegate(r_refdef.view.clipplane.normal, r_refdef.view.clipplane.normal);
+                       r_refdef.view.clipplane.dist = -r_refdef.view.clipplane.dist;
+                       PlaneClassify(&r_refdef.view.clipplane);
 
-                       R_RenderScene(scene, false);
+                       R_RenderScene(false);
 
                        // copy view into the screen texture
                        R_Mesh_TexBind(0, R_GetTexture(p->texture_refraction));
                        GL_ActiveTexture(0);
                        CHECKGLERROR
-                       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, scene->view.x, vid.height - (scene->view.y + scene->view.height), scene->view.width, scene->view.height);CHECKGLERROR
+                       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
                }
 
                if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFLECTION))
                {
                        // render reflected scene and copy into texture
-                       Matrix4x4_Reflect(&scene->view.matrix, p->plane.normal[0], p->plane.normal[1], p->plane.normal[2], p->plane.dist, -2);
-                       scene->view.clipplane = p->plane;
+                       Matrix4x4_Reflect(&r_refdef.view.matrix, p->plane.normal[0], p->plane.normal[1], p->plane.normal[2], p->plane.dist, -2);
+                       r_refdef.view.clipplane = p->plane;
                        // reverse the cullface settings for this render
-                       scene->view.cullface_front = GL_FRONT;
-                       scene->view.cullface_back = GL_BACK;
-                       if (scene->refdef.worldmodel && scene->refdef.worldmodel->brush.num_pvsclusterbytes)
+                       r_refdef.view.cullface_front = GL_FRONT;
+                       r_refdef.view.cullface_back = GL_BACK;
+                       if (r_refdef.worldmodel && r_refdef.worldmodel->brush.num_pvsclusterbytes)
                        {
-                               scene->view.usecustompvs = true;
+                               r_refdef.view.usecustompvs = true;
                                if (p->pvsvalid)
-                                       memcpy(scene->viewcache.world_pvsbits, p->pvsbits, scene->refdef.worldmodel->brush.num_pvsclusterbytes);
+                                       memcpy(r_refdef.viewcache.world_pvsbits, p->pvsbits, r_refdef.worldmodel->brush.num_pvsclusterbytes);
                                else
-                                       memset(scene->viewcache.world_pvsbits, 0xFF, scene->refdef.worldmodel->brush.num_pvsclusterbytes);
+                                       memset(r_refdef.viewcache.world_pvsbits, 0xFF, r_refdef.worldmodel->brush.num_pvsclusterbytes);
                        }
 
-                       R_ResetViewRendering3D(scene);
+                       R_ResetViewRendering3D();
                        R_ClearScreen(r_refdef.fogenabled);
                        if (r_timereport_active)
                                R_TimeReport("viewclear");
 
-                       R_RenderScene(scene, false);
+                       R_RenderScene(false);
 
                        R_Mesh_TexBind(0, R_GetTexture(p->texture_reflection));
                        GL_ActiveTexture(0);
                        CHECKGLERROR
-                       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, scene->view.x, vid.height - (scene->view.y + scene->view.height), scene->view.width, scene->view.height);CHECKGLERROR
+                       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
 
-                       R_ResetViewRendering3D(scene);
+                       R_ResetViewRendering3D();
                        R_ClearScreen(r_refdef.fogenabled);
                        if (r_timereport_active)
                                R_TimeReport("viewclear");
                }
 
-               scene->view = originalview;
-               scene->view.clear = true;
+               r_refdef.view = originalview;
+               r_refdef.view.clear = true;
                r_waterstate.renderingscene = false;
        }
        return;
 error:
-       scene->view = originalview;
+       r_refdef.view = originalview;
        r_waterstate.renderingscene = false;
        Cvar_SetValueQuick(&r_water, 0);
        Con_Printf("R_Water_ProcessPlanes: Error: texture creation failed!  Turned off r_water.\n");
@@ -2876,15 +2879,15 @@ void R_Bloom_StartFrame(void)
 
        // set bloomwidth and bloomheight to the bloom resolution that will be
        // used (often less than the screen resolution for faster rendering)
-       r_bloomstate.bloomwidth = bound(1, r_bloom_resolution.integer, r_view.width);
-       r_bloomstate.bloomheight = r_bloomstate.bloomwidth * r_view.height / r_view.width;
-       r_bloomstate.bloomheight = bound(1, r_bloomstate.bloomheight, r_view.height);
+       r_bloomstate.bloomwidth = bound(1, r_bloom_resolution.integer, r_refdef.view.width);
+       r_bloomstate.bloomheight = r_bloomstate.bloomwidth * r_refdef.view.height / r_refdef.view.width;
+       r_bloomstate.bloomheight = bound(1, r_bloomstate.bloomheight, r_refdef.view.height);
 
        // calculate desired texture sizes
        if (gl_support_arb_texture_non_power_of_two)
        {
-               screentexturewidth = r_view.width;
-               screentextureheight = r_view.height;
+               screentexturewidth = r_refdef.view.width;
+               screentextureheight = r_refdef.view.height;
                bloomtexturewidth = r_bloomstate.bloomwidth;
                bloomtextureheight = r_bloomstate.bloomheight;
        }
@@ -2949,10 +2952,10 @@ void R_Bloom_StartFrame(void)
        // set up a texcoord array for the full resolution screen image
        // (we have to keep this around to copy back during final render)
        r_bloomstate.screentexcoord2f[0] = 0;
-       r_bloomstate.screentexcoord2f[1] = (float)r_view.height / (float)r_bloomstate.screentextureheight;
-       r_bloomstate.screentexcoord2f[2] = (float)r_view.width / (float)r_bloomstate.screentexturewidth;
-       r_bloomstate.screentexcoord2f[3] = (float)r_view.height / (float)r_bloomstate.screentextureheight;
-       r_bloomstate.screentexcoord2f[4] = (float)r_view.width / (float)r_bloomstate.screentexturewidth;
+       r_bloomstate.screentexcoord2f[1] = (float)r_refdef.view.height / (float)r_bloomstate.screentextureheight;
+       r_bloomstate.screentexcoord2f[2] = (float)r_refdef.view.width / (float)r_bloomstate.screentexturewidth;
+       r_bloomstate.screentexcoord2f[3] = (float)r_refdef.view.height / (float)r_bloomstate.screentextureheight;
+       r_bloomstate.screentexcoord2f[4] = (float)r_refdef.view.width / (float)r_bloomstate.screentexturewidth;
        r_bloomstate.screentexcoord2f[5] = 0;
        r_bloomstate.screentexcoord2f[6] = 0;
        r_bloomstate.screentexcoord2f[7] = 0;
@@ -2982,12 +2985,12 @@ void R_Bloom_CopyScreenTexture(float colorscale)
        // copy view into the screen texture
        GL_ActiveTexture(0);
        CHECKGLERROR
-       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_view.height), r_view.width, r_view.height);CHECKGLERROR
-       r_refdef.stats.bloom_copypixels += r_view.width * r_view.height;
+       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
+       r_refdef.stats.bloom_copypixels += r_refdef.view.width * r_refdef.view.height;
 
        // now scale it down to the bloom texture size
        CHECKGLERROR
-       qglViewport(r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+       qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_Color(colorscale, colorscale, colorscale, 1);
        // TODO: optimize with multitexture or GLSL
@@ -2999,7 +3002,7 @@ void R_Bloom_CopyScreenTexture(float colorscale)
        R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
        GL_ActiveTexture(0);
        CHECKGLERROR
-       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
        r_refdef.stats.bloom_copypixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
 }
 
@@ -3008,8 +3011,8 @@ void R_Bloom_CopyHDRTexture(void)
        R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
        GL_ActiveTexture(0);
        CHECKGLERROR
-       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_view.height), r_view.width, r_view.height);CHECKGLERROR
-       r_refdef.stats.bloom_copypixels += r_view.width * r_view.height;
+       qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
+       r_refdef.stats.bloom_copypixels += r_refdef.view.width * r_refdef.view.height;
 }
 
 void R_Bloom_MakeTexture(void)
@@ -3025,7 +3028,7 @@ void R_Bloom_MakeTexture(void)
 
        // we have a bloom image in the framebuffer
        CHECKGLERROR
-       qglViewport(r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+       qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
 
        for (x = 1;x < min(r_bloom_colorexponent.value, 32);)
        {
@@ -3041,7 +3044,7 @@ void R_Bloom_MakeTexture(void)
                // copy the vertically blurred bloom view to a texture
                GL_ActiveTexture(0);
                CHECKGLERROR
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
                r_refdef.stats.bloom_copypixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
        }
 
@@ -3087,7 +3090,7 @@ void R_Bloom_MakeTexture(void)
                // copy the vertically blurred bloom view to a texture
                GL_ActiveTexture(0);
                CHECKGLERROR
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
                r_refdef.stats.bloom_copypixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
        }
 
@@ -3115,36 +3118,36 @@ void R_Bloom_MakeTexture(void)
                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
                GL_ActiveTexture(0);
                CHECKGLERROR
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view.x, vid.height - (r_view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_bloomstate.bloomheight), r_bloomstate.bloomwidth, r_bloomstate.bloomheight);CHECKGLERROR
                r_refdef.stats.bloom_copypixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
        }
 }
 
-void R_HDR_RenderBloomTexture(renderscene_t* scene)
+void R_HDR_RenderBloomTexture(void)
 {
        int oldwidth, oldheight;
        float oldcolorscale;
 
-       oldcolorscale = scene->view.colorscale;
-       oldwidth = scene->view.width;
-       oldheight = scene->view.height;
-       scene->view.width = r_bloomstate.bloomwidth;
-       scene->view.height = r_bloomstate.bloomheight;
+       oldcolorscale = r_refdef.view.colorscale;
+       oldwidth = r_refdef.view.width;
+       oldheight = r_refdef.view.height;
+       r_refdef.view.width = r_bloomstate.bloomwidth;
+       r_refdef.view.height = r_bloomstate.bloomheight;
 
        // TODO: support GL_EXT_framebuffer_object rather than reusing the framebuffer?  it might improve SLI performance.
        // TODO: add exposure compensation features
        // TODO: add fp16 framebuffer support
 
-       scene->view.showdebug = false;
-       scene->view.colorscale *= r_bloom_colorscale.value / bound(1, r_hdr_range.value, 16);
+       r_refdef.view.showdebug = false;
+       r_refdef.view.colorscale *= r_bloom_colorscale.value / bound(1, r_hdr_range.value, 16);
 
        R_ClearScreen(r_refdef.fogenabled);
        if (r_timereport_active)
                R_TimeReport("HDRclear");
 
        r_waterstate.numwaterplanes = 0;
-       R_RenderScene(scene, r_waterstate.enabled);
-       scene->view.showdebug = true;
+       R_RenderScene(r_waterstate.enabled);
+       r_refdef.view.showdebug = true;
 
        R_ResetViewRendering2D();
 
@@ -3152,11 +3155,11 @@ void R_HDR_RenderBloomTexture(renderscene_t* scene)
        R_Bloom_MakeTexture();
 
        // restore the view settings
-       scene->view.width = oldwidth;
-       scene->view.height = oldheight;
-       scene->view.colorscale = oldcolorscale;
+       r_refdef.view.width = oldwidth;
+       r_refdef.view.height = oldheight;
+       r_refdef.view.colorscale = oldcolorscale;
 
-       R_ResetViewRendering3D(scene);
+       R_ResetViewRendering3D();
 
        R_ClearScreen(r_refdef.fogenabled);
        if (r_timereport_active)
@@ -3178,7 +3181,7 @@ static void R_BlendView(void)
                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
                R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
-               r_refdef.stats.bloom_drawpixels += r_view.width * r_view.height;
+               r_refdef.stats.bloom_drawpixels += r_refdef.view.width * r_refdef.view.height;
        }
        else if (r_bloomstate.enabled)
        {
@@ -3206,14 +3209,14 @@ static void R_BlendView(void)
                else
                {
                        R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
-                       r_refdef.stats.bloom_drawpixels += r_view.width * r_view.height;
+                       r_refdef.stats.bloom_drawpixels += r_refdef.view.width * r_refdef.view.height;
                        // now blend on the bloom texture
                        GL_BlendFunc(GL_ONE, GL_ONE);
                        R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
                        R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
                }
                R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
-               r_refdef.stats.bloom_drawpixels += r_view.width * r_view.height;
+               r_refdef.stats.bloom_drawpixels += r_refdef.view.width * r_refdef.view.height;
        }
        if (r_refdef.viewblend[3] >= (1.0f / 256.0f))
        {
@@ -3227,6 +3230,8 @@ static void R_BlendView(void)
        }
 }
 
+void R_RenderScene(qboolean addwaterplanes);
+
 matrix4x4_t r_waterscrollmatrix;
 
 void R_UpdateFogColor(void) // needs to be called before HDR subrender too, as that changes colorscale!
@@ -3248,7 +3253,7 @@ void R_UpdateFogColor(void) // needs to be called before HDR subrender too, as t
                                fogvec[2] *= r_glsl_contrastboost.value / ((r_glsl_contrastboost.value - 1) * fogvec[2] + 1);
                        }
                        //   color.rgb *= ContrastBoost * SceneBrightness;
-                       VectorScale(fogvec, r_view.colorscale, fogvec);
+                       VectorScale(fogvec, r_refdef.view.colorscale, fogvec);
                        r_refdef.fogcolor[0] = bound(0.0f, fogvec[0], 1.0f);
                        r_refdef.fogcolor[1] = bound(0.0f, fogvec[1], 1.0f);
                        r_refdef.fogcolor[2] = bound(0.0f, fogvec[2], 1.0f);
@@ -3256,88 +3261,88 @@ void R_UpdateFogColor(void) // needs to be called before HDR subrender too, as t
        }
 }
 
-void R_UpdateVariables(renderscene_t* scene)
+void R_UpdateVariables(void)
 {
        R_Textures_Frame();
 
-       scene->refdef.farclip = 4096;
-       if (scene->refdef.worldmodel)
-               scene->refdef.farclip += VectorDistance(scene->refdef.worldmodel->normalmins, scene->refdef.worldmodel->normalmaxs);
-       scene->refdef.nearclip = bound (0.001f, r_nearclip.value, scene->refdef.farclip - 1.0f);
+       r_refdef.farclip = 4096;
+       if (r_refdef.worldmodel)
+               r_refdef.farclip += VectorDistance(r_refdef.worldmodel->normalmins, r_refdef.worldmodel->normalmaxs);
+       r_refdef.nearclip = bound (0.001f, r_nearclip.value, r_refdef.farclip - 1.0f);
 
        if (r_shadow_frontsidecasting.integer < 0 || r_shadow_frontsidecasting.integer > 1)
                Cvar_SetValueQuick(&r_shadow_frontsidecasting, 1);
-       scene->refdef.polygonfactor = 0;
-       scene->refdef.polygonoffset = 0;
-       scene->refdef.shadowpolygonfactor = scene->refdef.polygonfactor + r_shadow_polygonfactor.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
-       scene->refdef.shadowpolygonoffset = scene->refdef.polygonoffset + r_shadow_polygonoffset.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
-
-       scene->refdef.rtworld = r_shadow_realtime_world.integer;
-       scene->refdef.rtworldshadows = r_shadow_realtime_world_shadows.integer && gl_stencil;
-       scene->refdef.rtdlight = (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && !gl_flashblend.integer && r_dynamic.integer;
-       scene->refdef.rtdlightshadows = r_refdef.rtdlight && r_shadow_realtime_dlight_shadows.integer && gl_stencil;
-       scene->refdef.lightmapintensity = r_refdef.rtworld ? r_shadow_realtime_world_lightmaps.value : 1;
+       r_refdef.polygonfactor = 0;
+       r_refdef.polygonoffset = 0;
+       r_refdef.shadowpolygonfactor = r_refdef.polygonfactor + r_shadow_polygonfactor.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
+       r_refdef.shadowpolygonoffset = r_refdef.polygonoffset + r_shadow_polygonoffset.value * (r_shadow_frontsidecasting.integer ? 1 : -1);
+
+       r_refdef.rtworld = r_shadow_realtime_world.integer;
+       r_refdef.rtworldshadows = r_shadow_realtime_world_shadows.integer && gl_stencil;
+       r_refdef.rtdlight = (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && !gl_flashblend.integer && r_dynamic.integer;
+       r_refdef.rtdlightshadows = r_refdef.rtdlight && r_shadow_realtime_dlight_shadows.integer && gl_stencil;
+       r_refdef.lightmapintensity = r_refdef.rtworld ? r_shadow_realtime_world_lightmaps.value : 1;
        if (r_showsurfaces.integer)
        {
-               scene->refdef.rtworld = false;
-               scene->refdef.rtworldshadows = false;
-               scene->refdef.rtdlight = false;
-               scene->refdef.rtdlightshadows = false;
-               scene->refdef.lightmapintensity = 0;
+               r_refdef.rtworld = false;
+               r_refdef.rtworldshadows = false;
+               r_refdef.rtdlight = false;
+               r_refdef.rtdlightshadows = false;
+               r_refdef.lightmapintensity = 0;
        }
 
        if (gamemode == GAME_NEHAHRA)
        {
                if (gl_fogenable.integer)
                {
-                       scene->refdef.oldgl_fogenable = true;
-                       scene->refdef.fog_density = gl_fogdensity.value;
-                       scene->refdef.fog_red = gl_fogred.value;
-                       scene->refdef.fog_green = gl_foggreen.value;
-                       scene->refdef.fog_blue = gl_fogblue.value;
-                       scene->refdef.fog_alpha = 1;
-                       scene->refdef.fog_start = 0;
-                       scene->refdef.fog_end = gl_skyclip.value;
+                       r_refdef.oldgl_fogenable = true;
+                       r_refdef.fog_density = gl_fogdensity.value;
+                       r_refdef.fog_red = gl_fogred.value;
+                       r_refdef.fog_green = gl_foggreen.value;
+                       r_refdef.fog_blue = gl_fogblue.value;
+                       r_refdef.fog_alpha = 1;
+                       r_refdef.fog_start = 0;
+                       r_refdef.fog_end = gl_skyclip.value;
                }
-               else if (scene->refdef.oldgl_fogenable)
+               else if (r_refdef.oldgl_fogenable)
                {
-                       scene->refdef.oldgl_fogenable = false;
-                       scene->refdef.fog_density = 0;
-                       scene->refdef.fog_red = 0;
-                       scene->refdef.fog_green = 0;
-                       scene->refdef.fog_blue = 0;
-                       scene->refdef.fog_alpha = 0;
-                       scene->refdef.fog_start = 0;
-                       scene->refdef.fog_end = 0;
+                       r_refdef.oldgl_fogenable = false;
+                       r_refdef.fog_density = 0;
+                       r_refdef.fog_red = 0;
+                       r_refdef.fog_green = 0;
+                       r_refdef.fog_blue = 0;
+                       r_refdef.fog_alpha = 0;
+                       r_refdef.fog_start = 0;
+                       r_refdef.fog_end = 0;
                }
        }
 
-       scene->refdef.fog_alpha = bound(0, scene->refdef.fog_alpha, 1);
-       scene->refdef.fog_start = max(0, scene->refdef.fog_start);
-       scene->refdef.fog_end = max(scene->refdef.fog_start + 0.01, scene->refdef.fog_end);
+       r_refdef.fog_alpha = bound(0, r_refdef.fog_alpha, 1);
+       r_refdef.fog_start = max(0, r_refdef.fog_start);
+       r_refdef.fog_end = max(r_refdef.fog_start + 0.01, r_refdef.fog_end);
 
        // R_UpdateFogColor(); // why? R_RenderScene does it anyway
 
-       if (scene->refdef.fog_density)
+       if (r_refdef.fog_density)
        {
-               scene->refdef.fogenabled = true;
+               r_refdef.fogenabled = true;
                // this is the point where the fog reaches 0.9986 alpha, which we
                // consider a good enough cutoff point for the texture
                // (0.9986 * 256 == 255.6)
                if (r_fog_exp2.integer)
-                       scene->refdef.fogrange = 32 / (scene->refdef.fog_density * scene->refdef.fog_density) + scene->refdef.fog_start;
+                       r_refdef.fogrange = 32 / (r_refdef.fog_density * r_refdef.fog_density) + r_refdef.fog_start;
                else
-                       scene->refdef.fogrange = 2048 / scene->refdef.fog_density + scene->refdef.fog_start;
-               scene->refdef.fogrange = bound(scene->refdef.fog_start, scene->refdef.fogrange, scene->refdef.fog_end);
-               scene->refdef.fograngerecip = 1.0f / scene->refdef.fogrange;
-               scene->refdef.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * scene->refdef.fograngerecip;
+                       r_refdef.fogrange = 2048 / r_refdef.fog_density + r_refdef.fog_start;
+               r_refdef.fogrange = bound(r_refdef.fog_start, r_refdef.fogrange, r_refdef.fog_end);
+               r_refdef.fograngerecip = 1.0f / r_refdef.fogrange;
+               r_refdef.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * r_refdef.fograngerecip;
                // fog color was already set
                // update the fog texture
-               if (scene->refdef.fogmasktable_start != scene->refdef.fog_start || scene->refdef.fogmasktable_alpha != scene->refdef.fog_alpha || scene->refdef.fogmasktable_density != scene->refdef.fog_density || scene->refdef.fogmasktable_range != scene->refdef.fogrange)
-                       R_BuildFogTexture(scene);
+               if (r_refdef.fogmasktable_start != r_refdef.fog_start || r_refdef.fogmasktable_alpha != r_refdef.fog_alpha || r_refdef.fogmasktable_density != r_refdef.fog_density || r_refdef.fogmasktable_range != r_refdef.fogrange)
+                       R_BuildFogTexture();
        }
        else
-               scene->refdef.fogenabled = false;
+               r_refdef.fogenabled = false;
 }
 
 /*
@@ -3345,12 +3350,12 @@ void R_UpdateVariables(renderscene_t* scene)
 R_RenderView
 ================
 */
-void R_RenderView(renderscene_t* scene)
+void R_RenderView(void)
 {
-       if (!scene->refdef.entities/* || !r_refdef.worldmodel*/)
+       if (!r_refdef.entities/* || !r_refdef.worldmodel*/)
                return; //Host_Error ("R_RenderView: NULL worldmodel");
 
-       r_view.colorscale = r_hdr_scenebrightness.value;
+       r_refdef.view.colorscale = r_hdr_scenebrightness.value;
 
        R_Shadow_UpdateWorldLightSelection();
 
@@ -3361,24 +3366,24 @@ void R_RenderView(renderscene_t* scene)
        if (r_timereport_active)
                R_TimeReport("viewsetup");
 
-       R_ResetViewRendering3D(scene);
+       R_ResetViewRendering3D();
 
-       if (scene->view.clear || scene->refdef.fogenabled)
+       if (r_refdef.view.clear || r_refdef.fogenabled)
        {
                R_ClearScreen(r_refdef.fogenabled);
                if (r_timereport_active)
                        R_TimeReport("viewclear");
        }
-       scene->view.clear = true;
+       r_refdef.view.clear = true;
 
-       scene->view.showdebug = true;
+       r_refdef.view.showdebug = true;
 
        // this produces a bloom texture to be used in R_BlendView() later
        if (r_hdr.integer)
-               R_HDR_RenderBloomTexture(scene);
+               R_HDR_RenderBloomTexture();
 
        r_waterstate.numwaterplanes = 0;
-       R_RenderScene(scene, r_waterstate.enabled);
+       R_RenderScene(r_waterstate.enabled);
 
        R_BlendView();
        if (r_timereport_active)
@@ -3395,16 +3400,16 @@ extern void R_DrawPortals (void);
 extern cvar_t cl_locs_show;
 static void R_DrawLocs(void);
 static void R_DrawEntityBBoxes(void);
-void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
+void R_RenderScene(qboolean addwaterplanes)
 {
-       Matrix4x4_Invert_Simple(&r_view.inverse_matrix, &r_view.matrix);
+       Matrix4x4_Invert_Simple(&r_refdef.view.inverse_matrix, &r_refdef.view.matrix);
        R_UpdateFogColor();
 
        if (addwaterplanes)
        {
-               R_ResetViewRendering3D(scene);
+               R_ResetViewRendering3D();
 
-               R_View_Update(scene);
+               R_View_Update();
                if (r_timereport_active)
                        R_TimeReport("watervis");
 
@@ -3419,16 +3424,16 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
                if (r_refdef.extraupdate)
                        S_ExtraUpdate ();
 
-               R_DrawModelsAddWaterPlanes(scene);
+               R_DrawModelsAddWaterPlanes();
                if (r_timereport_active)
                        R_TimeReport("watermodels");
 
-               R_Water_ProcessPlanes(scene);
+               R_Water_ProcessPlanes();
                if (r_timereport_active)
                        R_TimeReport("waterscenes");
        }
 
-       R_ResetViewRendering3D(scene);
+       R_ResetViewRendering3D();
 
        // don't let sound skip if going slow
        if (r_refdef.extraupdate)
@@ -3438,7 +3443,7 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
 
        R_SkyStartFrame();
 
-       R_View_Update(scene);
+       R_View_Update();
        if (r_timereport_active)
                R_TimeReport("visibility");
 
@@ -3469,7 +3474,7 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
        }
        if (r_depthfirst.integer >= 2)
        {
-               R_DrawModelsDepth(scene);
+               R_DrawModelsDepth();
                if (r_timereport_active)
                        R_TimeReport("modeldepth");
        }
@@ -3485,7 +3490,7 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
        if (r_refdef.extraupdate)
                S_ExtraUpdate ();
 
-       R_DrawModels(scene);
+       R_DrawModels();
        if (r_timereport_active)
                R_TimeReport("models");
 
@@ -3495,9 +3500,9 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
 
        if (r_shadows.integer > 0 && r_refdef.lightmapintensity > 0)
        {
-               R_DrawModelShadows(scene);
+               R_DrawModelShadows();
 
-               R_ResetViewRendering3D(scene);
+               R_ResetViewRendering3D();
 
                // don't let sound skip if going slow
                if (r_refdef.extraupdate)
@@ -3537,7 +3542,7 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
        }
        VM_CL_AddPolygonsToMeshQueue();
 
-       if (r_view.showdebug)
+       if (r_refdef.view.showdebug)
        {
                if (cl_locs_show.integer)
                {
@@ -3574,12 +3579,12 @@ void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes)
                qglUseProgramObjectARB(0);CHECKGLERROR
        }
 
-       if (r_view.showdebug && r_refdef.worldmodel && r_refdef.worldmodel->DrawDebug && (r_showtris.value > 0 || r_shownormals.value > 0 || r_showcollisionbrushes.value > 0))
+       if (r_refdef.view.showdebug && r_refdef.worldmodel && r_refdef.worldmodel->DrawDebug && (r_showtris.value > 0 || r_shownormals.value > 0 || r_showcollisionbrushes.value > 0))
        {
                r_refdef.worldmodel->DrawDebug(r_refdef.worldentity);
                if (r_timereport_active)
                        R_TimeReport("worlddebug");
-               R_DrawModelsDebug(scene);
+               R_DrawModelsDebug();
                if (r_timereport_active)
                        R_TimeReport("modeldebug");
        }
@@ -3674,7 +3679,7 @@ static void R_DrawEntityBBoxes_Callback(const entity_render_t *ent, const rtligh
                color[3] *= r_showbboxes.value;
                color[3] = bound(0, color[3], 1);
                GL_DepthTest(!r_showdisabledepthtest.integer);
-               GL_CullFace(r_view.cullface_front);
+               GL_CullFace(r_refdef.view.cullface_front);
                R_DrawBBoxMesh(edict->priv.server->areamins, edict->priv.server->areamaxs, color[0], color[1], color[2], color[3]);
        }
        SV_VM_End();
@@ -3759,7 +3764,7 @@ void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight
        GL_DepthRange(0, (ent->flags & RENDER_VIEWMODEL) ? 0.0625 : 1);
        GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
        GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
-       GL_CullFace((ent->effects & EF_DOUBLESIDED) ? GL_NONE : r_view.cullface_back);
+       GL_CullFace((ent->effects & EF_DOUBLESIDED) ? GL_NONE : r_refdef.view.cullface_back);
        R_Mesh_VertexPointer(nomodelvertex3f, 0, 0);
        if (r_refdef.fogenabled)
        {
@@ -3795,7 +3800,7 @@ void R_DrawNoModel(entity_render_t *ent)
        vec3_t org;
        Matrix4x4_OriginFromMatrix(&ent->matrix, org);
        //if ((ent->effects & EF_ADDITIVE) || (ent->alpha < 1))
-               R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : org, R_DrawNoModel_TransparentCallback, ent, 0, rsurface.rtlight);
+               R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_refdef.view.origin : org, R_DrawNoModel_TransparentCallback, ent, 0, rsurface.rtlight);
        //else
        //      R_DrawNoModelCallback(ent, 0);
 }
@@ -3807,12 +3812,12 @@ void R_CalcBeam_Vertex3f (float *vert, const vec3_t org1, const vec3_t org2, flo
        VectorSubtract (org2, org1, normal);
 
        // calculate 'right' vector for start
-       VectorSubtract (r_view.origin, org1, diff);
+       VectorSubtract (r_refdef.view.origin, org1, diff);
        CrossProduct (normal, diff, right1);
        VectorNormalize (right1);
 
        // calculate 'right' vector for end
-       VectorSubtract (r_view.origin, org2, diff);
+       VectorSubtract (r_refdef.view.origin, org2, diff);
        CrossProduct (normal, diff, right2);
        VectorNormalize (right2);
 
@@ -3847,10 +3852,10 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
        {
                scalex1 = -scalex1;
                scalex2 = -scalex2;
-               GL_CullFace(r_view.cullface_front);
+               GL_CullFace(r_refdef.view.cullface_front);
        }
        else
-               GL_CullFace(r_view.cullface_back);
+               GL_CullFace(r_refdef.view.cullface_back);
 
        GL_DepthMask(false);
        GL_DepthRange(0, depthshort ? 0.0625 : 1);
@@ -3875,8 +3880,8 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
        R_Mesh_ResetTextureState();
        R_Mesh_TexBind(0, R_GetTexture(texture));
        R_Mesh_TexCoordPointer(0, 2, spritetexcoord2f, 0, 0);
-       // FIXME: fixed function path can't properly handle r_view.colorscale > 1
-       GL_Color(cr * fog * r_view.colorscale, cg * fog * r_view.colorscale, cb * fog * r_view.colorscale, ca);
+       // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
+       GL_Color(cr * fog * r_refdef.view.colorscale, cg * fog * r_refdef.view.colorscale, cb * fog * r_refdef.view.colorscale, ca);
        R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
 
        if (blendfunc2 == GL_ONE_MINUS_SRC_ALPHA)
@@ -3997,9 +4002,9 @@ static void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1,
        layer->blendfunc2 = blendfunc2;
        layer->texture = texture;
        layer->texmatrix = *matrix;
-       layer->color[0] = r * r_view.colorscale;
-       layer->color[1] = g * r_view.colorscale;
-       layer->color[2] = b * r_view.colorscale;
+       layer->color[0] = r * r_refdef.view.colorscale;
+       layer->color[1] = g * r_refdef.view.colorscale;
+       layer->color[2] = b * r_refdef.view.colorscale;
        layer->color[3] = a;
 }
 
@@ -4314,7 +4319,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                                        // were darkened by fog already, and we should not add fog color
                                        // (because the background was not darkened, there is no fog color
                                        // that was lost behind it).
-                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_BLENDED) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->currentskinframe->fog, &identitymatrix, r_refdef.fogcolor[0] / r_view.colorscale, r_refdef.fogcolor[1] / r_view.colorscale, r_refdef.fogcolor[2] / r_view.colorscale, t->lightmapcolor[3]);
+                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_BLENDED) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->currentskinframe->fog, &identitymatrix, r_refdef.fogcolor[0] / r_refdef.view.colorscale, r_refdef.fogcolor[1] / r_refdef.view.colorscale, r_refdef.fogcolor[2] / r_refdef.view.colorscale, t->lightmapcolor[3]);
                                }
                        }
                }
@@ -4375,7 +4380,7 @@ void RSurf_ActiveWorldEntity(void)
        rsurface.matrix = identitymatrix;
        rsurface.inversematrix = identitymatrix;
        R_Mesh_Matrix(&identitymatrix);
-       VectorCopy(r_view.origin, rsurface.modelorg);
+       VectorCopy(r_refdef.view.origin, rsurface.modelorg);
        VectorSet(rsurface.modellight_ambient, 0, 0, 0);
        VectorSet(rsurface.modellight_diffuse, 0, 0, 0);
        VectorSet(rsurface.modellight_lightdir, 0, 0, 1);
@@ -4443,7 +4448,7 @@ void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, q
        rsurface.matrix = ent->matrix;
        rsurface.inversematrix = ent->inversematrix;
        R_Mesh_Matrix(&rsurface.matrix);
-       Matrix4x4_Transform(&rsurface.inversematrix, r_view.origin, rsurface.modelorg);
+       Matrix4x4_Transform(&rsurface.inversematrix, r_refdef.view.origin, rsurface.modelorg);
        rsurface.modellight_ambient[0] = ent->modellight_ambient[0] * ent->colormod[0];
        rsurface.modellight_ambient[1] = ent->modellight_ambient[1] * ent->colormod[1];
        rsurface.modellight_ambient[2] = ent->modellight_ambient[2] * ent->colormod[2];
@@ -4628,9 +4633,9 @@ void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generateta
                case Q3DEFORM_NONE:
                        break;
                case Q3DEFORM_AUTOSPRITE:
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.forward, newforward);
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.right, newright);
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.up, newup);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, newforward);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.right, newright);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.up, newup);
                        VectorNormalize(newforward);
                        VectorNormalize(newright);
                        VectorNormalize(newup);
@@ -4671,9 +4676,9 @@ void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generateta
                        rsurface.normal3f_bufferoffset = 0;
                        break;
                case Q3DEFORM_AUTOSPRITE2:
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.forward, newforward);
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.right, newright);
-                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.up, newup);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, newforward);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.right, newright);
+                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.up, newup);
                        VectorNormalize(newforward);
                        VectorNormalize(newright);
                        VectorNormalize(newup);
@@ -4747,7 +4752,7 @@ void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generateta
                                        VectorNormalize(up);
                                        // calculate a forward vector to use instead of the original plane normal (this is how we get a new right vector)
                                        //VectorSubtract(rsurface.modelorg, center, forward);
-                                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_view.forward, forward);
+                                       Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, forward);
                                        VectorNegate(forward, forward);
                                        VectorReflect(forward, 0, up, forward);
                                        VectorNormalize(forward);
@@ -5212,7 +5217,7 @@ static void RSurf_DrawBatch_ShowSurfaces(int texturenumsurfaces, msurface_t **te
                        const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
                        for (j = 0;j < surface->num_triangles;j++)
                        {
-                               float f = ((j + surface->num_firsttriangle) & 31) * (1.0f / 31.0f) * r_view.colorscale;
+                               float f = ((j + surface->num_firsttriangle) & 31) * (1.0f / 31.0f) * r_refdef.view.colorscale;
                                GL_Color(f, f, f, 1);
                                R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, 1, (rsurface.modelelement3i + 3 * (j + surface->num_firsttriangle)), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * (j + surface->num_firsttriangle)));
                        }
@@ -5224,7 +5229,7 @@ static void RSurf_DrawBatch_ShowSurfaces(int texturenumsurfaces, msurface_t **te
                {
                        const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
                        int k = (int)(((size_t)surface) / sizeof(msurface_t));
-                       GL_Color((k & 15) * (1.0f / 16.0f) * r_view.colorscale, ((k >> 4) & 15) * (1.0f / 16.0f) * r_view.colorscale, ((k >> 8) & 15) * (1.0f / 16.0f) * r_view.colorscale, 1);
+                       GL_Color((k & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, ((k >> 4) & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, ((k >> 8) & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, 1);
                        GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
                        R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (rsurface.modelelement3i + 3 * surface->num_firsttriangle), rsurface.modelelement3i_bufferobject, (sizeof(int[3]) * surface->num_firsttriangle));
                }
@@ -5456,7 +5461,7 @@ void RSurf_SetupDepthAndCulling(void)
        GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
        GL_PolygonOffset(rsurface.basepolygonfactor + rsurface.texture->biaspolygonfactor, rsurface.basepolygonoffset + rsurface.texture->biaspolygonoffset);
        GL_DepthTest(!(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
-       GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+       GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_refdef.view.cullface_back);
 }
 
 static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, msurface_t **texturesurfacelist)
@@ -5502,7 +5507,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, msurface_t **te
        // in Quake3 maps as it causes problems with q3map2 sky tricks,
        // and skymasking also looks very bad when noclipping outside the
        // level, so don't use it then either.
-       if (r_refdef.worldmodel && r_refdef.worldmodel->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_viewcache.world_novis)
+       if (r_refdef.worldmodel && r_refdef.worldmodel->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_refdef.viewcache.world_novis)
        {
                GL_Color(r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], 1);
                R_Mesh_ColorPointer(NULL, 0, 0);
@@ -5523,7 +5528,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, msurface_t **te
                RSurf_PrepareVerticesForBatch(false, false, texturenumsurfaces, texturesurfacelist);
                RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
                if (skyrendermasked)
-                       GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 1);
+                       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        }
 }
 
@@ -5924,7 +5929,7 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                if (r_depthfirst.integer == 3)
                {
                        int i = (int)(texturesurfacelist[0] - rsurface.modelsurfaces);
-                       if (!r_view.showdebug)
+                       if (!r_refdef.view.showdebug)
                                GL_Color(0, 0, 0, 1);
                        else
                                GL_Color(((i >> 6) & 7) / 7.0f, ((i >> 3) & 7) / 7.0f, (i & 7) / 7.0f,1);
@@ -5943,11 +5948,11 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                R_Mesh_ResetTextureState();
                RSurf_PrepareVerticesForBatch(false, false, texturenumsurfaces, texturesurfacelist);
                RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
-               GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 1);
+               GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        }
        else if (r_depthfirst.integer == 3)
                return;
-       else if (!r_view.showdebug && (r_showsurfaces.integer || gl_lightmaps.integer))
+       else if (!r_refdef.view.showdebug && (r_showsurfaces.integer || gl_lightmaps.integer))
        {
                GL_Color(0, 0, 0, 1);
                RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
@@ -5974,7 +5979,7 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                        rsurface.mode = RSURFMODE_MULTIPASS;
                GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
                GL_DepthTest(true);
-               GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+               GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_refdef.view.cullface_back);
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_DepthMask(writedepth);
                GL_Color(1,1,1,1);
@@ -6101,7 +6106,7 @@ void R_QueueSurfaceList(entity_render_t *ent, int numsurfaces, msurface_t **surf
                        tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
                        tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
                        Matrix4x4_Transform(&rsurface.matrix, tempcenter, center);
-                       R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_view.origin : center, R_DrawSurface_TransparentCallback, ent, surface - rsurface.modelsurfaces, rsurface.rtlight);
+                       R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_refdef.view.origin : center, R_DrawSurface_TransparentCallback, ent, surface - rsurface.modelsurfaces, rsurface.rtlight);
                }
                else
                {
@@ -6154,9 +6159,9 @@ void R_DrawLoc_Callback(const entity_render_t *ent, const rtlight_t *rtlight, in
        R_Mesh_ResetTextureState();
 
        i = surfacelist[0];
-       GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_view.colorscale,
-                        ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_view.colorscale,
-                        ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_view.colorscale,
+       GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
+                        ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
+                        ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
                        surfacelist[0] < 0 ? 0.5f : 0.125f);
 
        if (VectorCompare(loc->mins, loc->maxs))
@@ -6216,7 +6221,7 @@ void R_DrawDebugModel(entity_render_t *ent)
                        if (brush->colbrushf && brush->colbrushf->numtriangles)
                        {
                                R_Mesh_VertexPointer(brush->colbrushf->points->v, 0, 0);
-                               GL_Color((i & 31) * (1.0f / 32.0f) * r_view.colorscale, ((i >> 5) & 31) * (1.0f / 32.0f) * r_view.colorscale, ((i >> 10) & 31) * (1.0f / 32.0f) * r_view.colorscale, r_showcollisionbrushes.value);
+                               GL_Color((i & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((i >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((i >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
                                R_Mesh_Draw(0, brush->colbrushf->numpoints, brush->colbrushf->numtriangles, brush->colbrushf->elements, 0, 0);
                        }
                }
@@ -6225,7 +6230,7 @@ void R_DrawDebugModel(entity_render_t *ent)
                        if (surface->num_collisiontriangles)
                        {
                                R_Mesh_VertexPointer(surface->data_collisionvertex3f, 0, 0);
-                               GL_Color((i & 31) * (1.0f / 32.0f) * r_view.colorscale, ((i >> 5) & 31) * (1.0f / 32.0f) * r_view.colorscale, ((i >> 10) & 31) * (1.0f / 32.0f) * r_view.colorscale, r_showcollisionbrushes.value);
+                               GL_Color((i & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((i >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((i >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
                                R_Mesh_Draw(0, surface->num_collisionvertices, surface->num_collisiontriangles, surface->data_collisionelement3i, 0, 0);
                        }
                }
@@ -6247,7 +6252,7 @@ void R_DrawDebugModel(entity_render_t *ent)
                }
                for (i = 0, j = model->firstmodelsurface, surface = model->data_surfaces + j;i < model->nummodelsurfaces;i++, j++, surface++)
                {
-                       if (ent == r_refdef.worldentity && !r_viewcache.world_surfacevisible[j])
+                       if (ent == r_refdef.worldentity && !r_refdef.viewcache.world_surfacevisible[j])
                                continue;
                        rsurface.texture = surface->texture->currentframe;
                        if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
@@ -6256,11 +6261,11 @@ void R_DrawDebugModel(entity_render_t *ent)
                                if (r_showtris.value > 0)
                                {
                                        if (!rsurface.texture->currentlayers->depthmask)
-                                               GL_Color(r_view.colorscale, 0, 0, r_showtris.value);
+                                               GL_Color(r_refdef.view.colorscale, 0, 0, r_showtris.value);
                                        else if (ent == r_refdef.worldentity)
-                                               GL_Color(r_view.colorscale, r_view.colorscale, r_view.colorscale, r_showtris.value);
+                                               GL_Color(r_refdef.view.colorscale, r_refdef.view.colorscale, r_refdef.view.colorscale, r_showtris.value);
                                        else
-                                               GL_Color(0, r_view.colorscale, 0, r_showtris.value);
+                                               GL_Color(0, r_refdef.view.colorscale, 0, r_showtris.value);
                                        elements = (ent->model->surfmesh.data_element3i + 3 * surface->num_firsttriangle);
                                        CHECKGLERROR
                                        qglBegin(GL_LINES);
@@ -6280,10 +6285,10 @@ void R_DrawDebugModel(entity_render_t *ent)
                                        for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
                                        {
                                                VectorCopy(rsurface.vertex3f + l * 3, v);
-                                               GL_Color(r_view.colorscale, 0, 0, 1);
+                                               GL_Color(r_refdef.view.colorscale, 0, 0, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                                VectorMA(v, r_shownormals.value, rsurface.svector3f + l * 3, v);
-                                               GL_Color(r_view.colorscale, 1, 1, 1);
+                                               GL_Color(r_refdef.view.colorscale, 1, 1, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
@@ -6292,10 +6297,10 @@ void R_DrawDebugModel(entity_render_t *ent)
                                        for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
                                        {
                                                VectorCopy(rsurface.vertex3f + l * 3, v);
-                                               GL_Color(0, r_view.colorscale, 0, 1);
+                                               GL_Color(0, r_refdef.view.colorscale, 0, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                                VectorMA(v, r_shownormals.value, rsurface.tvector3f + l * 3, v);
-                                               GL_Color(r_view.colorscale, 1, 1, 1);
+                                               GL_Color(r_refdef.view.colorscale, 1, 1, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
@@ -6304,10 +6309,10 @@ void R_DrawDebugModel(entity_render_t *ent)
                                        for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
                                        {
                                                VectorCopy(rsurface.vertex3f + l * 3, v);
-                                               GL_Color(0, 0, r_view.colorscale, 1);
+                                               GL_Color(0, 0, r_refdef.view.colorscale, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                                VectorMA(v, r_shownormals.value, rsurface.normal3f + l * 3, v);
-                                               GL_Color(r_view.colorscale, 1, 1, 1);
+                                               GL_Color(r_refdef.view.colorscale, 1, 1, 1);
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
@@ -6370,10 +6375,10 @@ void R_DrawWorldSurfaces(qboolean skysurfaces, qboolean writedepth, qboolean dep
        while (j < endj)
        {
                // quickly skip over non-visible surfaces
-               for (;j < endj && !r_viewcache.world_surfacevisible[j];j++)
+               for (;j < endj && !r_refdef.viewcache.world_surfacevisible[j];j++)
                        ;
                // quickly iterate over visible surfaces
-               for (;j < endj && r_viewcache.world_surfacevisible[j];j++)
+               for (;j < endj && r_refdef.viewcache.world_surfacevisible[j];j++)
                {
                        // process this surface
                        surface = model->data_surfaces + j;
index fafbf1d39e3d5415931a3fee893da1611faa4254..b5cd1c701e03eafce96e212cf1a5aa19980edc9e 100644 (file)
@@ -341,9 +341,9 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r
        R_Mesh_ResetTextureState();
 
        i = surfacelist[0];
-       GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_view.colorscale,
-                        ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_view.colorscale,
-                        ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_view.colorscale,
+       GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
+                        ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
+                        ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
                         0.125f);
        for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
                VectorCopy(portal->points[i].position, v);
@@ -361,7 +361,7 @@ void R_DrawPortals(void)
                return;
        for (leafnum = 0;leafnum < r_refdef.worldmodel->brush.num_leafs;leafnum++)
        {
-               if (r_viewcache.world_leafvisible[leafnum])
+               if (r_refdef.viewcache.world_leafvisible[leafnum])
                {
                        //for (portalnum = 0, portal = model->brush.data_portals;portalnum < model->brush.num_portals;portalnum++, portal++)
                        for (portal = r_refdef.worldmodel->brush.data_leafs[leafnum].portals;portal;portal = portal->next)
@@ -391,42 +391,42 @@ void R_View_WorldVisibility(qboolean forcenovis)
        if (!model)
                return;
 
-       if (r_view.usecustompvs)
+       if (r_refdef.view.usecustompvs)
        {
                // clear the visible surface and leaf flags arrays
-               memset(r_viewcache.world_surfacevisible, 0, model->num_surfaces);
-               memset(r_viewcache.world_leafvisible, 0, model->brush.num_leafs);
-               r_viewcache.world_novis = false;
+               memset(r_refdef.viewcache.world_surfacevisible, 0, model->num_surfaces);
+               memset(r_refdef.viewcache.world_leafvisible, 0, model->brush.num_leafs);
+               r_refdef.viewcache.world_novis = false;
 
                // simply cull each marked leaf to the frustum (view pyramid)
                for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
                {
                        // if leaf is in current pvs and on the screen, mark its surfaces
-                       if (CHECKPVSBIT(r_viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
+                       if (CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
                        {
                                r_refdef.stats.world_leafs++;
-                               r_viewcache.world_leafvisible[j] = true;
+                               r_refdef.viewcache.world_leafvisible[j] = true;
                                if (leaf->numleafsurfaces)
                                        for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
-                                               r_viewcache.world_surfacevisible[*mark] = true;
+                                               r_refdef.viewcache.world_surfacevisible[*mark] = true;
                        }
                }
                return;
        }
 
        // if possible find the leaf the view origin is in
-       viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_view.origin) : NULL;
+       viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_refdef.view.origin) : NULL;
        // if possible fetch the visible cluster bits
        if (!r_lockpvs.integer && model->brush.FatPVS)
-               model->brush.FatPVS(model, r_view.origin, 2, r_viewcache.world_pvsbits, sizeof(r_viewcache.world_pvsbits), false);
+               model->brush.FatPVS(model, r_refdef.view.origin, 2, r_refdef.viewcache.world_pvsbits, sizeof(r_refdef.viewcache.world_pvsbits), false);
 
        if (!r_lockvisibility.integer)
        {
                // clear the visible surface and leaf flags arrays
-               memset(r_viewcache.world_surfacevisible, 0, model->num_surfaces);
-               memset(r_viewcache.world_leafvisible, 0, model->brush.num_leafs);
+               memset(r_refdef.viewcache.world_surfacevisible, 0, model->num_surfaces);
+               memset(r_refdef.viewcache.world_leafvisible, 0, model->brush.num_leafs);
 
-               r_viewcache.world_novis = false;
+               r_refdef.viewcache.world_novis = false;
 
                // if floating around in the void (no pvs data available, and no
                // portals available), simply use all on-screen leafs.
@@ -435,17 +435,17 @@ void R_View_WorldVisibility(qboolean forcenovis)
                        // no visibility method: (used when floating around in the void)
                        // simply cull each leaf to the frustum (view pyramid)
                        // similar to quake's RecursiveWorldNode but without cache misses
-                       r_viewcache.world_novis = true;
+                       r_refdef.viewcache.world_novis = true;
                        for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
                        {
                                // if leaf is in current pvs and on the screen, mark its surfaces
                                if (!R_CullBox(leaf->mins, leaf->maxs))
                                {
                                        r_refdef.stats.world_leafs++;
-                                       r_viewcache.world_leafvisible[j] = true;
+                                       r_refdef.viewcache.world_leafvisible[j] = true;
                                        if (leaf->numleafsurfaces)
                                                for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
-                                                       r_viewcache.world_surfacevisible[*mark] = true;
+                                                       r_refdef.viewcache.world_surfacevisible[*mark] = true;
                                }
                        }
                }
@@ -460,13 +460,13 @@ void R_View_WorldVisibility(qboolean forcenovis)
                        for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
                        {
                                // if leaf is in current pvs and on the screen, mark its surfaces
-                               if (CHECKPVSBIT(r_viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
+                               if (CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
                                {
                                        r_refdef.stats.world_leafs++;
-                                       r_viewcache.world_leafvisible[j] = true;
+                                       r_refdef.viewcache.world_leafvisible[j] = true;
                                        if (leaf->numleafsurfaces)
                                                for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
-                                                       r_viewcache.world_surfacevisible[*mark] = true;
+                                                       r_refdef.viewcache.world_surfacevisible[*mark] = true;
                                }
                        }
                }
@@ -489,14 +489,14 @@ void R_View_WorldVisibility(qboolean forcenovis)
                        while (leafstackpos)
                        {
                                leaf = leafstack[--leafstackpos];
-                               if (r_viewcache.world_leafvisible[leaf - model->brush.data_leafs])
+                               if (r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs])
                                        continue;
                                r_refdef.stats.world_leafs++;
-                               r_viewcache.world_leafvisible[leaf - model->brush.data_leafs] = true;
+                               r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs] = true;
                                // mark any surfaces bounding this leaf
                                if (leaf->numleafsurfaces)
                                        for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
-                                               r_viewcache.world_surfacevisible[*mark] = true;
+                                               r_refdef.viewcache.world_surfacevisible[*mark] = true;
                                // follow portals into other leafs
                                // the checks are:
                                // if viewer is behind portal (portal faces outward into the scene)
@@ -507,9 +507,9 @@ void R_View_WorldVisibility(qboolean forcenovis)
                                for (p = leaf->portals;p;p = p->next)
                                {
                                        r_refdef.stats.world_portals++;
-                                       if (DotProduct(r_view.origin, p->plane.normal) < (p->plane.dist + 1)
-                                        && !r_viewcache.world_leafvisible[p->past - model->brush.data_leafs]
-                                        && CHECKPVSBIT(r_viewcache.world_pvsbits, p->past->clusterindex)
+                                       if (DotProduct(r_refdef.view.origin, p->plane.normal) < (p->plane.dist + 1)
+                                        && !r_refdef.viewcache.world_leafvisible[p->past - model->brush.data_leafs]
+                                        && CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, p->past->clusterindex)
                                         && !R_CullBox(p->mins, p->maxs)
                                         && leafstackpos < (int)(sizeof(leafstack) / sizeof(leafstack[0])))
                                                leafstack[leafstackpos++] = p->past;
@@ -1056,7 +1056,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                if (ent == r_refdef.worldentity)
                {
                        for (;i < endsurface;i++)
-                               if (r_viewcache.world_surfacevisible[surfacelist[i]])
+                               if (r_refdef.viewcache.world_surfacevisible[surfacelist[i]])
                                        batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[i];
                }
                else
@@ -1087,7 +1087,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                                                tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
                                                tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
                                                Matrix4x4_Transform(&rsurface.matrix, tempcenter, center);
-                                               R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_view.origin : center, R_Q1BSP_DrawLight_TransparentCallback, ent, surface - rsurface.modelsurfaces, rsurface.rtlight);
+                                               R_MeshQueue_AddTransparent(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST ? r_refdef.view.origin : center, R_Q1BSP_DrawLight_TransparentCallback, ent, surface - rsurface.modelsurfaces, rsurface.rtlight);
                                        }
                                }
                                else
diff --git a/host.c b/host.c
index 511ad1131f91d44e52f42ba437edd9e776fcffba..060bbea771352ffa12236382c08349955f30b4cb 100644 (file)
--- a/host.c
+++ b/host.c
@@ -873,7 +873,7 @@ void Host_Main(void)
                                cl.csqc_usecsqclistener = false;
                        }
                        else
-                               S_Update(&r_view.matrix);
+                               S_Update(&r_refdef.view.matrix);
 
                        CDAudio_Update();
 
diff --git a/image.c b/image.c
index 71cacb6e0b7e25168e61fb647997f5d7114474a0..2146a64758756dbde6d5dc1ad2170f2c4af1aae2 100644 (file)
--- a/image.c
+++ b/image.c
@@ -327,14 +327,15 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize)
        targa_header.y_origin = f[10] + f[11] * 256;
        targa_header.width = image_width = f[12] + f[13] * 256;
        targa_header.height = image_height = f[14] + f[15] * 256;
+       targa_header.pixel_size = f[16];
+       targa_header.attributes = f[17];
+
        if (image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0)
        {
                Con_Print("LoadTGA: invalid size\n");
                PrintTargaHeader(&targa_header);
                return NULL;
        }
-       targa_header.pixel_size = f[16];
-       targa_header.attributes = f[17];
 
        // advance to end of header
        fin = f + 18;
diff --git a/menu.c b/menu.c
index d7078b4f2af1179799624142aa6637c9e894bde0..29467965802cf1c5f50e6c4c383ff0063ca50e05 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -5068,16 +5068,11 @@ void MP_KeyEvent (int key, char ascii, qboolean downevent)
        PRVM_End;
 }
 
-extern renderscene_t menu_renderscene;
-
 void MP_Draw (void)
 {
        PRVM_Begin;
        PRVM_SetProg(PRVM_MENUPROG);
 
-       // Here?
-       R_UpdateVariables (&menu_renderscene);
-
        PRVM_ExecuteProgram(prog->funcoffsets.m_draw,"m_draw() required");
 
        PRVM_End;
@@ -5228,7 +5223,4 @@ void MR_Init(void)
                MR_SetRouting (TRUE);
        else
                MR_SetRouting (FALSE);
-
-       // FIXME: needed so cl.max_entities is set
-       CL_ClearState ();
 }
index f1d01edc54f13f2d95ebbdb15c213b073e9f8c85..7d5a9c3aacf4d35ea80c0b1713604886d68a8b1e 100644 (file)
@@ -22,7 +22,7 @@ int mqt_total;
 void R_MeshQueue_BeginScene(void)
 {
        mqt_count = 0;
-       mqt_viewplanedist = DotProduct(r_view.origin, r_view.forward);
+       mqt_viewplanedist = DotProduct(r_refdef.view.origin, r_refdef.view.forward);
        mqt_viewmaxdist = 0;
 }
 
@@ -46,7 +46,7 @@ void R_MeshQueue_AddTransparent(const vec3_t center, void (*callback)(const enti
        mq->ent = ent;
        mq->surfacenumber = surfacenumber;
        mq->rtlight = rtlight;
-       mq->dist = DotProduct(center, r_view.forward) - mqt_viewplanedist;
+       mq->dist = DotProduct(center, r_refdef.view.forward) - mqt_viewplanedist;
        mq->next = NULL;
        mqt_viewmaxdist = max(mqt_viewmaxdist, mq->dist);
 }
index 6dc565334e38b8ade7408d2a6c1b5df6bc5217fc..11d0ddc92cb73b8b576523757a853a9f4c149147 100644 (file)
@@ -1,7 +1,6 @@
 #include "quakedef.h"
 
 #include "prvm_cmds.h"
-#include "clvm_cmds.h"
 #include "menu.h"
 
 //============================================================================
@@ -24,7 +23,6 @@ char *vm_m_extensions =
 #ifdef SUPPORT_GECKO
 "DP_GECKO_SUPPORT "
 #endif
-"DP_QC_RENDER_SCENE"
 ;
 
 /*
@@ -874,9 +872,9 @@ VM_altstr_ins,                                              //  #86
 VM_findflags,                                          //  #87
 VM_findchainflags,                             //  #88
 VM_cvar_defstring,                             //  #89
-VM_CL_setmodel,                                        // #90 void(entity e, string m) setmodel (QUAKE)
-VM_CL_precache_model,                  // #91 void(string s) precache_model (QUAKE)
-VM_CL_setorigin,                               // #92 void(entity e, vector o) setorigin (QUAKE)
+NULL,                                                                  //  #90
+NULL,                                                                  //  #91
+NULL,                                                                  //  #92
 NULL,                                                                  //  #93
 NULL,                                                                  //  #94
 NULL,                                                                  //  #95
@@ -1084,17 +1082,16 @@ NULL,                                                                   // #296
 NULL,                                                                  // #297
 NULL,                                                                  // #298
 NULL,                                                                  // #299
-// CSQC range #300-#399
-VM_CL_R_ClearScene,                            // #300 void() clearscene (DP_QC_RENDER_SCENE)
-VM_CL_R_AddEntities,                   // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
-VM_CL_R_AddEntity,                             // #302 void(entity ent) addentity (DP_QC_RENDER_SCENE)
-VM_CL_R_SetView,                               // #303 float(float property, ...) setproperty (DP_QC_RENDER_SCENE)
-VM_CL_R_RenderScene,                   // #304 void() renderscene (DP_QC_RENDER_SCENE)
-VM_CL_R_AddDynamicLight,               // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (DP_QC_RENDER_SCENE)
-VM_CL_R_PolygonBegin,                  // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
-VM_CL_R_PolygonVertex,                 // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
-VM_CL_R_PolygonEnd,                            // #308 void() R_EndPolygon
-NULL/*VM_CL_R_LoadWorldModel*/,                                // #309 void(string modelname) R_LoadWorldModel
+NULL,                                                                  // #300
+NULL,                                                                  // #301
+NULL,                                                                  // #302
+NULL,                                                                  // #303
+NULL,                                                                  // #304
+NULL,                                                                  // #305
+NULL,                                                                  // #306
+NULL,                                                                  // #307
+NULL,                                                                  // #308
+NULL,                                                                  // #309
 NULL,                                                                  // #310
 NULL,                                                                  // #311
 NULL,                                                                  // #312
@@ -1424,39 +1421,13 @@ VM_M_getextresponse                             // #624
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
 
-renderscene_t menu_renderscene;
-
 void VM_M_Cmd_Init(void)
 {
        VM_Cmd_Init();
-       VM_Polygons_Reset();
-       renderscenes[PRVM_MENUPROG] = &menu_renderscene;
-       memset (&menu_renderscene, 0, sizeof (renderscene_t));
-       
-       menu_renderscene.refdef.frustumscale_x = 1;
-       menu_renderscene.refdef.frustumscale_y = 1;
-       menu_renderscene.refdef.maxentities = MAX_EDICTS + 256 + 512;
-       menu_renderscene.refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * menu_renderscene.refdef.maxentities);
-       
-       menu_renderscene.view.width = vid.width;
-       menu_renderscene.view.height = vid.height;
-       menu_renderscene.view.depth = 1;
-       menu_renderscene.view.x = 0;
-       menu_renderscene.view.y = 0;
-       menu_renderscene.view.z = 0;
-       menu_renderscene.view.colormask[0] = true;
-       menu_renderscene.view.colormask[1] = true;
-       menu_renderscene.view.colormask[2] = true;
-       menu_renderscene.view.colormask[3] = true;
-       
-       menu_renderscene.view.useperspective = true;
-       menu_renderscene.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0);
-       menu_renderscene.view.frustum_x = r_view.frustum_y * (float)menu_renderscene.view.width / (float)menu_renderscene.view.height / vid_pixelheight.value;
 }
 
 void VM_M_Cmd_Reset(void)
 {
        //VM_Cmd_Init();
        VM_Cmd_Reset();
-       VM_Polygons_Reset();
 }
index 90a5fcf5d664ad3e763d19705b7b1ebb2ec2e4cc..268e9806dd1a2124bb384066126aef859de5b1cc 100644 (file)
@@ -190,7 +190,7 @@ static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, cons
        GL_DepthRange(0, 1);
        GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
        GL_DepthTest(true);
-       GL_CullFace(r_view.cullface_back);
+       GL_CullFace(r_refdef.view.cullface_back);
        R_Mesh_Matrix(&identitymatrix);
 
        R_Mesh_ColorPointer(NULL, 0, 0);
@@ -202,8 +202,8 @@ static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, cons
        {
                const explosion_t *e = explosion + surfacelist[surfacelistindex];
                R_Mesh_VertexPointer(e->vert[0], 0, 0);
-               // FIXME: fixed function path can't properly handle r_view.colorscale > 1
-               GL_Color(e->alpha * r_view.colorscale, e->alpha * r_view.colorscale, e->alpha * r_view.colorscale, 1);
+               // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
+               GL_Color(e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, 1);
                GL_LockArrays(0, numverts);
                R_Mesh_Draw(0, numverts, numtriangles, explosiontris[0], 0, 0);
                GL_LockArrays(0, 0);
index dae55398f105e2b465845b11a0d036af8445edb8..0ee3f20f0f2d68a4e84299949d4cf197be62795d 100644 (file)
@@ -248,7 +248,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
                r_lightningbeams_setuptexture();
 
        R_Mesh_VertexPointer(vertex3f, 0, 0);
-       // FIXME: fixed function path can't properly handle r_view.colorscale > 1
+       // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
        if (r_refdef.fogenabled)
        {
                // per vertex colors if fog is used
@@ -258,7 +258,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
        {
                // solid color if fog is not used
                R_Mesh_ColorPointer(NULL, 0, 0);
-               GL_Color(r_lightningbeam_color_red.value * r_view.colorscale, r_lightningbeam_color_green.value * r_view.colorscale, r_lightningbeam_color_blue.value * r_view.colorscale, 1);
+               GL_Color(r_lightningbeam_color_red.value * r_refdef.view.colorscale, r_lightningbeam_color_green.value * r_refdef.view.colorscale, r_lightningbeam_color_blue.value * r_refdef.view.colorscale, 1);
        }
        memset(&m, 0, sizeof(m));
        if (r_lightningbeam_qmbtexture.integer)
@@ -288,7 +288,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
 
                // calculate up vector such that it points toward viewer, and rotates around the beamdir
                // get direction from start of beam to viewer
-               VectorSubtract(r_view.origin, start, up);
+               VectorSubtract(r_refdef.view.origin, start, up);
                // remove the portion of the vector that moves along the beam
                // (this leaves only a vector pointing directly away from the beam)
                t1 = -DotProduct(up, beamdir);
@@ -361,7 +361,7 @@ void R_DrawLightningBeams(void)
                        CL_Beam_CalculatePositions(b, start, end);
                        // calculate the nearest point on the line (beam) for depth sorting
                        VectorSubtract(end, start, dir);
-                       dist = (DotProduct(r_view.origin, dir) - DotProduct(start, dir)) / (DotProduct(end, dir) - DotProduct(start, dir));
+                       dist = (DotProduct(r_refdef.view.origin, dir) - DotProduct(start, dir)) / (DotProduct(end, dir) - DotProduct(start, dir));
                        dist = bound(0, dist, 1);
                        VectorLerp(start, dist, end, org);
                        // now we have the nearest point on the line, so sort with it
index 14d671cd4967931cb2f215867eceb64970627d1c..a78bf7cba4c5ccc2f3b733a557ae36a4644acd4d 100644 (file)
@@ -909,11 +909,11 @@ void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *verte
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCIL)
        {
                // decrement stencil if backface is behind depthbuffer
-               GL_CullFace(r_view.cullface_front);
+               GL_CullFace(r_refdef.view.cullface_front);
                qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
                R_Mesh_Draw(0, numvertices, numtriangles, element3i, 0, 0);
                // increment stencil if frontface is behind depthbuffer
-               GL_CullFace(r_view.cullface_back);
+               GL_CullFace(r_refdef.view.cullface_back);
                qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
        }
        R_Mesh_Draw(0, numvertices, numtriangles, element3i, 0, 0);
@@ -1030,7 +1030,7 @@ void R_Shadow_RenderMode_Begin(void)
        GL_DepthTest(true);
        GL_DepthMask(false);
        GL_Color(0, 0, 0, 1);
-       GL_Scissor(r_view.x, r_view.y, r_view.width, r_view.height);
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
 
        r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE;
 
@@ -1076,9 +1076,9 @@ void R_Shadow_RenderMode_Reset(void)
        qglStencilMask(~0);CHECKGLERROR
        qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);CHECKGLERROR
        qglStencilFunc(GL_ALWAYS, 128, ~0);CHECKGLERROR
-       GL_CullFace(r_view.cullface_back);
+       GL_CullFace(r_refdef.view.cullface_back);
        GL_Color(1, 1, 1, 1);
-       GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 1);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
 }
 
@@ -1094,17 +1094,17 @@ void R_Shadow_RenderMode_StencilShadowVolumes(qboolean clearstencil)
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_SEPARATESTENCIL)
        {
                GL_CullFace(GL_NONE);
-               qglStencilOpSeparate(r_view.cullface_front, GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
-               qglStencilOpSeparate(r_view.cullface_back, GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
+               qglStencilOpSeparate(r_refdef.view.cullface_front, GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
+               qglStencilOpSeparate(r_refdef.view.cullface_back, GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
        }
        else if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCILTWOSIDE)
        {
                GL_CullFace(GL_NONE);
                qglEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);CHECKGLERROR
-               qglActiveStencilFaceEXT(r_view.cullface_front);CHECKGLERROR
+               qglActiveStencilFaceEXT(r_refdef.view.cullface_front);CHECKGLERROR
                qglStencilMask(~0);CHECKGLERROR
                qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
-               qglActiveStencilFaceEXT(r_view.cullface_back);CHECKGLERROR
+               qglActiveStencilFaceEXT(r_refdef.view.cullface_back);CHECKGLERROR
                qglStencilMask(~0);CHECKGLERROR
                qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
        }
@@ -1145,7 +1145,7 @@ void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent)
                R_Mesh_TexBind(9, R_GetTexture(r_texture_black)); // glow
                //R_Mesh_TexMatrix(3, rsurface.entitytolight); // light filter matrix
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-               GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 0);
+               GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 0);
                CHECKGLERROR
        }
 }
@@ -1157,7 +1157,7 @@ void R_Shadow_RenderMode_VisibleShadowVolumes(void)
        GL_BlendFunc(GL_ONE, GL_ONE);
        GL_DepthRange(0, 1);
        GL_DepthTest(r_showshadowvolumes.integer < 2);
-       GL_Color(0.0, 0.0125 * r_view.colorscale, 0.1 * r_view.colorscale, 1);
+       GL_Color(0.0, 0.0125 * r_refdef.view.colorscale, 0.1 * r_refdef.view.colorscale, 1);
        GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);CHECKGLERROR
        GL_CullFace(GL_NONE);
        r_shadow_rendermode = R_SHADOW_RENDERMODE_VISIBLEVOLUMES;
@@ -1170,7 +1170,7 @@ void R_Shadow_RenderMode_VisibleLighting(qboolean stenciltest, qboolean transpar
        GL_BlendFunc(GL_ONE, GL_ONE);
        GL_DepthRange(0, 1);
        GL_DepthTest(r_showlighting.integer < 2);
-       GL_Color(0.1 * r_view.colorscale, 0.0125 * r_view.colorscale, 0, 1);
+       GL_Color(0.1 * r_refdef.view.colorscale, 0.0125 * r_refdef.view.colorscale, 0, 1);
        if (!transparent)
        {
                qglDepthFunc(GL_EQUAL);CHECKGLERROR
@@ -1189,7 +1189,7 @@ void R_Shadow_RenderMode_End(void)
        R_Shadow_RenderMode_Reset();
        R_Shadow_RenderMode_ActiveLight(NULL);
        GL_DepthMask(true);
-       GL_Scissor(r_view.x, r_view.y, r_view.width, r_view.height);
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
        r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE;
 }
 
@@ -1230,17 +1230,17 @@ qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs)
                return false;
 
        // if view is inside the light box, just say yes it's visible
-       if (BoxesOverlap(r_view.origin, r_view.origin, mins, maxs))
+       if (BoxesOverlap(r_refdef.view.origin, r_refdef.view.origin, mins, maxs))
        {
-               GL_Scissor(r_view.x, r_view.y, r_view.width, r_view.height);
+               GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
                return false;
        }
 
        x1 = y1 = x2 = y2 = 0;
 
        // transform all corners that are infront of the nearclip plane
-       VectorNegate(r_view.frustum[4].normal, plane4f);
-       plane4f[3] = r_view.frustum[4].dist;
+       VectorNegate(r_refdef.view.frustum[4].normal, plane4f);
+       plane4f[3] = r_refdef.view.frustum[4].dist;
        numvertices = 0;
        for (i = 0;i < 8;i++)
        {
@@ -1306,10 +1306,10 @@ qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs)
        //Con_Printf("%f %f %f %f\n", x1, y1, x2, y2);
 
        // clamp it to the screen
-       if (ix1 < r_view.x) ix1 = r_view.x;
-       if (iy1 < r_view.y) iy1 = r_view.y;
-       if (ix2 > r_view.x + r_view.width) ix2 = r_view.x + r_view.width;
-       if (iy2 > r_view.y + r_view.height) iy2 = r_view.y + r_view.height;
+       if (ix1 < r_refdef.view.x) ix1 = r_refdef.view.x;
+       if (iy1 < r_refdef.view.y) iy1 = r_refdef.view.y;
+       if (ix2 > r_refdef.view.x + r_refdef.view.width) ix2 = r_refdef.view.x + r_refdef.view.width;
+       if (iy2 > r_refdef.view.y + r_refdef.view.height) iy2 = r_refdef.view.y + r_refdef.view.height;
 
        // if it is inside out, it's not visible
        if (ix2 <= ix1 || iy2 <= iy1)
@@ -1536,7 +1536,7 @@ static void R_Shadow_GenTexCoords_Specular_NormalCubeMap(int firstvertex, int nu
 static void R_Shadow_RenderLighting_VisibleLighting(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, const vec3_t lightcolorbase, const vec3_t lightcolorpants, const vec3_t lightcolorshirt, rtexture_t *basetexture, rtexture_t *pantstexture, rtexture_t *shirttexture, rtexture_t *normalmaptexture, rtexture_t *glosstexture, float ambientscale, float diffusescale, float specularscale, qboolean dopants, qboolean doshirt)
 {
        // used to display how many times a surface is lit for level design purposes
-       GL_Color(0.1 * r_view.colorscale, 0.025 * r_view.colorscale, 0, 1);
+       GL_Color(0.1 * r_refdef.view.colorscale, 0.025 * r_refdef.view.colorscale, 0, 1);
        R_Mesh_ColorPointer(NULL, 0, 0);
        R_Mesh_ResetTextureState();
        R_Mesh_Draw(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset);
@@ -1574,7 +1574,7 @@ static void R_Shadow_RenderLighting_Light_Dot3_Finalize(int firstvertex, int num
 {
        // shared final code for all the dot3 layers
        int renders;
-       GL_ColorMask(r_view.colormask[0], r_view.colormask[1], r_view.colormask[2], 0);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 0);
        for (renders = 0;renders < 64 && (r > 0 || g > 0 || b > 0);renders++, r--, g--, b--)
        {
                GL_Color(bound(0, r, 1), bound(0, g, 1), bound(0, b, 1), 1);
@@ -2144,25 +2144,25 @@ static void R_Shadow_RenderLighting_Light_Dot3(int firstvertex, int numvertices,
                return;
        R_Mesh_ColorPointer(NULL, 0, 0);
        if (doambient)
-               R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, basetexture, ambientscale * r_view.colorscale);
+               R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, basetexture, ambientscale * r_refdef.view.colorscale);
        if (dodiffuse)
-               R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, basetexture, normalmaptexture, diffusescale * r_view.colorscale);
+               R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, basetexture, normalmaptexture, diffusescale * r_refdef.view.colorscale);
        if (dopants)
        {
                if (doambient)
-                       R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorpants, pantstexture, ambientscale * r_view.colorscale);
+                       R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorpants, pantstexture, ambientscale * r_refdef.view.colorscale);
                if (dodiffuse)
-                       R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorpants, pantstexture, normalmaptexture, diffusescale * r_view.colorscale);
+                       R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorpants, pantstexture, normalmaptexture, diffusescale * r_refdef.view.colorscale);
        }
        if (doshirt)
        {
                if (doambient)
-                       R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorshirt, shirttexture, ambientscale * r_view.colorscale);
+                       R_Shadow_RenderLighting_Light_Dot3_AmbientPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorshirt, shirttexture, ambientscale * r_refdef.view.colorscale);
                if (dodiffuse)
-                       R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorshirt, shirttexture, normalmaptexture, diffusescale * r_view.colorscale);
+                       R_Shadow_RenderLighting_Light_Dot3_DiffusePass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorshirt, shirttexture, normalmaptexture, diffusescale * r_refdef.view.colorscale);
        }
        if (dospecular)
-               R_Shadow_RenderLighting_Light_Dot3_SpecularPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, glosstexture, normalmaptexture, specularscale * r_view.colorscale);
+               R_Shadow_RenderLighting_Light_Dot3_SpecularPass(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset, lightcolorbase, glosstexture, normalmaptexture, specularscale * r_refdef.view.colorscale);
 }
 
 void R_Shadow_RenderLighting_Light_Vertex_Pass(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, vec3_t diffusecolor2, vec3_t ambientcolor2)
@@ -2264,12 +2264,12 @@ static void R_Shadow_RenderLighting_Light_Vertex(int firstvertex, int numvertice
        float ambientcolorpants[3], diffusecolorpants[3];
        float ambientcolorshirt[3], diffusecolorshirt[3];
        rmeshstate_t m;
-       VectorScale(lightcolorbase, ambientscale * 2 * r_view.colorscale, ambientcolorbase);
-       VectorScale(lightcolorbase, diffusescale * 2 * r_view.colorscale, diffusecolorbase);
-       VectorScale(lightcolorpants, ambientscale * 2 * r_view.colorscale, ambientcolorpants);
-       VectorScale(lightcolorpants, diffusescale * 2 * r_view.colorscale, diffusecolorpants);
-       VectorScale(lightcolorshirt, ambientscale * 2 * r_view.colorscale, ambientcolorshirt);
-       VectorScale(lightcolorshirt, diffusescale * 2 * r_view.colorscale, diffusecolorshirt);
+       VectorScale(lightcolorbase, ambientscale * 2 * r_refdef.view.colorscale, ambientcolorbase);
+       VectorScale(lightcolorbase, diffusescale * 2 * r_refdef.view.colorscale, diffusecolorbase);
+       VectorScale(lightcolorpants, ambientscale * 2 * r_refdef.view.colorscale, ambientcolorpants);
+       VectorScale(lightcolorpants, diffusescale * 2 * r_refdef.view.colorscale, diffusecolorpants);
+       VectorScale(lightcolorshirt, ambientscale * 2 * r_refdef.view.colorscale, ambientcolorshirt);
+       VectorScale(lightcolorshirt, diffusescale * 2 * r_refdef.view.colorscale, diffusecolorshirt);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
        memset(&m, 0, sizeof(m));
@@ -2583,15 +2583,15 @@ void R_Shadow_ComputeShadowCasterCullingPlanes(rtlight_t *rtlight)
        rsurface.rtlight_numfrustumplanes = 0;
 
        // haven't implemented a culling path for ortho rendering
-       if (!r_view.useperspective)
+       if (!r_refdef.view.useperspective)
        {
                // check if the light is on screen and copy the 4 planes if it is
                for (i = 0;i < 4;i++)
-                       if (PlaneDiff(rtlight->shadoworigin, &r_view.frustum[i]) < -0.03125)
+                       if (PlaneDiff(rtlight->shadoworigin, &r_refdef.view.frustum[i]) < -0.03125)
                                break;
                if (i == 4)
                        for (i = 0;i < 4;i++)
-                               rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_view.frustum[i];
+                               rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_refdef.view.frustum[i];
                return;
        }
 
@@ -2610,10 +2610,10 @@ void R_Shadow_ComputeShadowCasterCullingPlanes(rtlight_t *rtlight)
        {
                // quickly reject standard frustum planes that put the light
                // origin outside the frustum
-               if (PlaneDiff(rtlight->shadoworigin, &r_view.frustum[i]) < -0.03125)
+               if (PlaneDiff(rtlight->shadoworigin, &r_refdef.view.frustum[i]) < -0.03125)
                        continue;
                // copy the plane
-               rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_view.frustum[i];
+               rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_refdef.view.frustum[i];
        }
        // if all the standard frustum planes were accepted, the light is onscreen
        // otherwise we need to generate some more planes below...
@@ -2625,12 +2625,12 @@ void R_Shadow_ComputeShadowCasterCullingPlanes(rtlight_t *rtlight)
                {
                        // create a plane using the view origin and light origin, and a
                        // single point from the frustum corner set
-                       TriangleNormal(r_view.origin, r_view.frustumcorner[i], rtlight->shadoworigin, plane.normal);
+                       TriangleNormal(r_refdef.view.origin, r_refdef.view.frustumcorner[i], rtlight->shadoworigin, plane.normal);
                        VectorNormalize(plane.normal);
-                       plane.dist = DotProduct(r_view.origin, plane.normal);
+                       plane.dist = DotProduct(r_refdef.view.origin, plane.normal);
                        // see if this plane is backwards and flip it if so
                        for (j = 0;j < 4;j++)
-                               if (j != i && DotProduct(r_view.frustumcorner[j], plane.normal) - plane.dist < -0.03125)
+                               if (j != i && DotProduct(r_refdef.view.frustumcorner[j], plane.normal) - plane.dist < -0.03125)
                                        break;
                        if (j < 4)
                        {
@@ -2638,7 +2638,7 @@ void R_Shadow_ComputeShadowCasterCullingPlanes(rtlight_t *rtlight)
                                plane.dist *= -1;
                                // flipped plane, test again to see if it is now valid
                                for (j = 0;j < 4;j++)
-                                       if (j != i && DotProduct(r_view.frustumcorner[j], plane.normal) - plane.dist < -0.03125)
+                                       if (j != i && DotProduct(r_refdef.view.frustumcorner[j], plane.normal) - plane.dist < -0.03125)
                                                break;
                                // if the plane is still not valid, then it is dividing the
                                // frustum and has to be rejected
@@ -2664,7 +2664,7 @@ void R_Shadow_ComputeShadowCasterCullingPlanes(rtlight_t *rtlight)
        for (i = 0;i < rsurface.rtlight_numfrustumplanes;i++)
        {
                plane = rsurface.rtlight_frustumplanes[i];
-               Con_Printf("light %p plane #%i %f %f %f : %f (%f %f %f %f %f)\n", rtlight, i, plane.normal[0], plane.normal[1], plane.normal[2], plane.dist, PlaneDiff(r_view.frustumcorner[0], &plane), PlaneDiff(r_view.frustumcorner[1], &plane), PlaneDiff(r_view.frustumcorner[2], &plane), PlaneDiff(r_view.frustumcorner[3], &plane), PlaneDiff(rtlight->shadoworigin, &plane));
+               Con_Printf("light %p plane #%i %f %f %f : %f (%f %f %f %f %f)\n", rtlight, i, plane.normal[0], plane.normal[1], plane.normal[2], plane.dist, PlaneDiff(r_refdef.view.frustumcorner[0], &plane), PlaneDiff(r_refdef.view.frustumcorner[1], &plane), PlaneDiff(r_refdef.view.frustumcorner[2], &plane), PlaneDiff(r_refdef.view.frustumcorner[3], &plane), PlaneDiff(rtlight->shadoworigin, &plane));
        }
 #endif
 
@@ -2754,11 +2754,11 @@ void R_Shadow_DrawWorldShadow(int numsurfaces, int *surfacelist, const unsigned
                        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCIL)
                        {
                                // decrement stencil if backface is behind depthbuffer
-                               GL_CullFace(r_view.cullface_front);
+                               GL_CullFace(r_refdef.view.cullface_front);
                                qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
                                R_Mesh_Draw(0, mesh->numverts, mesh->numtriangles, mesh->element3i, mesh->ebo, 0);
                                // increment stencil if frontface is behind depthbuffer
-                               GL_CullFace(r_view.cullface_back);
+                               GL_CullFace(r_refdef.view.cullface_back);
                                qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
                        }
                        R_Mesh_Draw(0, mesh->numverts, mesh->numtriangles, mesh->element3i, mesh->ebo, 0);
@@ -2935,7 +2935,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
        if (numleafs)
        {
                for (i = 0;i < numleafs;i++)
-                       if (r_viewcache.world_leafvisible[leaflist[i]])
+                       if (r_refdef.viewcache.world_leafvisible[leaflist[i]])
                                break;
                if (i == numleafs)
                        return;
@@ -2967,7 +2967,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
                                continue;
                        if (!(model = ent->model))
                                continue;
-                       if (r_viewcache.entityvisible[i] && model->DrawLight && (ent->flags & RENDER_LIGHT))
+                       if (r_refdef.viewcache.entityvisible[i] && model->DrawLight && (ent->flags & RENDER_LIGHT))
                        {
                                // this entity wants to receive light, is visible, and is
                                // inside the light box
@@ -3030,7 +3030,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
        // count this light in the r_speeds
        r_refdef.stats.lights++;
 
-       if (r_showshadowvolumes.integer && r_view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
+       if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
        {
                // optionally draw visible shape of the shadow volumes
                // for performance analysis by level designers
@@ -3061,7 +3061,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
 
                        // optionally draw the illuminated areas
                        // for performance analysis by level designers
-                       if (r_showlighting.integer && r_view.showdebug)
+                       if (r_showlighting.integer && r_refdef.view.showdebug)
                        {
                                R_Shadow_RenderMode_VisibleLighting(!r_showdisabledepthtest.integer, false);
                                for (i = 0;i < numlightentities_noselfshadow;i++)
@@ -3084,7 +3084,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
 
                        // optionally draw the illuminated areas
                        // for performance analysis by level designers
-                       if (r_showlighting.integer && r_view.showdebug)
+                       if (r_showlighting.integer && r_refdef.view.showdebug)
                        {
                                R_Shadow_RenderMode_VisibleLighting(!r_showdisabledepthtest.integer, false);
                                if (numsurfaces)
@@ -3109,7 +3109,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
 
                        // optionally draw the illuminated areas
                        // for performance analysis by level designers
-                       if (r_showlighting.integer && r_view.showdebug)
+                       if (r_showlighting.integer && r_refdef.view.showdebug)
                        {
                                R_Shadow_RenderMode_VisibleLighting(false, false);
                                if (numsurfaces)
@@ -3165,7 +3165,7 @@ void R_ShadowVolumeLighting(qboolean visible)
 
 extern void R_SetupView(void);
 extern cvar_t r_shadows_throwdistance;
-void R_DrawModelShadows(renderscene_t* scene)
+void R_DrawModelShadows(void)
 {
        int i;
        float relativethrowdistance;
@@ -3179,7 +3179,7 @@ void R_DrawModelShadows(renderscene_t* scene)
                return;
 
        CHECKGLERROR
-       GL_Scissor(scene->view.x, scene->view.y, scene->view.width, scene->view.height);
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
 
        r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE;
 
@@ -3192,9 +3192,9 @@ void R_DrawModelShadows(renderscene_t* scene)
 
        R_Shadow_RenderMode_StencilShadowVolumes(true);
 
-       for (i = 0;i < scene->refdef.numentities;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               ent = scene->refdef.entities[i];
+               ent = r_refdef.entities[i];
                // cast shadows from anything that is not a submodel of the map
                if (ent->model && ent->model->DrawShadowVolume != NULL && !ent->model->brush.submodel && (ent->flags & RENDER_SHADOW))
                {
@@ -3219,8 +3219,8 @@ void R_DrawModelShadows(renderscene_t* scene)
 
        // set up ortho view for rendering this pass
        GL_SetupView_Mode_Ortho(0, 0, 1, 1, -10, 100);
-       GL_Scissor(scene->view.x, scene->view.y, scene->view.width, scene->view.height);
-       GL_ColorMask(scene->view.colormask[0], scene->view.colormask[1], scene->view.colormask[2], 1);
+       GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_ScissorTest(true);
        R_Mesh_Matrix(&identitymatrix);
        R_Mesh_ResetTextureState();
@@ -3234,7 +3234,7 @@ void R_DrawModelShadows(renderscene_t* scene)
        GL_DepthMask(false);
        GL_PolygonOffset(0, 0);CHECKGLERROR
        GL_Color(0, 0, 0, 0.5);
-       GL_ColorMask(scene->view.colormask[0], scene->view.colormask[1], scene->view.colormask[2], 1);
+       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        qglDepthFunc(GL_ALWAYS);CHECKGLERROR
        qglEnable(GL_STENCIL_TEST);CHECKGLERROR
        qglStencilMask(~0);CHECKGLERROR
@@ -3277,11 +3277,11 @@ void R_DrawCoronas(void)
                        continue;
                cscale = rtlight->corona * r_coronas.value* 0.25f;
                scale = rtlight->radius * rtlight->coronasizescale;
-               if (VectorDistance2(rtlight->shadoworigin, r_view.origin) < 16.0f * 16.0f)
+               if (VectorDistance2(rtlight->shadoworigin, r_refdef.view.origin) < 16.0f * 16.0f)
                        continue;
-               if (CL_Move(r_view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+               if (CL_Move(r_refdef.view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
                        continue;
-               R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+               R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
        }
        for (i = 0;i < r_refdef.numlights;i++)
        {
@@ -3290,7 +3290,7 @@ void R_DrawCoronas(void)
                        continue;
                if (rtlight->corona <= 0)
                        continue;
-               if (VectorDistance2(rtlight->shadoworigin, r_view.origin) < 32.0f * 32.0f)
+               if (VectorDistance2(rtlight->shadoworigin, r_refdef.view.origin) < 32.0f * 32.0f)
                        continue;
                if (gl_flashblend.integer)
                {
@@ -3304,9 +3304,9 @@ void R_DrawCoronas(void)
                }
                if (VectorLength(rtlight->color) * cscale < (1.0f / 256.0f))
                        continue;
-               if (CL_Move(r_view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+               if (CL_Move(r_refdef.view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
                        continue;
-               R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+               R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
        }
 }
 
@@ -3507,7 +3507,7 @@ void R_Shadow_SelectLight(dlight_t *light)
 void R_Shadow_DrawCursor_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 {
        // this is never batched (there can be only one)
-       R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, r_editlights_sprcursor->tex, r_editlights_sprcursor->tex, false, false, r_editlights_cursorlocation, r_view.right, r_view.up, EDLIGHTSPRSIZE, -EDLIGHTSPRSIZE, -EDLIGHTSPRSIZE, EDLIGHTSPRSIZE, 1, 1, 1, 1);
+       R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, r_editlights_sprcursor->tex, r_editlights_sprcursor->tex, false, false, r_editlights_cursorlocation, r_refdef.view.right, r_refdef.view.up, EDLIGHTSPRSIZE, -EDLIGHTSPRSIZE, -EDLIGHTSPRSIZE, EDLIGHTSPRSIZE, 1, 1, 1, 1);
 }
 
 void R_Shadow_DrawLightSprite_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
@@ -3537,10 +3537,10 @@ void R_Shadow_DrawLightSprite_TransparentCallback(const entity_render_t *ent, co
                pic = r_editlights_sprnoshadowlight;
        else
                pic = r_editlights_sprlight;
-       R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, pic->tex, pic->tex, false, false, light->origin, r_view.right, r_view.up, s, -s, -s, s, spritecolor[0], spritecolor[1], spritecolor[2], 1);
+       R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, pic->tex, pic->tex, false, false, light->origin, r_refdef.view.right, r_refdef.view.up, s, -s, -s, s, spritecolor[0], spritecolor[1], spritecolor[2], 1);
        // draw selection sprite if light is selected
        if (light->selected)
-               R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, r_editlights_sprselection->tex, r_editlights_sprselection->tex, false, false, light->origin, r_view.right, r_view.up, s, -s, -s, s, 1, 1, 1, 1);
+               R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, r_editlights_sprselection->tex, r_editlights_sprselection->tex, false, false, light->origin, r_refdef.view.right, r_refdef.view.up, s, -s, -s, s, 1, 1, 1, 1);
        // VorteX todo: add normalmode/realtime mode light overlay sprites?
 }
 
@@ -3570,12 +3570,12 @@ void R_Shadow_SelectLightInView(void)
                light = Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex);
                if (!light)
                        continue;
-               VectorSubtract(light->origin, r_view.origin, temp);
-               rating = (DotProduct(temp, r_view.forward) / sqrt(DotProduct(temp, temp)));
+               VectorSubtract(light->origin, r_refdef.view.origin, temp);
+               rating = (DotProduct(temp, r_refdef.view.forward) / sqrt(DotProduct(temp, temp)));
                if (rating >= 0.95)
                {
                        rating /= (1 + 0.0625f * sqrt(DotProduct(temp, temp)));
-                       if (bestrating < rating && CL_Move(light->origin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1.0f)
+                       if (bestrating < rating && CL_Move(light->origin, vec3_origin, vec3_origin, r_refdef.view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1.0f)
                        {
                                bestrating = rating;
                                best = light;
@@ -4007,8 +4007,8 @@ void R_Shadow_SetCursorLocationForView(void)
        vec_t dist, push;
        vec3_t dest, endpos;
        trace_t trace;
-       VectorMA(r_view.origin, r_editlights_cursordistance.value, r_view.forward, dest);
-       trace = CL_Move(r_view.origin, vec3_origin, vec3_origin, dest, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false);
+       VectorMA(r_refdef.view.origin, r_editlights_cursordistance.value, r_refdef.view.forward, dest);
+       trace = CL_Move(r_refdef.view.origin, vec3_origin, vec3_origin, dest, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false);
        if (trace.fraction < 1)
        {
                dist = trace.fraction * r_editlights_cursordistance.value;
@@ -4016,7 +4016,7 @@ void R_Shadow_SetCursorLocationForView(void)
                if (push > dist)
                        push = dist;
                push = -push;
-               VectorMA(trace.endpos, push, r_view.forward, endpos);
+               VectorMA(trace.endpos, push, r_refdef.view.forward, endpos);
                VectorMA(endpos, r_editlights_cursorpushoff.value, trace.plane.normal, endpos);
        }
        else
diff --git a/r_sky.c b/r_sky.c
index 0933f939127decf48e38a0756a9f82288af1b295..a4f5628c1f3f3f0a4cdaa0beabaabdd00977fbd8 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -268,8 +268,8 @@ static const int skyboxelements[6*2*3] =
 static void R_SkyBox(void)
 {
        int i;
-       // FIXME: fixed function path can't properly handle r_view.colorscale > 1
-       GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
+       // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
+       GL_Color(1 * r_refdef.view.colorscale, 1 * r_refdef.view.colorscale, 1 * r_refdef.view.colorscale, 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_CullFace(GL_NONE);
        GL_DepthMask(false);
@@ -381,8 +381,8 @@ static void R_SkySphere(void)
        speedscale -= (int)speedscale;
        Matrix4x4_CreateTranslate(&scroll2matrix, speedscale, speedscale, 0);
 
-       // FIXME: fixed function path can't properly handle r_view.colorscale > 1
-       GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
+       // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
+       GL_Color(1 * r_refdef.view.colorscale, 1 * r_refdef.view.colorscale, 1 * r_refdef.view.colorscale, 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_CullFace(GL_NONE);
        GL_DepthMask(true);
@@ -395,7 +395,7 @@ static void R_SkySphere(void)
        R_Mesh_TexBind(0, R_GetTexture(r_refdef.worldmodel->brush.solidskytexture));
        R_Mesh_TexCoordPointer(0, 2, skysphere_texcoord2f, 0, 0);
        R_Mesh_TexMatrix(0, &scroll1matrix);
-       if (r_textureunits.integer >= 2 && r_view.colorscale == 1)
+       if (r_textureunits.integer >= 2 && r_refdef.view.colorscale == 1)
        {
                // one pass using GL_DECAL or GL_INTERPOLATE_ARB for alpha layer
                R_Mesh_TexBind(1, R_GetTexture(r_refdef.worldmodel->brush.alphaskytexture));
@@ -437,7 +437,7 @@ void R_Sky(void)
        matrix4x4_t skymatrix;
        if (skyrendermasked)
        {
-               Matrix4x4_CreateTranslate(&skymatrix, r_view.origin[0], r_view.origin[1], r_view.origin[2]);
+               Matrix4x4_CreateTranslate(&skymatrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2]);
                R_Mesh_Matrix(&skymatrix);
                if (skyrendersphere)
                {
index b41041bdc9d2df4954ba588c6875aa22da742f4f..e1a8b180624ce80ea0debc3fac880317eab5ea19 100644 (file)
@@ -38,16 +38,16 @@ void R_TrackSprite(const entity_render_t *ent, vec3_t origin, vec3_t left, vec3_
        unsigned int i;
 
        // temporarily abuse bCoord as the vector player->sprite-origin
-       VectorSubtract(origin, r_view.origin, bCoord);
+       VectorSubtract(origin, r_refdef.view.origin, bCoord);
        distance = VectorLength(bCoord);
 
        // Now get the bCoords :)
-       Matrix4x4_Transform(&r_view.inverse_matrix, origin, bCoord);
+       Matrix4x4_Transform(&r_refdef.view.inverse_matrix, origin, bCoord);
 
        *edge = 0; // FIXME::should assume edge == 0, which is correct currently
        for(i = 0; i < 4; ++i)
        {
-               if(PlaneDiff(origin, &r_view.frustum[i]) < -EPSILON)
+               if(PlaneDiff(origin, &r_refdef.view.frustum[i]) < -EPSILON)
                        break;
        }
 
@@ -58,8 +58,8 @@ void R_TrackSprite(const entity_render_t *ent, vec3_t origin, vec3_t left, vec3_
                float ax, ay;  // absolute coords, used for division
                // I divide x and y by the greater absolute value to get ranges -1.0 to +1.0
                
-               bCoord[2] *= r_view.frustum_x;
-               bCoord[1] *= r_view.frustum_y;
+               bCoord[2] *= r_refdef.view.frustum_x;
+               bCoord[1] *= r_refdef.view.frustum_y;
 
                //Con_Printf("%f %f %f\n", bCoord[0], bCoord[1], bCoord[2]);
                
@@ -107,16 +107,16 @@ void R_TrackSprite(const entity_render_t *ent, vec3_t origin, vec3_t left, vec3_
                // d = sqrt(r*r / (1 + fxa*fxa + gyb*gyb))
                // thus:
                distance = sqrt((distance*distance) / (1.0 +
-                                       r_view.frustum_x*r_view.frustum_x * x*x * ax*ax +
-                                       r_view.frustum_y*r_view.frustum_y * y*y * ay*ay));
+                                       r_refdef.view.frustum_x*r_refdef.view.frustum_x * x*x * ax*ax +
+                                       r_refdef.view.frustum_y*r_refdef.view.frustum_y * y*y * ay*ay));
                // ^ the one we want        ^ the one we have       ^ our factors
                
                // Place the sprite a few units ahead of the player
-               VectorCopy(r_view.origin, origin);
-               VectorMA(origin, distance, r_view.forward, origin);
+               VectorCopy(r_refdef.view.origin, origin);
+               VectorMA(origin, distance, r_refdef.view.forward, origin);
                // Move the sprite left / up the screeen height
-               VectorMA(origin, distance * r_view.frustum_x * x * ax, left, origin);
-               VectorMA(origin, distance * r_view.frustum_y * y * ay, up, origin);
+               VectorMA(origin, distance * r_refdef.view.frustum_x * x * ax, left, origin);
+               VectorMA(origin, distance * r_refdef.view.frustum_y * y * ay, up, origin);
 
                if(r_track_sprites_flags.integer & TSF_ROTATE_CONTINOUSLY)
                {
@@ -186,7 +186,7 @@ void R_RotateSprite(const mspriteframe_t *frame, vec3_t origin, vec3_t left, vec
                        angle += 180.0f;
 
                // Rotate around rotation_angle - frame_angle
-               // The axis SHOULD equal r_view.forward, but let's generalize this:
+               // The axis SHOULD equal r_refdef.view.forward, but let's generalize this:
                CrossProduct(up, left, axis);
                if(r_track_sprites_flags.integer & TSF_ROTATE_CONTINOUSLY)
                        Matrix4x4_CreateRotate(&rotm, dir_angle - angle, axis[0], axis[1], axis[2]);
@@ -210,15 +210,15 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
 
        // nudge it toward the view to make sure it isn't in a wall
        Matrix4x4_ToVectors(&ent->matrix, mforward, mleft, mup, org);
-       VectorSubtract(org, r_view.forward, org);
+       VectorSubtract(org, r_refdef.view.forward, org);
        switch(model->sprite.sprnum_type)
        {
        case SPR_VP_PARALLEL_UPRIGHT:
                // flames and such
                // vertical beam sprite, faces view plane
-               scale = ent->scale / sqrt(r_view.forward[0]*r_view.forward[0]+r_view.forward[1]*r_view.forward[1]);
-               left[0] = -r_view.forward[1] * scale;
-               left[1] = r_view.forward[0] * scale;
+               scale = ent->scale / sqrt(r_refdef.view.forward[0]*r_refdef.view.forward[0]+r_refdef.view.forward[1]*r_refdef.view.forward[1]);
+               left[0] = -r_refdef.view.forward[1] * scale;
+               left[1] = r_refdef.view.forward[0] * scale;
                left[2] = 0;
                up[0] = 0;
                up[1] = 0;
@@ -227,9 +227,9 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
        case SPR_FACING_UPRIGHT:
                // flames and such
                // vertical beam sprite, faces viewer's origin (not the view plane)
-               scale = ent->scale / sqrt((org[0] - r_view.origin[0])*(org[0] - r_view.origin[0])+(org[1] - r_view.origin[1])*(org[1] - r_view.origin[1]));
-               left[0] = (org[1] - r_view.origin[1]) * scale;
-               left[1] = -(org[0] - r_view.origin[0]) * scale;
+               scale = ent->scale / sqrt((org[0] - r_refdef.view.origin[0])*(org[0] - r_refdef.view.origin[0])+(org[1] - r_refdef.view.origin[1])*(org[1] - r_refdef.view.origin[1]));
+               left[0] = (org[1] - r_refdef.view.origin[1]) * scale;
+               left[1] = -(org[0] - r_refdef.view.origin[0]) * scale;
                left[2] = 0;
                up[0] = 0;
                up[1] = 0;
@@ -241,8 +241,8 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
        case SPR_VP_PARALLEL:
                // normal sprite
                // faces view plane
-               VectorScale(r_view.left, ent->scale, left);
-               VectorScale(r_view.up, ent->scale, up);
+               VectorScale(r_refdef.view.left, ent->scale, left);
+               VectorScale(r_refdef.view.up, ent->scale, up);
                break;
        case SPR_LABEL_SCALE:
                // normal sprite
@@ -252,15 +252,15 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                // honors a global label scaling cvar
 
                // See the R_TrackSprite definition for a reason for this copying
-               VectorCopy(r_view.left, left);
-               VectorCopy(r_view.up, up);
+               VectorCopy(r_refdef.view.left, left);
+               VectorCopy(r_refdef.view.up, up);
                // It has to be done before the calculations, because it moves the origin.
                if(r_track_sprites.integer)
                        R_TrackSprite(ent, org, left, up, &edge, &dir_angle);
                
-               scale = 2 * ent->scale * (DotProduct(r_view.forward, org) - DotProduct(r_view.forward, r_view.origin)) * r_labelsprites_scale.value;
-               VectorScale(left, scale * r_view.frustum_x / vid_conwidth.integer, left); // 1px
-               VectorScale(up, scale * r_view.frustum_y / vid_conheight.integer, up); // 1px
+               scale = 2 * ent->scale * (DotProduct(r_refdef.view.forward, org) - DotProduct(r_refdef.view.forward, r_refdef.view.origin)) * r_labelsprites_scale.value;
+               VectorScale(left, scale * r_refdef.view.frustum_x / vid_conwidth.integer, left); // 1px
+               VectorScale(up, scale * r_refdef.view.frustum_y / vid_conheight.integer, up); // 1px
                break;
        case SPR_LABEL:
                // normal sprite
@@ -272,19 +272,19 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                // FIXME assumes that 1qu is 1 pixel in the sprite like in SPR32 format. Should not do that, but instead query the source image! This bug only applies to the roundtopixels case, though.
 
                // See the R_TrackSprite definition for a reason for this copying
-               VectorCopy(r_view.left, left);
-               VectorCopy(r_view.up, up);
+               VectorCopy(r_refdef.view.left, left);
+               VectorCopy(r_refdef.view.up, up);
                // It has to be done before the calculations, because it moves the origin.
                if(r_track_sprites.integer)
                        R_TrackSprite(ent, org, left, up, &edge, &dir_angle);
                
-               scale = 2 * (DotProduct(r_view.forward, org) - DotProduct(r_view.forward, r_view.origin));
+               scale = 2 * (DotProduct(r_refdef.view.forward, org) - DotProduct(r_refdef.view.forward, r_refdef.view.origin));
 
                if(r_labelsprites_roundtopixels.integer)
                {
                        hud_vs_screen = max(
-                               vid_conwidth.integer / (float) r_view.width,
-                               vid_conheight.integer / (float) r_view.height
+                               vid_conwidth.integer / (float) r_refdef.view.width,
+                               vid_conheight.integer / (float) r_refdef.view.height
                        ) / max(0.125, r_labelsprites_scale.value);
 
                        // snap to "good sizes"
@@ -302,29 +302,29 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                        if(hud_vs_screen)
                        {
                                // use screen pixels
-                               VectorScale(left, scale * r_view.frustum_x / (r_view.width * hud_vs_screen), left); // 1px
-                               VectorScale(up, scale * r_view.frustum_y / (r_view.height * hud_vs_screen), up); // 1px
+                               VectorScale(left, scale * r_refdef.view.frustum_x / (r_refdef.view.width * hud_vs_screen), left); // 1px
+                               VectorScale(up, scale * r_refdef.view.frustum_y / (r_refdef.view.height * hud_vs_screen), up); // 1px
                        }
                        else
                        {
                                // use HUD pixels
-                               VectorScale(left, scale * r_view.frustum_x / vid_conwidth.integer * r_labelsprites_scale.value, left); // 1px
-                               VectorScale(up, scale * r_view.frustum_y / vid_conheight.integer * r_labelsprites_scale.value, up); // 1px
+                               VectorScale(left, scale * r_refdef.view.frustum_x / vid_conwidth.integer * r_labelsprites_scale.value, left); // 1px
+                               VectorScale(up, scale * r_refdef.view.frustum_y / vid_conheight.integer * r_labelsprites_scale.value, up); // 1px
                        }
 
                        if(hud_vs_screen == 1)
                        {
-                               VectorMA(r_view.origin, scale, r_view.forward, middle); // center of screen in distance scale
-                               dx = 0.5 - fmod(r_view.width * 0.5 + (DotProduct(org, left) - DotProduct(middle, left)) / DotProduct(left, left) + 0.5, 1.0);
-                               dy = 0.5 - fmod(r_view.height * 0.5 + (DotProduct(org, up) - DotProduct(middle, up)) / DotProduct(up, up) + 0.5, 1.0);
+                               VectorMA(r_refdef.view.origin, scale, r_refdef.view.forward, middle); // center of screen in distance scale
+                               dx = 0.5 - fmod(r_refdef.view.width * 0.5 + (DotProduct(org, left) - DotProduct(middle, left)) / DotProduct(left, left) + 0.5, 1.0);
+                               dy = 0.5 - fmod(r_refdef.view.height * 0.5 + (DotProduct(org, up) - DotProduct(middle, up)) / DotProduct(up, up) + 0.5, 1.0);
                                VectorMAMAM(1, org, dx, left, dy, up, org);
                        }
                }
                else
                {
                        // use HUD pixels
-                       VectorScale(left, scale * r_view.frustum_x / vid_conwidth.integer * r_labelsprites_scale.value, left); // 1px
-                       VectorScale(up, scale * r_view.frustum_y / vid_conheight.integer * r_labelsprites_scale.value, up); // 1px
+                       VectorScale(left, scale * r_refdef.view.frustum_x / vid_conwidth.integer * r_labelsprites_scale.value, left); // 1px
+                       VectorScale(up, scale * r_refdef.view.frustum_y / vid_conheight.integer * r_labelsprites_scale.value, up); // 1px
                }
                break;
        case SPR_ORIENTED:
@@ -337,12 +337,12 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                // I have no idea what people would use this for...
                // oriented relative to view space
                // FIXME: test this and make sure it mimicks software
-               left[0] = mleft[0] * r_view.forward[0] + mleft[1] * r_view.left[0] + mleft[2] * r_view.up[0];
-               left[1] = mleft[0] * r_view.forward[1] + mleft[1] * r_view.left[1] + mleft[2] * r_view.up[1];
-               left[2] = mleft[0] * r_view.forward[2] + mleft[1] * r_view.left[2] + mleft[2] * r_view.up[2];
-               up[0] = mup[0] * r_view.forward[0] + mup[1] * r_view.left[0] + mup[2] * r_view.up[0];
-               up[1] = mup[0] * r_view.forward[1] + mup[1] * r_view.left[1] + mup[2] * r_view.up[1];
-               up[2] = mup[0] * r_view.forward[2] + mup[1] * r_view.left[2] + mup[2] * r_view.up[2];
+               left[0] = mleft[0] * r_refdef.view.forward[0] + mleft[1] * r_refdef.view.left[0] + mleft[2] * r_refdef.view.up[0];
+               left[1] = mleft[0] * r_refdef.view.forward[1] + mleft[1] * r_refdef.view.left[1] + mleft[2] * r_refdef.view.up[1];
+               left[2] = mleft[0] * r_refdef.view.forward[2] + mleft[1] * r_refdef.view.left[2] + mleft[2] * r_refdef.view.up[2];
+               up[0] = mup[0] * r_refdef.view.forward[0] + mup[1] * r_refdef.view.left[0] + mup[2] * r_refdef.view.up[0];
+               up[1] = mup[0] * r_refdef.view.forward[1] + mup[1] * r_refdef.view.left[1] + mup[2] * r_refdef.view.up[1];
+               up[2] = mup[0] * r_refdef.view.forward[2] + mup[1] * r_refdef.view.left[2] + mup[2] * r_refdef.view.up[2];
                break;
        }
 
@@ -399,6 +399,6 @@ void R_Model_Sprite_Draw(entity_render_t *ent)
                return;
 
        Matrix4x4_OriginFromMatrix(&ent->matrix, org);
-       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : org, R_Model_Sprite_Draw_TransparentCallback, ent, 0, rsurface.rtlight);
+       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_refdef.view.origin : org, R_Model_Sprite_Draw_TransparentCallback, ent, 0, rsurface.rtlight);
 }
 
index 4982b4a44002774aab6d020a9493e2221126904b..49d3c3620aa4a2f1e203a11f78f90bf0e948b8be 100644 (file)
--- a/render.h
+++ b/render.h
@@ -121,8 +121,8 @@ extern cvar_t r_wateralpha;
 extern cvar_t r_dynamic;
 
 void R_Init(void);
-void R_UpdateVariables(renderscene_t* scene); // must call after setting up most of r_refdef, but before calling R_RenderView
-void R_RenderView(renderscene_t* scene); // must set r_refdef and call R_UpdateVariables first
+void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView
+void R_RenderView(void); // must set r_refdef and call R_UpdateVariables first
 
 
 void R_InitSky (unsigned char *src, int bytesperpixel); // called at level load
index 1e36c7683e199809d5015d15b19bb6224cbfbca8..c9f6c1e7635dfcc8c84650d47aed5c08b6463caa 100644 (file)
@@ -155,7 +155,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &outputDeviceID);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioHardwarePropertyDefaultOutputDevice\n", status);
+               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioHardwarePropertyDefaultOutputDevice\n", (int)status);
                return false;
        }
        if (outputDeviceID == kAudioDeviceUnknown)
@@ -170,7 +170,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioDeviceSetProperty(outputDeviceID, NULL, 0, false, kAudioDevicePropertyBufferSize, propertySize, &bufferByteCount);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceSetProperty() returned %d when setting kAudioDevicePropertyBufferSize to %d\n", status, CHUNK_SIZE);
+               Con_Printf("CoreAudio: AudioDeviceSetProperty() returned %d when setting kAudioDevicePropertyBufferSize to %d\n", (int)status, CHUNK_SIZE);
                return false;
        }
 
@@ -178,7 +178,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioDeviceGetProperty(outputDeviceID, 0, false, kAudioDevicePropertyBufferSize, &propertySize, &bufferByteCount);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when setting kAudioDevicePropertyBufferSize\n", status);
+               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when setting kAudioDevicePropertyBufferSize\n", (int)status);
                return false;
        }
 
@@ -196,22 +196,22 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioDeviceGetProperty(outputDeviceID, 0, false, kAudioDevicePropertyStreamFormat, &propertySize, &streamDesc);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioDevicePropertyStreamFormat\n", status);
+               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioDevicePropertyStreamFormat\n", (int)status);
                return false;
        }
 
        Con_DPrint ("   Hardware format:\n");
        Con_DPrintf("    %5d mSampleRate\n", (unsigned int)streamDesc.mSampleRate);
        Con_DPrintf("     %c%c%c%c mFormatID\n",
-                               (streamDesc.mFormatID & 0xff000000) >> 24,
-                               (streamDesc.mFormatID & 0x00ff0000) >> 16,
-                               (streamDesc.mFormatID & 0x0000ff00) >>  8,
-                               (streamDesc.mFormatID & 0x000000ff) >>  0);
-       Con_DPrintf("    %5d mBytesPerPacket\n", streamDesc.mBytesPerPacket);
-       Con_DPrintf("    %5d mFramesPerPacket\n", streamDesc.mFramesPerPacket);
-       Con_DPrintf("    %5d mBytesPerFrame\n", streamDesc.mBytesPerFrame);
-       Con_DPrintf("    %5d mChannelsPerFrame\n", streamDesc.mChannelsPerFrame);
-       Con_DPrintf("    %5d mBitsPerChannel\n", streamDesc.mBitsPerChannel);
+                               (char)(streamDesc.mFormatID >> 24),
+                               (char)(streamDesc.mFormatID >> 16),
+                               (char)(streamDesc.mFormatID >>  8),
+                               (char)(streamDesc.mFormatID >>  0));
+       Con_DPrintf("    %5u mBytesPerPacket\n", (unsigned int)streamDesc.mBytesPerPacket);
+       Con_DPrintf("    %5u mFramesPerPacket\n", (unsigned int)streamDesc.mFramesPerPacket);
+       Con_DPrintf("    %5u mBytesPerFrame\n", (unsigned int)streamDesc.mBytesPerFrame);
+       Con_DPrintf("    %5u mChannelsPerFrame\n", (unsigned int)streamDesc.mChannelsPerFrame);
+       Con_DPrintf("    %5u mBitsPerChannel\n", (unsigned int)streamDesc.mBitsPerChannel);
 
        // Suggest proper settings if they differ
        if (requested->channels != streamDesc.mChannelsPerFrame || requested->speed != streamDesc.mSampleRate)
@@ -235,7 +235,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioDeviceAddIOProc(outputDeviceID, audioDeviceIOProc, NULL);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceAddIOProc() returned %d\n", status);
+               Con_Printf("CoreAudio: AudioDeviceAddIOProc() returned %d\n", (int)status);
                return false;
        }
 
@@ -255,7 +255,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        status = AudioDeviceStart(outputDeviceID, audioDeviceIOProc);
        if (status)
        {
-               Con_Printf("CoreAudio: AudioDeviceStart() returned %d\n", status);
+               Con_Printf("CoreAudio: AudioDeviceStart() returned %d\n", (int)status);
                pthread_mutex_destroy(&coreaudio_mutex);
                AudioDeviceRemoveIOProc(outputDeviceID, audioDeviceIOProc);
                return false;
@@ -284,7 +284,7 @@ void SndSys_Shutdown(void)
        status = AudioDeviceStop(outputDeviceID, audioDeviceIOProc);
        if (status)
        {
-               Con_Printf("AudioDeviceStop: returned %d\n", status);
+               Con_Printf("AudioDeviceStop: returned %d\n", (int)status);
                return;
        }
        s_isRunning = false;
@@ -294,7 +294,7 @@ void SndSys_Shutdown(void)
        status = AudioDeviceRemoveIOProc(outputDeviceID, audioDeviceIOProc);
        if (status)
        {
-               Con_Printf("AudioDeviceRemoveIOProc: returned %d\n", status);
+               Con_Printf("AudioDeviceRemoveIOProc: returned %d\n", (int)status);
                return;
        }
 
diff --git a/view.c b/view.c
index a7a5c385a1d8af5a29ebd34aebec9355385bd26e..a3f684f2700f24a91bbf7c7a04f019c1e3a13b20 100644 (file)
--- a/view.c
+++ b/view.c
@@ -336,7 +336,7 @@ void V_CalcRefdef (void)
        trace_t trace;
        VectorClear(gunorg);
        viewmodelmatrix = identitymatrix;
-       r_view.matrix = identitymatrix;
+       r_refdef.view.matrix = identitymatrix;
        if (cls.state == ca_connected && cls.signon == SIGNONS)
        {
                // ent is the view entity (visible when out of body)
@@ -358,13 +358,13 @@ void V_CalcRefdef (void)
                {
                        // entity is a fixed camera, just copy the matrix
                        if (cls.protocol == PROTOCOL_QUAKEWORLD)
-                               Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, cl.qw_intermission_origin[0], cl.qw_intermission_origin[1], cl.qw_intermission_origin[2], cl.qw_intermission_angles[0], cl.qw_intermission_angles[1], cl.qw_intermission_angles[2], 1);
+                               Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, cl.qw_intermission_origin[0], cl.qw_intermission_origin[1], cl.qw_intermission_origin[2], cl.qw_intermission_angles[0], cl.qw_intermission_angles[1], cl.qw_intermission_angles[2], 1);
                        else
                        {
-                               r_view.matrix = ent->render.matrix;
-                               Matrix4x4_AdjustOrigin(&r_view.matrix, 0, 0, cl.stats[STAT_VIEWHEIGHT]);
+                               r_refdef.view.matrix = ent->render.matrix;
+                               Matrix4x4_AdjustOrigin(&r_refdef.view.matrix, 0, 0, cl.stats[STAT_VIEWHEIGHT]);
                        }
-                       viewmodelmatrix = r_view.matrix;
+                       viewmodelmatrix = r_refdef.view.matrix;
                }
                else
                {
@@ -542,14 +542,14 @@ void V_CalcRefdef (void)
                        }
                        // calculate a view matrix for rendering the scene
                        if (v_idlescale.value)
-                               Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0] + v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value, viewangles[1] + v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value, viewangles[2] + v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value, 1);
+                               Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0] + v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value, viewangles[1] + v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value, viewangles[2] + v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value, 1);
                        else
-                               Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0], viewangles[1], viewangles[2] + v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value, 1);
+                               Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, vieworg[0], vieworg[1], vieworg[2], viewangles[0], viewangles[1], viewangles[2] + v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value, 1);
                        // calculate a viewmodel matrix for use in view-attached entities
                        Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, gunorg[0], gunorg[1], gunorg[2], viewangles[0], viewangles[1], viewangles[2], cl_viewmodel_scale.value);
                        VectorCopy(vieworg, cl.csqc_origin);
                        VectorCopy(viewangles, cl.csqc_angles);
-                       Matrix4x4_Invert_Simple(&r_view.inverse_matrix, &r_view.matrix);
+                       Matrix4x4_Invert_Simple(&r_refdef.view.inverse_matrix, &r_refdef.view.matrix);
                }
        }
 }
@@ -584,7 +584,7 @@ void V_CalcViewBlend(void)
                // set contents color
                int supercontents;
                vec3_t vieworigin;
-               Matrix4x4_OriginFromMatrix(&r_view.matrix, vieworigin);
+               Matrix4x4_OriginFromMatrix(&r_refdef.view.matrix, vieworigin);
                supercontents = CL_PointSuperContents(vieworigin);
                if (supercontents & SUPERCONTENTS_LIQUIDSMASK)
                {