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

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.