void Pass::finalize() { GL_SwitchTexUnit(GL_TEXTURE0_ARB); //GL_TextureEnvMode(GL_REPLACE); if(viewer) GL_PopCamera(); //GL_Disable(GL_SCISSOR_TEST); GL_DepthMask(GL_FALSE); GL_Disable(GL_DEPTH_TEST); GL_Disable(GL_FOG); GL_Disable(GL_ALPHA_TEST); if(gfx_postProcessing.integer) { target->unmakeTarget(); } else { glScreen->unmakeTarget(); } GL_Disable(GL_LIGHTING); for(lightCount-=1;lightCount>=0;lightCount--) GL_Disable(GL_LIGHT0+lightCount); Cvar_SetVarValue(&gfx_GLSLPass, 0); glPopAttrib(); //if(gfx_postProcessing.integer && gfx_GLSLQuality.integer>1) //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboTargetBufferId); #ifdef DEBUG GLSL_catchLastError("Pass::finalize(): "); #endif }
void Pass2D::setup(GLRenderer *r) { Pass::setup(r); GL_Enable(GL_SCISSOR_TEST); GL_Disable(GL_LIGHTING); GL_Disable(GL_DEPTH_TEST); GL_Disable(GL_CULL_FACE); GL_Enable(GL_BLEND); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 0.01f); Cvar_SetVarValue(&gfx_GLSLPass, 0); GL_TexModulate(1.0); GL_UseProgram(0); GL_MatrixMode(GL_PROJECTION); GL_PushMatrix(); glLoadIdentity(); glOrtho(0, Vid_GetScreenW(), Vid_GetScreenH(), 0, -1.0, 1.0); GL_MatrixMode(GL_MODELVIEW); GL_PushMatrix(); glLoadIdentity(); #ifdef DEBUG GLSL_catchLastError("Pass2D::setup(): "); #endif }
/* ============== R_ShadowBlend Draws projection shadow(s) from stenciled volume ============== */ void R_ShadowBlend (float shadowalpha) { const vec4_t color[4] = { {0, 0, 0, shadowalpha}, {0, 0, 0, shadowalpha}, {0, 0, 0, shadowalpha}, {0, 0, 0, shadowalpha} }; static const vec3_t verts[4] = { {10, 100, 100}, {10, -100, 100}, {10, -100, -100}, {10, 100, -100} }; static const uint32_t indices[6] = { 0, 1, 2, 0, 2, 3 }; if (r_shadows->value != 3) return; GL_PushMatrix(GL_MODELVIEW); GL_LoadMatrix(GL_MODELVIEW, glState.axisRotation); GL_Disable (GL_ALPHA_TEST); GL_Enable (GL_BLEND); GL_Disable (GL_DEPTH_TEST); GL_DisableTexture(0); GL_StencilFunc(GL_NOTEQUAL, 0, 255); glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); GL_Enable(GL_STENCIL_TEST); rb_vertex = rb_index = 0; memcpy(indexArray, indices, sizeof(indices)); memcpy(vertexArray, verts, sizeof(vec3_t) * 4); memcpy(colorArray, color, sizeof(vec4_t) * 4); rb_index += 6; rb_vertex += 4; RB_RenderMeshGeneric (false); GL_PopMatrix(GL_MODELVIEW); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_Disable (GL_BLEND); GL_EnableTexture(0); GL_Enable (GL_DEPTH_TEST); GL_Disable(GL_STENCIL_TEST); //GL_Enable (GL_ALPHA_TEST); glColor4f(1,1,1,1); }
/* ============= R_DrawStretchImage ============= */ void R_DrawStretchImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *gl, float alpha) { const vec4_t color[4] = { {1.0, 1.0, 1.0, alpha}, {1.0, 1.0, 1.0, alpha}, {1.0, 1.0, 1.0, alpha}, {1.0, 1.0, 1.0, alpha} }; const vec3_t verts[4] = { {x, y, 0}, {x+w, y, 0}, {x+w, y+h, 0}, {x, y+h, 0} }; if (scrap_dirty) Scrap_Upload (); // Psychospaz's transparent console support if (gl->has_alpha || alpha < 1.0) { GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_DepthMask (false); } GL_Bind (gl->texnum); rb_vertex = rb_index = 0; memcpy(&indexArray[rb_index], indices, sizeof(indices)); rb_index = 6; Vector2Set(texCoordArray[0][0], gl->sl, gl->tl); Vector2Set(texCoordArray[0][1], gl->sh, gl->tl); Vector2Set(texCoordArray[0][2], gl->sh, gl->th); Vector2Set(texCoordArray[0][3], gl->sl, gl->th); memcpy(vertexArray, verts, sizeof(vec3_t) * 4); memcpy(colorArray[rb_vertex], color, sizeof(vec4_t) * 4); rb_vertex = 4; RB_RenderMeshGeneric (false); // Psychospaz's transparent console support if (gl->has_alpha || alpha < 1.0) { GL_DepthMask (true); GL_TexEnv (GL_REPLACE); GL_Disable (GL_BLEND); GL_Enable (GL_ALPHA_TEST); } }
void CascadedShadowPass::setup(GLRenderer *r) { if(gfx_shadowDebug.integer) target = glScreen; else target = shadowTarget; Pass::setup(r); if(!gfx_postProcessing.integer) target->makeTarget(); saveGLSLQuality = gfx_GLSLQuality.integer; saveGrass = gfx_grass.integer; saveClouds = gfx_clouds.integer; if(!canRender()) { glScreen->makeTarget(); return; } Cvar_SetVarValue(&gfx_sky, 0); Cvar_SetVarValue(&gfx_GLSLQuality, 1); Cvar_SetVarValue(&gfx_grass, 0); Cvar_SetVarValue(&gfx_clouds, 0); if(shadowSplit==0) updateSplitDist(shadowFrusta, scene_cam->nearclip, scene_cam->farclip); if(gfx_shadowQuality.integer >= 2) { GL_PopCamera(); GL_PushCSMCamera(viewer, scene_cam, shadowSplit); //CSM or UniformSM } if(!gfx_shadowDebug.integer) ((GLDepthRenderTarget*)target)->makeTargetLayer(shadowSplit); shadowSplit++; glClear(GL_DEPTH_BUFFER_BIT); GL_Disable(GL_LIGHTING); GL_Disable(GL_POLYGON_SMOOTH); if(!gfx_shadowDebug.integer) glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glShadeModel(GL_FLAT); //GL_CullFace(GL_FRONT); layer2_enabled = terrain_layer2.integer; layer3_enabled = terrain_layer3.integer; Cvar_SetVarValue(&terrain_layer2, 0); Cvar_SetVarValue(&terrain_layer3, 0); }
/* ============= R_DrawStretchImage ============= */ void R_DrawStretchImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *gl, float alpha) { int32_t i; vec2_t texCoord[4], verts[4]; if (scrap_dirty) Scrap_Upload (); // Psychospaz's transparent console support if (gl->has_alpha || alpha < 1.0) { GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_DepthMask (false); } GL_Bind (gl->texnum); Vector2Set(texCoord[0], gl->sl, gl->tl); Vector2Set(texCoord[1], gl->sh, gl->tl); Vector2Set(texCoord[2], gl->sh, gl->th); Vector2Set(texCoord[3], gl->sl, gl->th); Vector2Set(verts[0], x, y); Vector2Set(verts[1], x+w, y); Vector2Set(verts[2], x+w, y+h); Vector2Set(verts[3], x, y+h); rb_vertex = rb_index = 0; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+1; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+3; for (i=0; i<4; i++) { VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]); VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0); VA_SetElem4(colorArray[rb_vertex], 1.0, 1.0, 1.0, alpha); rb_vertex++; } RB_RenderMeshGeneric (false); // Psychospaz's transparent console support if (gl->has_alpha || alpha < 1.0) { GL_DepthMask (true); GL_TexEnv (GL_REPLACE); GL_Disable (GL_BLEND); GL_Enable (GL_ALPHA_TEST); } }
/* ====================== R_DrawFill Fills a box of pixels with a 24-bit color w/ alpha =========================== */ void R_DrawFill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t red, int32_t green, int32_t blue, int32_t alpha) { const vec_t r = min(red, 255)*DIV255; const vec_t g = min(green, 255)*DIV255; const vec_t b = min(blue, 255)*DIV255; const vec_t a = max(min(alpha, 255), 1)*DIV255; const vec4_t color[4] = { {r, g, b, a}, {r, g, b, a}, {r, g, b, a}, {r, g, b, a} }; const vec3_t verts[4] = { {x, y, 0}, {x+w, y, 0}, {x+w, y+h, 0}, {x, y+h, 0} }; // GL_DisableTexture (0); GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_DepthMask (false); GL_Bind (glMedia.whitetexture->texnum); rb_vertex = rb_index = 0; memcpy(&indexArray[rb_index], indices, sizeof(indices)); rb_index = 6; memcpy(vertexArray, verts, sizeof(vec3_t) * 4); memcpy(colorArray, color, sizeof(vec4_t) * 4); rb_vertex = 4; RB_RenderMeshGeneric (false); GL_DepthMask (true); GL_Disable (GL_BLEND); GL_TexEnv (GL_REPLACE); GL_Enable (GL_ALPHA_TEST); // GL_EnableTexture (0); }
/* * ================= * R_Bloom_DrawEffect * ================= */ void R_Bloom_DrawEffect(void) { GL_Bind(r_bloomeffecttexture->texnum); GL_Enable(GL_BLEND); GL_BlendFunc(GL_ONE, GL_ONE); GL_TexEnv(GL_MODULATE); rb_vertex = rb_index = 0; indexArray[rb_index++] = rb_vertex + 0; indexArray[rb_index++] = rb_vertex + 1; indexArray[rb_index++] = rb_vertex + 2; indexArray[rb_index++] = rb_vertex + 0; indexArray[rb_index++] = rb_vertex + 2; indexArray[rb_index++] = rb_vertex + 3; VA_SetElem2(texCoordArray[0][rb_vertex], 0, sampleText_tch); VA_SetElem3(vertexArray[rb_vertex], curView_x, curView_y, 0); VA_SetElem4(colorArray[rb_vertex], r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f); rb_vertex++; VA_SetElem2(texCoordArray[0][rb_vertex], 0, 0); VA_SetElem3(vertexArray[rb_vertex], curView_x, curView_y + curView_height, 0); VA_SetElem4(colorArray[rb_vertex], r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f); rb_vertex++; VA_SetElem2(texCoordArray[0][rb_vertex], sampleText_tcw, 0); VA_SetElem3(vertexArray[rb_vertex], curView_x + curView_width, curView_y + curView_height, 0); VA_SetElem4(colorArray[rb_vertex], r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f); rb_vertex++; VA_SetElem2(texCoordArray[0][rb_vertex], sampleText_tcw, sampleText_tch); VA_SetElem3(vertexArray[rb_vertex], curView_x + curView_width, curView_y, 0); VA_SetElem4(colorArray[rb_vertex], r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f); rb_vertex++; RB_DrawArrays(); rb_vertex = rb_index = 0; GL_Disable(GL_BLEND); }
/* ============= RB_DrawMeshTris Re-draws a mesh in outline mode ============= */ void RB_DrawMeshTris (void) { int i, numTMUs = 0; if (!r_showtris->value) return; if (r_showtris->value == 1) GL_Disable(GL_DEPTH_TEST); qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); for (i=0; i<glConfig.max_texunits; i++) if (glState.activetmu[i]) { numTMUs++; GL_DisableTexture (i); } qglDisableClientState (GL_COLOR_ARRAY); qglColor4f(1.0, 1.0, 1.0, 1.0); RB_DrawArrays (); qglEnableClientState (GL_COLOR_ARRAY); for (i=0; i<numTMUs; i++) GL_EnableTexture(i); qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); if (r_showtris->value == 1) GL_Enable(GL_DEPTH_TEST); }
/* ============= RB_DrawMeshTris Re-draws a mesh in outline mode ============= */ void RB_DrawMeshTris (GLenum polyMode, int numTMUs) { int i; if (!r_showtris->value) return; if (r_showtris->value == 1) GL_Disable(GL_DEPTH_TEST); qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); for (i=0; i<numTMUs; i++) GL_DisableTexture (i); qglDisableClientState (GL_COLOR_ARRAY); qglColor4f(1.0, 1.0, 1.0, 1.0); RB_DrawArrays(polyMode); qglEnableClientState (GL_COLOR_ARRAY); for (i=0; i<numTMUs; i++) GL_EnableTexture(i); qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); if (r_showtris->value == 1) GL_Enable(GL_DEPTH_TEST); }
void DepthPass::setup(GLRenderer *r) { Pass::setup(r); GL_Disable(GL_LIGHTING); GL_Disable(GL_BLEND); normalShader->use(); setCurrentShader(normalShader); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); saveClouds = gfx_clouds.integer; saveGrass = gfx_grass.integer; Cvar_SetVarValue(&gfx_sky, 0); Cvar_SetVarValue(&gfx_clouds, 0); Cvar_SetVarValue(&gfx_grass, 0); Cvar_SetVarValue(&gfx_GLSLPass, 0); }
/* ================= R_SetBlendModeOff ================= */ void R_SetBlendModeOff (void) { if ( currententity->flags & RF_TRANSLUCENT ) { GL_DepthMask (true); GL_Disable(GL_BLEND); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } }
/* ================ R_FlushChars ================ */ void R_FlushChars (void) { if (rb_vertex == 0 || rb_index == 0) // nothing to flush return; GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_DepthMask (false); GL_Bind(draw_chars->texnum); RB_RenderMeshGeneric (false); char_count = 0; GL_DepthMask (true); GL_Disable (GL_BLEND); GL_TexEnv (GL_REPLACE); GL_Enable (GL_ALPHA_TEST); }
/* ====================== R_DrawFill Fills a box of pixels with a 24-bit color w/ alpha =========================== */ void R_DrawFill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t red, int32_t green, int32_t blue, int32_t alpha) { int32_t i; vec2_t verts[4]; red = min(red, 255); green = min(green, 255); blue = min(blue, 255); alpha = max(min(alpha, 255), 1); // GL_DisableTexture (0); GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_DepthMask (false); GL_Bind (glMedia.whitetexture->texnum); Vector2Set(verts[0], x, y); Vector2Set(verts[1], x+w, y); Vector2Set(verts[2], x+w, y+h); Vector2Set(verts[3], x, y+h); rb_vertex = rb_index = 0; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+1; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+3; for (i=0; i<4; i++) { VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0); VA_SetElem4(colorArray[rb_vertex], red*DIV255, green*DIV255, blue*DIV255, alpha*DIV255); rb_vertex++; } RB_RenderMeshGeneric (false); GL_DepthMask (true); GL_Disable (GL_BLEND); GL_TexEnv (GL_REPLACE); GL_Enable (GL_ALPHA_TEST); // GL_EnableTexture (0); }
void DepthNormalPass::setup(GLRenderer *r) { Pass::setup(r); glClear(GL_COLOR_BUFFER_BIT); GL_Disable(GL_LIGHTING); GL_Disable(GL_BLEND); normalShader->use(); setCurrentShader(normalShader); saveClouds = gfx_clouds.integer; saveGrass = gfx_grass.integer; Cvar_SetVarValue(&gfx_sky, 0); Cvar_SetVarValue(&gfx_clouds, 0); Cvar_SetVarValue(&gfx_grass, 0); Cvar_SetVarValue(&gfx_GLSLPass, 0); }
/* ================= R_Bloom_DownsampleView ================= */ void R_Bloom_DownsampleView( void ) { GL_Disable( GL_BLEND ); qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); //stepped downsample if( r_screendownsamplingtexture_size ) { int midsample_width = r_screendownsamplingtexture_size * sampleText_tcw; int midsample_height = r_screendownsamplingtexture_size * sampleText_tch; //copy the screen and draw resized GL_Bind(r_bloomscreentexture->texnum); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, curView_x, vid.height - (curView_y + curView_height), curView_width, curView_height); R_Bloom_Quad( 0, vid.height-midsample_height, midsample_width, midsample_height, screenText_tcw, screenText_tch ); //now copy into Downsampling (mid-sized) texture GL_Bind(r_bloomdownsamplingtexture->texnum); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, midsample_width, midsample_height); //now draw again in bloom size qglColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); R_Bloom_Quad( 0, vid.height-sample_height, sample_width, sample_height, sampleText_tcw, sampleText_tch ); //now blend the big screen texture into the bloom generation space (hoping it adds some blur) GL_Enable( GL_BLEND ); GL_BlendFunc(GL_ONE, GL_ONE); qglColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); GL_Bind(r_bloomscreentexture->texnum); R_Bloom_Quad( 0, vid.height-sample_height, sample_width, sample_height, screenText_tcw, screenText_tch ); qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); GL_Disable( GL_BLEND ); } else { //downsample simple GL_Bind(r_bloomscreentexture->texnum); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, curView_x, vid.height - (curView_y + curView_height), curView_width, curView_height); R_Bloom_Quad( 0, vid.height-sample_height, sample_width, sample_height, screenText_tcw, screenText_tch ); } }
void Pass2D::finalize() { GL_MatrixMode(GL_PROJECTION); GL_PopMatrix(); GL_MatrixMode(GL_MODELVIEW); GL_PopMatrix(); GL_Disable(GL_SCISSOR_TEST); GL_Enable(GL_CULL_FACE); Pass::finalize(); }
void ShadowPass::setup(GLRenderer *r) { if(!gfx_shadowDebug.integer) target = shadowTarget; else target = glScreen; Pass::setup(r); saveGLSLQuality = gfx_GLSLQuality.integer; saveGrass = gfx_grass.integer; if(!canRender()) return; Cvar_SetVarValue(&gfx_sky, 0); Cvar_SetVarValue(&gfx_GLSLQuality, 1); Cvar_SetVarValue(&gfx_grass, 0); /*updateSplitDist(shadowFrusta, scene_cam->nearclip, scene_cam->farclip); shadowSplit = 0; if(gfx_shadowQuality.integer != 3) { GL_PopCamera(); GL_PushCSMCamera(viewer, scene_cam, shadowSplit); //CSM or UniformSM }*/ GL_Disable(GL_LIGHTING); GL_Disable(GL_POLYGON_SMOOTH); if(!gfx_shadowDebug.integer) glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glShadeModel(GL_FLAT); //GL_CullFace(GL_FRONT); layer2_enabled = terrain_layer2.integer; layer3_enabled = terrain_layer3.integer; Cvar_SetVarValue(&terrain_layer2, 0); Cvar_SetVarValue(&terrain_layer3, 0); }
/* ================= R_SetShellBlend ================= */ void R_SetShellBlend (qboolean toggle) { // shells only if ( !(currententity->flags & RF_MASK_SHELL) ) return; if (toggle) //turn on { // Psychospaz's envmapping if (EnvMapShell()) { glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); GL_Bind(glMedia.spheremappic->texnum); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); } else if (FlowingShell()) GL_Bind(glMedia.shelltexture->texnum); else GL_DisableTexture(0); GL_ClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); GL_StencilFunc(GL_EQUAL, 1, 2); glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); GL_Enable(GL_STENCIL_TEST); shellFlowH = 0.25 * sin(r_newrefdef.time * 0.5 * M_PI); shellFlowV = -(r_newrefdef.time / 2.0); } else // turn off { // Psychospaz's envmapping if (EnvMapShell()) { glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } else if (FlowingShell()) { /*nothing*/ } else GL_EnableTexture(0); GL_Disable(GL_STENCIL_TEST); } }
void GL_RenderPath() { if ( navrep_render.integer != -1 ) { vec4_t white = {1,1,1,1}; GL_DisableTexture(GL_TEXTURE0_ARB); GL_Disable(GL_LIGHTING); GL_SetColor(white); glBegin(GL_LINES); NavRep_Render(); glEnd(); } }
void R_VR_EndFrame() { if (hmd && vr_enabled->value) { GL_Disable(GL_DEPTH_TEST); //draw the HUD into specific views R_VR_DrawHud(); // draw the HUD R_BindFBO(vrState.offscreen); GL_SetIdentity(GL_PROJECTION); GL_SetIdentity(GL_MODELVIEW); // tell the HMD renderer to draw composited scene hmd->present((qboolean) (loadingScreen || (vr_aimmode->value == 0))); } }
/* ================= R_DrawAliasModelBBox ================= */ void R_DrawAliasModelBBox (vec3_t bbox[8], entity_t *e) { if (!r_showbbox->value) return; if (e->flags & RF_WEAPONMODEL || e->flags & RF_VIEWERMODEL || e->flags & RF_BEAM || e->renderfx & RF2_CAMERAMODEL) return; GL_Disable (GL_CULL_FACE); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); GL_DisableTexture (0); // Draw top and sides glBegin(GL_TRIANGLE_STRIP); glVertex3fv( bbox[2] ); glVertex3fv( bbox[1] ); glVertex3fv( bbox[0] ); glVertex3fv( bbox[1] ); glVertex3fv( bbox[4] ); glVertex3fv( bbox[5] ); glVertex3fv( bbox[1] ); glVertex3fv( bbox[7] ); glVertex3fv( bbox[3] ); glVertex3fv( bbox[2] ); glVertex3fv( bbox[7] ); glVertex3fv( bbox[6] ); glVertex3fv( bbox[2] ); glVertex3fv( bbox[4] ); glVertex3fv( bbox[0] ); glEnd(); // Draw bottom glBegin(GL_TRIANGLE_STRIP); glVertex3fv( bbox[4] ); glVertex3fv( bbox[6] ); glVertex3fv( bbox[7] ); glEnd(); GL_EnableTexture (0); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); GL_Enable (GL_CULL_FACE); }
/* ================= R_Bloom_DrawEffect ================= */ void R_Bloom_DrawEffect( refdef_t *fd ) { GL_Bind(r_bloomeffecttexture->texnum); GL_Enable(GL_BLEND); GL_BlendFunc(GL_ONE, GL_ONE); qglColor4f(r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, 1.0f); GL_TexEnv(GL_MODULATE); qglBegin(GL_QUADS); qglTexCoord2f( 0, sampleText_tch ); qglVertex2f( curView_x, curView_y ); qglTexCoord2f( 0, 0 ); qglVertex2f( curView_x, curView_y + curView_height ); qglTexCoord2f( sampleText_tcw, 0 ); qglVertex2f( curView_x + curView_width, curView_y + curView_height ); qglTexCoord2f( sampleText_tcw, sampleText_tch ); qglVertex2f( curView_x + curView_width, curView_y ); qglEnd(); GL_Disable(GL_BLEND); }
//the "main" of the renderer void GLRenderer::render(float dt) { camera_t *viewer, *lastviewer=NULL; LightPass lightpasses[128]; int lightpass_count=0; unsigned int num_lights = lightList.size(); unsigned int maxLightsPass = gfx_GLSLQuality.integer>1 ? 4 : MIN(gfx_maxlightsperpass.integer, glMaxLights); renderer_meshculled=0; renderer_octculled=0; //// SORT SORTED LIST //// sortedRenderList.sort(dist_sort); //depth sorting sortedStaticRenderList.sort(dist_sort); //depth sorting if(gfx_sortAll.integer) unsortedRenderList.sort(rev_dist_sort); //// ADD IN OCTREE //// //octree list items always have to be near the start of the list for(std::list<GLRenderListItem*>::iterator itr = --octreeList.end(); itr != octreeList.begin(); itr--) { unsortedRenderList.push_front((*itr)->getRef()); } unsortedRenderList.push_front((*octreeList.begin())->getRef()); //// PRERENDER //// for(std::list<GLRenderListItem*>::iterator itr = unsortedRenderList.begin(); itr != unsortedRenderList.end(); itr++) { (*itr)->prerenderStage(dt); } for(std::list<GLRenderListItem*>::iterator itr = sortedRenderList.begin(); itr != sortedRenderList.end(); itr++) { (*itr)->prerenderStage(dt); } //// ADD LIGHTING PASSES //// if(num_lights > maxLightsPass && gfx_multipassLighting.integer) { for(unsigned int i=maxLightsPass; i<num_lights && lightpass_count<128; i+=maxLightsPass) { lightpasses[lightpass_count] = LightPass(); lightpasses[lightpass_count].setLightStart(i); addPass(&lightpasses[lightpass_count++]); } } if(vid_multisample.integer) GL_Enable(GL_MULTISAMPLE_ARB); //// PERFORM ALL RENDER PASSES //// for(std::list<Pass *>::iterator itr=passes.begin();itr!=passes.end();itr++) { currentPass = *itr; #ifdef DEBUG if(gfx_shadowDebug.integer&& !currentPass->isShadowPass()) break; #endif //DEBUG ONLY: if(gfx_flush.integer) glClear(GL_COLOR_BUFFER_BIT); GL_ResetColor(); //setup the pass currentPass->setup(this); if(currentPass->canRender()) { viewer = currentPass->getViewer(); if(lastviewer != viewer) { resetPass(); lastviewer = viewer; } if(gfx_GLSLQuality.integer > 1 && !currentPass->isShadowPass()) { GL_SwitchTexUnit(GL_TEXTURE1_ARB); shadowTarget->bindTexture(0); GL_BuildShadowTextureMatrix(viewer); } //render the lights for this pass unsigned int currentLight = 0; for(std::list<GLRenderListLightItem*>::iterator itr = lightList.begin(); itr != lightList.end(); itr++) { if(currentLight >= currentPass->getLightStart()+maxLightsPass) break; if((int)currentLight >= currentPass->getLightStart()) (*itr)->renderPass(this); currentLight++; } //determine visibility and render //unsorted items are drawn first std::for_each(unsortedRenderList.begin(), unsortedRenderList.end(), RenderIfVisible(this)); if(!(viewer->flags & CAM_NO_WORLDOBJECTS)) std::for_each(unsortedStaticRenderList.begin(), unsortedStaticRenderList.end(), RenderIfVisible(this)); //sorted items are drawn next (translucent & additive stuff) if(!(viewer->flags & CAM_NO_WORLDOBJECTS)) std::for_each(sortedStaticRenderList.begin(), sortedStaticRenderList.end(), RenderIfVisible(this)); std::for_each(sortedRenderList.begin(), sortedRenderList.end(), RenderIfVisible(this)); //effects last, as they always look better as overlays //for nice effects, do this if(gfx_niceEffects.integer && gfx_GLSLQuality.integer>=1 && gfx_postProcEnabled.integer) { GL_BeginPostProcessingEffects(); std::for_each(effectsList.begin(), effectsList.end(), RenderIfVisible(this)); GL_EndPostProcessingEffects(); } else { std::for_each(effectsList.begin(), effectsList.end(), RenderIfVisible(this)); } #ifdef DEBUG for(unsigned int i=0;i<bboxCount;i++) { vec3_t bmin, bmax; M_AddVec3(bboxes[i].min,bboxes[i].pos, bmin); M_AddVec3(bboxes[i].max,bboxes[i].pos, bmax); //Draw the box GL_DrawBox(bmin, bmax); } #endif if(gfx_GLSLQuality.integer > 1 && !currentPass->isShadowPass()) { GL_SwitchTexUnit(GL_TEXTURE1_ARB); shadowTarget->unbindTexture(0); } GL_RenderPath(); } currentPass->finalize(); } if(gfx_GLSLQuality.integer > 1 && gfx_postProcessing.integer && gfx_postProcEnabled.integer) GL_DoPostProcessing(); if(vid_multisample.integer) GL_Disable(GL_MULTISAMPLE_ARB); #ifdef DEBUG bboxCount=0; #endif //// RESET //// //resetPass(); std::for_each(unsortedRenderList.begin(), unsortedRenderList.end(), std::mem_fun(&GLRenderListItem::reset)); std::for_each(sortedRenderList.begin(), sortedRenderList.end(), std::mem_fun(&GLRenderListItem::reset)); std::for_each(effectsList.begin(), effectsList.end(), std::mem_fun(&GLRenderListItem::reset)); //// CLEAR //// passes.clear(); sortedRenderList.clear(); unsortedRenderList.clear(); effectsList.clear(); lightList.clear(); meshpool.clear(); spritepool.clear(); polypool.clear(); lightpool.clear(); //Console_DPrintf("Mesh Total: %d Culled: %d\n", renderer_meshcount, renderer_meshculled); //Console_DPrintf("Oct Total: %d Culled: %d\n", oci, renderer_octculled); renderer_meshcount=0; }
/* ================== GL_Setup2D TODO: time is messed up ================== */ void GL_Setup2D (int time){ mat4_t projectionMatrix = {2.0f / backEnd.cropWidth, 0.0f, 0.0f, 0.0f, 0.0f, -2.0f / backEnd.cropHeight, 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 0.0f, -1.0f, 1.0f, -1.0f, 1.0f}; QGL_LogPrintf("---------- RB_Setup2D ----------\n"); backEnd.projection2D = true; backEnd.time = time; backEnd.floatTime = MS2SEC(Sys_Milliseconds()); backEnd.viewport.x = 0; backEnd.viewport.y = 0; backEnd.viewport.width = backEnd.cropWidth; backEnd.viewport.height = backEnd.cropHeight; backEnd.scissor.x = 0; backEnd.scissor.y = 0; backEnd.scissor.width = backEnd.cropWidth; backEnd.scissor.height = backEnd.cropHeight; backEnd.coordScale[0] = 1.0f / backEnd.viewport.width; backEnd.coordScale[1] = 1.0f / backEnd.viewport.height; backEnd.coordBias[0] = -backEnd.viewport.x * backEnd.coordScale[0]; backEnd.coordBias[1] = -backEnd.viewport.y * backEnd.coordScale[1]; backEnd.depthFilling = false; backEnd.debugRendering = false; backEnd.currentColorCaptured = SORT_BAD; backEnd.currentDepthCaptured = false; // Set up the viewport GL_Viewport(backEnd.viewport); // Set up the scissor GL_Scissor(backEnd.viewport); // Set up the depth bounds if (glConfig.depthBoundsTestAvailable) GL_DepthBounds(0.0f, 1.0f); // Set the projection matrix GL_LoadMatrix(GL_PROJECTION, projectionMatrix); // Set the modelview matrix GL_LoadIdentity(GL_MODELVIEW); // Set the GL state GL_PolygonMode(GL_FILL); GL_Disable(GL_CULL_FACE); GL_Disable(GL_POLYGON_OFFSET_FILL); GL_Disable(GL_BLEND); GL_Disable(GL_ALPHA_TEST); GL_Disable(GL_DEPTH_TEST); GL_Disable(GL_STENCIL_TEST); GL_DepthRange(0.0f, 1.0f); GL_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); GL_DepthMask(GL_FALSE); GL_StencilMask(255); // Disable the clip plane qglDisable(GL_CLIP_PLANE0); // Disable multisampling if available if (glConfig.multiSamples > 1) qglDisable(GL_MULTISAMPLE); // Check for errors if (!r_ignoreGLErrors->integerValue) GL_CheckForErrors(); QGL_LogPrintf("--------------------\n"); }
/* ================= R_DrawSpriteModel ================= */ void R_DrawSpriteModel (entity_t *e) { float alpha = 1.0f; vec2_t texCoord[4]; vec3_t point[4]; dsprite_t *psprite; dsprframe_t *frame; float *up, *right; int i; // don't even bother culling, because it's just a single // polygon without a surface cache psprite = (dsprite_t *)currentmodel->extradata; e->frame %= psprite->numframes; frame = &psprite->frames[e->frame]; if (!frame) return; c_alias_polys += 2; // normal sprite up = vup; right = vright; if (e->flags & RF_TRANSLUCENT) alpha = e->alpha; R_SetVertexRGBScale (true); // Psychospaz's additive transparency if ((currententity->flags & RF_TRANS_ADDITIVE) && (alpha != 1.0f)) { GL_Enable (GL_BLEND); GL_TexEnv (GL_MODULATE); GL_Disable (GL_ALPHA_TEST); GL_DepthMask (false); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE); } else { GL_TexEnv (GL_MODULATE); if (alpha == 1.0f) { GL_Enable (GL_ALPHA_TEST); GL_DepthMask (true); } else { GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask (false); GL_Enable (GL_BLEND); GL_Disable (GL_ALPHA_TEST); } } GL_Bind(currentmodel->skins[0][e->frame]->texnum); Vector2Set(texCoord[0], 0, 1); Vector2Set(texCoord[1], 0, 0); Vector2Set(texCoord[2], 1, 0); Vector2Set(texCoord[3], 1, 1); VectorMA (e->origin, -frame->origin_y, up, point[0]); VectorMA (point[0], -frame->origin_x, right, point[0]); VectorMA (e->origin, frame->height - frame->origin_y, up, point[1]); VectorMA (point[1], -frame->origin_x, right, point[1]); VectorMA (e->origin, frame->height - frame->origin_y, up, point[2]); VectorMA (point[2], frame->width - frame->origin_x, right, point[2]); VectorMA (e->origin, -frame->origin_y, up, point[3]); VectorMA (point[3], frame->width - frame->origin_x, right, point[3]); rb_vertex = rb_index = 0; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+1; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+0; indexArray[rb_index++] = rb_vertex+2; indexArray[rb_index++] = rb_vertex+3; for (i=0; i<4; i++) { VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]); VA_SetElem3(vertexArray[rb_vertex], point[i][0], point[i][1], point[i][2]); VA_SetElem4(colorArray[rb_vertex], 1.0f, 1.0f, 1.0f, alpha); rb_vertex++; } RB_DrawArrays (); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_TexEnv (GL_REPLACE); GL_DepthMask (true); GL_Disable (GL_ALPHA_TEST); GL_Disable (GL_BLEND); R_SetVertexRGBScale (false); RB_DrawMeshTris (); rb_vertex = rb_index = 0; }
void R_VR_DrawHud() { float fov = vr_hud_fov->value; float depth = vr_hud_depth->value; int numsegments = vr_hud_segments->value; int index = 0; vec_t mat[4][4], temp[4][4]; if (!vr_enabled->value) return; // enable alpha testing so only pixels that have alpha info get written out // prevents black pixels from being rendered into the view GL_Enable(GL_ALPHA_TEST); GL_AlphaFunc(GL_GREATER, 0.0f); // if hud transparency is enabled, enable blending if (vr_hud_transparency->value) { GL_Enable(GL_BLEND); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } // bind the texture GL_MBind(0, hud.texture); // disable this for the loading screens since they are not at 60fps if ((vr_hud_bounce->value > 0) && !loadingScreen && ((int32_t) vr_aimmode->value > 0)) { // load the quaternion directly into a rotation matrix vec4_t q; VR_GetOrientationEMAQuat(q); q[2] = -q[2]; QuatToRotation(q, mat); } else { // identity matrix TranslationMatrix(0,0,0,mat); } // set proper mode // glEnableClientState (GL_TEXTURE_COORD_ARRAY); // glEnableClientState (GL_VERTEX_ARRAY); glDisableClientState (GL_COLOR_ARRAY); // bind vertex buffer and set tex coord parameters R_BindIVBO(&hudVBO,NULL,0); glTexCoordPointer(2,GL_FLOAT,sizeof(vert_t),(void *)( sizeof(GL_FLOAT) * 3)); glVertexPointer(3,GL_FLOAT,sizeof(vert_t),NULL); for (index = 0; index < 2; index++) { // bind the eye FBO R_BindFBO(vrState.eyeFBO[index]); // set the perspective matrix for that eye R_PerspectiveScale(vrState.renderParams[index].projection, 0.24, 251.0); // build the eye translation matrix if (vr_autoipd->value) { TranslationMatrix(-vrState.renderParams[index].viewOffset[0], vrState.renderParams[index].viewOffset[1], vrState.renderParams[index].viewOffset[2], temp); } else { float viewOffset = (vr_ipd->value / 2000.0); TranslationMatrix((-1 + index * 2) * -viewOffset, 0, 0, temp); } // load the view matrix MatrixMultiply(temp, mat, temp); GL_LoadMatrix(GL_MODELVIEW, temp); // draw the hud for that eye R_DrawIVBO(&hudVBO); } // teardown R_ReleaseIVBO(); GL_MBind(0, 0); glEnableClientState (GL_COLOR_ARRAY); glTexCoordPointer (2, GL_FLOAT, sizeof(texCoordArray[0][0]), texCoordArray[0][0]); glVertexPointer (3, GL_FLOAT, sizeof(vertexArray[0]), vertexArray[0]); GL_Disable(GL_BLEND); GL_Disable(GL_ALPHA_TEST); }
void GlassViewer::draw(gcn::Graphics *g) { sceneobj_t sc; int x,y; vec4_t rect; if(isCulled(g)) return; getAbsolutePosition(x, y); gcn::Rectangle r = g->getCurrentClipArea(); //setup camera Cam_DefaultCamera(&cam, r.width, r.height, 0.1, Cvar_GetValue("gfx_farclip")); cam.fovx = fov; cam.fog_near = cam.fog_far = 10000; cam.x = x; cam.y = Vid_GetScreenH()-y-mDimension.height; cam.use_viewport = true; Cam_CalcFovy(&cam); //Cam_SetDistance(&cam, 1000); M_CopyVec3(target, cam.viewaxis[AXIS_FORWARD]); M_GetAxisFromForwardVec(cam.viewaxis[AXIS_FORWARD], cam.viewaxis); M_CopyVec3(camPos, cam.origin); cam.time = Host_Milliseconds()/1000.0f; SET_VEC4(rect, 0, 0, r.width, r.height); if(mOpaque) { g->setColor(getBackgroundColor()); g->fillRectangle(gcn::Rectangle(0,0,getWidth(),getHeight())); } Scene_Clear(); Scene_SetFrustum(&cam, rect); if(model!=(residx_t)-1) { CLEAR_SCENEOBJ(sc); //SET_VEC3(cam.viewaxis[AXIS_FORWARD], target[0]-camPos[0], target[1]-camPos[1], target[2]-camPos[2]); //M_Normalize(cam.viewaxis[AXIS_FORWARD]); //M_GetAxisFromForwardVec(cam.viewaxis[AXIS_FORWARD], cam.viewaxis); M_MultVec3(cam.viewaxis[AXIS_FORWARD], -distance, cam.origin); M_AddVec3(cam.origin, camPos, cam.origin); sc.model = model; sc.skeleton = &skeleton; sc.flags = SCENEOBJ_NEVER_CULL | SCENEOBJ_USE_AXIS; SET_VEC3(sc.rimColor, 1.0, 1.0, 1.0); if(animState.size() > 0) { Geom_BeginPose(sc.skeleton, sc.model); Geom_SetBoneAnim("", animState.c_str(), Host_Milliseconds(), Host_Milliseconds(), 0, 0); Geom_EndPose(); } M_CopyVec3(position, sc.pos); sc.angle[0] = sc.angle[1] = 0; sc.angle[2] = angle; M_GetAxis(sc.angle[0], sc.angle[1], sc.angle[2], sc.axis); if(mAutoRotate) angle = int(angle + dAngle) % 360; if(angle<0) angle +=360; Scene_AddObject(&sc); } if(!world) { cam.fog_near = 9000; cam.fog_far = 10000; cam.flags |= CAM_NO_WORLD; } else { cam.flags &= ~CAM_NO_WORLD; cam.fog_near = Cvar_GetValue("gfx_fog_near"); cam.fog_far = Cvar_GetValue("gfx_fog_far"); WO_RenderEmitters(cam.origin); WL_RenderLights(cam.origin); } //FIXME: add post-processing with viewers int old = gfx_postProcessing.integer; Cvar_SetVarValue(&gfx_postProcessing, 0); GL_EndFrame(); GL_Enable(GL_CULL_FACE); Scene_Render(&cam, cam.origin, 0); GL_Disable(GL_CULL_FACE); GL_BeginFrame(); Cvar_SetVarValue(&gfx_postProcessing, old); if(animState.size() > 0 && model != (residx_t)-1) Geom_FreeSkeleton(&skeleton); }
/* ================== GL_Setup3D TODO: time is messed up ================== */ void GL_Setup3D (int time){ double clipPlane[4]; QGL_LogPrintf("---------- RB_Setup3D ----------\n"); backEnd.projection2D = false; backEnd.time = time; backEnd.floatTime = MS2SEC(Sys_Milliseconds()); backEnd.viewport.x = backEnd.viewParms.viewport.x; backEnd.viewport.y = backEnd.viewParms.viewport.y; backEnd.viewport.width = backEnd.viewParms.viewport.width; backEnd.viewport.height = backEnd.viewParms.viewport.height; backEnd.scissor.x = backEnd.viewParms.scissor.x; backEnd.scissor.y = backEnd.viewParms.scissor.y; backEnd.scissor.width = backEnd.viewParms.scissor.width; backEnd.scissor.height = backEnd.viewParms.scissor.height; backEnd.coordScale[0] = 1.0f / backEnd.viewport.width; backEnd.coordScale[1] = 1.0f / backEnd.viewport.height; backEnd.coordBias[0] = -backEnd.viewport.x * backEnd.coordScale[0]; backEnd.coordBias[1] = -backEnd.viewport.y * backEnd.coordScale[1]; backEnd.depthFilling = false; backEnd.debugRendering = false; backEnd.currentColorCaptured = SORT_BAD; backEnd.currentDepthCaptured = false; // Set up the viewport GL_Viewport(backEnd.viewport); // Set up the scissor GL_Scissor(backEnd.viewport); // Set up the depth bounds if (glConfig.depthBoundsTestAvailable) GL_DepthBounds(0.0f, 1.0f); // Set the projection matrix GL_LoadMatrix(GL_PROJECTION, backEnd.viewParms.projectionMatrix); // Set the modelview matrix GL_LoadIdentity(GL_MODELVIEW); // Set the GL state GL_PolygonMode(GL_FILL); GL_Disable(GL_CULL_FACE); GL_Disable(GL_POLYGON_OFFSET_FILL); GL_Disable(GL_BLEND); GL_Disable(GL_ALPHA_TEST); GL_Disable(GL_DEPTH_TEST); GL_Disable(GL_STENCIL_TEST); GL_DepthRange(0.0f, 1.0f); GL_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); GL_DepthMask(GL_TRUE); GL_StencilMask(255); // Enable the clip plane if needed if (backEnd.viewParms.viewType != VIEW_MIRROR) qglDisable(GL_CLIP_PLANE0); else { clipPlane[0] = -DotProduct(backEnd.viewParms.axis[1], backEnd.viewParms.clipPlane.normal); clipPlane[1] = DotProduct(backEnd.viewParms.axis[2], backEnd.viewParms.clipPlane.normal); clipPlane[2] = -DotProduct(backEnd.viewParms.axis[0], backEnd.viewParms.clipPlane.normal); clipPlane[3] = DotProduct(backEnd.viewParms.origin, backEnd.viewParms.clipPlane.normal) - backEnd.viewParms.clipPlane.dist; qglEnable(GL_CLIP_PLANE0); qglClipPlane(GL_CLIP_PLANE0, clipPlane); } // Enable multisampling if available if (glConfig.multiSamples > 1) qglEnable(GL_MULTISAMPLE); // Clear the buffers qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); qglClearDepth(1.0f); qglClearStencil(0); if (backEnd.viewParms.primaryView) qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); else qglClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Check for errors if (!r_ignoreGLErrors->integerValue) GL_CheckForErrors(); QGL_LogPrintf("--------------------\n"); }
void Pass::setup(GLRenderer *) { vec4_t ambient = { sunLight.ambient[0] * 0.8, sunLight.ambient[1] * 0.8, sunLight.ambient[2] * 0.95, 1 }; GLSL_reset(); shader = NULL; lightCount = 0; glPushAttrib(attrib_bits); //GL_Enable(GL_SCISSOR_TEST); GL_SwitchTexUnit(GL_TEXTURE0_ARB); //defaults for pass GL_Enable(GL_BLEND); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_Enable(GL_CULL_FACE); GL_Enable(GL_ALPHA_TEST); //glAlphaFunc(GL_GREATER, 0.0); GL_ResetColor(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //enable the lights for this pass by default if(allowLighting()) { if(gfx_GLSLQuality.integer <= 1) M_MultVec3(ambient, 1.5, ambient); GL_Enable(GL_LIGHTING); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, true); glShadeModel(GL_SMOOTH); } //GL_Enable(GL_NORMALIZE); //framebuffer if(gfx_postProcessing.integer) { if(!target) target = glScreen; target->makeTarget(); } else { glScreen->makeTarget(); } //depth GL_Enable(GL_DEPTH_TEST); GL_DepthMask(depthMask); GL_DepthFunc(depthFunc); if(preclearDepth) { glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); } if(viewer) { vec4_t rect; //FIXME: probably should be a data member for configurable pass "windows" SET_VEC4(rect, 0, 0, viewer->width, viewer->height); Scene_SetFrustum(viewer, rect); Scene_BuildOccluderList(viewer); if(gfx_debugCamera.integer>0) { camera_t debugcam; vec3_t back; M_MultVec3(viewer->viewaxis[AXIS_FORWARD], -gfx_debugCamera.integer, back); memcpy(&debugcam, viewer, sizeof(camera_t)); M_AddVec3(debugcam.origin, back, debugcam.origin); GL_PushCamera(&debugcam); } else { GL_PushCamera(viewer); //scene_cam = viewer; } //fog if (viewer->fog_far > 0 && gfx_fog.integer) { vec4_t fog_color = { gfx_fogr.value, gfx_fogg.value, gfx_fogb.value, 0 }; GL_Enable(GL_FOG); if(gfx_nicerFog.integer) { glFogf(GL_FOG_MODE, GL_EXP2); glFogf(GL_FOG_DENSITY, 1.5 / viewer->fog_far); // Notaus: old value was fixed at 0.00072 and not appropriate for very foggy maps } else { glFogf(GL_FOG_MODE, GL_LINEAR); } glHint(GL_FOG_HINT, GL_NICEST); if (viewer->fog_near > 0 && viewer->fog_far >= viewer->fog_near) { glFogf(GL_FOG_START, viewer->fog_near); glFogf(GL_FOG_END, viewer->fog_far); fog_near = viewer->fog_near; fog_far = viewer->fog_far; } else { glFogf(GL_FOG_START, gfx_fog_near.value); glFogf(GL_FOG_END, gfx_fog_far.value); fog_near = gfx_fog_near.value; fog_far = gfx_fog_far.value; } glFogfv(GL_FOG_COLOR, fog_color); } else if (gfx_fog.integer==0) { GL_Enable(GL_FOG); glFogf(GL_FOG_START, 90000); glFogf(GL_FOG_END, 100000); //shaders make it better just to set this ridiculously far out } else { GL_Disable(GL_FOG); } } else { GL_Disable(GL_FOG); } if(gfx_GLSL.integer) Cvar_SetVarValue(&gfx_GLSLPass, 1); else GL_TexModulate(2.0); #ifdef DEBUG GLSL_catchLastError("Pass::setup()"); #endif }