13 #ifndef OGLPLUS_PROG_VAR_WRAPPER_1405052234_HPP
14 #define OGLPLUS_PROG_VAR_WRAPPER_1405052234_HPP
25 template <
typename VarTag>
26 class ProgVarCommonOps
27 :
public ProgVarLoc<VarTag>
30 ProgVarCommonOps(ProgVarLoc<VarTag> pvloc)
37 template <
typename OpsTag,
typename VarTag,
typename ChkTag,
typename T>
39 :
public ProgVarGetSetOps<OpsTag, VarTag, typename AdjustProgVar<T>::BaseType>
40 ,
public ProgVarTypecheck<ChkTag, VarTag>
43 typedef typename AdjustProgVar<T>::BaseType BaseType;
44 typedef ProgVarGetSetOps<OpsTag, VarTag, BaseType> BaseGetSetOps;
45 typedef ProgVarTypecheck<ChkTag, VarTag> Typecheck;
50 , Typecheck((BaseType*)0)
55 : BaseGetSetOps(pvloc)
56 , Typecheck((BaseType*)0)
61 : BaseGetSetOps(
ProgVarLoc<VarTag>(program, GLint(location)))
62 , Typecheck((BaseType*)0)
67 : BaseGetSetOps(
ProgVarLoc<VarTag>(program, identifier))
68 , Typecheck((BaseType*)0)
70 Typecheck::CheckType(program, this->_location, identifier);
75 : BaseGetSetOps(
ProgVarLoc<VarTag>(program, identifier, active_only))
76 , Typecheck((BaseType*)0)
78 Typecheck::CheckType(program, this->_location, identifier);
83 : BaseGetSetOps(
ProgVarLoc<VarTag>(program, identifier, false))
84 , Typecheck((BaseType*)0)
86 Typecheck::CheckType(program, this->_location, identifier);
91 BaseGetSetOps::BindTo(identifier);
100 ProgVar operator[](std::size_t offset)
const
103 ProgramName(this->_program),
104 this->_location+offset
108 ProgVar& operator = (ProgVarLoc<VarTag> pvloc)
110 BaseGetSetOps::Assign(pvloc);
120 BaseGetSetOps::RequireActive();
121 BaseGetSetOps::SetValue(AdjustProgVar<T>::Adjust(value));
125 void Set(std::size_t count,
const T* values)
127 BaseGetSetOps::RequireActive();
128 BaseGetSetOps::SetValues(count, values);
131 void Set(
const std::vector<T>& values)
133 Set(values.size(), values.data());
136 template <
typename T0,
typename T1>
137 void Set(T0 v0, T1 v1)
142 template <
typename T0,
typename T1,
typename T2>
143 void Set(T0 v0, T1 v1, T2 v2)
148 template <
typename T0,
typename T1,
typename T2,
typename T3>
149 void Set(T0 v0, T1 v1, T2 v2, T3 v3)
159 BaseGetSetOps::SetValue(AdjustProgVar<T>::Adjust(value));
171 template <
typename OpsTag,
typename VarTag>
172 class ProgVar<OpsTag, VarTag, tag::NoTypecheck, void>
173 :
public ProgVarCommonOps<VarTag>
176 typedef ProgVarCommonOps<VarTag> BaseOps;
180 : BaseOps(ProgVarLoc<VarTag>())
184 ProgVar(ProgVarLoc<VarTag> pvloc)
189 ProgVar(ProgramName program, GLuint location)
190 : BaseOps(ProgVarLoc<VarTag>(program, GLint(location)))
195 : BaseOps(ProgVarLoc<VarTag>(program, identifier))
199 ProgVar(ProgramName program,
StrCRef identifier,
bool active_only)
200 : BaseOps(ProgVarLoc<VarTag>(program, identifier, active_only))
205 : BaseOps(ProgVarLoc<VarTag>(program, identifier, false))
209 #if !OGLPLUS_NO_INHERITED_CONSTRUCTORS
210 #define OGLPLUS_IMPLEMENT_PROG_VAR_CTRS(VAR_TAG, PROG_VAR, BASE) \
214 #define OGLPLUS_IMPLEMENT_PROG_VAR_CTRS(VAR_TAG, PROG_VAR, BASE) \
215 PROG_VAR(void) : BASE() { } \
216 PROG_VAR(ProgVarLoc<VAR_TAG> pvloc) : BASE(pvloc) { } \
217 PROG_VAR(ProgramName program, GLuint location) \
218 : BASE(program, location) { } \
219 PROG_VAR(ProgramName program, StrCRef identifier) \
220 : BASE(program, identifier) { } \
221 PROG_VAR(ProgramName program, StrCRef identifier, bool active_only) \
222 : BASE(program, identifier, active_only) { } \
223 PROG_VAR(ProgramName program, StrCRef identifier, std::nothrow_t nt) \
224 : BASE(program, identifier, nt) { }
227 #if !OGLPLUS_NO_TEMPLATE_ALIASES
230 #define OGLPLUS_DECLARE_PROG_VAR(PROG_VAR, OPS_TAG, VAR_TAG, CHK_TAG) \
231 template <typename T> \
232 using PROG_VAR = ProgVar<OPS_TAG, VAR_TAG, CHK_TAG, T>;
237 #define OGLPLUS_DECLARE_PROG_VAR(PROG_VAR, OPS_TAG, VAR_TAG, CHK_TAG) \
238 template <typename T> \
240 : public ProgVar<OPS_TAG, VAR_TAG, CHK_TAG, T> \
243 typedef ProgVar<OPS_TAG, VAR_TAG, CHK_TAG, T> Base;\
245 OGLPLUS_IMPLEMENT_PROG_VAR_CTRS(VAR_TAG, PROG_VAR, Base) \
246 PROG_VAR& operator = (ProgVarLoc<VAR_TAG> pvloc) \
248 Base::Assign(pvloc); \
251 PROG_VAR& operator = (typename Base::ParamType value) \
257 template <typename T> \
258 struct Classify<PROG_VAR<T>> \
259 : Classify<ProgVar<OPS_TAG, VAR_TAG, CHK_TAG, T>> \
265 #endif // include guard
ProgVar(ProgVarLoc< VarTag > pvloc)
Variable from a ProgVarLoc.
Definition: wrapper.hpp:54
AdjustProgVar< T >::ValueType ParamType
Parameter value type.
Definition: wrapper.hpp:115
void Set(ParamType value)
Set the variable value.
Definition: wrapper.hpp:118
Program variable location wrapper.
ProgVar(ProgramName program, StrCRef identifier, bool active_only)
Variable with the specified identifier in the specified program.
Definition: wrapper.hpp:74
void TrySet(ParamType value)
Sets the variable value if it is active.
Definition: wrapper.hpp:155
ProgVarLoc(void)
Default construction.
Definition: location.hpp:55
Wrapper encapsulating program variable location/index.
Definition: fwd.hpp:191
void Set(std::size_t count, const T *values)
Set multiple values.
Definition: wrapper.hpp:125
Helper classes and functions used for program variable typechecking.
String const reference wrapper template.
Definition: ref_tpl.hpp:72
ProgVar(void)
Default construction.
Definition: wrapper.hpp:48
ProgVar(ProgramName program, StrCRef identifier, std::nothrow_t)
Variable with the specified identifier in the specified program.
Definition: wrapper.hpp:82
Program variable (vertex attrib / uniform ) wrapper.
Definition: fwd.hpp:222
ProgVar(ProgramName program, GLuint location)
Variable with the specified location in the specified program.
Definition: wrapper.hpp:60
ProgVar(ProgramName program, StrCRef identifier)
Variable with the specified identifier in the specified program.
Definition: wrapper.hpp:66