Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
attribute.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_ATTRIBUTE_H_
19 #define ION_GFX_ATTRIBUTE_H_
20 
21 #include "ion/gfx/shaderinput.h"
22 
23 #include "base/integral_types.h"
24 #include "ion/base/variant.h"
25 #include "ion/gfx/bufferobject.h"
26 #include "ion/math/matrix.h"
27 #include "ion/math/vector.h"
28 
29 namespace ion {
30 namespace gfx {
31 
36 
41 
46 
49 };
50 
51 typedef base::Variant<float, math::VectorBase2f, math::VectorBase3f,
52  math::VectorBase4f, math::Matrix2f, math::Matrix3f,
54 
55 class ION_API Attribute :
56  public ShaderInput<AttributeValueType, AttributeType> {
57  public:
63  normalize_(false),
64  divisor_(0) {}
66 
68  static const char* GetShaderInputTypeName();
69 
71  static const char* GetValueTypeName(const ValueType type);
72 
75  template <typename T> static ValueType GetTypeByValue();
76 
78  static Tag GetTag() { return kAttribute; }
79 
86  bool IsFixedPointNormalized() const { return normalize_; }
87  void SetFixedPointNormalized(bool normalize) { normalize_ = normalize; }
88 
89  bool operator==(const Attribute& other) const;
91  bool operator!=(const Attribute& other) const {
92  return !(*this == other);
93  }
94 
96  unsigned int GetDivisor() const { return divisor_; }
97  void SetDivisor(unsigned int divisor) { divisor_ = divisor; }
98 
99  private:
101  bool normalize_;
104  unsigned int divisor_;
105 };
106 
107 } // namespace gfx
108 } // namespace ion
109 
110 #endif // ION_GFX_ATTRIBUTE_H_
Matrix< 4, float > Matrix4f
Definition: matrix.h:371
AttributeType
The AttributeType enum defines all supported attribute shader argument types.
Definition: attribute.h:33
std::string type
Definition: printer.cc:353
base::Variant< float, math::VectorBase2f, math::VectorBase3f, math::VectorBase4f, math::Matrix2f, math::Matrix3f, math::Matrix4f, BufferObjectElement > AttributeValueType
Definition: attribute.h:53
Matrix< 3, float > Matrix3f
Definition: matrix.h:369
Tag
This is only used to determine the type of a ShaderInputRegistry::Spec since Attributes and Uniforms ...
Definition: shaderinput.h:35
Structure for clients to use to encapsulate Elements.
Definition: bufferobject.h:378
void SetDivisor(unsigned int divisor)
Definition: attribute.h:97
The Variant class is similar to boost::variant.
Definition: variant.h:201
static Tag GetTag()
Returns the tag for this input type.
Definition: attribute.h:78
unsigned int GetDivisor() const
Sets/Gets the attribute divisor.
Definition: attribute.h:96
Matrix< 2, float > Matrix2f
Dimension- and type-specific typedefs.
Definition: matrix.h:367
bool operator!=(const Attribute &other) const
Needed for Field::Set().
Definition: attribute.h:91
A ShaderInput instance represents a general shader input.
Definition: shaderinput.h:50
bool IsFixedPointNormalized() const
Checks and sets whether integer values should be mapped to the range [-1,1] (for signed values) or [0...
Definition: attribute.h:86
Scalar types.
Definition: attribute.h:35
void SetFixedPointNormalized(bool normalize)
Definition: attribute.h:87
Attribute()
The default constructor creates an invalid Attribute instance, which should never be used as is...
Definition: attribute.h:61
bool operator==(const StlAllocator< T1 > &lhs, const StlAllocator< T2 > &rhs)
Each StlAllocator holds an Allocator.
Definition: stlallocator.h:237