• Advertisement

Archived

This topic is now archived and is closed to further replies.

glTexGen Problems

This topic is 6453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''m having some problems with the glTexGen function. I''m trying to texture map a cube but can only seem to get it to texture the front and back. When I just use glTexCoord all sides texture properly. I don''t think I properly understand how to set the s_vector and t_vector values. Could anyone offer some guidance? Is there a good example of 2D automatic texture coordinate generation on the net? My code sample: GLfloat s_vector[4] = {1.0, 0.0, 0.0, 0.0}; GLfloat t_vector[4] = {0.0, 1.0, 0.0, 0.0}; GLfloat r_vector[4] = {0.0, 0.0, 1.0, 0.0}; GLfloat q_vector[4] = {0.0, 0.0, 0.0, 10000.0}; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, s_vector); glTexGenfv(GL_T, GL_OBJECT_PLANE, t_vector); glTexGenfv(GL_R, GL_OBJECT_PLANE, r_vector); glTexGenfv(GL_Q, GL_OBJECT_PLANE, q_vector); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); glEnable(GL_TEXTURE_GEN_Q); // Enable texturing glEnable(GL_TEXTURE_2D); // Call the texture glCallList(BlueDenimTexture); glBegin(GL_TRIANGLES); // Right Side glNormal3f( 1.0f, 0.0f, 0.0f); glTexCoord2f(0.0, 0.0); glVertex3f( 0.0f, 0.0f, 20000.0f); glTexCoord2f(1.0, 0.0); glVertex3f( 0.0f, 0.0f, 10000.0f); glTexCoord2f(1.0, 1.0); glVertex3f( 0.0f, 10000.0f, 10000.0f); glTexCoord2f(1.0, 1.0); glVertex3f( 0.0f, 10000.0f, 10000.0f); glTexCoord2f(0.0, 1.0); glVertex3f( 0.0f, 10000.0f, 20000.0f glTexCoord2f(0.0, 0.0); glVertex3f( 0.0f, 0.0f, 20000.0f); // Left Side glNormal3f( -1.0f, 0.0f, 0.0f); ... I don''t seem to need the r and q vectors. Instead I can just divide the s and t vectors by q and get the same result. If I change the t vector to GLfloat t_vector[4] = {0.0, 0.0, 1.0, 0.0}; then I can get the top and bottom to texture but not the front. Also, this texture appears flipped backwards. I can''t seem to find a combination that will allow all sides to show the texture correctly. The Red Book was helpful but only has a 1D example. The glTexCoord calls aren''t needed - they were just there so I could prove to myself that I was texturing correctly. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement