diff --git a/BaseGLProject/BaseGLProject.vcxproj b/BaseGLProject/BaseGLProject.vcxproj
index 0b45579..e4f9ed4 100644
--- a/BaseGLProject/BaseGLProject.vcxproj
+++ b/BaseGLProject/BaseGLProject.vcxproj
@@ -95,7 +95,7 @@
true
Console
C:\Graphics\Tools\SOIL\lib;C:\Graphics\Tools\Assimp\lib\x86;C:\Graphics\Tools\glfw\lib\x86;C:\Graphics\Tools\glew\lib;%(AdditionalLibraryDirectories)
- assimp.lib;SOIL.lib;glfw3.lib;glew32.lib;opengl32.lib;%(AdditionalDependencies)
+ assimp.lib;SOIL.lib;glfw3.lib;glew32.lib;opengl32.lib;FreeImage.lib;%(AdditionalDependencies)
@@ -147,6 +147,7 @@
+
@@ -155,15 +156,19 @@
+
+
+
+
@@ -177,11 +182,14 @@
+
+
+
@@ -195,6 +203,8 @@
+
+
Geometry
diff --git a/BaseGLProject/BaseGLProject.vcxproj.filters b/BaseGLProject/BaseGLProject.vcxproj.filters
index a3dfe79..e3cd1e0 100644
--- a/BaseGLProject/BaseGLProject.vcxproj.filters
+++ b/BaseGLProject/BaseGLProject.vcxproj.filters
@@ -22,6 +22,9 @@
{af32f844-b061-4424-a685-e3f537232cf8}
+
+ {b0c228ca-8e29-48df-a9f6-59fb58accad5}
+
@@ -69,6 +72,18 @@
Source Files
+
+ MankyuCode
+
+
+ MankyuCode
+
+
+ MankyuCode
+
+
+ Source Files
+
@@ -131,6 +146,18 @@
Header Files
+
+ MankyuCode
+
+
+ MankyuCode
+
+
+ MankyuCode
+
+
+ Header Files
+
@@ -190,6 +217,12 @@
Shaders
+
+ MankyuCode
+
+
+ MankyuCode
+
diff --git a/BaseGLProject/Multipass.cpp b/BaseGLProject/Multipass.cpp
new file mode 100644
index 0000000..efd2f76
--- /dev/null
+++ b/BaseGLProject/Multipass.cpp
@@ -0,0 +1,118 @@
+#include "Multipass.h"
+
+Multipass::Multipass() : _quad_shader("textureViewer.vert", "textureViewer.frag")
+{
+ _draw_buffers_size = 0;
+ glGenFramebuffers(1, &_fboId);
+ glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
+ _createQuad();
+}
+
+void Multipass::setDrawBuffers()
+{
+ glDrawBuffers(_draw_buffers_size, _draw_buffers);
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ throw std::runtime_error("Error during framebuffer initialisation");
+}
+
+void Multipass::bindToFrameBuffer(GLenum type, GLenum texture, std::string texName)
+{
+ glFramebufferTexture2D(GL_FRAMEBUFFER, type, texture, _pass_textures[texName], 0);
+ if (type != GL_DEPTH_ATTACHMENT) {
+ _draw_buffers[_draw_buffers_size] = type;
+ _draw_buffers_size++;
+ }
+}
+
+Multipass::~Multipass()
+{
+ glDeleteFramebuffers(1, &_fboId);
+}
+
+void Multipass::addTexture(const std::string & tex_name, GLuint filter, GLuint type, GLuint type_2,
+ bool depth, SceneContext &scnctx)
+{
+ glGenTextures(1, &_pass_textures[tex_name]);;
+ glBindTexture(GL_TEXTURE_2D, _pass_textures[tex_name]);
+ glTexImage2D(GL_TEXTURE_2D, 0, type, scnctx.width, scnctx.height, 0, type_2, GL_FLOAT, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ if (depth)
+ {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+}
+
+void Multipass::enableFrameBufferTexture(const std::string tex_name)
+{
+ _current_tex = tex_name;
+ glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
+}
+
+void Multipass::drawResultToScreen(SceneContext & scnctx)
+{
+ //EXAMPLE CODE
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glViewport(0, 0, scnctx.width, scnctx.height);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ _quad_shader.enable();
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, _pass_textures[_current_tex]);
+ _quad_shader.addUniform("tex", (int)_pass_textures[_current_tex]);
+ glBindVertexArray(_quad_vao);
+ glBindBuffer(GL_ARRAY_BUFFER, _quad_vbo);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+ _quad_shader.disable();
+}
+
+void Multipass::_createQuad()
+{
+ float pos[] = {
+ -1.0, 1.0,
+ 1.0, 1.0,
+ -1.0, -1.0,
+ 1.0, -1.0
+ };
+
+ float uv[] = {
+ 0.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 0.0,
+ 1.0, 0.0
+ };
+
+ //Generate VAO
+ glGenVertexArrays(1, &_quad_vao);
+ //Bind VAO
+ glBindVertexArray(_quad_vao);
+
+ //Generate VBO
+ glGenBuffers(1, &_quad_vbo);
+ //Bind VBO
+ glBindBuffer(GL_ARRAY_BUFFER, _quad_vbo);
+ //Alocate buffer
+ glBufferData(GL_ARRAY_BUFFER, sizeof(pos) + sizeof(uv), NULL, GL_STATIC_DRAW);
+ //Fill VBO
+ glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(pos), pos);
+ glBufferSubData(GL_ARRAY_BUFFER, 8 * sizeof(float), sizeof(uv), uv);
+
+ //Fill attributes and uniforms
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, (sizeof(float) * 2), (void*)0);
+
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, (sizeof(float) * 2), (GLvoid*)(sizeof(float) * 8));
+
+ //unbind buffer
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ glBindVertexArray(0);
+}
diff --git a/BaseGLProject/Multipass.h b/BaseGLProject/Multipass.h
new file mode 100644
index 0000000..e94cfda
--- /dev/null
+++ b/BaseGLProject/Multipass.h
@@ -0,0 +1,37 @@
+#pragma once
+#include
+#include