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);
}
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);
}
// end of code taken from QuakeWorld
- flag = CL_NewTempEntity(&client_scene);
+ flag = CL_NewTempEntity();
if (!flag)
return;
{
// 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
}
// 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;
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);
}
}
}
d = VectorNormalizeLength(dist);
while (d > 0)
{
- ent = CL_NewTempEntity (&client_scene);
+ ent = CL_NewTempEntity ();
if (!ent)
return;
//VectorCopy (org, ent->render.origin);
// 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
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;
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;
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
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 ();
//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)
{
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)
{
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];
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);
}
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);
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);
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);
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)
{
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)
// 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
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();
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)
{
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)
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)
SCR_DrawScreen();
- r_view.matrix = originalmatrix;
+ r_refdef.view.matrix = originalmatrix;
}
else
SCR_DrawScreen();
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);
}
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
// 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,
}
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
#include "cl_collision.h"
#include "r_shadow.h"
-/* Per-VM scenes */
-renderscene_t* renderscenes[PRVM_MAXPROGS];
-#define RENDERSCENE (*renderscenes[prognum])
-
//============================================================================
// Client
//[515]: unsolved PROBLEMS
}
// #2 void(entity e, vector o) setorigin
-void VM_CL_setorigin (void)
+static void VM_CL_setorigin (void)
{
prvm_edict_t *e;
float *org;
}
// #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;
// #20 void(string s) precache_model
-void VM_CL_precache_model (void)
+static void VM_CL_precache_model (void)
{
const char *name;
int i;
//============================================================================
//[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;
//#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);
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);
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);
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;
}
//#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);
}
//============================================================================
{
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)
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)
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)
#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)
{
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;
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))
}
//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;
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)
{
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);
}
/*
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
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;
+ }
}
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__ */
}
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;
if (!model)
return false;
- e = CL_NewTempEntity(scene);
+ e = CL_NewTempEntity();
if (!e)
return false;
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;
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
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
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" };
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)
{
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)
// 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
{
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:
//==================================================================================
-static void R_View_UpdateEntityVisible (renderscene_t* scene)
+static void R_View_UpdateEntityVisible (void)
{
int i, renderimask;
entity_render_t *ent;
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;
}
}
}
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));
}
}
}
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)
}
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;
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
}
}
-static void R_DrawModelsDepth(renderscene_t* scene)
+static void R_DrawModelsDepth(void)
{
int i;
entity_render_t *ent;
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;
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;
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);
}
}
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);
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)
{
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);
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);
}
/*
"#endif // FRAGMENT_SHADER\n"
*/
-void R_RenderScene(renderscene_t* scene, qboolean addwaterplanes);
+void R_RenderScene(qboolean addwaterplanes);
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
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;
}
}
-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++)
// 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");
// 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;
}
// 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;
// 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
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;
}
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)
// 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);)
{
// 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;
}
// 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;
}
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();
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)
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)
{
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))
{
}
}
+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!
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);
}
}
-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;
}
/*
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();
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)
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");
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)
R_SkyStartFrame();
- R_View_Update(scene);
+ R_View_Update();
if (r_timereport_active)
R_TimeReport("visibility");
}
if (r_depthfirst.integer >= 2)
{
- R_DrawModelsDepth(scene);
+ R_DrawModelsDepth();
if (r_timereport_active)
R_TimeReport("modeldepth");
}
if (r_refdef.extraupdate)
S_ExtraUpdate ();
- R_DrawModels(scene);
+ R_DrawModels();
if (r_timereport_active)
R_TimeReport("models");
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)
}
VM_CL_AddPolygonsToMeshQueue();
- if (r_view.showdebug)
+ if (r_refdef.view.showdebug)
{
if (cl_locs_show.integer)
{
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");
}
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();
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)
{
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);
}
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);
{
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);
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)
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;
}
// 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]);
}
}
}
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);
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];
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);
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);
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);
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)));
}
{
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));
}
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)
// 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);
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);
}
}
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);
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);
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);
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
{
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))
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);
}
}
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);
}
}
}
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)
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);
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();
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();
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();
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;
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);
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)
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.
// 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;
}
}
}
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;
}
}
}
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)
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;
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
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
cl.csqc_usecsqclistener = false;
}
else
- S_Update(&r_view.matrix);
+ S_Update(&r_refdef.view.matrix);
CDAudio_Update();
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;
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;
MR_SetRouting (TRUE);
else
MR_SetRouting (FALSE);
-
- // FIXME: needed so cl.max_entities is set
- CL_ClearState ();
}
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;
}
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);
}
#include "quakedef.h"
#include "prvm_cmds.h"
-#include "clvm_cmds.h"
#include "menu.h"
//============================================================================
#ifdef SUPPORT_GECKO
"DP_GECKO_SUPPORT "
#endif
-"DP_QC_RENDER_SCENE"
;
/*
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
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
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();
}
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);
{
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);
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
{
// 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)
// 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);
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
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);
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;
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);
}
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
}
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
}
}
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;
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
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;
}
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++)
{
//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)
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);
{
// 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);
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)
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));
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;
}
{
// 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...
{
// 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)
{
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
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
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);
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;
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
// 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
// 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++)
// 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)
// 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)
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;
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;
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))
{
// 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();
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
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++)
{
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)
{
}
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);
}
}
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)
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?
}
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;
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;
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
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);
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);
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));
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)
{
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;
}
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]);
// 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)
{
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]);
// 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;
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;
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
// 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
// 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"
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:
// 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;
}
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);
}
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
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)
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;
}
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;
}
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)
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;
}
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;
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;
status = AudioDeviceRemoveIOProc(outputDeviceID, audioDeviceIOProc);
if (status)
{
- Con_Printf("AudioDeviceRemoveIOProc: returned %d\n", status);
+ Con_Printf("AudioDeviceRemoveIOProc: returned %d\n", (int)status);
return;
}
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)
{
// 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
{
}
// 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);
}
}
}
// 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)
{