2D Texgen

Both S & T coordinates can use texgen, to apply 2D textures with automatic coordinates.

This is done by making similar glTexGen calls for the T coordinate (but using a different plane).


GLfloat SplaneCoefficients[4] = { 1, 0, 0, 0 };
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, SplaneCoefficients);
glTexGenfv(GL_S, GL_OBJECT_PLANE, SplaneCoefficients);

GLfloat TplaneCoefficients[4] = { 0, 1, 0, 0 };
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, TplaneCoefficients);
glTexGenfv(GL_T, GL_OBJECT_PLANE, TplaneCoefficients);

Example: texgen2d.cpp



next