OpenGL (1.2 - 2.0) Code Samples - Page 2

Indexed Geometry
 

This sample demonstrates how to optimize performance by using indexed geometry. As a demonstration, the sample reduces the vertex count of a simple cube from 24 to 8 by redefining the cube’s geometry using an indices array. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: glInterleavedArrays, glDrawElements, glDrawArrays, GL_C3F_V3F, and GL_QUADS.

 

Transforms
 

Demonstrates how to use the transformation commands glScalef, glRotatef, and glTranslatef  to create a simulated solar system. As an additional example, the sample also demonstrates how to use a user-defined matrix utility class to perform the same transforms. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: glMatrixMode, glLoadIdentity, glScalef, glRotatef, glTranslatef, glPushMatrix, glPopMatrix, gluLookAt, and glutWireSphere.

 

Near/Far Clipping Plane
 

This sample demonstrates how adjustments to OpenGL's near and far clip planes effect the view.

Relevant Keywords: glViewport, gluPerspective, glMultMatrixf, glLoadIdentity, glScalef, glTranslatef, glPolygonMode, glPushMatrix, glPopMatrix, glutWireTeapot, glColor3f, GL_FRONT, GL_LINE, GL_TRIANGLES, and GL_N3F_V3F.

 

Texture Mapping
 

Demonstrates basic texture mapping using a textured quad and a bitmap of some wooden floor tiles. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: auxDIBImageLoad, glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glEnable, AUX_RGBImageRec, GL_T2F_V3F, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, GL_LINEAR, and GL_UNSIGNED_BYTE.

 

Texture Filtering
 

Demonstrates how to filter out unwanted graphical artifacts from OpenGL textures. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: auxDIBImageLoad, glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glEnable, AUX_RGBImageRec, GL_T2F_V3F, GL_TEXTURE_2D, GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, and GL_LINEAR_MIPMAP_LINEAR.