I don't know if the title is clear, but here's the problem.
I doing a small game/rendering engine for my 3D programming class and I have to implement basic controls to enable/disable certain features : different types of lighting, shadow, normal mapping, controlling an avatar, camera, ... and to edit the terrain I made a basic terrain editor where i can insert objects, alter the heightmap, .... . So i have 2 controll modes (normal and sceen editor) and stuff to controll.
I started managing them with a nasty block of switch than had to make an if else but it is annoying me. It is so ugly to in see that big if else code and it is getting annoying to maintain and change the controls as more stuff are being added.
so my idea is to make a simple structure containing :
- the control name
- vector of pointers to function that should be executed.
and then with a simple loop i can remove that ugly block.
the problem is the function does not have the same number of parameters or the same type. so for example making a vector of (void)(*func)(int) won't work.
so is there anyway to make a pointer to a random function in c++ ? or solve this problem in a different way ?
I doing a small game/rendering engine for my 3D programming class and I have to implement basic controls to enable/disable certain features : different types of lighting, shadow, normal mapping, controlling an avatar, camera, ... and to edit the terrain I made a basic terrain editor where i can insert objects, alter the heightmap, .... . So i have 2 controll modes (normal and sceen editor) and stuff to controll.
I started managing them with a nasty block of switch than had to make an if else but it is annoying me. It is so ugly to in see that big if else code and it is getting annoying to maintain and change the controls as more stuff are being added.
so my idea is to make a simple structure containing :
- the control name
- vector of pointers to function that should be executed.
and then with a simple loop i can remove that ugly block.
the problem is the function does not have the same number of parameters or the same type. so for example making a vector of (void)(*func)(int) won't work.
so is there anyway to make a pointer to a random function in c++ ? or solve this problem in a different way ?