texturing a heightmap
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
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 1glEnd()glBindTexture(...texture2...)glBegin(...)... draw geometry using texture 2glEnd()etc...
BTW: Moved to the OpenGL forum.
/ Yann
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?
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?
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++)
{
}
I think you want...
for(i = 0; i < 32; i++)
{
}
This may be the kind of form you should look at:
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]
glBindTexture();glBegin(GL_TRIANGLE_STRIP);for(i=1; i<32; i++){for(j=1; j<32; j++){//draw 4 vertices (2 triangles) from heightmapif (item [i][j] has a different texture){glEnd();glBindTexture(); // new textureglBegin(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]
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?
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?
You can use the [ source ] [ /source ] tags or the older
tags. Check out the forum faq( labeled as "faq" ) on any page of the forums.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement