Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

robirt

texturing a heightmap

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

what is a good way for texturing a heightmap? Right now i am rendering as triangle strips and i have been having problems getting this to work. When i put glBindTexture between glBegin(GL_TRIANGLE_STRIP) and glEnd, it doesnt work. also i have heard that it is best to render all polygons of the same texture at the same time. so you dont call bindtexture for the same texture more than once a frame. someone help please

Share this post


Link to post
Share on other sites
Advertisement
quote:

When i put glBindTexture between glBegin(GL_TRIANGLE_STRIP) and glEnd, it doesnt work.


Calling glBindTexture() between a Begin/End pair is invalid, the command will be ignored. Put your glBindTexture call before glBegin.

quote:

also i have heard that it is best to render all polygons of the same texture at the same time. so you dont call bindtexture for the same texture more than once a frame


You heard right.

Example:

glBindTexture(...texture1...)
glBegin(...)
... draw geometry using texture 1
glEnd()

glBindTexture(...texture2...)
glBegin(...)
... draw geometry using texture 2
glEnd()

etc...


BTW: Moved to the OpenGL forum.

/ Yann

Share this post


Link to post
Share on other sites
thanks. so, will i have to give up on the triangle strips since there may be different textures or what?

my terrain rendering code is something like this:

for(x=1; x++; x<32)
{
glBegin(GL_TRIANGLE_STRIP);
for(x=1; x++; x<32)
{
glBindTexture();
//draw 4 vertices (2 triangles) from heightmap
}
glEnd();
}

i know this doesnt work, but can you tell me a correct way to get the results i want?

Share this post


Link to post
Share on other sites
The reason it doesn''t work may have something to do with the fact that you APPEAR to have the syntax of the for loop a little wrong. The loop as you have written it won''t generate errors, but it won''t accomplish what you want it too either.

I think you want...

for(i = 0; i < 32; i++)
{
}

Share this post


Link to post
Share on other sites
This may be the kind of form you should look at:

    
glBindTexture();
glBegin(GL_TRIANGLE_STRIP);
for(i=1; i<32; i++)
{
for(j=1; j<32; j++)
{
//draw 4 vertices (2 triangles) from heightmap

if (item [i][j] has a different texture)
{
glEnd();
glBindTexture(); // new texture

glBegin(GL_TRIANGLE_STRIP);
}
}
}


Also, because heightmaps don't generally change, you may want to consider using display lists if you aren't already.

(Note: this is an idea off the top of my head and is certain to have flaws)

_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________


[edited by - Thunder_Hawk on July 1, 2002 11:59:00 PM]

Share this post


Link to post
Share on other sites
that loop code wasnt exact from my code, it is correct in my real code.

anyway, I will try thunderhawks idea, but i am planning on having fully deformable terrain, so i dont use a display list.
Thanks all.

btw how do i make a textbox for code in the forum?

Share this post


Link to post
Share on other sites
You can use the [ source ] [ /source ] tags or the older [ code ] [ /code ] tags. Check out the forum faq( labeled as "faq" ) on any page of the forums.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!