post-processing test

This commit is contained in:
MihailRis
2024-03-08 21:49:38 +03:00
parent e7af5830cf
commit 8ed65ca51e
13 changed files with 268 additions and 113 deletions
+11 -1
View File
@@ -23,7 +23,7 @@ Framebuffer::Framebuffer(uint width, uint height, bool alpha)
// Setup color attachment (texture)
GLuint tex;
GLuint format = alpha ? GL_RGBA : GL_RGB;
format = alpha ? GL_RGBA : GL_RGB;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
@@ -55,6 +55,16 @@ void Framebuffer::unbind() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void Framebuffer::resize(uint width, uint height) {
if (this->width == width && this->height == height) {
return;
}
GLuint texid = texture->getId();
texture->bind();
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
texture->unbind();
}
Texture* Framebuffer::getTexture() const {
return texture.get();
}