Open GL Super Bible

Previous Table of Contents Next


Reference Section

glTexCoord

Purpose
Specifies the current texture image coordinate for textured polygon rendering.
Include File
<GL/gl.h>
Syntax
void glTexCoord1{dfis}(TYPE s);
void glTexCoord1{dfis}v(TYPE *s);
void glTexCoord2{dfis}(TYPE s, TYPE t);
void glTexCoord2{dfis}v(TYPE *st);
void glTexCoord3{dfis}(TYPE s, TYPE t, TYPE r);
void glTexCoord3{dfis}v(TYPE *stq);
void glTexCoord4{dfis}(TYPE s, TYPE t, TYPE r, TYPE q);
void glTexCoord4{dfis}v(TYPE *strq);
Description
These functions set the current texture image coordinate in 1–4 dimensions. For example, the s and t parameters correspond to the horizontal and vertical image coordinates of a 2D texture image.

Parameters

s
The horizontal texture image coordinate.
t
The vertical texture image coordinate.
r
The texture image depth coordinate.
q
The texture image “time” coordinate.
Returns
None.
Example
See the example in CH12\TEXSCENE.C on the source code CD-ROM.
See Also
glTexEnv, glTexGen, glTexImage1D, glTexImage2D, glTexParameter

glTexEnv

Purpose
Sets texturing parameters.
Include File
<GL/gl.h>
Syntax
void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
void glTexEnvfv(GLenum target, GLenum pname, GLfloat *param);
void glTexEnvi(GLenum target, GLenum pname, GLint param);
void glTexEnviv(GLenum target, GLenum pname, GLint *param);
Description
The glTexEnv functions set texture-mapping parameters that control how texture images are mapped to polygons. The GL_DECAL texturing mode uses a texture image directly to draw polygon. GL_BLEND and GL_MODULATE texture modes use the GL_TEXTURE_ENV_COLOR color and the current framebuffer to determine what pixels are textured.

Parameters

target
GLenum: The texture environment to define; must be GL_TEXTURE_ENV.
pname
GLenum: The parameter name to define. Valid names are as follows:
GL_TEXTURE_ENV_MODE Specifies the type of texturing to do.
GL_TEXTURE_ENV_COLOR Specifies the color to use for blending.
param
The parameter value. For GL_TEXTURE_ENV_COLOR, param is a pointer to an RGBA color value. For GL_TEXTURE_ENV_MODE, it can be one of the following constants:
GL_DECAL Texture images are directly mapped to the framebuffer.
GL_BLEND Texture images are blended with a constant color (GL_TEXTURE_ENV_ COLOR) before being mapped to the framebuffer.
GL_MODULATE Texture images are multiplied with the framebuffer before being mapped to it.
Returns
None.
Example
See the example in CH12\TEXSCENE.C on the source code CD-ROM.
See Also
glTexCoord, glTexGen, glTexImage1D, glTexImage2D, glTexParameter

glTexGen

Purpose
Defines parameters for texture coordinate generation.
Include File
<GL/gl.h>
Syntax
void glTexGend(GLenum coord, GLenum pname, GLdouble param);
void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
void glTexGeni(GLenum coord, GLenum pname, GLint param);
void glTexGendv(GLenum coord, GLenum pname, GLdouble *param);
void glTexGenfv(GLenum coord, GLenum pname, GLfloat *param);
void glTexGeniv(GLenum coord, GLenum pname, GLint *param);
Description
This function sets parameters for texture coordinate generation when one or more of GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R, or GL_TEXTURE_GEN_Q is enabled with glEnable.
When GL_TEXTURE_GEN_MODE is set to GL_OBJECT_LINEAR, texture coordinates are generated by multiplying the current object (vertex) coordinates by the constant vector specified by GL_OBJECT_PLANE:
    coordinate = v[0] * p[0] + v[1] * p[1] + v[2] * p[2] + v[3] * p[3]
For GL_EYE_LINEAR, the eye coordinates (object coordinate multiplied through the GL_MODELVIEWmatrix) are used.
When GL_TEXTURE_GEN_MODE is set to GL_SPHERE_MAP, coordinates are generated in a sphere about the current viewing position or origin.

Parameters

coord
GLenum: The texture coordinate to map. Must be one of GL_S, GL_T, GL_R, or GL_Q.
pname
GLenum: The parameter to set. Must be one of GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, or GL_EYE_PLANE.
param
The parameter value. For GL_TEXTURE_GEN_MODE, param is one of the following:
GL_OBJECT_LINEAR Texture coordinates are calculated from object (vertex) coordinates.
GL_EYE_LINEAR Texture coordinates are calculated by eye coordinates (object coordinates multiplied through the GL_MODELVIEW matrix).
GL_SPHERE_MAP Texture coordinates are generated in a sphere around the viewing position.
For GL_OBJECT_PLANE and GL_EYE_PLANE, param is a 4-element array that is used as a multiplier for object or eye coordinates.
Returns
None.
Example
See the example in CH12\TEXSCEN2.C on the source code CD-ROM.
See Also
glTexCoord, glTexEnv, glTexImage1D, glTexImage2D, glTexParameter


Previous Table of Contents Next