Jump to content
  • Advertisement
Sign in to follow this  
steg

OpenGL Draw filled 2d landscape

This topic is 2608 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,

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
Advertisement
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

Landscape on iPhone


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!