Hi, I'm trying to use a vertex buffer object in OpenGL and have some problem understanding why it doesn't work without a vertex array object.
Here is
the code and shaders sources.
It's simple:
- create a VBO, bind it, fill it with data;
- create shaders and program (I checked for errors and it compiles and links);
- bind and set the vertex attributes;
- use glDrawArrays to draw a triangle.
The results:
- OpengGL context 3.2 (created with wglCreateContextAttribsARB) without VAO: glDrawArrays raise an GL_INVALID_OPERATION error but I don't do what the
doc says about that error.
- OpenGL context 3.2 with VAO: no problems.
- OpenGL context 3.1 with or without VAO: no problems.
Note: I use an AMD graphics card and GL_VERSION always returns the same version (4.5.13399 Compatibility Profile) but the behaviour of OpenGL seems to change (as the 3.1 test works without VAO). I asked a friend to test the 3 exe on his NVidia card and he got the same results, exept the GL_VERSION string corresponded to the version asked.
To my understanding (I'm new to OpenGL as you may have guessed), VAO are some quick way to re-set the buffer bindings and vertex attribute and should not be required. Am I missing something ? Does a VAO do other things ? Do I need to set other states in OpenGL to use VBO without VAO ?
Thanks for your time.