Display Lists and 2D Animation
I'm looking into display lists and drawing 2D sprites. I'm still reading up on the topic, but I was hoping to sort a few things out. For a 2D based game is using display lists even a good idea? Would I have a list for each frame? I was thinking of having a vector of display lists and just going through the vector on each frame.
Anyway, does anybody have any good suggested reading or just some general suggestions?
Anyway, does anybody have any good suggested reading or just some general suggestions?
for smallish sprites having a large texture that contains all of your animation frames and modifying the texture coordinates each render is a good way to do it. So for a 4 frame animation you might have the 4 frames in a row on a single texture, then give it coords of 0, 0.25 then 0.25, 0.5 then 0.5, 0.75 and so on.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Display lists are less efficient than straight glVertex() calls below a certain number of vertices. I don't know how you plan on handling your sprites, but if you are just pasting a texture over a quad then display lists aren't going to help you at all. I would just keep track of each sprites size and texture ID, and each frame bind the texture then draw an appropriately sized quad.
The way reubert mentioned for doing animation sounds like a good one.
The way reubert mentioned for doing animation sounds like a good one.
Thanks for the info. I didn't even think of clipping the texture. For some reason going to GL I just threw out my old knowledge of animation
.
.
reubert Wrote:for smallish sprites having a large texture that contains all of your animation frames and modifying the texture coordinates each render is a good way to do it. So for a 4 frame animation you might have the 4 frames in a row on a single texture, then give it coords of 0, 0.25 then 0.25, 0.5 then 0.5, 0.75 and so on.
If you do this, you'd probably want to leave at least a 1-pixel padding space between animation frames. Otherwise, you're likely to sometimes see rows or columns of pixels from other animation frames at the edges.
Alex Diener
Remember, however, that using sections of a texture and display lists mean you won't have to recalculate texture coordinates every frame. I'm pretty sure display lists helped my performance doing exactly this when I was working on a 2D openGL engine for my canceled uDevGame 2003 entry.
I'll be checking into it pretty soon for this year's entry.
I'll be checking into it pretty soon for this year's entry.
"Pay no attention to that man behind the curtain." - Wizard of Oz
In Yoink I simply divided all of my tile images into independent textures as I loaded them, then drew each tile/sprite as a separate GL_QUAD in immediate mode. Even though this is the most brute-force method imaginable, it still runs more than fast enough for my needs, even on comparatively slow hardware!
The moral of this story is: you don't necessarily have to write optimal OpenGL code to get good performance.
The moral of this story is: you don't necessarily have to write optimal OpenGL code to get good performance.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Display Lists and Obj. File Loader Problems | merrill541 | 0 | 1,656 |
Oct 17, 2008 06:42 PM Last Post: merrill541 |
|
| Display Lists or Vertex Arrays with texturing | seven | 6 | 3,316 |
Oct 17, 2005 09:24 AM Last Post: seven |
|
| Slowing Frame Rates and Display Lists | Nick | 4 | 2,690 |
Mar 27, 2005 06:08 AM Last Post: wadesworld |
|
| More display lists not working... | SOUR-Monkey | 1 | 2,142 |
Dec 8, 2004 09:11 PM Last Post: SOUR-Monkey |
|
| Display Lists not working | Jake | 6 | 3,521 |
Dec 8, 2004 04:10 PM Last Post: TomorrowPlusX |
|

