MeVisLab Toolbox Reference
SoUniformParameterBase.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef SO_UNIFORM_PARAMETER_BASE_H
14#define SO_UNIFORM_PARAMETER_BASE_H
15
16
18
19#include "SoShaderSystem.h"
20#include <Inventor/SbString.h>
21#include <mlOpenGL.h>
22
23#ifdef WIN32
24# pragma warning( push )
25# pragma warning( disable : 4100 )
26#endif
27
30{
31 protected:
32
35
38
39 public:
40
42 virtual int addTextureSampler(const SbString & /*name*/) { return 0; }
43
44 // These functions are used to assign values to uniform parameter via OpenGL
45 virtual void set1f(const SbString & /*name*/, const float /*value*/) {}
46 virtual void set2f(const SbString & /*name*/, const float * /*value*/) {}
47 virtual void set3f(const SbString & /*name*/, const float * /*value*/) {}
48 virtual void set4f(const SbString & /*name*/, const float * /*value*/) {}
49 virtual void set2f(const SbString & /*name*/, const float /*value0*/, const float /*value1*/) {}
50 virtual void set3f(const SbString & /*name*/, const float /*value0*/, const float /*value1*/, const float /*value2*/) {}
51 virtual void set4f(const SbString & /*name*/, const float /*value0*/, const float /*value1*/, const float /*value2*/, const float /*value3*/) {}
52
53 virtual void set1fv(const SbString & /*name*/, const int /*num*/, const float * /*value*/) {}
54 virtual void set2fv(const SbString & /*name*/, const int /*num*/, const float * /*value*/) {}
55 virtual void set3fv(const SbString & /*name*/, const int /*num*/, const float * /*value*/) {}
56 virtual void set4fv(const SbString & /*name*/, const int /*num*/, const float * /*value*/) {}
57
58 virtual void set1i(const SbString & /*name*/, const int32_t /*value*/) {}
59 virtual void set2i(const SbString & /*name*/, const int32_t * /*value*/) {}
60 virtual void set2i(const SbString & /*name*/, const SbVec2s & /*value*/) {}
61 virtual void set3i(const SbString & /*name*/, const int32_t * /*value*/) {}
62 virtual void set3i(const SbString & /*name*/, const SbVec3s & /*value*/) {}
63 virtual void set4i(const SbString & /*name*/, const int32_t * /*value*/) {}
64
65 virtual void setMatrix3f(const SbString & name, const float * values, SbBool transpose = FALSE) { setMatrix3fv(name, 1, values, transpose); }
66 virtual void setMatrix4f(const SbString & name, const float * values, SbBool transpose = FALSE) { setMatrix4fv(name, 1, values, transpose); }
67 virtual void setMatrix3fv(const SbString & /*name*/, int /*num*/, const float * /*value*/, SbBool /*transpose*/ = FALSE) {}
68 virtual void setMatrix4fv(const SbString & /*name*/, int /*num*/, const float * /*value*/, SbBool /*transpose*/ = FALSE) {}
69
70 public:
71
78
79 // Provide additional information about the purpose of a uniform parameter. Those information
80 // may be collected and analyzed by derived classes.
81 virtual void setSamplerInfo(const SbString & /*name*/, SamplerType /*type*/, uint32_t /*texId*/) {}
82};
83
86public:
87 //all these functions are used by uniform parameters to notify the collector
88 void set1f(const SbString &name, const float value) override;
89 void set2f(const SbString &name, const float *value) override;
90 void set3f(const SbString &name, const float *value) override;
91 void set4f(const SbString &name, const float *value) override;
92 void set2f(const SbString &name, const float value0, const float value1) override;
93 void set3f(const SbString &name, const float value0, const float value1, const float value2) override;
94 void set4f(const SbString &name, const float value0, const float value1, const float value2, const float value3) override;
95
96 void set1fv(const SbString &name, const int num, const float *value) override;
97 void set2fv(const SbString &name, const int num, const float *value) override;
98 void set3fv(const SbString &name, const int num, const float *value) override;
99 void set4fv(const SbString &name, const int num, const float *value) override;
100
101 void set1i(const SbString &name, const int32_t value) override;
102 void set2i(const SbString &name, const int32_t *value) override;
103 void set2i(const SbString &name, const SbVec2s &value) override;
104 void set3i(const SbString &name, const int32_t *value) override;
105 void set3i(const SbString &name, const SbVec3s &value) override;
106 void set4i(const SbString &name, const int32_t *value) override;
107
108 void setMatrix3fv(const SbString &name, int num, const float *value, SbBool transpose = FALSE) override;
109 void setMatrix4fv(const SbString &name, int num, const float *value, SbBool transpose = FALSE) override;
110
111 void setSamplerInfo(const SbString &name, SamplerType type, uint32_t texId) override;
112
113 const std::vector<ml::OpenGL::TypeInfo>& getUniforms() const { return _uniforms; }
114
115private:
116 std::vector<ml::OpenGL::TypeInfo> _uniforms;
117
118};
119
120#ifdef WIN32
121# pragma warning( pop )
122#endif
123
124#endif // _SO_UNIFORM_PARAMETER_BASE_
A helper class that collects uniforms instead of setting them to a shader.
void set4fv(const SbString &name, const int num, const float *value) override
void set3fv(const SbString &name, const int num, const float *value) override
void set3f(const SbString &name, const float value0, const float value1, const float value2) override
const std::vector< ml::OpenGL::TypeInfo > & getUniforms() const
void set2f(const SbString &name, const float value0, const float value1) override
void set3i(const SbString &name, const SbVec3s &value) override
void set2i(const SbString &name, const SbVec2s &value) override
void set1f(const SbString &name, const float value) override
void set2fv(const SbString &name, const int num, const float *value) override
void setSamplerInfo(const SbString &name, SamplerType type, uint32_t texId) override
void set4f(const SbString &name, const float *value) override
void setMatrix3fv(const SbString &name, int num, const float *value, SbBool transpose=FALSE) override
void setMatrix4fv(const SbString &name, int num, const float *value, SbBool transpose=FALSE) override
void set1i(const SbString &name, const int32_t value) override
void set3f(const SbString &name, const float *value) override
void set4f(const SbString &name, const float value0, const float value1, const float value2, const float value3) override
void set3i(const SbString &name, const int32_t *value) override
void set1fv(const SbString &name, const int num, const float *value) override
void set2i(const SbString &name, const int32_t *value) override
void set4i(const SbString &name, const int32_t *value) override
void set2f(const SbString &name, const float *value) override
Base class for uniform shader parameters.
virtual void setMatrix3fv(const SbString &, int, const float *, SbBool=FALSE)
virtual void set3i(const SbString &, const SbVec3s &)
virtual void set4f(const SbString &, const float *)
virtual ~SoUniformParameterBase()
Hidden destructor.
virtual void setMatrix4f(const SbString &name, const float *values, SbBool transpose=FALSE)
virtual void set2f(const SbString &, const float, const float)
virtual void set1f(const SbString &, const float)
virtual void set2fv(const SbString &, const int, const float *)
virtual void setMatrix4fv(const SbString &, int, const float *, SbBool=FALSE)
virtual void setSamplerInfo(const SbString &, SamplerType, uint32_t)
virtual void set4fv(const SbString &, const int, const float *)
virtual void set4f(const SbString &, const float, const float, const float, const float)
SoUniformParameterBase()
Hidden constructor.
virtual void set3i(const SbString &, const int32_t *)
virtual void setMatrix3f(const SbString &name, const float *values, SbBool transpose=FALSE)
virtual void set1i(const SbString &, const int32_t)
virtual int addTextureSampler(const SbString &)
Adds a texture sampler with the given name and returns the assigned texture unit.
virtual void set4i(const SbString &, const int32_t *)
virtual void set3fv(const SbString &, const int, const float *)
virtual void set2i(const SbString &, const SbVec2s &)
virtual void set3f(const SbString &, const float *)
virtual void set1fv(const SbString &, const int, const float *)
virtual void set2i(const SbString &, const int32_t *)
virtual void set3f(const SbString &, const float, const float, const float)
virtual void set2f(const SbString &, const float *)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.