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

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.