Texture Examples
Here are a variety of examples for working with texture maps in OpenGL.
Some of these import images from files two sample image files are Martini.ppm
(512x512) and spots.ppm. (320x200)
- texsimple.cpp is a first example for texture
mapping. This creates a red and while checkerboard pattern and maps it onto
a rectangle. If you move the light around you can see that it has no effect
on the image.
- tex2.cpp displays two rectangles with checkerboard
patterns. The upper rectangle uses the same technique as in texsimple.cpp.
The lower rectangle uses automatic texture generation. Note that the lighting
does work in these examples.
- tex3.cpp is similar to tex2.cpp, but instead of a
checkerboard pattern it opens up the Martini ppm file and maps that onto the
rectangle.
- texquadric.cpp gives several methods for texturing
quadric surfaces -- spheres, cylinders, cones (the subject of this example)
and so forth.
- texSpline.cpp displays two copies of the bottle-shaped
spline surface from SplineExamples/closedSurface.c and gives two methods for
texturing such splines with a checkerboard.
- texSpline2.cpp has only one copy of the bottle
and maps the Martine picture onto it as a label.
- texSpline3.cpp shows how to work with textures
from image files whose dimensions aren't powers of two.
Here is the makefile for these programs.