13 #ifndef OGLPLUS_PROG_VAR_SET_OPS_1107121519_HPP
14 #define OGLPLUS_PROG_VAR_SET_OPS_1107121519_HPP
19 #include <oglplus/prog_var/callers.hpp>
21 #include <type_traits>
26 template <
class OpsTag,
class VarTag,
class TypTag,
class T, std::
size_t M>
27 class ProgVarBaseSetOps;
29 template <
typename OpsTag,
typename VarTag,
typename T, std::
size_t M>
30 class ProgVarBaseSetOps<OpsTag, VarTag, tag::NativeTypes, T, M>
31 :
public ProgVarSetters<OpsTag, VarTag, tag::NativeTypes>
32 ,
public ProgVarCallers<OpsTag, T>
35 typedef ProgVarSetters<OpsTag, VarTag, tag::NativeTypes> Setters;
36 typedef ProgVarCallers<OpsTag, T> Callers;
38 OGLPLUS_ERROR_REUSE_CONTEXT(Setters)
40 typedef std::false_type _set_done;
41 typedef std::true_type _set_cont;
43 template <std::
size_t N>
44 static std::integral_constant<
bool, (N > 4)> _set_mode(
void)
46 return std::integral_constant<bool, (N > 4)>();
49 template <std::
size_t N,
typename V>
50 static void _do_set_v(
58 std::integral_constant<std::size_t, 4> nparam;
62 Setters::_fns_v(nparam, v),
79 template <std::
size_t N,
typename V>
80 static void _do_set_v(
88 std::integral_constant<std::size_t, N> nparam;
92 Setters::_fns_v(nparam, v),
102 template <std::
size_t N,
typename V>
103 static void _do_set_n(
106 GLuint base_location,
112 std::integral_constant<std::size_t, N> nparam;
113 Callers::_call_set_vn(
117 Setters::_fns_v(nparam, v),
128 #if !OGLPLUS_NO_VARIADIC_TEMPLATES
129 template <
typename S,
typename ... V>
130 static void _do_set_t(
133 GLuint base_location,
135 S v0,
S v1,
S v2,
S v3,
139 std::integral_constant<std::size_t, 4> nparam;
140 Callers::_call_set_t(
143 Setters::_fns_t(nparam, &v0),
152 _set_mode<
sizeof...(V)>(),
160 template <
typename ... V>
161 static void _do_set_t(
164 GLuint base_location,
169 std::integral_constant<std::size_t,
sizeof...(V)> nparam;
170 Callers::_call_set_t(
173 Setters::_fns_t(nparam, &v...),
182 #endif //NO_VARIADIC_TEMPLATES
186 #if !OGLPLUS_NO_VARIADIC_TEMPLATES
187 template <
typename ... V>
188 static void _do_set(GLuint program, GLuint location, V ... v)
191 (
sizeof...(V) > 0) && (
sizeof...(V) <= M),
192 "Set requires 1 to M arguments"
195 _set_mode<
sizeof...(V)>(),
208 template <
typename V>
209 static void _do_set(GLuint program, GLuint location, V v0)
211 std::integral_constant<std::size_t, 1> nparam;
212 Callers::_call_set_t(
215 Setters::_fns_t(nparam, &v0),
225 template <
typename V>
226 static void _do_set(GLuint program, GLuint location, V v0, V v1)
228 std::integral_constant<std::size_t, 2> nparam;
229 Callers::_call_set_t(
232 Setters::_fns_t(nparam, &v0),
242 template <
typename V>
243 static void _do_set(GLuint program, GLuint location, V v0, V v1, V v2)
245 std::integral_constant<std::size_t, 3> nparam;
246 Callers::_call_set_t(
249 Setters::_fns_t(nparam, &v0),
259 template <
typename V>
260 static void _do_set(GLuint program, GLuint location, V v0, V v1, V v2, V v3)
262 std::integral_constant<std::size_t, 4> nparam;
263 Callers::_call_set_t(
266 Setters::_fns_t(nparam, &v0),
275 #endif //NO_VARIADIC_TEMPLATES
277 template <std::
size_t Cols,
typename V>
278 static void _do_set(GLuint program, GLuint location,
const V* v)
281 (Cols > 0) && (Cols <= M),
282 "The number of elements must be between 1 and M"
293 template <std::
size_t Cols,
typename V>
294 static void _do_set_many(GLuint prog, GLuint location, GLsizei n,
const V*v)
297 (Cols > 0) && (Cols <= M),
298 "The number of elements must be between 1 and M"
311 template <
typename OpsTag,
typename VarTag,
typename T, std::
size_t M>
312 class ProgVarBaseSetOps<OpsTag, VarTag, tag::MatrixTypes, T, M>
313 :
public ProgVarSetters<OpsTag, VarTag, tag::MatrixTypes>
314 ,
public ProgVarCallers<OpsTag, T>
317 typedef ProgVarSetters<OpsTag, VarTag, tag::MatrixTypes> Setters;
318 typedef ProgVarCallers<OpsTag, T> Callers;
320 OGLPLUS_ERROR_REUSE_CONTEXT(Setters)
322 template <std::
size_t Cols, std::
size_t Rows, typename V>
323 static
void _do_set_mat(
332 (Cols > 0) && (Cols <= 4),
333 "The number of columns must be between 1 and 4"
336 (Rows > 0) && (Rows <= 4),
337 "The number of rows must be between 1 and 4"
339 std::integral_constant<std::size_t, Rows> rows;
340 std::integral_constant<std::size_t, Cols> cols;
341 Callers::_call_set_m(
345 transpose ? GL_TRUE : GL_FALSE,
346 Setters::_fns_v(cols, rows, v),
356 #if !OGLPLUS_NO_VARIADIC_TEMPLATES
357 template <std::size_t Cols,
typename V,
typename ... P>
358 static void _do_set_mat_p(
367 (Cols > 0) && (Cols <= 4),
368 "The number of columns must be between 1 and 4"
371 (
sizeof...(P) + 1) % Cols == 0,
372 "Not enough values for the last row"
374 V values[] = {v, V(p)...};
375 _do_set_mat<Cols, (
sizeof...(P) + 1) / Cols, V>(
383 #endif //NO_VARIADIC_TEMPLATES
388 #endif // include guard
Helper macro for optional checking of availability of GL function.
Declaration of basic OGLplus' exceptions.