* fixed template magic

This commit is contained in:
end 2016-09-27 17:57:41 +02:00
parent a4557a2762
commit f77e1b779d
4 changed files with 76 additions and 46 deletions

View file

@ -3,6 +3,8 @@
#include <epoxy/gl.h>
#include <epoxy/glx.h>
#include <string>
namespace endofthejedi {
template <GLenum T> class BufferObject {
@ -37,10 +39,45 @@ class VAO {
class Shader {
private:
GLuint m_program;
protected:
public:
Shader();
~Shader();
void bind();
void unbind();
void load(std::string data, GLenum shadertype);
};
}
#define TBufferObject_(pre, post) \
template <GLenum T> pre endofthejedi::BufferObject<T>::post
#define TBufferObject(...) TBufferObject_(__VA_ARGS__)
TBufferObject(, BufferObject)() { glGenBuffers(1, &m_name); }
TBufferObject(, ~BufferObject)() { glDeleteBuffers(1, &m_name); }
TBufferObject(void, bind)() { glBindBuffer(T, m_name); }
TBufferObject(void, bind)(GLuint index, GLintptr offset, GLsizeiptr size) {
// todo
}
TBufferObject(void, fill)(GLenum usage, GLsizei size, GLvoid *data) {
glBufferData(T, size, data, usage);
}
TBufferObject(void, subfill)(GLintptr offset, GLsizei size,
const GLvoid *data) {
glBufferSubData(T, offset, size, data);
}
TBufferObject(void, map)(GLenum access) {
// todo
}
TBufferObject(void, unmap)() {
// todo
}

View file

@ -5,10 +5,15 @@
#include <epoxy/gl.h>
#include <epoxy/glx.h>
#include <include/glclasses.h>
namespace endofthejedi {
class Renderer {
private:
VBO m_vbo;
VAO m_vao;
Shader m_shader;
protected:
public:
Renderer();