The most efficient method of drawing multiple quads in OpenGL

Posted by CPatton on Stack Overflow See other posts from Stack Overflow or by CPatton
Published on 2010-05-14T01:53:57Z Indexed on 2010/05/14 7:54 UTC
Read the original article Hit count: 424

Filed under:
|
|
|
|

I'm not very keen with OpenGL and I was wondering if someone could give me some insight on this. I'm a 'seasoned' programmer, I've read the redbook about VBOs and the like, but I was wondering from a more experienced person about the best/most efficient way of achieving this.

I've been producing this 2d tile-based game engine to be used in several projects.

I have a class called "ScreenObject" which is mainly composed of a

Dictionary<Point, Tile>

The Point key is to show where to render the Tile on the screen, and the Tile contains one or more textures to be drawn at that point. This ScreenObject is where the tiles will be modified, deleted, added, etc..

My original method of drawing the tiles in the testing I've done was to iterate through the ScreenObject and draw each quad at each location separately. From what I've read, this is a massive waste of resources. It wasn't horribly slow in the testing, but after I've completed the animation classes and effect classes, I'm sure it would be extremely slow.

And one last thing, if you wouldn't mind.. As I said before, the Tile class can contain multiple textures to be drawn at the Point location on the screen.

I recognize possibly two options for me here. Either add a quad at that location for each texture to be drawn, or, somehow.. use a multiple texture for the same quad (if it's possible). Even if each tile contained one texture only, that would be 64 quads to be drawn on the screen. Most of the tiles will contain 2-5 textures, so the number of total quads would increase dramatically with this method. Would it be feasible to add a quad for each new texture, or am I ignoring a better way to do this?

Just need some help understanding this if you don't mind :) I've tried to be as concise as possible, and I'd greatly appreciate any responses.. and even some criticism. Programming is often a learning process and one who develops seems to never stops learning.

Thanks for your time.

© Stack Overflow or respective owner

Related posts about c#

Related posts about opengl