Display Lists and 2D Animation

cloke
Unregistered
 
Post: #1
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?
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #2
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
Quote this message in a reply
Member
Posts: 70
Joined: 2004.06
Post: #3
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.
Quote this message in a reply
cloke
Unregistered
 
Post: #4
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 Smile.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
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
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #6
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.

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #7
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.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Display Lists and Obj. File Loader Problems merrill541 0 1,981 Oct 17, 2008 06:42 PM
Last Post: merrill541
  Display Lists or Vertex Arrays with texturing seven 6 3,894 Oct 17, 2005 09:24 AM
Last Post: seven
  Slowing Frame Rates and Display Lists Nick 4 3,072 Mar 27, 2005 06:08 AM
Last Post: wadesworld
  More display lists not working... SOUR-Monkey 1 2,396 Dec 8, 2004 09:11 PM
Last Post: SOUR-Monkey
  Display Lists not working Jake 6 3,889 Dec 8, 2004 04:10 PM
Last Post: TomorrowPlusX