LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Cornix on May 17, 2013, 23:42:41

Title: glBegin(GL_QUAD) + glEnd vs VBO's
Post by: Cornix on May 17, 2013, 23:42:41
Hi.
Until now i have been drawing pictures (quads) for a 2D game by using
glBegin(GL_QUAD);
  GL11.glVertex3f(x1, y1, z);
  GL11.glVertex3f(x2, y2, z);
  GL11.glVertex3f(x3, y3, z);
  GL11.glVertex3f(x4, y4, z);
glEnd();

and read something about the use of VAO's and VBO's to put the data on the graphics cards memory.

My question is, does it make sense to use the VAO's for simple 2D-Sprites or are there any drawbacks to this which will outweight the performance gain?

Thanks in advance.
Title: Re: glBegin(GL_QUAD) + glEnd vs VBO's
Post by: quew8 on May 18, 2013, 12:04:36
There is no question about VBOs, they are pure speed and the only drawback is the complexity of understanding them. I don't think they're all that complex if you have a good tutorial and it seems like you already know what they do.
VAOs are another question and I think it's mainly down to hardware whether they would be quicker. I don't use them but that's in order to keep compatibility with OpenGL 2.1. On this site, I believe @princec has some opinions on them (that they aren't a good idea if I remember correctly) and I bow down to his superior experience.
Title: Re: glBegin(GL_QUAD) + glEnd vs VBO's
Post by: spasi on May 18, 2013, 12:27:26
Don't use VAOs, they have bad performance on all implementations. If they're required (i.e. for the Core Profile), create and bind one at start-up, then forget they even exist. Just pretend VAOs never happened and use the normal VBO binding mechanisms.
Title: Re: glBegin(GL_QUAD) + glEnd vs VBO's
Post by: Cornix on May 18, 2013, 14:53:48
Okay, thanks for the answers.