Let's take our rendering code to a higher level. Putting OpenGL code directly into the window class requires subclassing the window class and makes the window class more and more complex. Let's follow good programming practice and separate rendering code from window code.
Create a new class and call it AbstractGLScene. It will be the base class for definitions of OpenGL scenes. We also derive the class (with protected scope) from QOpenGLFunctions_1_1 to make accessing different OpenGL functions easier. Make the scene class accept a pointer to QOpenGLWindow, either in the constructor or through a dedicated setter method. Ensure that the pointer is stored in the class for easier access, as we will rely ...