diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index 32d2361b..b8c3f4c2 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -47,6 +47,7 @@ bool CFramebuffer::alloc(int w, int h) { glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_FRAMEBUFFER, g_pHyprOpenGL->m_iCurrentOutputFb); + m_bFramebufferCreated = true; m_Size = Vector2D(w, h); @@ -63,17 +64,18 @@ void CFramebuffer::bind() { } void CFramebuffer::release() { - if (m_iFb != (uint32_t)-1 && m_iFb) { + Debug::log(LOG, "Releasing FB %u tex %u", m_iFb, m_cTex.m_iTexID); + + if (m_bFramebufferCreated) glDeleteFramebuffers(1, &m_iFb); - } - if (m_cTex.m_iTexID) { + if (m_cTex.m_iTexID) glDeleteTextures(1, &m_cTex.m_iTexID); - } - m_cTex.m_iTexID = 0; - m_iFb = -1; - m_Size = Vector2D(); + m_cTex.m_iTexID = 0; + m_iFb = 0; + m_bFramebufferCreated = false; + m_Size = Vector2D(); } CFramebuffer::~CFramebuffer() { diff --git a/src/render/Framebuffer.hpp b/src/render/Framebuffer.hpp index 9dacbce3..5a412e51 100644 --- a/src/render/Framebuffer.hpp +++ b/src/render/Framebuffer.hpp @@ -18,7 +18,8 @@ class CFramebuffer { float m_fScale = 1; CTexture m_cTex; - GLuint m_iFb = -1; + GLuint m_iFb = 0; + bool m_bFramebufferCreated = false; CTexture* m_pStencilTex = nullptr;