// Hemi is Upper or Lower. Zero is not acceptable. // The current texture is used. SKYHEMI_NO_TOPCAP can be used. void GL_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; columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); if (hemi & SKYHEMI_JUST_CAP) { return; } // 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) { glBegin(GL_TRIANGLE_STRIP); SkyVertex(r + 1, 0); SkyVertex(r, 0); for(c = 1; c <= columns; c++) { SkyVertex(r + 1, c); SkyVertex(r, c); } glEnd(); } else { glBegin(GL_TRIANGLE_STRIP); SkyVertex(r, 0); SkyVertex(r + 1, 0); for(c = 1; c <= columns; c++) { SkyVertex(r, c); SkyVertex(r + 1, c); } glEnd(); } } }
void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) { int r, c; bool yflip = !!(hemi & SKYHEMI_LOWER); mPrimStart.Push(mVertices.Size()); for (c = 0; c < mColumns; c++) { SkyVertex(1, c, yflip); } // The total number of triangles per hemisphere can be calculated // as follows: rows * columns * 2 + 2 (for the top cap). for (r = 0; r < mRows; r++) { mPrimStart.Push(mVertices.Size()); for (c = 0; c <= mColumns; c++) { SkyVertex(r + yflip, c, yflip); SkyVertex(r + 1 - yflip, c, yflip); } } }
static void RenderSkyHemisphere(int hemi, bool mirror) { int r, c; if (hemi & SKYHEMI_LOWER) { yflip = true; } else { yflip = false; } skymirror = mirror; // 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; } // Draw the cap as one solid color polygon if (!foglayer) { columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1); foglayer=true; gl_RenderState.EnableTexture(false); gl_RenderState.Apply(true); if (!secondlayer) { glColor3f(R, G ,B); glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(1, c); } glEnd(); } gl_RenderState.EnableTexture(true); foglayer=false; gl_RenderState.Apply(); } else { gl_RenderState.Apply(true); columns=4; // no need to do more! glBegin(GL_TRIANGLE_FAN); for(c = 0; c < columns; c++) { SkyVertex(0, c); } glEnd(); } // 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) { glBegin(GL_TRIANGLE_STRIP); SkyVertex(r + 1, 0); SkyVertex(r, 0); for(c = 1; c <= columns; c++) { SkyVertex(r + 1, c); SkyVertex(r, c); } glEnd(); } else { glBegin(GL_TRIANGLE_STRIP); SkyVertex(r, 0); SkyVertex(r + 1, 0); for(c = 1; c <= columns; c++) { SkyVertex(r, c); SkyVertex(r + 1, c); } glEnd(); } } }