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();
No textures?
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
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
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.
Use the [ source ] tags next time too.
I have been using the [ code tags not wonder it doesn't work.
You were right should of been
You were right
grid[position].tex
grid[a].tex
Quote:Original post by coderWalker
I have been using the [ code tags not wonder it doesn't work.
You were right *** Source Snippet Removed *** should of been *** Source Snippet Removed ***
code-tags in action
source-tags in action
a-tags in action pointing to the FAQ
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement