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