Star developer diary

Star developer diary

About Star

Star is an hobby game developed by me for the purpose of improving my game development skills with OpenGL and C++. It's using the SDL library.

It's an arcade game where the player controls a spaceship and dodges incoming asteroids on its way to Earth. The latest playable version can be found in my portfolio.

Graphics resource management

CodingPosted by Marie Wed, April 25, 2012 22:19:22

I recently found a new solution for my resource management system:

The system asks the graphicsystem singleton to retrieve a pointer to a sprite by giving an enum as id. The underlying implementation relies on an X-macro (yes, I know they are blunt, pollute, hard to debug and overwrite stuff, but also most useful). By asking for an enum, it won't even compile unless a correct enum is given. Way better than using the other sprite info available (the sprite path url), that would show errors first when getting runtime exceptions.

Another advantage was that I could automate the resource loading. All resources specified in the X-macro will be loaded automatically by looping the enum. More info about the X macro solution I used can be found on DrDobbs website.

Code sample: