Applying textures to triangle strips
Now that I have all the right texture coords assigned to my triangles strips, I cant get the textures to bind.
The redbook lists glBindTexture as an invalid command for use inbetween glBegin and glEnd function.
What can be done to texture the strip with several different textures?
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
I had the very same problem as you. I ended up in the end (because I couldn''t find anyone to help me) creating a generic texture and just wrapping it arround my triangle fan. I know this doesn''t help but maybe it will give you a place to start.
/////////////////////////////////////////////////////////////////////////////////
// This Function Will Draw A Pyramid Around The Orgin With Pinicle At (0,1,0)
// yElongf Will Elongate Pyramid In The (0,-1,0) Direction
void GimmiePyrie(float yElongf){
///////////////////////////////////////////////////
glBindTexture(GL_TEXTURE_2D, tList[TriTex]);
glBegin(GL_TRIANGLE_FAN);
glColor3f(1.0f,0.0f,0.0f);
glTexCoord2f(0.5f,1.0f); glVertex3f(0.0f,0.0f,0.0f); // Top
glColor3f(0.0f,0.5f,1.0f);
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f); // Front Left-Bottom
glTexCoord2f(1.0f,0.0f); glVertex3f(1.0f,(-1.0f-yElongf),1.0f); // Front Right-Bottom
glTexCoord2f(0.0f,0.0f); glVertex3f(1.0f,(-1.0f-yElongf),-1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),-1.0f);
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, tList[LogoTag]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,1.0f); glVertex3f(1.0f,(-1.0f-yElongf),1.0f); // BAck-Right
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f); // top-Right
glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),-1.0f); // Top-Left
glTexCoord2f(1.0f,1.0f); glVertex3f(1.0f,(-1.0f-yElongf),-1.0f); // Back-Left
glEnd();
//////////////////////////////////////////////////
}
-The Headstones are talking... Can you hear them?
/////////////////////////////////////////////////////////////////////////////////
// This Function Will Draw A Pyramid Around The Orgin With Pinicle At (0,1,0)
// yElongf Will Elongate Pyramid In The (0,-1,0) Direction
void GimmiePyrie(float yElongf){
///////////////////////////////////////////////////
glBindTexture(GL_TEXTURE_2D, tList[TriTex]);
glBegin(GL_TRIANGLE_FAN);
glColor3f(1.0f,0.0f,0.0f);
glTexCoord2f(0.5f,1.0f); glVertex3f(0.0f,0.0f,0.0f); // Top
glColor3f(0.0f,0.5f,1.0f);
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f); // Front Left-Bottom
glTexCoord2f(1.0f,0.0f); glVertex3f(1.0f,(-1.0f-yElongf),1.0f); // Front Right-Bottom
glTexCoord2f(0.0f,0.0f); glVertex3f(1.0f,(-1.0f-yElongf),-1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),-1.0f);
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, tList[LogoTag]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,1.0f); glVertex3f(1.0f,(-1.0f-yElongf),1.0f); // BAck-Right
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),1.0f); // top-Right
glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,(-1.0f-yElongf),-1.0f); // Top-Left
glTexCoord2f(1.0f,1.0f); glVertex3f(1.0f,(-1.0f-yElongf),-1.0f); // Back-Left
glEnd();
//////////////////////////////////////////////////
}
-The Headstones are talking... Can you hear them?
-The Headstones are talking... Can you hear them?
Im working with terrain and tile sets.
my code to draw the strip looks like this.
glBegin()
//loop through width
//bind texture
//send 2 vertices to ogl
glEnd()
(I cant get the real code to post here, the forum garbles is up)
I have some other ways of drawing the terrain that work, the triangle strips are fast, and I was hopeing to get them to work.
Edited by - Eber Kain on February 9, 2002 4:07:03 PM
my code to draw the strip looks like this.
glBegin()
//loop through width
//bind texture
//send 2 vertices to ogl
glEnd()
(I cant get the real code to post here, the forum garbles is up)
I have some other ways of drawing the terrain that work, the triangle strips are fast, and I was hopeing to get them to work.
Edited by - Eber Kain on February 9, 2002 4:07:03 PM
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
As far as I know it''s not possible to apply different textures to one large strip with only one call. Make a displaylist for each chunk of your map you want to texture with a different texture. Then call the lists and change the texture between the calls. You could also use vertex arrays.
If anyone knows a better solution, please post it.
If anyone knows a better solution, please post it.
a dodgy way to do it (if you only have a few tile textures) would be to combine all the tile textures into one, and then play funky tex-coord games to offset correctly to the tile you want.
this will also keep overhead down in general, as there is only one texture bind.
[edit] actually, the way i would probably tackle it myself would be to strip the triangles according to their texture, and use vertex arrays to batch them up (you can stitch separate strips with the same texture together using degenerate triangles)
Edited by - Bad Monkey on February 9, 2002 9:45:27 PM
this will also keep overhead down in general, as there is only one texture bind.
[edit] actually, the way i would probably tackle it myself would be to strip the triangles according to their texture, and use vertex arrays to batch them up (you can stitch separate strips with the same texture together using degenerate triangles)
Edited by - Bad Monkey on February 9, 2002 9:45:27 PM
Guess ill have to use vertex arrays, display lists wont work because I want to be able to change the data that describes the geometry as the program runs.
I have everything working with just plain triangles, it runs slow because im rebinding a new texture every frame, and there is no way for me to put all the textures into one (alot of them are generated as the program runs). Perhaps I should draw my stuff based on the textures that are to be bound.
I have everything working with just plain triangles, it runs slow because im rebinding a new texture every frame, and there is no way for me to put all the textures into one (alot of them are generated as the program runs). Perhaps I should draw my stuff based on the textures that are to be bound.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement