Archived

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

optimizing my rendering

This topic is 5588 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

Im working ona 2d game (top-down view) and I''ve noticed that when things get crazy on screen (usually when there''s a lot of smoke objects around) that it starts to slow down mor than I''d like (because I have a pretty good system, so a lower system would keel over and die) Anyway, I''m looking to speed things up. At the moment, the render is a little limited as it uses glDrawVertex for each quad, simply updating the 4 coord array each time. The reason I haven''t made it create a long array of many quads is because I have implemented a basic height system in the game where objects can move above/below one another. As such, they have to be rendered in order of height no texture, so I can''t group them So I need another way of improving speed. I was considering using displayLists for the map drawing (tile based map). If I put the texture swapping in the display list generation code, will they be a lot faster than outside? Perhaps there is a way to compile other vertices and improve their speed? But as the vertices are constantly moving (orto projection and screen coordinate placing) they would need to be flexible. Would it be faster to scan the map array (screen only section 10*6 tiles) several times through and order the rendering into per texture sets to minimize swaps? would require several iterations though. And any other suggestions people can make for improvements are most welcome. Although most of my code is pretty bare-bone anyway so there isn''t really much aside from the rendering to optimize.

Share this post


Link to post
Share on other sites
hmmm, maybe reduce your texture size and bpp ?
i am not sure, since most optimisations are for viewing.

try converting all your heightmap into quads, then using glVertexPointer to draw? sorry i cant help you more.

Its my duty, to please that booty ! - John Shaft

Share this post


Link to post
Share on other sites
I already am using vertex arrays and triangle strips. The problme is, how do I make a long triangle strip (say one row of the tiled map) when there are multiple textures on that strip?

I''m thinking the only improvement available to me right now is to compile a display list for each row and compile a new list each time a new row enters the screen.

Is it possible to push all my quads into AGP memory and alter their positions directly in memory?

Share this post


Link to post
Share on other sites
try the opengl forum

not knowing what i''m talking about really -

i''d turn off the textures and see whether that makes a big difference.

remove different effects and get a better picture of how they effect everything.

it could be to do with the need to cull things too.

have you tried profiling your code to see where it is spending most of the time?

Share this post


Link to post
Share on other sites
yeah I thought about putting this in the ogl forum, but I was kinda hoping for a more general idea of optimization. Most of the OGL optimization tricks are designed for 3d games, not 2d where the tricks don''t always apply.

I did try profiling it, but for some bizarre reason it gets an assertion failed error each time. Even though I can run it in debug mode no problem.

Share this post


Link to post
Share on other sites
First, sort your quads from back to front. You will have to find a good sorting algorythm to get it as fast as possible. QuickSort and Radix are the most common high performance sorting algorythms but not necessarily the best for this case. In fact, once you sorted one frame, the other one is likely to be almost sorted. Quicksort is bad with already sorted lists.

Try to group as much tiles as you can in a single texture to minimize texture swaping. Dont grow them to big, it may have the inverse effect. Group your quads by texture and for each texture call glDrawPrimitive ONCE.

If you use 1 bit alpha, you can use ZBuffering instead of sorting, this will speed things up even more. Anyway, you will likely have to sort for thing with an alpha depth higher than 1bit.


[edited by - Coincoin on August 29, 2002 5:05:20 PM]

Share this post


Link to post
Share on other sites
in that case, you might as well make a list and use call list instead, that will save you sorting time anyway ..

about sending the data using agp, you have no control over that, dont think there is a way to force it. Not everyone uses an agp card. I am using a PCI geforce2 in the office..

Its my duty, to please that booty ! - John Shaft

Share this post


Link to post
Share on other sites
Hmm....here''s a thought - is it possible to construct display lists where the data you send in (eg the vertices, texture bind ID, color, etc) are sent as pointers, so that way you could alter the data in the memory address and the display list wouldn''t need to be recompiled to be displayed differently?

It''d be relatively easy for me to alter my rendering so all my sprites create a display list when their object is created and then call that instead of calling my draw sprite function.

Share this post


Link to post
Share on other sites