summaryrefslogtreecommitdiffstats
path: root/src/Framebuffer.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 10:54:29 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 10:58:17 +0100
commitf8af4c44d17b94ab814f1784060388afd7a24e03 (patch)
treee0c8e06c209fe964b03caae362169facecd3c949 /src/Framebuffer.cpp
parentImplemented new Shader class (diff)
downloadAltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.gz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.bz2
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.lz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.xz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.zst
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.zip
Diffstat (limited to '')
-rw-r--r--src/Framebuffer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Framebuffer.cpp b/src/Framebuffer.cpp
index 7127a57..fb7ebc7 100644
--- a/src/Framebuffer.cpp
+++ b/src/Framebuffer.cpp
@@ -2,12 +2,13 @@
#include "Shader.hpp"
#include <string>
#include "Utility.hpp"
+#include "AssetManager.hpp"
-GLuint quadVao, quadVbo;
-Shader *quadShader = nullptr;
+const GLuint magic = 316784;
+GLuint quadVao = magic, quadVbo = magic;
Framebuffer::Framebuffer(unsigned int width, unsigned int height, bool createDepthStencilBuffer) : width(width), height(height) {
- if (quadShader == nullptr) {
+ if (quadVao == magic) {
float quadVertices[] = {
// positions // texCoords
-1.0f, 1.0f, 0.0f, 1.0f,
@@ -28,9 +29,8 @@ Framebuffer::Framebuffer(unsigned int width, unsigned int height, bool createDep
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
- quadShader = new Shader("./shaders/fbo.vs", "./shaders/fbo.fs");
- quadShader->Use();
- glUniform1i(glGetUniformLocation(quadShader->Program, "inputTexture"), 1);
+ AssetManager::GetAsset<AssetShader>("/altcraft/shaders/fbo")->shader->Activate();
+ AssetManager::GetAsset<AssetShader>("/altcraft/shaders/fbo")->shader->SetUniform("inputTexture", 1);
glActiveTexture(GL_TEXTURE1);
glCheckError();
}
@@ -76,9 +76,9 @@ void Framebuffer::Activate() {
void Framebuffer::RenderTo(Framebuffer &target) {
glBindFramebuffer(GL_FRAMEBUFFER, target.fbo);
- glViewport(0, 0, target.width, target.height);
+ glViewport(0, 0, target.width, target.height);
+ AssetManager::GetAsset<AssetShader>("/altcraft/shaders/fbo")->shader->Activate();
glBindVertexArray(quadVao);
- glUseProgram(quadShader->Program);
glBindTexture(GL_TEXTURE_2D, texColor);
glDrawArrays(GL_TRIANGLES, 0, 6);
}