gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help with display lists

#170466 - FiveStringBass - Mon Sep 28, 2009 8:46 pm

Hi all,

I've been playing with the example display list in the 3D examples, I added an extra vertex and colour, and wanted to add an extra quad to the list. However, the new quad does not show up. I know i'm not specifying a colour for each new vertex on the 2nd quad, but shouldn't it be drawn in the last colour that was set, i.e. white (31,31,31)? The GL state should be set to quads and the draw colour set to white unless I change it in the meantime, shouldn't it?

Code:

u32 triangle[] =
{
   22,                  
   FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR),
      GL_QUAD,
      RGB15(31,0,0),
      VERTEX_PACK(inttov16(-1),inttov16(-1)),
      VERTEX_PACK(0,0),
      RGB15(0,31,0),

   // FIFO_COMMAND_PACK(#FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END),
   FIFO_COMMAND_PACK(FIFO_VERTEX16,FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR),
      VERTEX_PACK(inttov16(-1),inttov16(1)),
      VERTEX_PACK(0,0),
      RGB15(0,0,31),
      VERTEX_PACK(inttov16(1),inttov16(1)),
      VERTEX_PACK(0,0),
      RGB15(31,31,31),

   FIFO_COMMAND_PACK(FIFO_VERTEX16, /*FIFO_COLOR*/ FIFO_VERTEX16, FIFO_VERTEX16, FIFO_VERTEX16),
      VERTEX_PACK(inttov16(1), inttov16(-1)),
      VERTEX_PACK(0,0),   
   //   RGB15(31, 0, 31),
      VERTEX_PACK(inttov16(-1),inttov16(-1)),
      VERTEX_PACK(inttov16(-1),0),
      VERTEX_PACK(inttov16(-1),inttov16(1)),
      VERTEX_PACK(inttov16(-1),0),
      VERTEX_PACK(inttov16(1),inttov16(1)),
      VERTEX_PACK(inttov16(-2),0),

   FIFO_COMMAND_PACK(FIFO_VERTEX16, /*FIFO_VERTEX16*/  FIFO_NOP, FIFO_NOP, FIFO_NOP),
      VERTEX_PACK(inttov16(1),inttov16(1)),
      VERTEX_PACK(inttov16(-2),0),
   //   VERTEX_PACK(inttov16(1), inttov16(-1)),
   //   VERTEX_PACK(inttov16(-1),0)   
////////////////

};


Also, is the initial number a count of the commands (i.e. FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_END/FIFO_NOP), or is it a count of the data being pushed onto the queue (e.g. if you take the original triangle it was specified with 12 commands, and you would need 3 vectors and 3 colour values to specify it (so 3 * xyz = 9 values + 3*rgb values = 12 in total))?


Thanks,
5SB

#170474 - Pate - Tue Sep 29, 2009 5:02 am

The initial number is count of the data, and that seems to be the problem in your example. You should put 25 as the value and your code should work.

If you don't want to manually calculate the size, you can do something like this:

triangle[0] = (sizeof(triangle)-4)>>2;

Ps. Welcome to the forum!

Pate
_________________

#170501 - FiveStringBass - Tue Sep 29, 2009 7:46 pm

Thanks very much Pate - 25 did the trick, but i'm still confused to be honest. I want to be able to calculate the size manually for now just so I am sure what is happening.

If i'm going by the number of data items on the fifo, then with the 2 quads in the example, quad 1 contains 4 vertices and 4 colours = 16 data items, the second quad only contains 4 vertices, so 12 additional data items, making a total of 28.

If I count the number of commands, then I only count 21.

Sorry to appear dumb, I just don't get it...

5SB

#170510 - DiscoStew - Tue Sep 29, 2009 11:31 pm

The FIFO_COMMAND_PACK also counts as an item, and there are 4 in there, making it 25 in total.

Also, the 1st quad is 3 items per vertex (1 color, 2 vertex), making it 12 items, not 16. The 2nd quad is 2 items per vertex with having no change in color, so it would be 8 items.

12 + 8 + 1 (for GL_QUAD) + 4 (for 4 FIFO_COMMAND_PACKs) = 25
_________________
DS - It's all about DiscoStew

#170512 - FiveStringBass - Wed Sep 30, 2009 12:01 am

Ah, I see now. Fantastic, ta very much DiscoStew!

5SB