Original Post
Hi there, I've followed a tutorial (http://cityintherain.com/howtotex.html) on how to enable automatic texture coordinate with multitexturing on. Here is the set up of the stuff: Note that if I comment all code for automatic texture coord generation and uncomment the manual glMultiTexCoord2f() calls, everything works fine, proving the mistake is not in other part of the setup but simply the texture coord generation. Your eyes and wisdom are appreciated. :) [Edited by - methe on September 20, 2006 7:25:48 AM]
// Parameter used by the automatic texture coordinate generation
// Define how the S parameter depends on x, y, z, w
GLfloat paramS[ ] = {1.0, 0.0, 0.0, 0.0};
// Define how the T parameter depends on x, y, z, w
GLfloat paramT[ ] = {0.0, 1.0, 0.0, 0.0};
//We give the elevation as texture 0
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, gl_altitude_id);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//Set automatic coord generation for texture 1
//Set automatic texture coord generation for S axis
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, paramS);
//Set automatic texture coord generation for T axis
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_T, GL_OBJECT_PLANE, paramT);
//Enable automatic texture coordinate generation for S and T axis
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
//We give the normal as texture 1
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, gl_normal_id);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//Set automatic coord generation for texture 2
//Set automatic texture coord generation for S axis
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, paramS);
//Set automatic texture coord generation for T axis
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_T, GL_OBJECT_PLANE, paramT);
//Enable automatic texture coordinate generation for S and T axis
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glActiveTexture(GL_TEXTURE2);
glDisable(GL_TEXTURE_2D);
glBegin(GL_POLYGON);
// glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0);
// glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0);
glVertex2f(0.0, 0.0);
// glMultiTexCoord2f(GL_TEXTURE0, 1.0, 1.0);
// glMultiTexCoord2f(GL_TEXTURE1, 1.0, 1.0);
glVertex2f(1.0, 1.0);
// glMultiTexCoord2f(GL_TEXTURE0, 0.0, 1.0);
// glMultiTexCoord2f(GL_TEXTURE1, 0.0, 1.0);
glVertex2f(0.0, 1.0);
glEnd();