Game Development Reference
In-Depth Information
int texID[10], n;
//Allocate all texture objects and store each id in the array
//texID, n defines the total
//Use the textures
//Clean up
glDeleteTextures(n, texID);
To ensure that your code is working, try mapping a single bitmap to a
single four-sided polygon. Use the technique above to create and assign
a texture object. Enable textures using glEnable(GL_TEXTURE_2D). In
the render event for your code simply draw the textured polygon using
glRGB(255, 255, 255);
glNormal3d(0, 0, 1);
//first vertex
glTexCoord2f(0.0f, 0.0f);
glVertex3d(-1.0, 1.0, 0,0);
//second vertex
glTexCoord2f(1.0f, 0.0f);
glVertex3d(1.0, 1.0, 0,0);
//third vertex
glTexCoord2f(1.0f, 1.0f);
glVertex3d(1.0, -1.0, 0,0);
//fourth vertex
glTexCoord2f(0.0f, 1.0f);
glVertex3d(-1.0, -1.0, 0,0);
We are getting closer to being able to display a textured mesh. The next
step is to provide a way of mapping our pixel data onto our mesh. For this
we will need to create coordinates for each vertex in a textured polygon to
define what part of a bitmap the vertex uses.
Generating texture coordinates
Generating the texture coordinates can be done using the texture size,
centre and mapping type. Toon3D stores the texture coordinates in the
POLYGON structure, inside an indexed array of type TVEC.
Search Nedrilad ::

Custom Search