Multiple Textures Question.
Hi All, I am creating a board basically, which I want to have different textures. Here's basically what it'll be like, in an array form: 000000000000 011111111110 011111111110 011111111110 011111111110 011111111110 011111111110 000000000000 Where I want the 0 to have one texture, and the 1 to have another texture. Here is how I load them: CTargaImage image; image.Load("rock.tga"); glGenTextures(1, &m_floorTextures[0]); glBindTexture(GL_TEXTURE_2D, m_floorTextures[0]); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image.GetWidth(), image.GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, image.GetImage()); image.Release(); image.Load("water.tga"); glGenTextures(1, &m_floorTextures[1]); glBindTexture(GL_TEXTURE_2D, m_floorTextures[1]); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image.GetWidth(), image.GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, image.GetImage()); image.Release(); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); and here is where they are used: glBegin(GL_QUADS); for (int x=0; x<26; x++) { for (int y=0; y<19; y++) { if (boardLayout[y][x]==0) { // bind the texture glBindTexture(GL_TEXTURE_2D, m_floorTextures[0]); glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(x+1, y, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(x+1, y+1, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y+1, 0.0f); } if (boardLayout[y][x]==1) { glBindTexture(GL_TEXTURE_2D, m_floorTextures[1]); glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(x+1, y, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(x+1, y+1, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y+1, 0.0f); } } } glEnd(); But, when it runs, I get the water texture everywhere. It seems as though it's the second bind that holds, so how do I get the first texture to show up, and the second one? Any help would be most appreciated.
glBindTexture may not be called in the middle of a glBegin-glEnd pair.
Enigma
Enigma
the only thing i can think of is for you to draw another poly on top of the other but give the front poly a very small offset.
Quote:
Original post by Enigma
glBindTexture may not be called in the middle of a glBegin-glEnd pair.
Enigma
I see... So you are saying that I need to be binding the texture, and then entering the GL Begin... Will it allow me to bind a different texture at the start of another glBegin?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement