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 SH_GLSL_VAR_FRAGDATA,
00063
00064 SH_GLSL_VAR_NONE
00065 };
00066
00067 struct GlslVarBindingInfo {
00068 char* name;
00069 int size;
00070 bool indexed;
00071 };
00072
00073 class GlslVariable {
00074 public:
00075 static const GlslVarBindingInfo glslVarBindingInfo[SH_GLSL_VAR_NONE];
00076
00077 GlslVariable(const SH::ShVariableNodePtr& v);
00078 GlslVariable();
00079 GlslVariable(const GlslVariable& v);
00080
00081 std::string declaration() const;
00082
00083 const std::string& name() const { return m_name; }
00084 const int attribute() const { return m_attribute; }
00085 const SH::ShSemanticType& semantic_type() const { return m_semantic_type; }
00086 const int size() const { return m_size; }
00087 const bool builtin() const { return m_builtin; }
00088 const bool uniform() const { return m_uniform; }
00089 const bool texture() const { return m_texture; }
00090
00091 void name(int i, enum GlslProgramType unit);
00092 void attribute(int index);
00093 void builtin(GlslVarBinding binding, int index);
00094
00095 private:
00096 int m_attribute;
00097 bool m_builtin;
00098 bool m_texture;
00099 bool m_palette;
00100 bool m_uniform;
00101
00102 std::string m_name;
00103
00104 int m_size;
00105 SH::ShTextureDims m_dims;
00106 std::size_t m_length;
00107
00108 SH::ShBindingType m_kind;
00109 SH::ShValueType m_type;
00110 SH::ShSemanticType m_semantic_type;
00111
00112 std::string m_values;
00113
00114 std::string type_string() const;
00115 };
00116
00117 }
00118
00119 #endif