|
@@ -17,11 +17,11 @@ buffer(0), error(false) {
|
|
int counter = 0;
|
|
int counter = 0;
|
|
for(int i = 0; i < 4; i++) {
|
|
for(int i = 0; i < 4; i++) {
|
|
if(mode & data[i].mask) {
|
|
if(mode & data[i].mask) {
|
|
- setupTexture(i, size.width, size.height, attachments, counter);
|
|
+ setupTexture(i, size, attachments, counter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(mode & DEPTH) {
|
|
if(mode & DEPTH) {
|
|
- genTexture(4, size.width, size.height);
|
|
+ genTexture(4, size);
|
|
if(texCompare) {
|
|
if(texCompare) {
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
|
@@ -54,11 +54,12 @@ void Framebuffer::bind() const {
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
}
|
|
}
|
|
|
|
|
|
-void Framebuffer::resize(int width, int height) const {
|
|
+void Framebuffer::resize(const Size& size) const {
|
|
for(int i = 0; i < 5; i++) {
|
|
for(int i = 0; i < 5; i++) {
|
|
if(mode & data[i].mask) {
|
|
if(mode & data[i].mask) {
|
|
glBindTexture(GL_TEXTURE_2D, textures[i]);
|
|
glBindTexture(GL_TEXTURE_2D, textures[i]);
|
|
- glTexImage2D(GL_TEXTURE_2D, 0, data[i].internalFormat, width, height, 0, data[i].format, data[i].type, nullptr);
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, data[i].internalFormat,
|
|
|
|
+ size.width, size.height, 0, data[i].format, data[i].type, nullptr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -88,18 +89,19 @@ void Framebuffer::bindDepthTexture(int textureUnit) const {
|
|
bindTexture(textureUnit, textures[4]);
|
|
bindTexture(textureUnit, textures[4]);
|
|
}
|
|
}
|
|
|
|
|
|
-void Framebuffer::genTexture(int index, int width, int height) {
|
|
+void Framebuffer::genTexture(int index, const Size& size) {
|
|
glGenTextures(1, &(textures[index]));
|
|
glGenTextures(1, &(textures[index]));
|
|
glBindTexture(GL_TEXTURE_2D, textures[index]);
|
|
glBindTexture(GL_TEXTURE_2D, textures[index]);
|
|
- glTexImage2D(GL_TEXTURE_2D, 0, data[index].internalFormat, width, height, 0, data[index].format, data[index].type, nullptr);
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, data[index].internalFormat,
|
|
|
|
+ size.width, size.height, 0, data[index].format, data[index].type, nullptr);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
}
|
|
}
|
|
|
|
|
|
-void Framebuffer::setupTexture(int index, int width, int height, GLuint* attachments, int& counter) {
|
|
+void Framebuffer::setupTexture(int index, const Size& size, GLuint* attachments, int& counter) {
|
|
- genTexture(index, width, height);
|
|
+ genTexture(index, size);
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + counter, GL_TEXTURE_2D, textures[index], 0);
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + counter, GL_TEXTURE_2D, textures[index], 0);
|
|
attachments[counter] = GL_COLOR_ATTACHMENT0 + counter;
|
|
attachments[counter] = GL_COLOR_ATTACHMENT0 + counter;
|
|
counter++;
|
|
counter++;
|