From 58a604d363cac4cabf9148d402e3a17c44e28008 Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 05:49:05 +0100 Subject: [PATCH 1/6] Update gfxGLCircularVolatileBuffer.h --- Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h b/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h index c291cb229..6d7d0e4b1 100644 --- a/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h +++ b/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h @@ -143,6 +143,11 @@ public: init(); } + ~GLCircularVolatileBuffer() + { + glDeleteBuffers(1, &mBufferName); + } + void init() { glGenBuffers(1, &mBufferName); @@ -290,4 +295,4 @@ protected: }; -#endif \ No newline at end of file +#endif From 07282822870c6a86de7da7f42a1de4e85c15c402 Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 05:55:36 +0100 Subject: [PATCH 2/6] Update gfxGLTextureTarget.cpp --- Engine/source/gfx/gl/gfxGLTextureTarget.cpp | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Engine/source/gfx/gl/gfxGLTextureTarget.cpp b/Engine/source/gfx/gl/gfxGLTextureTarget.cpp index 1569b9a85..202265107 100644 --- a/Engine/source/gfx/gl/gfxGLTextureTarget.cpp +++ b/Engine/source/gfx/gl/gfxGLTextureTarget.cpp @@ -163,6 +163,10 @@ void _GFXGLTextureTargetFBOImpl::applyState() PRESERVE_FRAMEBUFFER(); glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); + bool drawbufs[16]; + int bufsize = 0; + for (int i = 0; i < 16; i++) + drawbufs[i] = false; bool hasColor = false; for(int i = 0; i < GFXGL->getNumRenderTargets(); ++i) { @@ -200,6 +204,20 @@ void _GFXGLTextureTargetFBOImpl::applyState() glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); } + GLenum *buf = new GLenum[bufsize]; + int count = 0; + for (int i = 0; i < bufsize; i++) + { + if (drawbufs[i]) + { + buf[count] = GL_COLOR_ATTACHMENT0 + i; + count++; + } + } + + glDrawBuffers(bufsize, buf); + + delete[] buf; CHECK_FRAMEBUFFER_STATUS(); } @@ -260,7 +278,10 @@ GFXGLTextureTarget::GFXGLTextureTarget() : mCopyFboSrc(0), mCopyFboDst(0) GFXGLTextureTarget::~GFXGLTextureTarget() { - GFXTextureManager::removeEventDelegate( this, &GFXGLTextureTarget::_onTextureEvent ); + GFXTextureManager::removeEventDelegate(this, &GFXGLTextureTarget::_onTextureEvent); + + glDeleteFramebuffers(1, &mCopyFboSrc); + glDeleteFramebuffers(1, &mCopyFboDst); } const Point2I GFXGLTextureTarget::getSize() From c3ef59e39c9784812810d7c24c17b775a91f0e48 Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 05:55:48 +0100 Subject: [PATCH 3/6] Update gfxGLWindowTarget.cpp --- Engine/source/gfx/gl/gfxGLWindowTarget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Engine/source/gfx/gl/gfxGLWindowTarget.cpp b/Engine/source/gfx/gl/gfxGLWindowTarget.cpp index c02ff1bc3..5f8808cae 100644 --- a/Engine/source/gfx/gl/gfxGLWindowTarget.cpp +++ b/Engine/source/gfx/gl/gfxGLWindowTarget.cpp @@ -42,6 +42,14 @@ GFXGLWindowTarget::GFXGLWindowTarget(PlatformWindow *win, GFXDevice *d) win->appEvent.notify(this, &GFXGLWindowTarget::_onAppSignal); } +GFXGLWindowTarget::~GFXGLWindowTarget() +{ + if(glIsFramebuffer(mCopyFBO)) + { + glDeleteFramebuffers(1, &mCopyFBO); + } +} + void GFXGLWindowTarget::resetMode() { if(mWindow->getVideoMode().fullScreen != mWindow->isFullscreen()) @@ -49,6 +57,7 @@ void GFXGLWindowTarget::resetMode() _teardownCurrentMode(); _setupNewMode(); } + GFX->beginReset(); } void GFXGLWindowTarget::_onAppSignal(WindowId wnd, S32 event) From 500a237892db6fa6a445aa646815f20cec7ccbfa Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 05:56:00 +0100 Subject: [PATCH 4/6] Update gfxGLWindowTarget.h --- Engine/source/gfx/gl/gfxGLWindowTarget.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Engine/source/gfx/gl/gfxGLWindowTarget.h b/Engine/source/gfx/gl/gfxGLWindowTarget.h index 4baa6a53f..af368e192 100644 --- a/Engine/source/gfx/gl/gfxGLWindowTarget.h +++ b/Engine/source/gfx/gl/gfxGLWindowTarget.h @@ -30,6 +30,8 @@ class GFXGLWindowTarget : public GFXWindowTarget public: GFXGLWindowTarget(PlatformWindow *win, GFXDevice *d); + ~GFXGLWindowTarget(); + const Point2I getSize() { return mWindow->getClientExtent(); @@ -64,4 +66,4 @@ private: void _WindowPresent(); }; -#endif \ No newline at end of file +#endif From ca31ef3f1aef7c3f0643246c788beeb980474b43 Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 06:15:07 +0100 Subject: [PATCH 5/6] Update gfxGLWindowTarget.cpp --- Engine/source/gfx/gl/gfxGLWindowTarget.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Engine/source/gfx/gl/gfxGLWindowTarget.cpp b/Engine/source/gfx/gl/gfxGLWindowTarget.cpp index 5f8808cae..c00506835 100644 --- a/Engine/source/gfx/gl/gfxGLWindowTarget.cpp +++ b/Engine/source/gfx/gl/gfxGLWindowTarget.cpp @@ -57,7 +57,6 @@ void GFXGLWindowTarget::resetMode() _teardownCurrentMode(); _setupNewMode(); } - GFX->beginReset(); } void GFXGLWindowTarget::_onAppSignal(WindowId wnd, S32 event) From e2d789e87de69d1b525763ca99aa5daef15b8e74 Mon Sep 17 00:00:00 2001 From: Anis Date: Mon, 18 Jan 2016 06:17:20 +0100 Subject: [PATCH 6/6] Update gfxGLTextureTarget.cpp --- Engine/source/gfx/gl/gfxGLTextureTarget.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Engine/source/gfx/gl/gfxGLTextureTarget.cpp b/Engine/source/gfx/gl/gfxGLTextureTarget.cpp index 202265107..ddb308adc 100644 --- a/Engine/source/gfx/gl/gfxGLTextureTarget.cpp +++ b/Engine/source/gfx/gl/gfxGLTextureTarget.cpp @@ -163,10 +163,6 @@ void _GFXGLTextureTargetFBOImpl::applyState() PRESERVE_FRAMEBUFFER(); glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); - bool drawbufs[16]; - int bufsize = 0; - for (int i = 0; i < 16; i++) - drawbufs[i] = false; bool hasColor = false; for(int i = 0; i < GFXGL->getNumRenderTargets(); ++i) { @@ -204,20 +200,6 @@ void _GFXGLTextureTargetFBOImpl::applyState() glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); } - GLenum *buf = new GLenum[bufsize]; - int count = 0; - for (int i = 0; i < bufsize; i++) - { - if (drawbufs[i]) - { - buf[count] = GL_COLOR_ATTACHMENT0 + i; - count++; - } - } - - glDrawBuffers(bufsize, buf); - - delete[] buf; CHECK_FRAMEBUFFER_STATUS(); }