|
@@ -12,8 +12,6 @@ static_assert(std::is_same<GL::Program, GLuint>::value, "p has invalid type");
|
|
static_assert(std::is_same<char, GLchar>::value, "char has invalid type");
|
|
static_assert(std::is_same<char, GLchar>::value, "char has invalid type");
|
|
static_assert(std::is_same<int, GLint>::value, "int has invalid type");
|
|
static_assert(std::is_same<int, GLint>::value, "int has invalid type");
|
|
static_assert(std::is_same<float, GLfloat>::value, "float has invalid type");
|
|
static_assert(std::is_same<float, GLfloat>::value, "float has invalid type");
|
|
-static_assert(std::is_same<GL::ShaderType, GLenum>::value,
|
|
|
|
- "shader type has invalid type");
|
|
|
|
static_assert(std::is_same<GL::Texture, GLuint>::value,
|
|
static_assert(std::is_same<GL::Texture, GLuint>::value,
|
|
"texture has invalid type");
|
|
"texture has invalid type");
|
|
static_assert(std::is_same<GL::Framebuffer, GLuint>::value,
|
|
static_assert(std::is_same<GL::Framebuffer, GLuint>::value,
|
|
@@ -24,19 +22,6 @@ static_assert(std::is_same<GL::VertexArray, GLuint>::value,
|
|
"vertex array has invalid type");
|
|
"vertex array has invalid type");
|
|
static_assert(std::is_same<GL::Buffer, GLuint>::value,
|
|
static_assert(std::is_same<GL::Buffer, GLuint>::value,
|
|
"buffer has invalid type");
|
|
"buffer has invalid type");
|
|
-static_assert(std::is_same<GL::BufferUsage, GLenum>::value,
|
|
|
|
- "buffer usage has invalid type");
|
|
|
|
-
|
|
|
|
-GL::ShaderType GL::NO_SHADER = 0;
|
|
|
|
-GL::ShaderType GL::VERTEX_SHADER = GL_VERTEX_SHADER;
|
|
|
|
-GL::ShaderType GL::FRAGMENT_SHADER = GL_FRAGMENT_SHADER;
|
|
|
|
-GL::ShaderType GL::GEOMETRY_SHADER = GL_GEOMETRY_SHADER;
|
|
|
|
-GL::ShaderType GL::TESSELATION_CONTROL_SHADER = GL_TESS_CONTROL_SHADER;
|
|
|
|
-GL::ShaderType GL::TESSELATION_EVALUATION_SHADER = GL_TESS_EVALUATION_SHADER;
|
|
|
|
-
|
|
|
|
-GL::BufferUsage GL::STATIC_DRAW = GL_STATIC_DRAW;
|
|
|
|
-GL::BufferUsage GL::STREAM_DRAW = GL_STREAM_DRAW;
|
|
|
|
-GL::BufferUsage GL::DYNAMIC_DRAW = GL_DYNAMIC_DRAW;
|
|
|
|
|
|
|
|
GL::Attribute::Attribute(int count_, int size_, int type_, bool normalized_)
|
|
GL::Attribute::Attribute(int count_, int size_, int type_, bool normalized_)
|
|
: count(count_), size(size_), type(type_), normalized(normalized_) {
|
|
: count(count_), size(size_), type(type_), normalized(normalized_) {
|
|
@@ -210,7 +195,17 @@ void GL::deleteProgram(Program p) {
|
|
}
|
|
}
|
|
|
|
|
|
GL::Shader GL::createShader(ShaderType type) {
|
|
GL::Shader GL::createShader(ShaderType type) {
|
|
- return glCreateShader(type);
|
|
|
|
|
|
+ static constexpr GLenum MAP[] = {0,
|
|
|
|
+ GL_VERTEX_SHADER,
|
|
|
|
+ GL_FRAGMENT_SHADER,
|
|
|
|
+ GL_GEOMETRY_SHADER,
|
|
|
|
+ GL_TESS_CONTROL_SHADER,
|
|
|
|
+ GL_TESS_EVALUATION_SHADER};
|
|
|
|
+ static constexpr int MAP_SIZE =
|
|
|
|
+ static_cast<int>(sizeof(MAP) / sizeof(GLenum));
|
|
|
|
+ int index = static_cast<int>(type);
|
|
|
|
+ GLenum realTyp = index < 0 || index >= MAP_SIZE ? MAP[0] : MAP[index];
|
|
|
|
+ return glCreateShader(realTyp);
|
|
}
|
|
}
|
|
|
|
|
|
void GL::compileShader(Shader s, const char* code) {
|
|
void GL::compileShader(Shader s, const char* code) {
|
|
@@ -398,7 +393,13 @@ void GL::bindBuffer(Buffer b) {
|
|
}
|
|
}
|
|
|
|
|
|
void GL::bufferData(int size, const void* data, BufferUsage usage) {
|
|
void GL::bufferData(int size, const void* data, BufferUsage usage) {
|
|
- glBufferData(GL_ARRAY_BUFFER, size, data, usage);
|
|
|
|
|
|
+ static constexpr GLenum MAP[] = {0, GL_STATIC_DRAW, GL_STREAM_DRAW,
|
|
|
|
+ GL_DYNAMIC_DRAW};
|
|
|
|
+ static constexpr int MAP_SIZE =
|
|
|
|
+ static_cast<int>(sizeof(MAP) / sizeof(GLenum));
|
|
|
|
+ int index = static_cast<int>(usage);
|
|
|
|
+ GLenum realUsage = index < 0 || index >= MAP_SIZE ? MAP[0] : MAP[index];
|
|
|
|
+ glBufferData(GL_ARRAY_BUFFER, size, data, realUsage);
|
|
}
|
|
}
|
|
|
|
|
|
void GL::bufferSubData(int offset, int size, const void* data) {
|
|
void GL::bufferSubData(int offset, int size, const void* data) {
|