• What is your GameDev Story?

Archived

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

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.

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 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*).

------------------------------------------------------------
Email
Website

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

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?
eg,
int id = glGenLists(1);
glNewList(id, GL_COMPILE);

I think that's correct.

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

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 10
• 9
• 11
• Forum Statistics

• Total Topics
634097
• Total Posts
3015495
×