|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
#include "client/rendering/wrapper/Framebuffer.h"
|
|
|
|
|
|
-Framebuffer::Framebuffer(const Size& size, uint mode, bool texCompare) : size(size), mode(mode), textures(0),
|
|
|
+Framebuffer::Framebuffer(const Size& size, int mode, bool texCompare) : size(size), mode(mode), textures(0),
|
|
|
buffer(0), error(false) {
|
|
|
glGenFramebuffers(1, &buffer);
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
|
|
@@ -14,8 +14,8 @@ buffer(0), error(false) {
|
|
|
data[4] = {DEPTH, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_FLOAT};
|
|
|
|
|
|
GLuint attachments[4];
|
|
|
- uint counter = 0;
|
|
|
- for(uint i = 0; i < 4; i++) {
|
|
|
+ int counter = 0;
|
|
|
+ for(int i = 0; i < 4; i++) {
|
|
|
if(mode & data[i].mask) {
|
|
|
setupTexture(i, size.width, size.height, attachments, counter);
|
|
|
}
|
|
@@ -54,8 +54,8 @@ void Framebuffer::bind() const {
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::resize(uint width, uint height) const {
|
|
|
- for(uint i = 0; i < 5; i++) {
|
|
|
+void Framebuffer::resize(int width, int height) const {
|
|
|
+ for(int i = 0; i < 5; i++) {
|
|
|
if(mode & data[i].mask) {
|
|
|
glBindTexture(GL_TEXTURE_2D, textures[i]);
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, data[i].internalFormat, width, height, 0, data[i].format, data[i].type, nullptr);
|
|
@@ -63,33 +63,33 @@ void Framebuffer::resize(uint width, uint height) const {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindTexture(uint textureUnit, GLuint texture) const {
|
|
|
+void Framebuffer::bindTexture(int textureUnit, GLuint texture) const {
|
|
|
glActiveTexture(GL_TEXTURE0 + textureUnit);
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindPositionTexture(uint textureUnit) const {
|
|
|
+void Framebuffer::bindPositionTexture(int textureUnit) const {
|
|
|
bindTexture(textureUnit, textures[0]);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindNormalTexture(uint textureUnit) const {
|
|
|
+void Framebuffer::bindNormalTexture(int textureUnit) const {
|
|
|
bindTexture(textureUnit, textures[1]);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindColorTexture(uint textureUnit) const {
|
|
|
+void Framebuffer::bindColorTexture(int textureUnit) const {
|
|
|
bindTexture(textureUnit, textures[2]);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindRedTexture(uint textureUnit) const {
|
|
|
+void Framebuffer::bindRedTexture(int textureUnit) const {
|
|
|
bindTexture(textureUnit, textures[3]);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::bindDepthTexture(uint textureUnit) const {
|
|
|
+void Framebuffer::bindDepthTexture(int textureUnit) const {
|
|
|
bindTexture(textureUnit, textures[4]);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::genTexture(uint index, uint width, uint height) {
|
|
|
- glGenTextures(1, textures + index);
|
|
|
+void Framebuffer::genTexture(int index, int width, int height) {
|
|
|
+ glGenTextures(1, &(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);
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
@@ -98,7 +98,7 @@ void Framebuffer::genTexture(uint index, uint width, uint height) {
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
}
|
|
|
|
|
|
-void Framebuffer::setupTexture(uint index, uint width, uint height, GLuint* attachments, uint& counter) {
|
|
|
+void Framebuffer::setupTexture(int index, int width, int height, GLuint* attachments, int& counter) {
|
|
|
genTexture(index, width, height);
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + counter, GL_TEXTURE_2D, textures[index], 0);
|
|
|
attachments[counter] = GL_COLOR_ATTACHMENT0 + counter;
|