Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/libprojectM/Renderer/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ Framebuffer::~Framebuffer()
{
if (!m_framebufferIds.empty())
{
// Delete attached textures first
m_attachments.clear();

// Delete FBOs first — this also releases driver references to attached textures.
glDeleteFramebuffers(static_cast<int>(m_framebufferIds.size()), m_framebufferIds.data());
m_framebufferIds.clear();

m_attachments.clear();
}
}

Expand Down Expand Up @@ -94,6 +94,8 @@ bool Framebuffer::SetSize(int width, int height)
Bind(attachments.first);
for (auto& texture : attachments.second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any real technical reason to add two new loops here? Each attachment is independently managed in an FBO, so the detach->reallocate->attach code can be placed in the very same loop without bloating the code.

{
// Detach old texture, resize (destroys old and creates new), reattach new.
glFramebufferTexture2D(GL_FRAMEBUFFER, texture.first, GL_TEXTURE_2D, 0, 0);
texture.second->SetSize(width, height);
glFramebufferTexture2D(GL_FRAMEBUFFER, texture.first, GL_TEXTURE_2D, texture.second->Texture()->TextureID(), 0);
}
Expand Down
Loading