Add this Code to your init() method glEnable(GL_FOG); // specifies the equation to be used to compute the fog blend factor. // GL_LINEAR, GL_EXP, and GL_EXP2. // initial fog mode is GL_EXP glFogi(GL_FOG_MODE, GL_LINEAR); // the fog color. Color components are in the range [0,1]. // the initial fog color is (0, 0, 0, 0). GLfloat fogColor[4] = { 0.5, 0.5, 0.5, 1.0 }; glFogfv(GL_FOG_COLOR, fogColor); //Used in exponential fog equations. The initial fog density is 1. // Only nonnegative densities are accepted. glFogf(GL_FOG_DENSITY, 0.25); // the near distance used in the linear fog equation. The initial near distance is 0 glFogf(GL_FOG_START, 10.0); // the far distance used in the linear fog equation. The initial far distance is 1. glFogf(GL_FOG_END, 6000.0);
Buffers (Color + Depth) § An extra data buffer, in addition to the color buffer and depth buffer § Depth-buffer. it keep track of the depth of every pixel on the screen
Buffers (Stencil) § Stencil-buffer. it is used to limit the area of rendering (stenciling) § Usually contains 8 bits per stencil value that amounts to a total of 256 different stencil values
// re-enable color glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // where a 1 was not rendered.. try GL_NOTEQUAL glStencilFunc(GL_EQUAL, 1, 1); // keep the pixel glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glEnable(GL_DEPTH_TEST); // display as usual here... glDisable(GL_STENCIL_TEST); glutSwapBuffers(); }