/* ================ R_RenderScene RI.refdef must be set before the first call ================ */ void R_RenderScene( const ref_params_t *fd ) { RI.refdef = *fd; if( !cl.worldmodel && RI.drawWorld ) Host_Error( "R_RenderScene: NULL worldmodel\n" ); R_PushDlights(); R_SetupFrame(); R_SetupFrustum(); R_SetupGL(); R_Clear( ~0 ); R_MarkLeaves(); R_CheckFog(); R_DrawWorld(); CL_ExtraUpdate (); // don't let sound get messed up if going slow R_DrawEntitiesOnList(); R_DrawWaterSurfaces(); R_EndGL(); }
/* ================ R_RenderView r_refdef must be set before the first call ================ */ void R_RenderView (void) { double time1 = 0.0; double time2; GLfloat colors[4] = {(GLfloat) 0.0, (GLfloat) 0.0, (GLfloat) 1, (GLfloat) 0.20}; if (r_norefresh.value) return; if (!r_worldentity.model || !cl.worldmodel) Sys_Error ("R_RenderView: NULL worldmodel"); if (r_speeds.value) { glFinish (); time1 = Sys_FloatTime (); c_brush_polys = 0; c_alias_polys = 0; } mirror = false; if (gl_finish.value) glFinish (); R_Clear (); // render normal view /***** Experimental silly looking fog ****** ****** Use r_fullbright if you enable ****** glFogi(GL_FOG_MODE, GL_LINEAR); glFogfv(GL_FOG_COLOR, colors); glFogf(GL_FOG_END, 512.0); glEnable(GL_FOG); ********************************************/ R_RenderScene (); R_DrawViewModel (); R_DrawWaterSurfaces (); // More fog right here :) // glDisable(GL_FOG); // End of all fog code... // render mirror view R_Mirror (); R_PolyBlend (); if (r_speeds.value) { // glFinish (); time2 = Sys_FloatTime (); Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys); } }
/* ================ R_RenderView r_refdef must be set before the first call ================ */ void R_RenderView (void) { double time1 = 0, time2; if (r_norefresh.value) return; if (!r_worldentity.model || !cl.worldmodel) Sys_Error ("R_RenderView: NULL worldmodel"); if (r_speeds.value) { glFinish (); time1 = Sys_DoubleTime (); c_brush_polys = 0; c_alias_polys = 0; } mirror = false; if (gl_finish.value) glFinish (); R_Clear (); // render normal view R_RenderScene (); R_DrawViewModel (); R_DrawWaterSurfaces (); // render mirror view // R_Mirror (); R_PolyBlend (); if (r_speeds.value) { // glFinish (); time2 = Sys_DoubleTime (); Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys); } }
/* ============= R_Mirror ============= */ void R_Mirror (void) { float d; msurface_t *s; entity_t *ent; if (!mirror) return; memcpy (r_base_world_matrix, r_world_matrix, sizeof(r_base_world_matrix)); d = DotProduct (r_refdef.vieworg, mirror_plane->normal) - mirror_plane->dist; VectorMA (r_refdef.vieworg, -2*d, mirror_plane->normal, r_refdef.vieworg); d = DotProduct (vpn, mirror_plane->normal); VectorMA (vpn, -2*d, mirror_plane->normal, vpn); r_refdef.viewangles[0] = -asin (vpn[2])/M_PI*180; r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0])/M_PI*180; r_refdef.viewangles[2] = -r_refdef.viewangles[2]; ent = &cl_entities[cl.viewentity]; if (cl_numvisedicts < MAX_VISEDICTS) { cl_visedicts[cl_numvisedicts] = ent; cl_numvisedicts++; } gldepthmin = 0.5; gldepthmax = 1; glDepthRange (gldepthmin, gldepthmax); glDepthFunc (GL_LEQUAL); R_RenderScene (); R_DrawWaterSurfaces (); gldepthmin = 0; gldepthmax = 0.5; glDepthRange (gldepthmin, gldepthmax); glDepthFunc (GL_LEQUAL); // blend on top glEnable (GL_BLEND); glMatrixMode(GL_PROJECTION); if (mirror_plane->normal[2]) glScalef (1,-1,1); else glScalef (-1,1,1); glCullFace(GL_FRONT); glMatrixMode(GL_MODELVIEW); glLoadMatrixf (r_base_world_matrix); glColor4f (1,1,1,r_mirroralpha.value); s = cl.worldmodel->textures[mirrortexturenum]->texturechain; for ( ; s ; s=s->texturechain) R_RenderBrushPoly (s); cl.worldmodel->textures[mirrortexturenum]->texturechain = NULL; glDisable (GL_BLEND); glColor4f (1,1,1,1); }