Sign in to follow this  
steg

OpenGL Draw filled 2d landscape

Recommended Posts

Hi,

Quite new to OpenGL but using OpenGL ES on mobile. Now I know it doesn't support GL_POLYGON so I thought maybe I can just use GL_TRIANGLE_STRIP. I want to create a
random 2d landscape for a side scroller, think of the old arcade game Defender, but I want the landscape filled in. Now I am guessing that I will need to create a lot of quads to do this and
fill each of them in? Is this the best approach?

Thanks,
Steve

Share this post


Link to post
Share on other sites
GL_POLYGON is dead meat in GL 3.0 as well.
For GL ES, use GL_TRIANGLE_STRIP or GL_TRIANGLES with glDrawElements.

Share this post


Link to post
Share on other sites
Thanks,

Was thinking of using glDrawArray?...

Would I have to draw each part of the landscape as a series of triangles that make a quad in order to fill them?

Many thanks,
Steve

Share this post


Link to post
Share on other sites
With GL_TRIANGLES and glDrawElements you can render the entire terrain with a single call.

With GL_TRIANGLE_STRIP and glDrawElements, it depends. You would either have to render each strip, one by one.
Or you can use NULL triangles and use a single call to glDrawElements. You would have to research the hardware capabilities of your target platform if it handles NULL triangles well.

I won't make performance recommendations since I don't program for embedded systems.

Share this post


Link to post
Share on other sites
Thanks for the info.

I've now generated the landscape using GL_TRIANGLE_FAN. Landscape kind of like the old moon patrol game if you know it? Would love to know how to create 'curved' landscape that is filled in, I guess you need some form of triangulator to do this? Was thinking of generating the curve with some simple math, but dunno how you would triangulate it?!

Thanks,
Steve

[url="http://www.youtube.com/watch?v=N7uvE9lTQWI"]Landscape on iPhone[/url]


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this