How to use VBOs without VAOs with OpenGL core profile?

Using VAOs is required in the core profile. From the OpenGL 3.3 spec, page 342, in the section E.2.2 "Removed Features":

The default vertex array object (the name zero) is also deprecated.

This means that you can't set up vertex attributes without creating and binding your own VAO.


No with a core 3.3+ profile you need a VAO to render.

You can however just create and bind a VAO and forget about it (keep it bound).

Besides that glEnableVertexAttribArray(0); must still be called even when using compatibility profile and not using a VAO.

A few other remarks is that you regenerate all buffers and VAOs every frame but don't clean it up. You should do that once during initialization and then rebind when drawing:

if(!use_vao){
      glBindBuffer(GL_ARRAY_BUFFER, VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
}
else
{
      glBindVertexArray(VAO);
}