View Full Version : Question about unbinding VAO before drawing

05-01-2015, 02:52 PM
Hi, I set up a VAO following a tutorial (before this I was just using VBOs, all data in the same array).

Assuming that I set it up correctly, I am wondering if there is any undefined behavior if, for whatever reason, I unbind the VAO, but still call glDraw*()?


/// render loop:
//commented out: glBindVertexArray(vao_ID[0]); // Bind to current VAO
glBindVertexArray(0); // Unbind before calling Draw!
glDrawArrays(GL_TRIANGLES, 0, 3 * 2); // (trying to) draw 2 triangles
// Can this cause error since nothing is binded, or will it simply not draw it?
// ...

OpenGL doesn't generate any specific errors, but, in other words, will it simply ignore the draw command since nothing is bound, or could it potentially cause an error/crash or junk to draw.

Using OpenGL 3.3+ (4.3 to be exact, though I don't think it should matter) with C++.

Alfonse Reinheart
05-01-2015, 03:11 PM
Core profile OpenGL does not allow you to render with VAO zero. You must have some VAO bound to avoid an OpenGL Error.

However, you don't have to put any arrays in that VAO. It can be a freshly created one. In which case, no user-defined vertex shader inputs will have defined values.

The compatibility profile makes VAO zero an actual default vertex array object. Which means it has actual state, so you can bind arrays to it (or not) and render with it.

05-01-2015, 03:37 PM
Oh okay, I wasn't even thinking about core vs compatibility, but that makes more sense now.

Turns out the version of SFML I am using can't offer the user a core profile, though I think the SFML team recently (March-ish?) added support to use the core profile, so I'll update that when I have the time.
Thanks, solved.