Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the ambiera forums
Where I want to be able to change MainSomething. I don't want to use a switch statement or a virtual function or a pointer to a function due to performance and readibility issues.
Basically I would like to be able to make the top and bottom parts a macro as I seem to remember some code used for scripting that did something similar but can't remember quite how it worked. I tried using a multi-line macro but just got compilation errors.
Use a virtual function. Its perfromance impact is neglictable. Todays all memory is allocated virtually. So it comes almost for free. Virtual function calls
are not bottlenecks at all.
Never use Macros.
a C programmer would tell you to use a pointer to a function, but that will have the same cost of virtual call.(didn't tested. Just readed)
if you want to do that just because you don't want to write the same piece of code zillion times:
1) bad design, rethink your code maybe help you to improve reusability of the code
2) maybe templates can help, not Macros. (but if every function does something different would be really hard using templates)
3) use functions of your IDE that can help you to copy-past similiar part of code.
anyway point 1 is most important, if you later you find some error in your code you have to replicate the change in ever place you pasted that code. Good design help
to avoid that
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
In the end I only needed to do this 3 times rather than the numerous times I thought I would have to do it (due to a change in the technical requirement) so it became a non-issue.