🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
texture on more than one polygon :it's possible?
it is possible to apply a texture on more than one polygon and if so what are the limits?i have tried to apply one texture on the lateral sides of a cube but don''t works.
What''s the problem?
Why should be there a limit for apply a texture on polygon''s?
You tell OpenGL which texture should be used for the next polygon''s and it will use it. Then you only have to define a texture position for each vertex. (nice experiment: When a triangle is defined change the used texture in this definition... which texture you will see at the end? I thing the texture which is set in front of ''glBegin()'')
When you define ''wrong'' positions the texture will look crazy or invisible.
Example:
glBindTexture(GL_TEXTURE_2D, texName);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glVertex3f(0, 0, 0);
glTexCoord2f(1, 0);
glVertex3f(1, 0, 0);
glTexCoord2f(1, 1);
glVertex3f(1, 1, 0);
.
.
.
glEnd();
Have I answered you question? (I confess, the question confuse me... (wow, english is a great language... it allows nice word games (laze, blaze, ablaze...)!!))
Why should be there a limit for apply a texture on polygon''s?
You tell OpenGL which texture should be used for the next polygon''s and it will use it. Then you only have to define a texture position for each vertex. (nice experiment: When a triangle is defined change the used texture in this definition... which texture you will see at the end? I thing the texture which is set in front of ''glBegin()'')
When you define ''wrong'' positions the texture will look crazy or invisible.
Example:
glBindTexture(GL_TEXTURE_2D, texName);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glVertex3f(0, 0, 0);
glTexCoord2f(1, 0);
glVertex3f(1, 0, 0);
glTexCoord2f(1, 1);
glVertex3f(1, 1, 0);
.
.
.
glEnd();
Have I answered you question? (I confess, the question confuse me... (wow, english is a great language... it allows nice word games (laze, blaze, ablaze...)!!))
i have tried in the following mode:glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f, -1.0f);
// Right face
glVertex3f( 1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
// Left Face
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
// Top Face
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glEnd();
it should extend the texture on the four lateral sides of a cube but it don''t works!
and what glbindtexture do?
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f, -1.0f);
// Right face
glVertex3f( 1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
// Left Face
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
// Top Face
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glEnd();
it should extend the texture on the four lateral sides of a cube but it don''t works!
and what glbindtexture do?
Okay, let me get this straight, do you want the same texture on each side, or do you want it to wrap around? glBindTexture() tells OpenGL which texture to use for drawing, for example:
That should put the same texture on each face, if you want to wrap the texture around, you will need to alter your texture coordinates.
Morgan
glBindTexture( GL_TEXTURE_2D, texture ); glBegin( GL_QUADS ); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Right face glVertex3f( 1.0f, -1.0f, -1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Left Face glVertex3f(-1.0f, -1.0f, -1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Face glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Bottom Face glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glEnd();
That should put the same texture on each face, if you want to wrap the texture around, you will need to alter your texture coordinates.
Morgan
one thing if u want a differnet texture on 2 different polys
youve gotta go
glBindTexture...
glBegin(..)
draw
glEnd();
glBindTexture... // diff texture
glBegin(..)
draw
glEnd();
u cant go
glBindTexture...
glBegin(..)
draw
glBindTexture...
draw
glEnd();
ie changing textures is not allowed between begin.. end statements
youve gotta go
glBindTexture...
glBegin(..)
draw
glEnd();
glBindTexture... // diff texture
glBegin(..)
draw
glEnd();
u cant go
glBindTexture...
glBegin(..)
draw
glBindTexture...
draw
glEnd();
ie changing textures is not allowed between begin.. end statements
now i have understand glbindtexture but what i want to do is extend a texture on more polygon .
for examble if i do a bootle can i do a etiquette(a single 2d texture) that cover the front of the bottle like a true bottle?or i have to do a mini texture with part of etiquette for every polygon?
for examble if i do a bootle can i do a etiquette(a single 2d texture) that cover the front of the bottle like a true bottle?or i have to do a mini texture with part of etiquette for every polygon?
You need to specify a tex coord for every vertex. You need the same amount of calls to glTexCoord as you do to GLVertex, period.
since you are using quads the front face would be:
glTexcoord2f(0,0); glVertex3f(-2,-2, 2);
glTexcoord2f(1,0); glVertex3f( 2,-2, 2);
glTexcoord2f(1,1); glVertex3f( 2, 2, 2);
glTexcoord2f(0,1); glVertex3f(-2, 2, 2);
OpenGL will not aoutomatically come up with the rest of the coords.
If you do it this way it will work, and you will have a total of 24 calls to each.
Another Thing, Never call glBindTexture() between gBegin() and glEnd() statements. It confuses it sometimes.
since you are using quads the front face would be:
glTexcoord2f(0,0); glVertex3f(-2,-2, 2);
glTexcoord2f(1,0); glVertex3f( 2,-2, 2);
glTexcoord2f(1,1); glVertex3f( 2, 2, 2);
glTexcoord2f(0,1); glVertex3f(-2, 2, 2);
OpenGL will not aoutomatically come up with the rest of the coords.
If you do it this way it will work, and you will have a total of 24 calls to each.
Another Thing, Never call glBindTexture() between gBegin() and glEnd() statements. It confuses it sometimes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement