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 – Drawing with a dynamic background color

Let's see how we can use the Vulkan API in our Qt project to change the background color of the window. We'll cycle through all possible hues of the color while retaining constant saturation and lightness. This may sound complicated when you think about a color in RGB space, but it's actually very easy if you work with the HSL (Hue, Saturation, Lightness) color model. Luckily, QColor supports multiple color models, including HSL.

First, add and initialize the m_devFuncs private field, as just shown. Next, add the float m_hue private field that will hold the current hue of the background color. Set its initial value to zero. We can now start writing our startNextFrame() function that ...

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