Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 09:42

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GameCallbackComponent
PostPosted: 10.11.2011, 05:25 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
Attached are the source files for a callback component for the game engine. Basically you can attach an arbitrary number of callbacks to any event which will be called for both checkEvent() and executeEvent().

The callback is:
Code:
typedef bool (*CALLBACK_FUNC)(bool aIsCheckEvent, GameEvent&);

You can also register a factory function of:
Code:
typedef CALLBACK_FUNC (*FACTORY_FUNC)(const char*);

That loadFromXml() can use to get a function ptr from a string in the XML.

The EventRegistry.zip is a few files that add a PITA string to EventID class that's part of modules. If you're okay with just using integral eventIds then you don't need it and can just change the loadFromXml() of the component to translate an int to an EventID.

Basically on construction the event registry mirrors the EventID enum in that it calls a REGISTER_EVENT() macro passing in the EventID and the comment originally attached to it. I'd really like to write a preprocessor that does the work of keeping this guy up to date rather than fussing with maintaining two places.

Warning: only very lightly tested ... but feel free to yell at me for mess-ups.


Attachments:
EventRegistry.zip [8.3 KiB]
Downloaded 1175 times
GameCallbackComponent.zip [5.44 KiB]
Downloaded 1198 times
Top
 Profile  
Reply with quote  
PostPosted: 10.11.2011, 07:12 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Thanks for your contribution. Unfortunately I can't add this currently to the community branch, because I currently don't use the GameEngine myself anymore and I don't know if the guys at the university have the time to integrate the patch. Because a lot of projects at the lab are based on the GameEngine, I don't want to commit something I haven't tested myself.

Kind regards,
Volker


Top
 Profile  
Reply with quote  
PostPosted: 10.11.2011, 07:54 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
No problem. Unless my prior login write rights to the community branch were stripped, I could have put it there myself along with the VS projects but opted not to due to having been out of the loop for a while, as well as preferring the opportunity of peer commentary before such things.

Nonetheless, it's here attached for any that would be interested. I was rather impressed with the "AAA" demo out there.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group