void GLDrawInfo::SetupFloodStencil(wallseg * ws) { int recursion = GLPortal::GetRecursion(); // Create stencil gl.StencilFunc(GL_EQUAL,recursion,~0); // create stencil gl.StencilOp(GL_KEEP,GL_KEEP,GL_INCR); // increment stencil of valid pixels gl.ColorMask(0,0,0,0); // don't write to the graphics buffer gl_EnableTexture(false); gl.Color3f(1,1,1); gl.Enable(GL_DEPTH_TEST); gl.DepthMask(true); gl_DisableShader(); gl.Begin(GL_TRIANGLE_FAN); gl.Vertex3f(ws->x1, ws->z1, ws->y1); gl.Vertex3f(ws->x1, ws->z2, ws->y1); gl.Vertex3f(ws->x2, ws->z2, ws->y2); gl.Vertex3f(ws->x2, ws->z1, ws->y2); gl.End(); gl.StencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil gl.ColorMask(1,1,1,1); // don't write to the graphics buffer gl_EnableTexture(true); gl.Disable(GL_DEPTH_TEST); gl.DepthMask(false); }
void GLDrawInfo::ClearFloodStencil(wallseg * ws) { int recursion = GLPortal::GetRecursion(); gl.StencilOp(GL_KEEP,GL_KEEP,GL_DECR); gl_EnableTexture(false); gl.ColorMask(0,0,0,0); // don't write to the graphics buffer gl.Color3f(1,1,1); gl_DisableShader(); gl.Begin(GL_TRIANGLE_FAN); gl.Vertex3f(ws->x1, ws->z1, ws->y1); gl.Vertex3f(ws->x1, ws->z2, ws->y1); gl.Vertex3f(ws->x2, ws->z2, ws->y2); gl.Vertex3f(ws->x2, ws->z1, ws->y2); gl.End(); // restore old stencil op. gl.StencilOp(GL_KEEP,GL_KEEP,GL_KEEP); gl.StencilFunc(GL_EQUAL,recursion,~0); gl_EnableTexture(true); gl.ColorMask(1,1,1,1); gl.Enable(GL_DEPTH_TEST); gl.DepthMask(true); }
bool OpenGLFrameBuffer::WipeDo(int ticks) { // Sanity checks. if (wipestartscreen == NULL || wipeendscreen == NULL) { return true; } gl_DisableShader(); bool done = ScreenWipe->Run(ticks, this); //DrawLetterbox(); return done; }
static void RenderSkyHemisphere(int hemi) { int r, c; if (hemi & SKYHEMI_LOWER) { yflip = true; } else { yflip = false; } // The top row (row 0) is the one that's faded out. // There must be at least 4 columns. The preferable number // is 4n, where n is 1, 2, 3... There should be at least // two rows because the first one is always faded. rows = 4; if (hemi & SKYHEMI_JUST_CAP) { return; } gl_DisableShader(); // Draw the cap as one solid color polygon if (!foglayer) { columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); foglayer=true; gl_EnableTexture(false); if (!secondlayer) { gl.Color3f(R, G ,B); gl.Begin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(1, c); } gl.End(); } gl_EnableTexture(true); foglayer=false; gl_ApplyShader(); } else { columns=4; // no need to do more! gl.Begin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(0, c); } gl.End(); } // The total number of triangles per hemisphere can be calculated // as follows: rows * columns * 2 + 2 (for the top cap). for(r = 0; r < rows; r++) { if (yflip) { gl.Begin(GL_TRIANGLE_STRIP); SkyVertex(r + 1, 0); SkyVertex(r, 0); for(c = 1; c <= columns; c++) { SkyVertex(r + 1, c); SkyVertex(r, c); } gl.End(); } else { gl.Begin(GL_TRIANGLE_STRIP); SkyVertex(r, 0); SkyVertex(r + 1, 0); for(c = 1; c <= columns; c++) { SkyVertex(r, c); SkyVertex(r + 1, c); } gl.End(); } } }