Me vs. hardware, properties and BMFont

Published May 04, 2010
Advertisement
Found a little time to code this weekend.

Worn down hard by hardware
I couldn't really code away to my hearts' desire because hardware failures kept interrupting my flow. My video card is cranky and when strained it likes to deadlock. Probably due to its cheap nature and the fact that there are no good drivers for Win7 yet. I foresee the purchase of a new one in the near future.

Properties using boost::any
I made a first attempt towards a limited property implementation. The idea is that every entity holds a dynamic set of properties which its components use to publish and share data.

My current system has a way of doing this through a string-to-float mapping that all components can access. However only being able to store floats has been cumbersome when trying to store 2D vectors and integers.

The new attempt uses a mapping from string to a boost::any object. The any can be viewed as a boostified void pointer, but without any unsafe casting.

Apparently boost::any it uses the typeid() operator but implements its own any_cast<>() operation instead of using dynamic_cast<>(). I have to admit I don't know the finer points to this or how it compares in speed, but the robustness is there all right.

Using this little magic bean I swiftly coded up a property container with a get<>() and set<>() templated interface. Now I can write get("position") or set("health", 10) and it simply works. Very nice! [grin]

Bitmap fonts using AngelCode BMFont
Another concern has been that the text output during debugging was eating up 80% of the CPU time. Not that debug output optimization is that important, really, but lately it's been very hard to profile other parts of the code as their time was overshadowed by the colossal times of the text.

Something had to be done. I went for AngelCode's Bitmap Font Generator and the great, short tutorial by Promit on parsing the FNT file.

With this at my disposal the rest was easy. A quick and dirty implementation lowered the debug output CPU time to 50% of total. This is still horrible but less so than before. More to come on this.
0 likes 3 comments

Comments

evolutional
Nice work on your property system, it sounds really interesting.
May 04, 2010 06:42 AM
Staffan E
Yeah, although I don't really feel I can take that much credit for it. [smile]

It's really just a thin wrapper around a boost::unordered_map<std::string, boost::any>.

I know I would have use for property inheritance, both from predefined prop-classes and from parent Entity objects. Hopefully I'll get there. [smile]
May 05, 2010 10:09 AM
Sly
We've used AngelCode's BMFont for several commercial titles on all modern platforms. It's safe to say we think it's damn good. Andreas has done very well.
May 08, 2010 05:24 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement