Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Guaranteed order of drawing quads within a VertexArray?  (Read 1893 times)

0 Members and 1 Guest are viewing this topic.

Jabberwocky

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Guaranteed order of drawing quads within a VertexArray?
« 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).
  • The first quad is the table texture
  • The second quad is the plate texture
  • The third quad is the apple texture

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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Guaranteed order of drawing quads within a VertexArray?
« Reply #1 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.
Laurent Gomila - SFML developer

Jabberwocky

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: Guaranteed order of drawing quads within a VertexArray?
« Reply #2 on: September 01, 2014, 11:44:03 am »
Wow, that was fast!  :)
That's good news.  Thanks, Laurent.

 

anything