source: GTP/trunk/App/Demos/Illum/EnvMap/Parameters.h @ 1488

Revision 1488, 3.6 KB checked in by szirmay, 18 years ago (diff)
Line 
1#include <assert.h>
2#define CHARBUF 250                             ///< length of the buffer (one line to be saved to file)
3
4/// Boolean variables that will be displayed as GUI checkboxes.
5typedef enum {  bShowHelp, /*bAutoGenCubeMap, bUseCosTexture, */
6                                bShowFireballs, bMultipleObjects, bConfineToRoom,
7                                LAST_BOOL } bool_t;
8
9/// Numeric variables that will be displayed as GUI sliders.
10typedef enum {  iWhichMethod, iWhichMesh, fMeshScale,
11                                iResolution, iShowCubeMap, fIntensity, iShininess,
12                                LAST_NUMBER } number_t;
13
14/// Possible values for #iWhichMethod.
15typedef enum {
16        DIFFUSE_SPECULAR_CLASSIC,               ///< Classic environment mapping technique.
17        DIFFUSE_SPECULAR_LOCALIZED,             ///< Our proposal.
18        DIFFUSE_SPECULAR_LOCALIZED_5TEX ///< Our proposal, using 5 texel only.
19} method_t;
20
21/// Parameter-manager buttons
22typedef enum {
23        IDC_RESET_BUTTON = -3,
24        IDC_SAVE_BUTTON,
25        IDC_LOAD_BUTTON
26} std_buttons_t;
27
28/// Conversion function (see Parameters::Add()).
29/// E.g. to create a slider that produces exponential values.
30typedef float (*CONVERTER)(float a);
31/// Change callback function (see Parameters::Add()).
32/// To be called when the respective parameter is modified.
33typedef void (*ONCHANGE_CALLBACK)(void);
34
35/// Default conversion function (see #CONVERTER).
36/// Does nothing but returning the value passed.
37float noconvert(float a);       // { return a; }
38/// Default change callback function (see #ONCHANGE_CALLBACK).
39/// Does nothing.
40void OnChange();                        // {}
41
42/**
43  \brief Manages application parameters.
44  \brief Creates GUI controls (sliders, checkboxes) and hotkeys.
45 
46  \author Istvan Lazanyi, TU Budapest
47  \date   2006-04-26
48*/
49class Parameters {
50        bool bparam[LAST_BOOL];                         ///< current param value (boolean)
51        wchar_t bname[LAST_BOOL][CHARBUF];      ///< param name
52        int radiogroup[LAST_BOOL];                      ///< for boolean params that are represented by a checkbox
53
54        int param[LAST_NUMBER];                         ///< current param value (numeric)
55        wchar_t name[LAST_NUMBER][CHARBUF];     ///< param name
56        int numsteps[LAST_NUMBER];                      ///< number of possible steps for param
57        bool rotate[LAST_NUMBER];                       ///< stores whether the slider can rotate around
58
59        CONVERTER ffunc[LAST_NUMBER];
60        ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3];
61        ONCHANGE_CALLBACK bchfunc[LAST_BOOL];
62
63        CDXUTDialog* g_HUD;
64
65        bool bSilent;                                           ///< to avoid an endless loop due to a change
66        const static int CHARBUFFER_SIZE = 200;
67        enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 };
68
69public:
70        void Setup( CDXUTDialog* g_HUD );
71        void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange);
72
73        bool Get( bool_t i );
74        float Get( number_t i );
75        int GetInt( number_t i );
76
77        void SetBool( bool_t ID, bool b );
78        void SetFloat( number_t ID, float v );
79        void SetInt( number_t ID, int v );
80
81        void Add( bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
82        void Add( int radiogroupID, bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
83
84        void Add( number_t ID, char* label, int num_steps);
85
86        void Add( number_t ID, char* label, int num_steps,
87                CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange );
88
89        void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr = 0,
90                CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange );
91
92        void SetEnabled( bool_t ID, bool bEnabled );
93        void SetEnabled( number_t ID, bool bEnabled );
94
95        void UpdateFromHUD( int controlID );
96
97        void SaveToFile( char* fileName );
98        void LoadFromFile( char* fileName );
99};
Note: See TracBrowser for help on using the repository browser.