C++ Runtime Invocation of Bound Function via Variadic Templates
A fellow traveler in the land of C++ was attempting to perform binding of a function using variadic templates and invoking it at runtime with an array of "variant" data types. Several of our companions asserted that this was impossible with C++11. Not quite believing them, I set out to solve the problem. The following is a very simple demo made to show how this can be done.
Zero-Trivial Constructors and Destructors
The C++ specification has an explicit definition of a trivial constructor (as well as a trivial copy constructor, move construct, assignment operators, and destructors). Triviality helps with a number of optimizations. Unfortunately, there are times when a constructor is "almost trivial" or when a destructor is trivial under certain circumstances. The C++ standard does not deal with this issues. I propose some simple traits that can be added to a custom framework to support these concepts and which could be added to C++ with some work.
Data Structures for Game Developers: The Slot Map
Data structures are an integral part of all of computer science, and the study of data structures makes up a large portion of most students' school work. While an essentially limitless number of data structures exist, each with their own ups and downs, there are a relatively small number which find repeated, frequent use in the field. Games in particular have their own set of highly useful data structures applicable to many scenarios. Today I'm going to describe one of the simpler ones: slot maps.
Experimenting with Fixed Size Delegates with User Data
A fairly common need in many programming tasks is to pass a function off to another function as a parameter. This allows all kinds of fancy higher-order functional programming. It's also really handy for event and messaging systems, particularly when building UIs. Games also make heavy use of such features, though all the peculiar requirements of games often make conventional solutions unusable.
Matrices, Handedness, Pre and Post Multiplication, Row vs Column Major, and Notations
I used to find myself needing to do a quick refresher on the different matrix notations and usage patterns in computer graphics every time I sat down to do any 3D math. I'm admittedly not a graphics expert and it took me a long while to beat this information into my head. There are a lot of articles online on the topic, but I found most of them to be incomplete or poorly written. In the interest of saving others some headaches, I decided to write up my own explanation. If you get confused by the different notations for matrices, the "right-handed" vs "left-handed" coordinate systems, pre- vs post-multiplication, or the differences between row-major and column-major matrices, read on.
DigiPen Game Engine Architecture Club
One of the things that's been taking up a ton of my time lately is the Game Engine Arhitecture Club at DigiPen. The club is focused on helping students learn techniques and skills for building games on custom technology, particularly in the areas that are not covered by standard curriculum. Most of our student presentations are available online for anyone to check out, and a new one is posted almost every week. Two presentations by yours truly are available at the given link, as well as a handful of presentations by other excellent students at DigiPen.
Personal Update & Component Slides
Hi everyone! I just wanted to post some news and status updates about myself, since there haven't had much time for posting technical articles.
In the last few months, I've finished up my Junior year DigiPen, started a new job at Gas Powered Games, and got a new student organization focused on engine architecture design off the ground. Between these three things, time has been pretty tight.
The slides from my first lecture at the engine architecture club at available online at my GitHub page.
Slides (and hopefully videos) for my other lectures will be up after they've been given. Also expect to see some more technical articles over the summer. I have one in the wings on high-performance half-float (16-bit IEEE.754 floating point) in C++, useful for anyone working on graphics or art pipelines.
Using std::enable_if<> on Constructors
I recently had a need to use template meta-programming to enable a particular set of constructors on a templated type only if one of the template parameters matched a particular value. Template specialization would have required copying a very large amount of code around, or using some undesirable inheritance tricks to get things to work. The normal means of using std::enable_if<> for functions and methods would not work because C++ constructors do not have return values. I found a work-around, but it has a few caveats that are worth pointing out for anyone else in a similar situation.
C++ Method Type Deduction Tricks
Working on the next part of the C++ Metadata series, I decided that I didn't like the way I was handling setters and getters for object properties. I wanted something even faster and with even less overhead while retaining the extreme simplicity of my API. I discovered some tricks (only tested in Visual Studio 2010 so far) that do exactly what I need. I'm afraid I'm a little too swamped to write anything about how these tricks work just now, but I wanted to get the code out there.
C++ Metadata – Part II, Inheritance, Dynamic Casting, and Allocation
In Part I in the series on C++ Metadata, I explored how to build the basics of a runtime metadata system for C++ types, including custom classes, third-party libraries' classes, and even C++ primitives. The article detailed building the low-level facilities to have metadata, but did not cover any real-world uses of metadata. Today's article is going to cover adding inheritance information to the metadata, using that information to construct a dynamic_cast<> work-alike, and adding a simple allocation helper.