Today’s blog post is about a small utility class in Qt with a… questionable name: QPointer. If you’re new to Qt, maybe don’t check out QPointer’s documentation just yet, and try to guess what the class does based on its name alone. I’ve seen countless users being very confused by it. Some end up using […]
Blog Archives
Optimizing and Sharing Shader Structures
When writing large graphics applications in Vulkan or OpenGL, there’s many data structures that need to be passed from the CPU to the GPU and vice versa. There are subtle differences in alignment, padding and so on between C++ and GLSL to keep track of as well. I’m going to cover a tool I wrote […]
Object Ownership
Last time we touched upon object lifetime and today we wrap up the basics with a bit of a spicy topic of object ownership. We covered the lifetime quirks, and we found out that manual memory management can be a nightmare, even if we new and delete in the correct order. There must be something […]
Object Lifetime
Last time we discussed Value Semantics. However, I missed one topic that is super important for a better understanding of basic building blocks of C++. Today, we are going to talk about an object. Without further ado, let’s dive deeper! Object What is an object? According to the C++ standard, part 3.9.8 under the name […]
Value Semantics
C++ is an old language. Many aspects of our programming styles have become habits that we do not think about too much today. In this blog, I’m going to address one major issue that has resulted from such habits and get you prepared for a new bright world of C++2b. So without further ado, let’s […]
Shader Variants Explosions of the Combinatorial Kind
If you have bought an AAA game in recent years and wondered what it is doing when it says it is compiling shaders for a long time (up to an hour or more), then this blog will explain it a little.
Pimpl for Small Classes
The familiar solution for thick value classes that want to preserve binary compatibility is to use the pimpl pattern (private implementation), also known as d-pointer (pointer to data). In future versions of our class, we can freely change the contents of the pimpl (i.e. adding, removing, and/or modifying data members) but the binary compatibility of […]
FMA Woes
Floating-point math is hard, and compilers will exploit every language loophole to make our FP calculations go faster, sometimes with surprising results.
QObjects, Ownership, propagate_const and C++ Evolution Const Correctness in Qt Applications
A very common implementation pattern for QObject subclasses is to declare its child QObjects as data members of type “pointer to child.” Raise your hand No, keep your hand on your computer input device 🙂 Nod if you have ever seen code like this (and maybe even written code like this yourself): A fairly common […]
On QVarLengthArray and Uninitialized Storage in C++
If you’re following our Youtube channel you might have heard me talking about QVarLengthArray. If you’re not… you should follow us! But let me give you a quick recap. QVarLengthArray is a Qt container that acts like a vector; its elements are stored contiguously in memory and it has a dynamic size. At any time […]