]> git.localhorst.tv Git - blobs.git/blob - src/graphics/gl_traits.hpp
new gcc version
[blobs.git] / src / graphics / gl_traits.hpp
1 #ifndef BLOBS_GRAPHICS_GL_TRAITS_HPP_
2 #define BLOBS_GRAPHICS_GL_TRAITS_HPP_
3
4 #include "../math/glm.hpp"
5
6 #include <GL/glew.h>
7
8
9 namespace blobs {
10 namespace graphics {
11
12 template<class T>
13 struct gl_traits {
14
15         /// number of components per generic attribute
16         /// must be 1, 2, 3, 4
17         // static constexpr GLint size;
18
19         /// component type
20         /// accepted values are:
21         ///   GL_BYTE, GL_UNSIGNED_BYTE,
22         ///   GL_SHORT, GL_UNSIGNED_SHORT,
23         ///   GL_INT, GL_UNSIGNED_INT,
24         ///   GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
25         ///   GL_FIXED, GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV
26         // static constexpr GLenum type;
27
28 };
29
30
31 // basic types
32
33 template<> struct gl_traits<signed char> {
34         static constexpr GLint size = 1;
35         static constexpr GLenum type = GL_BYTE;
36 };
37
38 template<> struct gl_traits<unsigned char> {
39         static constexpr GLint size = 1;
40         static constexpr GLenum type = GL_UNSIGNED_BYTE;
41 };
42
43 template<> struct gl_traits<short> {
44         static constexpr GLint size = 1;
45         static constexpr GLenum type = GL_SHORT;
46 };
47
48 template<> struct gl_traits<unsigned short> {
49         static constexpr GLint size = 1;
50         static constexpr GLenum type = GL_UNSIGNED_SHORT;
51 };
52
53 template<> struct gl_traits<int> {
54         static constexpr GLint size = 1;
55         static constexpr GLenum type = GL_INT;
56 };
57
58 template<> struct gl_traits<unsigned int> {
59         static constexpr GLint size = 1;
60         static constexpr GLenum type = GL_UNSIGNED_INT;
61 };
62
63 template<> struct gl_traits<float> {
64         static constexpr GLint size = 1;
65         static constexpr GLenum type = GL_FLOAT;
66 };
67
68 template<> struct gl_traits<double> {
69         static constexpr GLint size = 1;
70         static constexpr GLenum type = GL_DOUBLE;
71 };
72
73 // composite types
74
75 template<class T, glm::precision P>
76 struct gl_traits<glm::tvec1<T, P>> {
77         static constexpr GLint size = 1;
78         static constexpr GLenum type = gl_traits<T>::type;
79 };
80 template<class T, glm::precision P>
81 constexpr GLint gl_traits<glm::tvec1<T, P>>::size;
82 template<class T, glm::precision P>
83 constexpr GLenum gl_traits<glm::tvec1<T, P>>::type;
84
85 template<class T, glm::precision P>
86 struct gl_traits<glm::tvec2<T, P>> {
87         static constexpr GLint size = 2;
88         static constexpr GLenum type = gl_traits<T>::type;
89 };
90 template<class T, glm::precision P>
91 constexpr GLint gl_traits<glm::tvec2<T, P>>::size;
92 template<class T, glm::precision P>
93 constexpr GLenum gl_traits<glm::tvec2<T, P>>::type;
94
95 template<class T, glm::precision P>
96 struct gl_traits<glm::tvec3<T, P>> {
97         static constexpr GLint size = 3;
98         static constexpr GLenum type = gl_traits<T>::type;
99 };
100 template<class T, glm::precision P>
101 constexpr GLint gl_traits<glm::tvec3<T, P>>::size;
102 template<class T, glm::precision P>
103 constexpr GLenum gl_traits<glm::tvec3<T, P>>::type;
104
105 template<class T, glm::precision P>
106 struct gl_traits<glm::tvec4<T, P>> {
107         static constexpr GLint size = 4;
108         static constexpr GLenum type = gl_traits<T>::type;
109 };
110 template<class T, glm::precision P>
111 constexpr GLint gl_traits<glm::tvec4<T, P>>::size;
112 template<class T, glm::precision P>
113 constexpr GLenum gl_traits<glm::tvec4<T, P>>::type;
114
115 }
116 }
117
118 #endif