13 #ifndef OGLPLUS_PROG_VAR_TYPECHECK_1405052241_HPP
14 #define OGLPLUS_PROG_VAR_TYPECHECK_1405052241_HPP
17 #include <oglplus/config/basic.hpp>
18 #include <oglplus/config/compiler.hpp>
20 #include <oglplus/detail/enum_class.hpp>
27 struct GLSLtoCppTypeMatcher;
29 #if !OGLPLUS_NO_UNIFORM_TYPECHECK
37 struct GLSLtoCppTypeMatcher
39 static bool _matches(GLenum )
45 template <oglplus::SLDataType SLType>
46 struct GLSLtoCppTypeMatcher<oglplus::SLtoCpp<SLType> >
48 static bool _matches(GLenum sl_type)
50 return sl_type == GLenum(SLType);
55 struct GLSLtoCppTypeMatcher<bool>
57 static bool _matches(GLenum sl_type)
59 return sl_type == GL_BOOL;
64 struct GLSLtoCppTypeMatcher<GLint>
66 static bool _matches(GLenum sl_type);
70 struct GLSLtoCppTypeMatcher<GLuint>
72 static bool _matches(GLenum sl_type);
76 struct GLSLtoCppTypeMatcher<GLfloat>
78 static bool _matches(GLenum sl_type)
80 return sl_type == GL_FLOAT;
84 #if defined(GL_DOUBLE)
86 struct GLSLtoCppTypeMatcher<GLdouble>
88 static bool _matches(GLenum sl_type)
90 return sl_type == GL_DOUBLE;
95 #if defined(GL_UNSIGNED_INT64_ARB)
97 struct GLSLtoCppTypeMatcher<GLuint64>
99 static bool _matches(GLenum sl_type)
101 return sl_type == GL_UNSIGNED_INT64_ARB;
106 struct GLSLtoCppTypeMatcher_Vec
108 static std::size_t _type_idx(
bool*) {
return 0; }
109 static std::size_t _type_idx(GLint*) {
return 1; }
110 static std::size_t _type_idx(GLuint*) {
return 2; }
111 static std::size_t _type_idx(GLfloat*) {
return 3; }
112 #if defined(GL_DOUBLE)
113 static std::size_t _type_idx(GLdouble*) {
return 4; }
116 static bool _does_match(
118 std::size_t type_idx,
123 template <
typename T, std::
size_t N>
124 struct GLSLtoCppTypeMatcher<oglplus::Vector<T, N> >
125 :
public GLSLtoCppTypeMatcher_Vec
127 static_assert(N <= 4,
"Invalid vector size");
129 static T* _type_sel(
void) {
return nullptr; }
131 static bool _matches(GLenum sl_type)
133 return GLSLtoCppTypeMatcher_Vec::_does_match(
135 GLSLtoCppTypeMatcher_Vec::_type_idx(_type_sel()),
141 struct GLSLtoCppTypeMatcher_Mat
143 static std::size_t _type_idx(GLfloat*) {
return 0; }
145 static std::size_t _type_idx(GLdouble*) {
return 1; }
148 static bool _does_match(
150 std::size_t type_idx,
156 template <
typename T, std::
size_t Rows, std::
size_t Cols>
157 struct GLSLtoCppTypeMatcher<oglplus::Matrix<T, Rows, Cols> >
158 :
public GLSLtoCppTypeMatcher_Mat
160 static_assert(Rows >= 2,
"Invalid matrix size");
161 static_assert(Cols >= 2,
"Invalid matrix size");
163 static_assert(Rows <= 4,
"Invalid matrix size");
164 static_assert(Cols <= 4,
"Invalid matrix size");
166 static T* _type_sel(
void) {
return nullptr; }
168 static bool _matches(GLenum sl_type)
170 return GLSLtoCppTypeMatcher_Mat::_does_match(
172 GLSLtoCppTypeMatcher_Mat::_type_idx(_type_sel()),
181 :
public ProgVarTypeOps<tag::Uniform>
184 bool (*_type_matches)(GLenum);
186 static void _do_check(
194 template <
typename TypeSel>
195 ProgVarTypecheck(TypeSel*)
196 : _type_matches(&GLSLtoCppTypeMatcher<TypeSel>::_matches)
207 ProgVarTypeOps<tag::Uniform>::GetType(
218 #endif // !OGLPLUS_NO_UNIFORM_TYPECHECK
221 template <
typename ChkTag,
typename VarTag>
222 class ProgVarTypecheck
225 ProgVarTypecheck(
void*)
226 OGLPLUS_NOEXCEPT(true)
243 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
244 #include <oglplus/prog_var/typecheck.ipp>
245 #endif // OGLPLUS_LINK_LIB
247 #endif // include guard
String const reference wrapper template.
Definition: ref_tpl.hpp:72
Helper macro for optional checking of availability of GL function.
Program variable type operations.
SLDataType
OpenGL Shading Language data type enumeration.
Definition: data_type.hpp:123