* fixed fbo classes
This commit is contained in:
parent
5e8a04c54f
commit
9da97611e0
2 changed files with 24 additions and 14 deletions
|
@ -6,10 +6,11 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace endofthejedi {
|
namespace endofthejedi {
|
||||||
VAO::VAO() { glGenVertexArrays(1, &m_name); }
|
|
||||||
|
|
||||||
|
VAO::VAO() {}
|
||||||
VAO::~VAO() { glDeleteVertexArrays(1, &m_name); }
|
VAO::~VAO() { glDeleteVertexArrays(1, &m_name); }
|
||||||
|
|
||||||
|
void VAO::init() { glGenVertexArrays(1, &m_name); }
|
||||||
void VAO::bind() { glBindVertexArray(m_name); }
|
void VAO::bind() { glBindVertexArray(m_name); }
|
||||||
void VAO::unbind() { glBindVertexArray(0); }
|
void VAO::unbind() { glBindVertexArray(0); }
|
||||||
|
|
||||||
|
@ -125,27 +126,29 @@ GLuint Shader::location(const std::string &name) {
|
||||||
return glGetUniformLocation(m_program, name.c_str());
|
return glGetUniformLocation(m_program, name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture::Texture() { glGenTextures(1, &m_name); }
|
Texture::Texture() {}
|
||||||
|
|
||||||
Texture::~Texture() { glDeleteTextures(1, &m_name); }
|
Texture::~Texture() { glDeleteTextures(1, &m_name); }
|
||||||
|
|
||||||
|
void Texture::init() { glGenTextures(1, &m_name); }
|
||||||
|
|
||||||
void Texture::bind() { glBindTexture(GL_TEXTURE_2D, m_name); }
|
void Texture::bind() { glBindTexture(GL_TEXTURE_2D, m_name); }
|
||||||
|
|
||||||
void Texture::unbind() { glBindTexture(GL_TEXTURE_2D, 0); }
|
void Texture::unbind() { glBindTexture(GL_TEXTURE_2D, 0); }
|
||||||
|
|
||||||
void Texture::fill(GLenum target, GLint level, GLint internalFormat,
|
void Texture::fill(GLint level, GLint internalFormat, GLsizei width,
|
||||||
GLsizei width, GLsizei height, GLint border, GLenum format,
|
GLsizei height, GLint border, GLenum format, GLenum type,
|
||||||
GLenum type, const GLvoid *data) {
|
const GLvoid *data) {
|
||||||
bind();
|
bind();
|
||||||
glTexImage2D(target, level, internalFormat, width, height, border, format,
|
glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border,
|
||||||
type, data);
|
format, type, data);
|
||||||
}
|
}
|
||||||
GLuint Texture::getName() { return m_name; }
|
GLuint Texture::getName() { return m_name; }
|
||||||
|
|
||||||
Framebuffer::Framebuffer() { glGenFramebuffers(1, &m_name); }
|
Framebuffer::Framebuffer() {}
|
||||||
|
|
||||||
Framebuffer::~Framebuffer() { glDeleteFramebuffers(1, &m_name); }
|
Framebuffer::~Framebuffer() { glDeleteFramebuffers(1, &m_name); }
|
||||||
|
|
||||||
|
void Framebuffer::init() { glGenFramebuffers(1, &m_name); }
|
||||||
void Framebuffer::bind() { glBindFramebuffer(GL_FRAMEBUFFER, m_name); }
|
void Framebuffer::bind() { glBindFramebuffer(GL_FRAMEBUFFER, m_name); }
|
||||||
|
|
||||||
void Framebuffer::unbind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }
|
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);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, tex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderbuffer::Renderbuffer() { glGenRenderbuffers(1, &m_name); }
|
Renderbuffer::Renderbuffer() {}
|
||||||
|
|
||||||
Renderbuffer::~Renderbuffer() { glDeleteRenderbuffers(1, &m_name); }
|
Renderbuffer::~Renderbuffer() { glDeleteRenderbuffers(1, &m_name); }
|
||||||
|
|
||||||
|
void Renderbuffer::init() { glGenRenderbuffers(1, &m_name); }
|
||||||
void Renderbuffer::bind() { glBindRenderbuffer(GL_RENDERBUFFER, m_name); }
|
void Renderbuffer::bind() { glBindRenderbuffer(GL_RENDERBUFFER, m_name); }
|
||||||
|
|
||||||
void Renderbuffer::unbind() { glBindRenderbuffer(GL_RENDERBUFFER, 0); }
|
void Renderbuffer::unbind() { glBindRenderbuffer(GL_RENDERBUFFER, 0); }
|
||||||
|
|
|
@ -16,6 +16,7 @@ template <GLenum T> class BufferObject {
|
||||||
public:
|
public:
|
||||||
BufferObject();
|
BufferObject();
|
||||||
~BufferObject();
|
~BufferObject();
|
||||||
|
void init();
|
||||||
void bind();
|
void bind();
|
||||||
void bind(GLuint index, GLintptr offset = 0, GLsizeiptr size = 0);
|
void bind(GLuint index, GLintptr offset = 0, GLsizeiptr size = 0);
|
||||||
void fill(GLenum usage, GLsizei size = 0, GLvoid *data = NULL);
|
void fill(GLenum usage, GLsizei size = 0, GLvoid *data = NULL);
|
||||||
|
@ -35,6 +36,7 @@ class VAO {
|
||||||
public:
|
public:
|
||||||
VAO();
|
VAO();
|
||||||
~VAO();
|
~VAO();
|
||||||
|
void init();
|
||||||
void bind();
|
void bind();
|
||||||
void unbind();
|
void unbind();
|
||||||
void fill(GLuint index, GLint size, GLenum type, GLboolean normalized,
|
void fill(GLuint index, GLint size, GLenum type, GLboolean normalized,
|
||||||
|
@ -70,11 +72,11 @@ class Texture {
|
||||||
public:
|
public:
|
||||||
Texture();
|
Texture();
|
||||||
~Texture();
|
~Texture();
|
||||||
|
void init();
|
||||||
void bind();
|
void bind();
|
||||||
void unbind();
|
void unbind();
|
||||||
void fill(GLenum target, GLint level, GLint internalFormat, GLsizei width,
|
void fill(GLint level, GLint internalFormat, GLsizei width, GLsizei height,
|
||||||
GLsizei height, GLint border, GLenum format, GLenum type,
|
GLint border, GLenum format, GLenum type, const GLvoid *data);
|
||||||
const GLvoid *data);
|
|
||||||
GLuint getName();
|
GLuint getName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,6 +88,7 @@ class Framebuffer {
|
||||||
public:
|
public:
|
||||||
Framebuffer();
|
Framebuffer();
|
||||||
~Framebuffer();
|
~Framebuffer();
|
||||||
|
void init();
|
||||||
void bind();
|
void bind();
|
||||||
void unbind();
|
void unbind();
|
||||||
void attachRenderbuffer(GLenum attachment, GLuint rbo);
|
void attachRenderbuffer(GLenum attachment, GLuint rbo);
|
||||||
|
@ -100,6 +103,7 @@ class Renderbuffer {
|
||||||
public:
|
public:
|
||||||
Renderbuffer();
|
Renderbuffer();
|
||||||
~Renderbuffer();
|
~Renderbuffer();
|
||||||
|
void init();
|
||||||
void bind();
|
void bind();
|
||||||
void unbind();
|
void unbind();
|
||||||
void create(GLenum internalformat, GLsizei width, GLsizei height);
|
void create(GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
|
@ -110,10 +114,12 @@ class Renderbuffer {
|
||||||
template <GLenum T> pre endofthejedi::BufferObject<T>::post
|
template <GLenum T> pre endofthejedi::BufferObject<T>::post
|
||||||
#define TBufferObject(...) TBufferObject_(__VA_ARGS__)
|
#define TBufferObject(...) TBufferObject_(__VA_ARGS__)
|
||||||
|
|
||||||
TBufferObject(, BufferObject)() { glGenBuffers(1, &m_name); }
|
TBufferObject(, BufferObject)() {}
|
||||||
|
|
||||||
TBufferObject(, ~BufferObject)() { glDeleteBuffers(1, &m_name); }
|
TBufferObject(, ~BufferObject)() { glDeleteBuffers(1, &m_name); }
|
||||||
|
|
||||||
|
TBufferObject(void, init)() { glGenBuffers(1, &m_name); }
|
||||||
|
|
||||||
TBufferObject(void, bind)() { glBindBuffer(T, m_name); }
|
TBufferObject(void, bind)() { glBindBuffer(T, m_name); }
|
||||||
|
|
||||||
TBufferObject(void, bind)(GLuint index, GLintptr offset, GLsizeiptr size) {
|
TBufferObject(void, bind)(GLuint index, GLintptr offset, GLsizeiptr size) {
|
||||||
|
|
Loading…
Reference in a new issue