• Advertisement
Sign in to follow this  

Texture Mapping... it ain't looking right!

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a textured hieght map. Now, I can load polygons, draw polygons, draw filled polygons, and it all loooks dandy. But I cannot figure out how to use textures. I have drawn a 16x16 grass texture:Image Hosted by ImageShack.us x number of polygons make up the height map. I have 3D coordinates for all of the polygons. On every polygon, I want one copy of the texture to be displayed. This is my current code to draw the texture:
void CPolygon::drawPolygonTex()
{
    glTexCoord2f(0.0f, 1.0f); glVertex3f(points[0].x, points[0].y, points[0].z); // Back left
    glTexCoord2f(1.0f, 1.0f); glVertex3f(points[1].x, points[1].y, points[1].z); // Back right
    glTexCoord2f(1.0f, 0.0f); glVertex3f(points[2].x, points[2].y, points[2].z); // Front right
    glTexCoord2f(0.0f, 0.0f); glVertex3f(points[3].x, points[3].y, points[3].z); // Front left
}
Basically every polygon will draw themselves with the texture. (points is the variable that holds the vertices.) This is what happens when I draw a polygon using that code: Image Hosted by ImageShack.us And if I just draw it filled with the color green (the height dictates the brightness of the green, not any lighting): Image Hosted by ImageShack.us So what am I doing wrong? Thanks for any help! If you need more info/code, just ask.

Share this post


Link to post
Share on other sites
Advertisement
I just realized something that is possible screwing up everything... my polygons are not flat. Damnit... now I have to rework my height generation :(

Share this post


Link to post
Share on other sites
Use triangle strips instead of quads. Also, your grass texture doesn't have very good resolution. Try tiling it instead of stretching it over the entire face.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement