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