One problem which often arises during programming is building a base set of functionality which can be extended by the user, while still being modular enough to make it easy to replace only certain parts of an implementation. I guess everybody of us has faced this problem at least once, and came up with different solutions. There is a really powerful and elegant technique for solving this kind of problem, which is what I want to show today.
Monthly Archives: June 2011
Type-based dispatching
Today’s useful C++ technique is type-based dispatching. This can be used whenever you want to call different functions based on properties of a certain class, without paying unnecessary performance penalties.
Config values
Today’s post is about configuration values in the Molecule Engine – how they are declared, how they can be used, and how they are implemented.
The following things were important to me when designing the config system:
Hashed strings
One scenario that is quite common in all game engines is having to look-up some resource (texture, shader, material, script, etc.) based on a string, which could look like the following:
Texture* tex = TextureManager::FindTexture("my_texture");
Subtle differences in C++
Let’s start this post with a small C++ quiz. Consider the following class:
class Eater { public: template <size_t N> void Feed(const char (&str)[N]); void Feed(const char* str); };
Launch
Finally, another game-development blog sees the light of day. What to expect? Posts related to different aspects of game engine programming (low-level, graphics, tools, …), a gush of useful C++ techniques, and other things that cross my mind while working on the Molecule game engine.