Categories
3d code graphics gui opengl qt

WTH OpenGL 4? Rendering elements arrays with VAOs and VBOs in a QGLWidget

Simple example usage of OpenGL 4 and vertex array / vertex buffer rendering in a Qt QGLWidget.

I spent an entire day getting OpenGL 4 to display data from a VAO with VBOs so I thought I’d share the results with you guys, save you some pain.
I’m using the excellent GL wrappers from Qt, and in particular QGLShaderProgram.
This is pretty straightforward, but the thing to remember is that OpenGL is looking for the vertices/other elements (color? tex coords?) to come from some bound GL buffer or from the host. So if your app is not working and nothing appears on screen, just make sure GL has a bound buffer and the shader locations match up and consistent (see the const int I have on the class here).

Leave a Reply

Your email address will not be published. Required fields are marked *