Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: va!n on January 02, 2011
-
I need your help to solve a hopefully small problem and its impementation, due fact it caused me really some headache!
I am trying to code an own very basic tex gen. The user can select from the menubar different operators like Flat(), Rect(), Glow().... Each operator has a different number of parameters and of different types (uint, int, float), something like this:
genFlat(uint color)
genRect(uint color, int x1, int y1, int width, int height)
genGlow(uint color, int centerX, int centerY, int radiusX, int radiusY, float fAlpha, float fGamma)
The parameters of each operator can be changed in the user interface (sliders, inputbox). Atm each slider is only of the type INT...
Whats the best way and how to save the user defined parameters (uint/int/float) to soemthing like an array, list i.e.? I dont know a way yet, to save different types to one array/list of something...
The next thing is, due fact each operator has a different number of parameters, i thought to save all parameters (operator ID, operator parameters) sequentiell to an array/list. Is this the best way or how to handle all this stuff?
I am really running out of ideas yet and so it would be really great if someone could show me the right direction! (at least its all something like werkkzeug handle the stuff ^^)
thanks in advance
-
If you want to store them weakly typed, then an array of 32 bit values will manage ints and floats, and then you can have a list of these arrays as your collected data.
If you want them strongly typed, then create a struct/type for each function which represent the parameters and store a list of them in an array of void *.
If you did that, you might then take all the functions and change their signatures to take one of these structs as their single parameter. That might simplify the coding a bit.
Strongly typing data is often a good thing, but in the end it's going to be a design choice.
Jim
-
genFlat(uint color)
genRect(uint color, int x1, int y1, int width, int height)
genGlow(uint color, int centerX, int centerY, int radiusX, int radiusY, float fAlpha, float fGamma)
You could consider each of these functions as a generator-class with a set of parameters.
For each "generator" add functionality to read and write its' parameters from a data-stream.
This way you don't even have to know each parameter's type outside of the generator.