Skip to content

Fix: ensure to preserve gl state of calling application#981

Open
mbaetgen-wup wants to merge 1 commit intoprojectM-visualizer:masterfrom
mbaetgen-wup:fix-preserve-gl-state
Open

Fix: ensure to preserve gl state of calling application#981
mbaetgen-wup wants to merge 1 commit intoprojectM-visualizer:masterfrom
mbaetgen-wup:fix-preserve-gl-state

Conversation

@mbaetgen-wup
Copy link
Collaborator

No description provided.

Copy link
Member

@kblaschke kblaschke left a comment

Choose a reason for hiding this comment

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

Guess this might improve things a bit, especially with Qt. Just a few GLES fixes and more wrapping of the GL calls as suggested, then it should be fine. Can't test it currently so someone else would have to do it.

// Save the currently bound framebuffer so we can restore it after creating attachments.
// This is important when the host application uses a non-default framebuffer.
GLint previousFramebuffer{};
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFramebuffer);
Copy link
Member

Choose a reason for hiding this comment

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

AFAIR GLES doesn't support this constant, it only knows GL_DRAW_FRAMEBUFFER_BINDING and GL_READ_FRAMEBUFFER_BINDING, so I'd suggest storing them separately for both ES and Core profiles.

m_framebuffer.CreateColorAttachment(1, 0); // Main image 2

Renderer::Framebuffer::Unbind();
glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer);
Copy link
Member

Choose a reason for hiding this comment

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

Same here, bind read and draw buffers separately.

}

Framebuffer::Unbind();
glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer);
Copy link
Member

Choose a reason for hiding this comment

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

Please use the Framebuffer class to store the original framebuffer and rebind it. The class might need some tweaking (e.g. ignoring attachments), but this would keep the GL calls wrapped, whucbwas the idea behind the class. Will later make adding other rendering backends easier. Could also wrap it into the GLStateGuard class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants