Advertisement Jump to content
Sign in to follow this  
silverphyre673

A new one about texture mapping...

This topic is 4938 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

OK, let's just assume I have a texture loaded into memory successfully, with the ID stored in the GLuint "texture_id". If I'm drawing triangle strips according to the following algorithm, then how would I want to make my glTexCoord2f() calls so that the texture will be displayed properly? Here is the algorithm used for rendering:
void RenderHeightmap(const HeightMap * height_map)
{
    glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
    for (float y = 0.0f; y < (float)height_map->Height() - 1; ++y)
    {
        glBegin(GL_TRIANGLE_STRIP);
        for ( float x = 0.0f; x < (float)height_map->Width(); ++x)
        {
                //Where do the glTexCoord2f()s go?
                glVertex3f(x, y, height_map->GetTileInfo((int)x, (int)y).height);
                glVertex3f(x, y + 1.0f, height_map->GetTileInfo((int)x, (int)(y + 1.0f)).height);
        }
        glEnd();
    }
}
And here is a screenshot of the results, in wireframe mode: Image hosted by Photobucket.com Hopefully, with your help, it will be textured soon! Thanks.

Share this post


Link to post
Share on other sites
Advertisement
It should look like this:


glTexCoord2f(x/height_map->Width(), y/height_map->Height())
glVertex3f(x, y, height_map->GetTileInfo((int)x, (int)y).height);

glTexCoord2f(x/height_map->Width(),(y+1)/height_map->Height())
glVertex3f(x, y + 1.0f, height_map->GetTileInfo((int)x, (int)(y + 1.0f)).height);

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!