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

This topic is 3561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009398
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!