OGLplus (0.52.0) a C++ wrapper for OpenGL

data_type.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_DATA_TYPE_1107121519_HPP
14 #define OGLPLUS_DATA_TYPE_1107121519_HPP
15 
16 #include <oglplus/enumerations.hpp>
17 #include <type_traits>
18 
19 namespace oglplus {
20 
22 template <typename GLtype>
23 struct TypeTag
24 { };
25 
27 
34 OGLPLUS_ENUM_CLASS_BEGIN(DataType, GLenum)
35 #include <oglplus/enums/data_type.ipp>
36 OGLPLUS_ENUM_CLASS_END(DataType)
37 
38 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
39 #include <oglplus/enums/data_type_names.ipp>
40 #endif
41 
42 #if !OGLPLUS_ENUM_VALUE_RANGES
43 #include <oglplus/enums/data_type_range.ipp>
44 #endif
45 
46 // Compile-time data type getter
47 template <typename T>
48 struct DataTypeCT;
49 
50 template <>
51 struct DataTypeCT<GLbyte>
52  : public std::integral_constant<DataType, DataType::Byte>
53 { };
54 
55 template <>
56 struct DataTypeCT<GLshort>
57  : public std::integral_constant<DataType, DataType::Short>
58 { };
59 
60 template <>
61 struct DataTypeCT<GLint>
62  : public std::integral_constant<DataType, DataType::Int>
63 { };
64 
65 template <>
66 struct DataTypeCT<GLubyte>
67  : public std::integral_constant<DataType, DataType::UnsignedByte>
68 { };
69 
70 template <>
71 struct DataTypeCT<GLushort>
72  : public std::integral_constant<DataType, DataType::UnsignedShort>
73 { };
74 
75 template <>
76 struct DataTypeCT<GLuint>
77  : public std::integral_constant<DataType, DataType::UnsignedInt>
78 { };
79 
80 template <>
81 struct DataTypeCT<GLfloat>
82  : public std::integral_constant<DataType, DataType::Float>
83 { };
84 
85 #ifdef GL_DOUBLE
86 template <>
87 struct DataTypeCT<GLdouble>
88  : public std::integral_constant<DataType, DataType::Double>
89 { };
90 #endif
91 
93 template <typename T>
94 inline DataType GetDataType(void)
95 {
96  return DataType(DataTypeCT<T>::value);
97 }
98 
99 namespace aux {
100 
101 template <typename T>
102 std::true_type _get_is_gl_data_type(T*, typename DataTypeCT<T>::type* = nullptr);
103 std::false_type _get_is_gl_data_type(...);
104 
105 template <typename T>
106 struct _is_gl_data_type
107 {
108  typedef decltype(_get_is_gl_data_type((T*)0)) type;
109 };
110 
111 } // namespace aux
112 
113 // Checks if type T is an OpenGL data type
114 template <typename T>
115 struct IsGLDataType
116  : public aux::_is_gl_data_type<T>::type
117 { };
118 
120 
123 OGLPLUS_ENUM_CLASS_BEGIN(SLDataType, GLenum)
124 #include <oglplus/enums/sl_data_type.ipp>
125 OGLPLUS_ENUM_CLASS_END(SLDataType)
126 
127 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
128 #include <oglplus/enums/sl_data_type_names.ipp>
129 #endif
130 
131 #if !OGLPLUS_ENUM_VALUE_RANGES
132 #include <oglplus/enums/sl_data_type_range.ipp>
133 #endif
134 
135 } // namespace oglplus
136 
137 #endif // include guard
DataType
OpenGL data type enumeration.
Definition: data_type.hpp:34
A tag template used mainly for data-type-based function overload dispatching.
Definition: data_type.hpp:23
Enumeration-related declarations.
SLDataType
OpenGL Shading Language data type enumeration.
Definition: data_type.hpp:123
DataType GetDataType(void)
Returns the DataType for the specified type T.
Definition: data_type.hpp:94

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).