Creating textures
OpenGL offers the use of 1D, 2D, and 3D textures. 2D textures are the most commonly used, even in 3D games. Support for 3D textures was introduced with OpenGL 1.2. A 3D texture can be thought as a layered 2D texture. 1D textures can be used in situations where the texture doesn't change along one dimension, for example, a rainbow.
Getting ready
OpenGL, by default, doesn't use any textures. All polygons are rendered with solid color, defined by colors on the vertices. This method of rendering is called Flat shading. Optionally, these vertex colors can be interpolated with so-called Smooth shading or Gouraud shading. The difference between these two modes becomes apparent with vertex lighting as you can see in the following figure:
To use textures, you'll need to toggle the texturing state with the gl.Enable
function. There are altogether three states for texturing—GL_TEXTURE_1D
, GL_TEXTURE_2D
, and GL_TEXTURE_3D
. Each one allows you to use a certain type of texture. You can...