iDevGames Forums
Creating a 2D landscape from polygons - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Creating a 2D landscape from polygons (/thread-6438.html)



Creating a 2D landscape from polygons - aarku - Jul 16, 2004 02:01 PM

I've scrapped software tile-based rendering on my project due to speed issues and too many walls/restrictions. Now I want to draw the terrain you see in this mockup using OpenGL.

[Image: PPP_conceptual.jpeg]

What'd I'd like to do is be able to read in an Illustrator or EPS file with a path on it, and make it into a bunch of colored polygons:

[Image: poly1.png]

and then make it into something that looks like this:

[Image: poly2.png]

Would I need GL_LINES for the black line on the surface?

What would be the best and easiest way to store and load a terrain like this, if it wasn't illustrator paths? Keep in mind the levels are going to be very long horizontally, and possible vertically, at least meeting the 32,000+ pixels i could do with software. I'm planning on putting most of the level data in xml format.

I would like curves (lots of polygons), if possible, but I'm worried about speed on a Rage 128 16 megabyte card.

I could really use a tutor or a mentor to help me get this rolling. . . I can take it from there. I'm reading the Red Book and I have the Blue Book. I hang out in #idevgames while working on this and I have an AIM screename as well in my profile.

Any help or source code or things to read or resources to look at would be graciously appreciated.

-Jon


Creating a 2D landscape from polygons - SOUR-Monkey - Jul 16, 2004 03:27 PM

You may run into speed issues, because you will end up with a lot of vertices if you try and smooth the lines like you have in the mockup. I have no idea really though, it depends on your implementation and I don't know how fast OpenGL is anyway.

About outlining the polys, could you use polygon stippling to make it outline the polys? I don't use OGL enough to remember if this is possible or not, because I have a feeling that polygon stippling will apply the pattern to the entire polygon. I'm sure you can do it with stippling somehow, anyway.


Creating a 2D landscape from polygons - leggo - Jul 16, 2004 04:08 PM

aarku Wrote:What would be the best and easiest way to store and load a terrain like this, if it wasn't illustrator paths? Keep in mind the levels are going to be very long horizontally, and possible vertically, at least meeting the 32,000+ pixels i could do with software. I'm planning on putting most of the level data in xml format.

I would like curves (lots of polygons), if possible, but I'm worried about speed on a Rage 128 16 megabyte card.
-Jon

maybe with GL_LINE_STRIP and saving x and y of the verticles... however you'd have no curves Sad
I'm sure there are MUCH MUCH better solutions however Wacko


Creating a 2D landscape from polygons - kelvin - Jul 16, 2004 04:25 PM

If all you are talking about is the foreground ground that the vehicle is driving on then I don't see why you couldn't render this quickly in OpenGL. A simple two pass DrawElements on the same vertex data (GL_QUAD_STRIP, GL_LINES_STRIP (on even verts)) would be plenty fast, assuming you properly clip the polygons. Throw in some simple adaptive subdivision for curve->polygon vertex generation and you easily stay below the choke limit even on a rage 128.

As for your background hills... you're probably best off rendering those beforehand and drawing them with a big texture. 512x512 chunks will do fine on a Rage128 (assuming there aren't too many). Just stitch them.


Creating a 2D landscape from polygons - arekkusu - Jul 16, 2004 04:53 PM

This is 2D side scrolling?

Then, regardless of how exactly you draw the terrain, you will get a huge speed boost if you cache the drawing into a texture and only draw the newly exposed portion. (in funny tech terms: "a torroidal render-to-texture context.") If you are scrolling relatively slowly that will limit the number of vertices to a tiny number.

Other random GL info:
polygon stipple is useless here.
GL_LINES will work, but if you want antialiasing keep in mind GL_LINE_SMOOTH only works for 1 px wide lines on Rage 128, Geforce 2MX, Geforce 4MX.
Shoot Things contains OpenGL code to draw a randomly generated spiky terrain sort of similar to your pic, although not as detailed.