Texture

Started by
4 comments, last by ltrain_riders 21 years, 6 months ago
In this section of code: glBegin(GL_QUADS); glTexCoord2f( 1.0f, 1.0f );glVertex3f( 5.1f, 0.1f, -4.1f );// back right glTexCoord2f( 0.0f, 1.0f );glVertex3f( -5.1f, 0.1f, -4.1f );//back left glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.1f, 4.1f );//front left glTexCoord2f( 1.0f, 0.0f );glVertex3f( 5.1f, 0.1f, 4.1f ); //front right glEnd( ); I''m texturing the top of a quad but the texture is stretched out over the face of the quad. How can I map it so the texture isn''t "smeared". The full code and how I created the texture can be viewed here: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=1585
Advertisement
What do you want instead of the "smeared"?

if you want it to only cover 1/2 change the TexCoords2f()
Those line up the texutre with 0 being the min, 1 being the max.



When I say "smeared" I mean the texture is stretched out because of the face I''m mapping is large. A face I''m trying to map is 10 units wide (x direction) and 8 units deep (z direction) and I''m mapping the corners of the texture to each proper corner of the face thus stretching the texture. How is it possible to map the texture multiple times on the face? By doing this, would my face have a better detail and won''t look smeared and stretched?
try this.

glBegin(GL_QUADS);
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.1f, -4.1f );// back right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.1f, -4.1f );//back left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.1f, 4.1f );//front left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.1f, 4.1f ); //front right
glEnd( );
Ok, I changed to TexCoords( 10.0f,...) but I can''t manage to texture map other objects with a different texture. Both my wall.tga and floor.tga work because:
void init ( void )
{
if( (LoadTGA(&textures[0],"wood.TGA")) || (LoadTGA(&textures[1],"Floor.TGA") )) // Load The Font Texture
{ glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
whatever file I load in &textures[0] will work, but the objects I try to map &textures[1] won''t work. It''s not my .tga files because whatever file I load in &textures[0] works, its the second part that is troubling me. My code is set up so when I call LoadTGA( ), the argument will be passed to texture[0] and texture[0] will handle all the binding and generation of the texture.
When I run this, all the objects that were suppose to texturemapped from &textures[1] are gray. What the sh*t is going on here!?
here''s my updated code:
http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=1611

This topic is closed to new replies.

Advertisement