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); } }
/* ============= 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); }
/* ============= 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); }
/* ================= R_SetBlendModeOn ================= */ void R_SetBlendModeOn (image_t *skin) { GL_TexEnv( GL_MODULATE ); if (skin) GL_Bind(skin->texnum); GL_ShadeModel (GL_SMOOTH); if (currententity->flags & RF_TRANSLUCENT) { GL_DepthMask (false); if (currententity->flags & RF_TRANS_ADDITIVE) { GL_BlendFunc (GL_SRC_ALPHA, GL_ONE); glColor4ub(255, 255, 255, 255); GL_ShadeModel (GL_FLAT); } else GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_Enable (GL_BLEND); } }
void R_DrawSkyChain (msurface_t *surf) { msurface_t *reversechain = NULL; int numindexes = 0; if (!surf) return; // push the depth range back to far end of the z-buffer // rogue has some pretty - unusual - brush placement and needs this glDepthRange (gldepthmax, gldepthmax); glProgramUniformMatrix4fv (gl_skycubeprog, u_skylocalMatrix, 1, GL_FALSE, r_mvpmatrix.m[0]); glEnable (GL_TEXTURE_CUBE_MAP_SEAMLESS); GL_UseProgram (gl_skycubeprog); GL_BindTexture (GL_TEXTURE0, GL_TEXTURE_CUBE_MAP, r_skysampler, r_skytexture); GL_Enable (DEPTHTEST_BIT | (gl_cull->value ? CULLFACE_BIT : 0)); for (; surf; surf = surf->texturechain) { surf->reversechain = reversechain; reversechain = surf; numindexes += surf->numindexes; } R_DrawSurfaceChain (reversechain, numindexes); glDepthRange (gldepthmin, gldepthmax); glDisable (GL_TEXTURE_CUBE_MAP_SEAMLESS); }
/* * ================= * 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); }
void DepthNormalPass::finalize() { Cvar_SetVarValue(&gfx_GLSLPass, 1); Cvar_SetVarValue(&gfx_clouds, saveClouds); Cvar_SetVarValue(&gfx_grass, saveGrass); Cvar_SetVarValue(&gfx_sky, 1); GL_UseProgram(0); GL_Enable(GL_LIGHTING); GL_Enable(GL_BLEND); Pass::finalize(); GLSL_catchLastError("DepthNormalPass::finalize(): "); }
void CascadedShadowPass::finalize() { if(canRender()) { Cvar_SetVarValue(&gfx_sky, 1); Cvar_SetVarValue(&gfx_GLSLQuality, saveGLSLQuality); Cvar_SetVarValue(&gfx_grass, saveGrass); Cvar_SetVarValue(&gfx_clouds, saveClouds); //GL_CullFace(GL_BACK); GL_Enable(GL_POLYGON_SMOOTH); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glShadeModel(GL_SMOOTH); Cvar_SetVarValue(&terrain_layer2, layer2_enabled); Cvar_SetVarValue(&terrain_layer3, layer3_enabled); //glScreen->makeTarget(); } Pass::finalize(); #ifdef DEBUG GLSL_catchLastError("CascadedShadowPass::finalize(): "); #endif }
void ShadowPass::finalize() { if(canRender()) { Cvar_SetVarValue(&gfx_sky, 1); Cvar_SetVarValue(&gfx_GLSLQuality, saveGLSLQuality); Cvar_SetVarValue(&gfx_grass, saveGrass); //GL_CullFace(GL_BACK); GL_Enable(GL_POLYGON_SMOOTH); if(!gfx_shadowDebug.integer) glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glShadeModel(GL_SMOOTH); Cvar_SetVarValue(&terrain_layer2, layer2_enabled); Cvar_SetVarValue(&terrain_layer3, layer3_enabled); } GLSL_catchLastError("ShadowPass::finalize(): "); //GL_BuildShadowTextureMatrix(viewer); //GL_PopCamera(); Pass::finalize(); }
/* ================ 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 LightPass::setup(GLRenderer *r) { Pass::setup(r); //basically, light pass is like a normal pass but we don't have any ambient light vec4_t ambient = { 0, 0, 0, 1 }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); //but we do have additive blending GL_Enable(GL_BLEND); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); }
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(); }
/* ================= 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); } }
/* ================= 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); }
/* ================= 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 ); } }
/* * ================= * R_Bloom_GeneratexCross - alternative bluring method * ================= */ void R_Bloom_GeneratexCross(void) { int i; static int BLOOM_BLUR_RADIUS = 8; //static float BLOOM_BLUR_INTENSITY = 2.5f; float BLOOM_BLUR_INTENSITY; static float intensity; static float range; // set up sample size workspace glViewport(0, 0, sample_width, sample_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, sample_width, sample_height, 0, -10, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // copy small scene into r_bloomeffecttexture GL_Bind(0, r_bloomeffecttexture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height); // start modifying the small scene corner GL_Enable(GL_BLEND); // darkening passes if (r_bloom_darken->value) { GL_BlendFunc(GL_DST_COLOR, GL_ZERO); GL_TexEnv(GL_MODULATE); R_Bloom_DrawStart for (i = 0; i < r_bloom_darken->value; i++) { R_Bloom_SamplePass(0, 0, 1.0f, 1.0f, 1.0f, 1.0f); } R_Bloom_DrawFinish glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height); }
/* ================= 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); }
/* ============= RB_RenderWarpSurface backend for R_DrawWarpSurface ============= */ void RB_RenderWarpSurface (msurface_t *fa) { float args[7] = {0,0.05,0,0,0.04,0,0}; float alpha = colorArray[0][3]; image_t *image = R_TextureAnimation (fa); qboolean light = r_warp_lighting->value && !(fa->texinfo->flags & SURF_NOLIGHTENV); qboolean texShaderWarpNV = glConfig.NV_texshaders && glConfig.multitexture && r_pixel_shader_warp->value; qboolean texShaderWarpARB = glConfig.arb_fragment_program && glConfig.multitexture && r_pixel_shader_warp->value; qboolean texShaderWarp = (texShaderWarpNV || texShaderWarpARB); if (texShaderWarpNV && texShaderWarpARB) texShaderWarpARB = (r_pixel_shader_warp->value == 1.0f); if (rb_vertex == 0 || rb_index == 0) // nothing to render return; c_brush_calls++; // Psychospaz's vertex lighting if (light) { GL_ShadeModel (GL_SMOOTH); if (!texShaderWarp) R_SetVertexRGBScale (true); } /* Texture Shader waterwarp Damn this looks fantastic WHY texture shaders? because I can! - MrG */ if (texShaderWarpARB) { GL_SelectTexture(0); GL_MBind(0, image->texnum); GL_EnableTexture(1); GL_MBind(1, dst_texture_ARB); GL_Enable (GL_FRAGMENT_PROGRAM_ARB); qglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fragment_programs[F_PROG_WARP]); qglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, r_rgbscale->value, r_rgbscale->value, r_rgbscale->value, 1.0); } else if (texShaderWarpNV) { GL_SelectTexture(0); GL_MBind(0, dst_texture_NV); qglTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D); GL_EnableTexture(1); GL_MBind(1, image->texnum); qglTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D); qglTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV); qglTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB); qglTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]); // Psychospaz's lighting // use this so that the new water isnt so bright anymore // We won't bother check for the extensions availabiliy, as the hardware required // to make it this far definately supports this as well if (light) qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); GL_Enable (GL_TEXTURE_SHADER_NV); } else GL_Bind(image->texnum); RB_DrawArrays (); // MrG - texture shader waterwarp if (texShaderWarpARB) { GL_Disable (GL_FRAGMENT_PROGRAM_ARB); GL_DisableTexture(1); GL_SelectTexture(0); } else if (texShaderWarpNV) { GL_DisableTexture(1); if (light) qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Psychospaz's lighting GL_SelectTexture(0); GL_Disable (GL_TEXTURE_SHADER_NV); } // Psychospaz's vertex lighting if (light) { GL_ShadeModel (GL_FLAT); if (!texShaderWarp) R_SetVertexRGBScale (false); } RB_DrawMeshTris (); rb_vertex = rb_index = 0; }
void R_DrawCameraEffect (void) { image_t *image[2]; int32_t x, y, w, h, i, j; float texparms[2][4]; vec2_t texCoord[4]; vec3_t verts[4]; renderparms_t cameraParms; image[0] = R_DrawFindPic ("/gfx/2d/screenstatic.tga"); image[1] = R_DrawFindPic ("/gfx/2d/scanlines.tga"); if (!image[0] || !image[1]) return; x = y = 0; w = vid.width; h = vid.height; GL_Disable (GL_ALPHA_TEST); GL_TexEnv (GL_MODULATE); GL_Enable (GL_BLEND); GL_BlendFunc (GL_DST_COLOR, GL_SRC_COLOR); GL_DepthMask (false); VectorSet(verts[0], x, y, 0); VectorSet(verts[1], x+w, y, 0); VectorSet(verts[2], x+w, y+h, 0); VectorSet(verts[3], x, y+h, 0); Vector4Set(texparms[0], 2, 2, -30, 10); Vector4Set(texparms[1], 1, 10, 0, 0); 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; rb_vertex = 4; for (i=0; i<2; i++) { GL_Bind (image[i]->texnum); Vector2Set(texCoord[0], x/image[i]->width, y/image[i]->height); Vector2Set(texCoord[1], (x+w)/image[i]->width, y/image[i]->height); Vector2Set(texCoord[2], (x+w)/image[i]->width, (y+h)/image[i]->height); Vector2Set(texCoord[3], x/image[i]->width, (y+h)/image[i]->height); Mod_SetRenderParmsDefaults (&cameraParms); cameraParms.scale_x = texparms[i][0]; cameraParms.scale_y = texparms[i][1]; cameraParms.scroll_x = texparms[i][2]; cameraParms.scroll_y = texparms[i][3]; RB_ModifyTextureCoords (&texCoord[0][0], &verts[0][0], 4, cameraParms); for (j=0; j<4; j++) { VA_SetElem2(texCoordArray[0][j], texCoord[j][0], texCoord[j][1]); VA_SetElem3(vertexArray[j], verts[j][0], verts[j][1], verts[j][2]); VA_SetElem4(colorArray[j], 1, 1, 1, 1); } RB_DrawArrays (); } rb_vertex = rb_index = 0; GL_DepthMask (true); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_Disable (GL_BLEND); GL_TexEnv (GL_REPLACE); GL_Enable (GL_ALPHA_TEST); }
/* ============= R_DrawScaledImage Psychospaz's code for drawing stretched crosshairs ============= */ void R_DrawScaledImage (int32_t x, int32_t y, float scale, float alpha, image_t *gl) { float xoff, yoff; float scale_x, scale_y; int32_t i; vec2_t texCoord[4], verts[4]; if (scrap_dirty) Scrap_Upload (); // add alpha 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); scale_x = scale_y = scale; scale_x *= gl->replace_scale_w; // scale down if replacing a pcx image scale_y *= gl->replace_scale_h; // scale down if replacing a pcx image 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); xoff = gl->width*scale_x-gl->width; yoff = gl->height*scale_y-gl->height; Vector2Set(verts[0], x, y); Vector2Set(verts[1], x+gl->width+xoff, y); Vector2Set(verts[2], x+gl->width+xoff, y+gl->height+yoff); Vector2Set(verts[3], x, y+gl->height+yoff); 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); if (gl->has_alpha || alpha < 1.0) { GL_DepthMask (true); GL_TexEnv (GL_REPLACE); GL_Disable (GL_BLEND); GL_Enable (GL_ALPHA_TEST); // add alpha support } }
//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; }
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 }