Jump to content
  • Advertisement
Sign in to follow this  
coderWalker

No textures?

This topic is 2779 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

For some reason the textures are not showing on my cube? Do I have the calls arranged wrong? Drawing 1 side shows the texture, however drawing 6 sides does not.

//==Shows texture correctly
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D,grid[3].tex);
//Front
glBegin( GL_QUADS );
glNormal3f(0.0f, 0.0f, -1.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 1, 0 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 0, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 0, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 1, 0 );
glEnd();
glPopMatrix();

//==Shows White untextured objects
glPushMatrix();
glTranslatef(grid[a].x,grid[a].y,grid[a].z);
glBindTexture( GL_TEXTURE_2D,grid[position].tex );
//Front
glBegin( GL_QUADS );
glNormal3f(0.0f, 0.0f, -1.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 1, 0 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 0, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 0, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 1, 0 );
glEnd();
//Back
glBegin( GL_QUADS );
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 1, 1 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 0, 1 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 0, 1 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 1, 1 );
glEnd();
//Top
glBegin( GL_QUADS );
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 1, 1 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 1, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 1, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 1, 1 );
glEnd();
//Bottom
glBegin( GL_QUADS );
glNormal3f(0.0f, -1.0f, 0.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 0, 1 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 0, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 0, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 0, 1 );
glEnd();
//Left
glBegin( GL_QUADS );
glNormal3f(-1.0f, 0.0f, 0.0f);
glTexCoord2d(1.0,1.0);glVertex3f(0, 1, 1 );
glTexCoord2d(1.0,0.0);glVertex3f(0, 1, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(0, 0, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(0, 0, 1 );
glEnd();
//Right
glBegin( GL_QUADS );
glNormal3f(1.0f, 0.0f, 0.0f);
glTexCoord2d(1.0,1.0);glVertex3f(1, 1, 1 );
glTexCoord2d(1.0,0.0);glVertex3f(1, 1, 0 );
glTexCoord2d(0.0,0.0);glVertex3f(1, 0, 0 );
glTexCoord2d(0.0,1.0);glVertex3f(1, 0, 1 );
glEnd();
glPopMatrix();

Share this post


Link to post
Share on other sites
Advertisement
Hi,

You may get this result if:
-You're not enabling GL_TEXTURE_2D in your second code
-grid[position].tex doesn't exist (or doesn't work right). Try drawing the second code with grid[3].tex, and see if that fixes it.
-you're drawing these two methods from different places.
-the glTranslatef(...) call in the second method alters the rendering (i.e., if you have white fog enabled, and you move it further away, you'll get problems).

Also, for optimization, you only need one glBegin(...)/glEnd() wrapper for ALL of those polygons.

-G

Share this post


Link to post
Share on other sites
Are you enabling texturing in the second example? It's hard to see if it might be elsewhere in your code or not. Also, is the position variable pointing to the right texture?

Use the [ source ] tags next time too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!