CHAPTER 8 - Implementation 3

Objectives<next>


Basic Strategy


Texture Mapping


Texture Example


Texture Mapping and the OpenGL Pipeline


Specify Texture Image


Define Image as a Texture

glTexImage2D( target, level, components, w, h, border, format, type, texels );

glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_texels);


Converting A Texture Image


Mapping a Texture


Typical Code

(see cubeTex.c)


glBegin(GL_POLYGON);
glColor3f(r0, g0, b0);
glNormal3f(u0, v0, w0);
glTexCoord2f(s0, t0);
glVertex3f(x0, y0, z0);
glColor3f(r1, g1, b1);
glNormal3f(u1, v1, w1);
glTexCoord2f(s1, t1);
glVertex3f(x1, y1, z1);
.
.
glEnd();


Interpolation


Texture Parameters


Wrapping Mode


Magnification and Minification


Filter Modes


Mipmapped Textures


Example




Texture Functions


Perspective Correction Hint

 


Generating Texture Coordinates


Texture Objects


Applying Textures II

  1. specify textures in texture objects
  2. set texture filter
  3. set texture function
  4. set texture wrap mode
  5. set optional perspective correction hint
  6. bind texture object
  7. enable texturing
  8. supply texture coordinates for vertex
    1. coordinates can also be generated

Other Texture Features


<next>