* fixed fbo classes

This commit is contained in:
end 2016-10-03 20:11:10 +02:00
parent 5e8a04c54f
commit 9da97611e0
2 changed files with 24 additions and 14 deletions

View file

@ -6,10 +6,11 @@
#include <sstream>
namespace endofthejedi {
VAO::VAO() { glGenVertexArrays(1, &m_name); }
VAO::VAO() {}
VAO::~VAO() { glDeleteVertexArrays(1, &m_name); }
void VAO::init() { glGenVertexArrays(1, &m_name); }
void VAO::bind() { glBindVertexArray(m_name); }
void VAO::unbind() { glBindVertexArray(0); }
@ -125,27 +126,29 @@ GLuint Shader::location(const std::string &name) {
return glGetUniformLocation(m_program, name.c_str());
}
Texture::Texture() { glGenTextures(1, &m_name); }
Texture::Texture() {}
Texture::~Texture() { glDeleteTextures(1, &m_name); }
void Texture::init() { glGenTextures(1, &m_name); }
void Texture::bind() { glBindTexture(GL_TEXTURE_2D, m_name); }
void Texture::unbind() { glBindTexture(GL_TEXTURE_2D, 0); }
void Texture::fill(GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLint border, GLenum format,
GLenum type, const GLvoid *data) {
void Texture::fill(GLint level, GLint internalFormat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const GLvoid *data) {
bind();
glTexImage2D(target, level, internalFormat, width, height, border, format,
type, data);
glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border,
format, type, data);
}
GLuint Texture::getName() { return m_name; }
Framebuffer::Framebuffer() { glGenFramebuffers(1, &m_name); }
Framebuffer::Framebuffer() {}
Framebuffer::~Framebuffer() { glDeleteFramebuffers(1, &m_name); }
void Framebuffer::init() { glGenFramebuffers(1, &m_name); }
void Framebuffer::bind() { glBindFramebuffer(GL_FRAMEBUFFER, m_name); }
void Framebuffer::unbind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }
@ -160,10 +163,11 @@ void Framebuffer::attachTexture(GLenum attachment, GLuint tex) {
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, tex, 0);
}
Renderbuffer::Renderbuffer() { glGenRenderbuffers(1, &m_name); }
Renderbuffer::Renderbuffer() {}
Renderbuffer::~Renderbuffer() { glDeleteRenderbuffers(1, &m_name); }
void Renderbuffer::init() { glGenRenderbuffers(1, &m_name); }
void Renderbuffer::bind() { glBindRenderbuffer(GL_RENDERBUFFER, m_name); }
void Renderbuffer::unbind() { glBindRenderbuffer(GL_RENDERBUFFER, 0); }

View file

@ -16,6 +16,7 @@ template <GLenum T> class BufferObject {
public:
BufferObject();
~BufferObject();
void init();
void bind();
void bind(GLuint index, GLintptr offset = 0, GLsizeiptr size = 0);
void fill(GLenum usage, GLsizei size = 0, GLvoid *data = NULL);
@ -35,6 +36,7 @@ class VAO {
public:
VAO();
~VAO();
void init();
void bind();
void unbind();
void fill(GLuint index, GLint size, GLenum type, GLboolean normalized,
@ -70,11 +72,11 @@ class Texture {
public:
Texture();
~Texture();
void init();
void bind();
void unbind();
void fill(GLenum target, GLint level, GLint internalFormat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const GLvoid *data);
void fill(GLint level, GLint internalFormat, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, const GLvoid *data);
GLuint getName();
};
@ -86,6 +88,7 @@ class Framebuffer {
public:
Framebuffer();
~Framebuffer();
void init();
void bind();
void unbind();
void attachRenderbuffer(GLenum attachment, GLuint rbo);
@ -100,6 +103,7 @@ class Renderbuffer {
public:
Renderbuffer();
~Renderbuffer();
void init();
void bind();
void unbind();
void create(GLenum internalformat, GLsizei width, GLsizei height);
@ -110,10 +114,12 @@ class Renderbuffer {
template <GLenum T> pre endofthejedi::BufferObject<T>::post
#define TBufferObject(...) TBufferObject_(__VA_ARGS__)
TBufferObject(, BufferObject)() { glGenBuffers(1, &m_name); }
TBufferObject(, BufferObject)() {}
TBufferObject(, ~BufferObject)() { glDeleteBuffers(1, &m_name); }
TBufferObject(void, init)() { glGenBuffers(1, &m_name); }
TBufferObject(void, bind)() { glBindBuffer(T, m_name); }
TBufferObject(void, bind)(GLuint index, GLintptr offset, GLsizeiptr size) {