O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Scene-based rendering

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required