Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
uniform.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_UNIFORM_H_
19 #define ION_GFX_UNIFORM_H_
20 
21 #include <limits>
22 
23 #include "ion/gfx/shaderinput.h"
24 
25 #include "base/integral_types.h"
26 
27 #include "ion/base/variant.h"
28 #include "ion/gfx/cubemaptexture.h"
29 #include "ion/gfx/texture.h"
30 #include "ion/math/matrix.h"
31 #include "ion/math/vector.h"
32 
33 namespace ion {
34 namespace gfx {
35 
42 
46 
57 
62 };
63 
64 typedef base::Variant<
65  float, int, uint32,
66  math::VectorBase2f, math::VectorBase3f, math::VectorBase4f,
67  math::VectorBase2i, math::VectorBase3i, math::VectorBase4i,
68  math::VectorBase2ui, math::VectorBase3ui, math::VectorBase4ui,
71 
76 class ION_API Uniform : public ShaderInput<UniformValueType, UniformType> {
77  public:
81  Uniform() {}
82  ~Uniform() {}
83 
85  static const char* GetShaderInputTypeName();
86 
88  static const char* GetValueTypeName(const ValueType type);
89 
92  template <typename T> static ValueType GetTypeByValue();
93 
95  static Tag GetTag() { return kUniform; }
96 
100  void MergeValuesFrom(const Uniform& replacement);
101 
102  bool operator==(const Uniform& other) const;
103  bool operator!=(const Uniform& other) const {
104  return !(*this == other);
105  }
106 
109  static bool GetMerged(
110  const Uniform& base, const Uniform& replacement, Uniform* merged);
111 
112  private:
113  template <typename T> void MergeValuesInternal(const Uniform& other);
114 };
115 
116 } // namespace gfx
117 } // namespace ion
118 
119 #endif // ION_GFX_UNIFORM_H_
Matrix< 4, float > Matrix4f
Definition: matrix.h:371
std::string type
Definition: printer.cc:353
Uniform()
The default constructor creates an invalid Uniform instance, which should never be used as is...
Definition: uniform.h:81
Matrix< 3, float > Matrix3f
Definition: matrix.h:369
base::ReferentPtr< CubeMapTexture >::Type CubeMapTexturePtr
Convenience typedef for shared pointer to a CubeMapTexture.
base::Variant< float, int, uint32, math::VectorBase2f, math::VectorBase3f, math::VectorBase4f, math::VectorBase2i, math::VectorBase3i, math::VectorBase4i, math::VectorBase2ui, math::VectorBase3ui, math::VectorBase4ui, math::Matrix2f, math::Matrix3f, math::Matrix4f, CubeMapTexturePtr, TexturePtr > UniformValueType
Definition: uniform.h:70
A Uniform instance represents a uniform shader argument.
Definition: uniform.h:76
Tag
This is only used to determine the type of a ShaderInputRegistry::Spec since Attributes and Uniforms ...
Definition: shaderinput.h:35
Scalar types.
Definition: uniform.h:39
bool operator!=(const Uniform &other) const
Definition: uniform.h:103
The Variant class is similar to boost::variant.
Definition: variant.h:201
Matrix types.
Definition: uniform.h:59
Matrix< 2, float > Matrix2f
Dimension- and type-specific typedefs.
Definition: matrix.h:367
static Tag GetTag()
Returns the tag for this input type.
Definition: uniform.h:95
A ShaderInput instance represents a general shader input.
Definition: shaderinput.h:50
bool operator==(const StlAllocator< T1 > &lhs, const StlAllocator< T2 > &rhs)
Each StlAllocator holds an Allocator.
Definition: stlallocator.h:237
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60
UniformType
The UniformType enum defines all supported uniform shader argument types.
Definition: uniform.h:37