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:
Hopefully, with your help, it will be textured soon! Thanks.
A new one about texture mapping...
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:
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);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement