Game Development Reference
In-Depth Information
5.
Specify a two-dimensional texture subimage using
glTexSubImage2D
with the following parameters:
GL_TEXTURE_2D
: It specifies the target texture.
Level
: It specifies the level of detail number. Level 0 is the base
image level.
Xoffset
: It specifies a texel (texture pixel) offset in the x direction
within the texture array.
Yoffset
: It specifies a texel offset in the y direction within the texture
array.
Width
: It specifies the width of the texture subimage.
Height
: It specifies the height of the texture subimage.
Format
: It specifies the format of the pixel data.
Type
: It specifies the data type of the pixel data.
Data
: It specifies a pointer to the image data in memory.
6.
Draw the Quad vertices, coordinates, and indices by calling the following:
glFrontFace
: It enables the front face of the Quad.
glVertexPointer: It defines the array of the Quad's vertex data with a
size of 3, of type GL_FLOAT, and a stride of 0.
glTexCoordPointer: It defines the Quad's array of texture coordinates
with a size of 2, of type GL_FLOAT, and a stride of 0.
ts
: It renders primitives from the data array using
triangles (
GL_TRIANGLES
), with 4 elements (hence a Quad) of type
short (
GL_UNSIGNED_SHORT
) plus a pointer to the indices.
In Listing 3-12 you see that the range of coordinates of the Quad is (-1, 1) in both axes. This
is because the range of the OpenGL coordinate system is (-1, 1) where the origin (0,0) is the
center (see Figure
3-9
).
glDrawElemen
Figure 3-9.
OpenGL coordinate system