Creating a 2D landscape from polygons
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]](http://www.tc.umn.edu/~czec0035/images/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]](http://www.tc.umn.edu/~czec0035/images/poly1.png)
and then make it into something that looks like this:
![[Image: poly2.png]](http://www.tc.umn.edu/~czec0035/images/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
![[Image: PPP_conceptual.jpeg]](http://www.tc.umn.edu/~czec0035/images/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]](http://www.tc.umn.edu/~czec0035/images/poly1.png)
and then make it into something that looks like this:
![[Image: poly2.png]](http://www.tc.umn.edu/~czec0035/images/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
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.
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.
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

I'm sure there are MUCH MUCH better solutions however

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.
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.
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
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.
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.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
SLOW performance drawing multiple polygons per frame with stencil buffer | clam61 | 7 | 10,617 |
Apr 27, 2013 11:53 AM Last Post: clam61 |
|
antialiasing polygons | honkFactory | 37 | 25,690 |
Apr 3, 2006 09:19 AM Last Post: akb825 |
|
n00b question: getting rid of lines along edges of polygons | Andrew | 2 | 4,061 |
Jun 5, 2005 05:57 PM Last Post: Andrew |
|
Depth Sorting Polygons | thaeez | 2 | 4,549 |
Aug 11, 2004 04:23 PM Last Post: thaeez |
|
textures vs lines and polygons | reubert | 16 | 10,478 |
Jul 9, 2003 05:20 PM Last Post: henryj |