00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __RE_Uniform__
00020 #define __RE_Uniform__
00021
00022 #include "RE_API.h"
00023
00024 #include <UT/UT_HashTable.h>
00025 #include <UT/UT_String.h>
00026
00027 class RE_Render;
00028
00029 enum RE_UniformLanguage
00030 {
00031 RE_UNIFORM_CG = 1,
00032 RE_UNIFORM_GLSL = 1 << 1,
00033 RE_UNIFORM_ALL_LANGUAGES = ~0
00034 };
00035
00036
00037
00038
00039 enum RE_UniformBuiltIn
00040 {
00041 RE_UNIFORM_EMISSION = 0,
00042 RE_UNIFORM_INV_VIEW_MATRIX,
00043 RE_UNIFORM_LIGHT_ENABLED,
00044 RE_UNIFORM_VIEW_MATRIX,
00045 RE_UNIFORM_BUILT_IN__count
00046 };
00047
00048
00049 enum RE_UniformBinding
00050 {
00051 RE_UNIFORM_BIND_ALL,
00052 RE_UNIFORM_BIND_DISPLAY_LIST_INDEPENDENT,
00053 RE_UNIFORM_BIND_DISPLAY_LIST_DEPENDENT
00054 };
00055
00056
00057
00058 enum RE_UniformType
00059 {
00060 RE_UNIFORM_FLOAT,
00061 RE_UNIFORM_FLOAT_VEC2,
00062 RE_UNIFORM_FLOAT_VEC3,
00063 RE_UNIFORM_FLOAT_VEC4,
00064 RE_UNIFORM_INT,
00065 RE_UNIFORM_INT_VEC2,
00066 RE_UNIFORM_INT_VEC3,
00067 RE_UNIFORM_INT_VEC4,
00068 RE_UNIFORM_FLOAT_MAT2,
00069 RE_UNIFORM_FLOAT_MAT3,
00070 RE_UNIFORM_FLOAT_MAT4,
00071 RE_UNIFORM_SAMPLER_2D,
00072 RE_UNIFORM_SAMPLER_3D,
00073 RE_UNIFORM_SAMPLER_CUBE,
00074 RE_UNIFORM_TYPE__count
00075 };
00076
00077 class RE_API RE_Uniform
00078 {
00079 public:
00080
00081 RE_Uniform(const UT_String &name, RE_UniformType type, int size);
00082 RE_Uniform(RE_UniformBuiltIn built_in, int size);
00083 virtual ~RE_Uniform();
00084
00085
00086
00087 static void getArrayNameAndIndex(const char *str,
00088 UT_String &name_out,
00089 int *index_out);
00090
00091
00092
00093 virtual void getIndexedName(int index, UT_String &out)const;
00094
00095 virtual const UT_String &getName() const { return myName; }
00096
00097
00098
00099
00100 virtual int getSize() const { return mySize; }
00101 virtual RE_UniformType getType() const { return myType; }
00102
00103
00104
00105
00106 virtual const void *getValue(int index=0) const;
00107 virtual void setValue(const void *value, int index=0);
00108
00109
00110
00111 virtual int getVersion() const { return myVersion; }
00112
00113
00114
00115
00116
00117 static int getBuiltIn(const RE_Uniform *uniform,
00118 int languages =
00119 RE_UNIFORM_ALL_LANGUAGES);
00120 static int getBuiltIn(const UT_String &name,
00121 RE_UniformType type,
00122 int languages =
00123 RE_UNIFORM_ALL_LANGUAGES);
00124
00125
00126
00127 static const char *getBuiltInName(RE_UniformBuiltIn built_in);
00128 static RE_UniformType getBuiltInType(RE_UniformBuiltIn built_in);
00129 static int isDisplayListDependent(RE_UniformBuiltIn built_in);
00130
00131
00132
00133
00134
00135
00136 static void registerBuiltIn(RE_Render *r,
00137 RE_UniformBuiltIn built_in,
00138 const RE_Uniform *uniform);
00139 static void unregisterBuiltIn(RE_Render *r,
00140 RE_UniformBuiltIn built_in,
00141 const RE_Uniform *uniform =
00142 NULL);
00143
00144 private:
00145 static const int theTypeSizes[RE_UNIFORM_TYPE__count];
00146 static UT_HashTable theBuiltIns;
00147 UT_String myName;
00148 RE_UniformType myType;
00149 int mySize;
00150 int myVersion;
00151 char *myValues;
00152 };
00153
00154 #endif
00155