Introduction to OpenGL with Qt
We are not experts on OpenGL, so in this part of the chapter, we will not teach you to do any fancy stuff with OpenGL and Qt but will show you how to enable the use of your OpenGL skills in Qt applications. There are a lot of tutorials and courses on OpenGL out there, so if you're not that skilled with OpenGL, you can still benefit from what is described here by employing the knowledge gained here to more easily learn fancy stuff. You can use external materials and a high-level API offered by Qt, which will speed up many of the tasks described in the tutorials.
OpenGL windows and contexts
There are many ways you can perform OpenGL rendering in Qt. The most straightforward way that we will mainly use is to subclass QOpenGLWindow
. It allows OpenGL to render your content directly to a whole window and is suitable if you draw everything in your application with OpenGL. You can make it a fullscreen window if you want. However, later we will also discuss other approaches...