1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#pragma once
#include <GL/glew.h>
#include <array>
#include <glm/common.hpp>
#include <glm/fwd.hpp>
template<typename T> struct gl_traits;
struct gl_traits_base {
static constexpr GLint size {1};
};
struct gl_traits_float : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
glVertexAttribPointer(index, size, type, GL_FALSE, stride, pointer);
}};
};
struct gl_traits_longfloat : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
glVertexAttribLPointer(index, size, type, stride, pointer);
}};
};
struct gl_traits_integer : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
glVertexAttribIPointer(index, size, type, stride, pointer);
}};
};
template<> struct gl_traits<glm::f32> : public gl_traits_float {
static constexpr GLenum type {GL_FLOAT};
};
template<> struct gl_traits<glm::f64> : public gl_traits_longfloat {
static constexpr GLenum type {GL_DOUBLE};
};
template<> struct gl_traits<glm::int8> : public gl_traits_integer {
static constexpr GLenum type {GL_BYTE};
};
template<> struct gl_traits<glm::int16> : public gl_traits_integer {
static constexpr GLenum type {GL_SHORT};
};
template<> struct gl_traits<glm::int32> : public gl_traits_integer {
static constexpr GLenum type {GL_INT};
};
template<> struct gl_traits<glm::uint8> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_BYTE};
};
template<> struct gl_traits<glm::uint16> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_SHORT};
};
template<> struct gl_traits<glm::uint32> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_INT};
};
template<typename T, std::size_t S> struct gl_traits<std::array<T, S>> : public gl_traits<T> {
static constexpr GLint size {S * gl_traits<T>::size};
};
template<glm::length_t L, typename T, glm::qualifier Q> struct gl_traits<glm::vec<L, T, Q>> : public gl_traits<T> {
static constexpr GLint size {L};
};
template<glm::length_t C, glm::length_t R, typename T, glm::qualifier Q>
struct gl_traits<glm::mat<C, R, T, Q>> : public gl_traits<T> {
static constexpr GLint size {C * R};
};
|