Modern OpenGL with Qt
The OpenGL code shown in the previous section uses a very old technique of streaming vertices one by one into a fixed OpenGL pipeline. Nowadays, modern hardware is much more feature-rich and not only does it allow faster processing of vertex data but also offers the ability to adjust different processing stages, with the use of reprogrammable units called shaders. In this section, we will take a look at what Qt has to offer in the domain of a "modern" approach to using OpenGL.
Shaders
Qt can make use of shaders through a set of classes based around QOpenGLShaderProgram
. This class allows compiling, linking, and executing of shader programs written in GLSL. You can check whether your OpenGL implementation supports shaders by inspecting the result of a static QOpenGLShaderProgram::hasOpenGLShaderPrograms()
call that accepts a pointer to an OpenGL context. All modern hardware and all decent graphics drivers should have some support for shaders.
Qt supports all kinds of shaders...