SFML community forums

Help => Graphics => Topic started by: Jabberwocky on September 01, 2014, 11:29:31 am

Title: Guaranteed order of drawing quads within a VertexArray?
Post by: Jabberwocky on September 01, 2014, 11:29:31 am
Hi,

Here's a simple use-case to set the stage for my question.

I'm making a top-down view game.  I'm rendering a table top, with a plate on the table, and an apple on the plate.  I want to draw this with a single VertexArray (using a texture atlas) for performance / batch count reasons.  The table, plate, and apple are separate images within the atlas (and must be so, so different tables can have different items on top). 

So I make a VertexArray of Quads primitive type.  The VertexArray has 3 quads (12 verticies).

Question:  Am I guaranteed that the apple will always be drawn overtop on the plate, and the plate overtop the table?  Or is there no guarantee of which order the quads within a VertexArray will be drawn?

Thanks for the help.
Title: Re: Guaranteed order of drawing quads within a VertexArray?
Post by: Laurent on September 01, 2014, 11:37:48 am
Quote
Am I guaranteed that the apple will always be drawn overtop on the plate, and the plate overtop the table?
Yes, OpenGL draws primitives in the order they appear in the vertex array.
Title: Re: Guaranteed order of drawing quads within a VertexArray?
Post by: Jabberwocky on September 01, 2014, 11:44:03 am
Wow, that was fast!  :)
That's good news.  Thanks, Laurent.