Hazel icon indicating copy to clipboard operation
Hazel copied to clipboard

"Fire" event

Open AItah opened this issue 7 years ago • 1 comments

Just to verify, Is it possible that currently the events callback are only related to the the Window class. Therefore, there is no mechanism that enable to set callbacks to application events?

Can you please help how to propagate application events when using hazel engine?

Originally: I didn't understand how to "fire" an application event using hazel engine. Can someone please explain it?

10X in advance!

AItah avatar May 06 '19 10:05 AItah

Maybe I answer to myself, however, maybe it will be useful for someone else who also try to improve his C++ skills by learning from this game engine series. Probably senior C++ programmers will see it as a trivial issue :)

In the following link: https://github.com/embeddedartistry/embedded-resources/blob/master/examples/cpp/callbacks.cpp There is a very nice examples regarding callbacks. It indeed help me to better understand the concept of function pointer and they way to use it using lambda, std::function and std::bind.

The solution: For the required classes which are part of our application a dedicated callbacks is added. Also a std::vector which hold these callbacks is used and it dispatches the callback when needed.

BTW, currently performance is ok. In some papers it is written that std::function has some performance drawbacks, however, since I am newbie with C++ the current solution seems ok and extra optimization is not an issue for me at this moment.

Cheers

AItah avatar May 07 '19 18:05 AItah