Advertisement Jump to content


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

Austrian Coder

I have a little problem with render a terrain

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

Hi Gamedevelopers, i have found some infos about the Circles Algorithm and so i decided to code a terrain-System based on Circles Algorithm. Now i can generate the terrain and i can get from every Point (x/y) his height (z). Now my question, if anyone has an idea how to render this? I have tryed this: void CompileTerrain (void) { glNewList(1, GL_COMPILE); glBegin(GL_TRIANGLES); for (int x = 0; x < terrain.GetSize(); ++x) { for (int y = 0; y < terrain.GetSize (); y++) { float z = terrain.GetCell (x,y); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex3f(x-1.0f, y-1.0f, z-1.0f); glVertex3f(x, y, z); glVertex3f(x+1.0f, y+1.0f, z+1.0f); glEnd(); } } glEnd(); glEndList(); } but then when i render it (glCallList(1), it looks very strange. Thanks for all posts, Austrian Coder

Share this post

Link to post
Share on other sites
maybe, just maybe.. for your (for loops) try

for (int y = 0; y < terrain.GetSize() - 1; y++)
for (int x = 0; x < terrain.GetSize() - 1; x++)

that''s just how I do it, and i''m not sure if there there will be much of a difference.

and I''m pretty sure that GL_TRIANGLE_STRIP works better when you specify 4 Vertices (glVertex*).


"If you try and don''t succeed, destroy all evidence that you tried."

Share this post

Link to post
Share on other sites
By the looks of things you want to use GL_TRIANGLES instead of GL_TRIANGLE_STRIP.
No guarantees that will fix the problem(the vertices might be at fault), but it seems more correct from the code you've given.
And also, 'it looks very strange' is a bit vague.

Lastly, aren't you supposed to call glGenLists to get the list Id?
int id = glGenLists(1);
glNewList(id, GL_COMPILE);

I think that's correct.

[edited by - TheCray on April 18, 2002 5:32:07 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!