00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef GLSLVARIABLE_HPP
00021 #define GLSLVARIABLE_HPP
00022
00023 #include "Glsl.hpp"
00024 #include "ShVariableType.hpp"
00025 #include "ShVariableNode.hpp"
00026 #include <string>
00027
00028 namespace shgl {
00029
00031 enum GlslVarBinding {
00032
00033 SH_GLSL_VAR_TEXCOORD,
00034
00035
00036 SH_GLSL_VAR_COLOR,
00037 SH_GLSL_VAR_SECONDARYCOLOR,
00038
00039
00040 SH_GLSL_VAR_VERTEX,
00041 SH_GLSL_VAR_NORMAL,
00042 SH_GLSL_VAR_MULTITEXCOORD0,
00043 SH_GLSL_VAR_MULTITEXCOORD1,
00044 SH_GLSL_VAR_MULTITEXCOORD2,
00045 SH_GLSL_VAR_MULTITEXCOORD3,
00046 SH_GLSL_VAR_MULTITEXCOORD4,
00047 SH_GLSL_VAR_MULTITEXCOORD5,
00048 SH_GLSL_VAR_MULTITEXCOORD6,
00049 SH_GLSL_VAR_MULTITEXCOORD7,
00050
00051
00052 SH_GLSL_VAR_FRAGCOORD,
00053
00054
00055 SH_GLSL_VAR_POSITION,
00056 SH_GLSL_VAR_FRONTCOLOR,
00057 SH_GLSL_VAR_FRONTSECONDARYCOLOR,
00058
00059
00060 SH_GLSL_VAR_FRAGDEPTH,
00061 SH_GLSL_VAR_FRAGCOLOR,
00062
00063 SH_GLSL_VAR_NONE
00064 };
00065
00066 struct GlslVarBindingInfo {
00067 char* name;
00068 int size;
00069 bool indexed;
00070 };
00071
00072 class GlslVariable {
00073 public:
00074 static const GlslVarBindingInfo glslVarBindingInfo[SH_GLSL_VAR_NONE];
00075
00076 GlslVariable(const SH::ShVariableNodePtr& v);
00077 GlslVariable();
00078 GlslVariable(const GlslVariable& v);
00079
00080 std::string declaration() const;
00081
00082 const std::string& name() const { return m_name; }
00083 const SH::ShSemanticType& semantic_type() const { return m_semantic_type; }
00084 const int size() const { return m_size; }
00085 const bool builtin() const { return m_builtin; }
00086 const bool uniform() const { return m_uniform; }
00087 const bool texture() const { return m_texture; }
00088
00089 void name(int i, enum GlslProgramType unit);
00090 void builtin(GlslVarBinding binding, int index);
00091
00092 private:
00093 bool m_builtin;
00094 bool m_texture;
00095 bool m_palette;
00096 bool m_uniform;
00097
00098 std::string m_name;
00099
00100 int m_size;
00101 SH::ShTextureDims m_dims;
00102 std::size_t m_length;
00103
00104 SH::ShBindingType m_kind;
00105 SH::ShValueType m_type;
00106 SH::ShSemanticType m_semantic_type;
00107
00108 std::string m_values;
00109
00110 std::string type_string() const;
00111 };
00112
00113 }
00114
00115 #endif