Getting started with Qt + OpenGL 3.1

I want to develop projects based on the 2010 edition of OpenGL’s Superbible with Qt. I want to do things like move lights, change their color, activate/deactivate textures, etc. Simple stuff. The Qt documentation I have found so far has been overwhelming. Where can I find a simple tutorial suited to my simple needs?

Um, if you want to make a GL application using Qt, the basic story is make a QGLWidget, implement paintGL to do draw a frame and optionally, initializeGL to do one time initialization that requires a GL context (this is because at the time of construction, a QGLWidget derived widget does NOT have a GL context).

Qt has some (very poor) GL support in it’s QGLContext class methods. Additionally, last time I checked Qt has zero support for the new ways to make a GL context. Currently for ATI and NVIDIA that just means you get a compatibility profile instead of a core profile (and you cannot get a context that supports better error reporting, see for instance GL_AMD_debug_output and GL_ARB_debug_output, also see GL_ARB_robustness about getting a context with robust behavior).

Additionally, mixing QPainter calls with GL calls in paintGL often enough completely borks double buffering on many systems… there are ways around this, but the way of finding those ways is basically reading the Qt source code. Basically if you wish to mix QPainter and GL calls to a window, implement paintEvent() (and not paintGL and initializeGL), create the QPainter object at the beginning of the function and surround your block of GL code with QPainter::beginNativePainting/QPainter::endNativePainting calls.

In all brutal honesty I strongly advise going with something else besides Qt to get a windows with a GL context such as GLFW , SFML or SDL. SDL1.3 has support for more of the context options (and there was a patch for SDL1.2 for the same as well quite some time ago too). Additionally, Qt’s event model is a disaster to use for games and using QTimers for animations is a recipe for garbage.

Qt has a large number of issues, although at first it seems like there is a lot for documentation, I have found repeatedly that the documentation is too shallow with too much behavior being undefined with respect to GL (and at times events too)… additionally, Qt’s GL “integration” borders on being garbage… just the simple operation of making a GL texture from a QImage borders on being useless (QGLContext::bindTexture and QGLWidget::convertToGLFormat I am looking right at you)