Handmade Hero»Forums»Code
Oliver Marsh
193 posts / 1 project
Olster1.github.io
Using function pointers
Hey everyone,

I was trying to implement a GUI system and I ended up with the idea of allocating items, like buttons, to a list like Casey did with the renderer, pushing the different types of draw objects into a preallocated slot of memory.

I was wondering if it would be a good idea to store a function pointer on each GUI object, like a button, so I could go through the list of GUI items and if the user interacts with one, I just call the function pointer to initiate the pre-defined action. This feels rather like an object-orientated design, and was wondering if this is a good way of doing things?

Thanks,
Oliver
Mox
32 posts
Using function pointers
This might be what Casey would have to say on this matter: http://mollyrocket.com/861
Oliver Marsh
193 posts / 1 project
Olster1.github.io
Using function pointers
Thanks, the video helped alot.
Ginger Bill
222 posts / 3 projects
I am ginger thus have no soul.
Using function pointers
Here is a very good example of Immediate Mode GUI in C++:
https://github.com/ocornut/imgui