diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 73642fe5b..92b583508 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -31,7 +31,6 @@ #include "graphics/post_processing.hpp" #include "graphics/referee.hpp" #include "graphics/shaders.hpp" -#include "graphics/shadow_importance.hpp" #include "graphics/stkanimatedmesh.hpp" #include "graphics/stkbillboard.hpp" #include "graphics/stkmeshscenenode.hpp" diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index d0aca483f..9b1a95716 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -33,7 +33,6 @@ #include "graphics/rtts.hpp" #include "graphics/screenquad.hpp" #include "graphics/shaders.hpp" -#include "graphics/shadow_importance.hpp" #include "graphics/stkmeshscenenode.hpp" #include "graphics/stkinstancedscenenode.hpp" #include "graphics/wind.hpp" @@ -713,8 +712,7 @@ void IrrDriver::renderShadows() glDisable(GL_BLEND); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.5, 0.); - glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getShadowFBO()); - glViewport(0, 0, 1024, 1024); + m_rtts->getShadowFBO().Bind(); glClear(GL_DEPTH_BUFFER_BIT); glDrawBuffer(GL_NONE); diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp index cfb737372..955a9d8bb 100644 --- a/src/graphics/rtts.cpp +++ b/src/graphics/rtts.cpp @@ -139,18 +139,14 @@ RTT::RTT(size_t width, size_t height) if (irr_driver->getGLSLVersion() >= 150) { - glGenFramebuffers(1, &shadowFBO); - glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO); glGenTextures(1, &shadowColorTex); glBindTexture(GL_TEXTURE_2D_ARRAY, shadowColorTex); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_R8, 1024, 1024, 4, 0, GL_RED, GL_UNSIGNED_BYTE, 0); glGenTextures(1, &shadowDepthTex); glBindTexture(GL_TEXTURE_2D_ARRAY, shadowDepthTex); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 4, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, shadowColorTex, 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowDepthTex, 0); - GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER); - assert(result == GL_FRAMEBUFFER_COMPLETE_EXT); + + shadowFBO = FrameBuffer(std::vector {shadowColorTex}, shadowDepthTex, 1024, 1024); } glBindFramebuffer(GL_FRAMEBUFFER, 0); } @@ -161,7 +157,6 @@ RTT::~RTT() glDeleteTextures(1, &DepthStencilTexture); if (irr_driver->getGLSLVersion() >= 150) { - glDeleteFramebuffers(1, &shadowFBO); glDeleteTextures(1, &shadowColorTex); glDeleteTextures(1, &shadowDepthTex); } diff --git a/src/graphics/rtts.hpp b/src/graphics/rtts.hpp index 699246d11..6307235b8 100644 --- a/src/graphics/rtts.hpp +++ b/src/graphics/rtts.hpp @@ -37,7 +37,7 @@ public: RTT(size_t width, size_t height); ~RTT(); - unsigned getShadowFBO() const { return shadowFBO; } + FrameBuffer &getShadowFBO() { return shadowFBO; } unsigned getShadowDepthTex() const { return shadowDepthTex; } unsigned getDepthStencilTexture() const { return DepthStencilTexture; } @@ -48,7 +48,8 @@ private: PtrVector FrameBuffers; unsigned DepthStencilTexture; - unsigned shadowFBO, shadowColorTex, shadowDepthTex; + unsigned shadowColorTex, shadowDepthTex; + FrameBuffer shadowFBO; LEAK_CHECK(); };