Sign in to follow this  
Defend

Triangle, check. Now I want to draw lots of 2D quads efficiently. How?

Recommended Posts

When creating a game with tile based 2D graphics, I know there's a particular way to define a strip of quads so that every 2 new vertices defines a new quad. Sounds efficient, but 1, I can't remember how to do this, and 2, saving vertices isn't the priority is it? So my question is, what is the recommended way to build my set of tiles for different 2D layers, with the fastest drawing time? I remember that reducing the number of calls to the rendering function is the way to keep it fast, so if I have 10 layers of background, is it possible to render these with only 10 DrawPrimitive() ? Cheers [Edited by - Defend on January 18, 2009 1:17:54 PM]

Share this post


Link to post
Share on other sites
Assuming the number of tiles is small (hundreds, low thousands), then the number of vertices and quads would indeed matter less than the number of draw calls. The other thing that can slow you down is anything that changes in your geometry, but if your background layers are fixed for the level, then that won't be a problem. Also remember that you can stick all your static stuff in one vertex buffer, so less buffer switching this way.

I think that 10 calls should certainly work. You could potentially it even with less, but that could be tricky, and I'm not sure it's necessary. So just create a vertex buffer with the vertices of all your quads, and see how it works for you.

Share this post


Link to post
Share on other sites
So (going off bad memory here), I could render in a way that reads 4 vertices as 1 quad, the next 2 vertices as another quad, the next 2 as another, and so on... until I have rendered an entire *row* of tiles. Then switch to the next row and render again in the same way.

OR

I could render in a way that reads the first 4 vertices as 1 quad, the next 4 vertices as the next quad, the next 4 as another, and so on... until I have rendered an entire *layer* of tiles.

The latter has double the amount of vertex points and isn't using any trick (TRIANGLELIST - is this the thing I'm talking about?) to economise on memory for the geometry, but has many times less calls to DrawPrimitive().

Does this sound like I'm going up the right alley? It's been years, and I remember that I used to use something like the first method I described.

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