Fix: ensure to preserve gl state of calling application#981
Fix: ensure to preserve gl state of calling application#981mbaetgen-wup wants to merge 1 commit intoprojectM-visualizer:masterfrom
Conversation
cec2b7a to
171d522
Compare
kblaschke
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Same here, bind read and draw buffers separately.
| } | ||
|
|
||
| Framebuffer::Unbind(); | ||
| glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); |
There was a problem hiding this comment.
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.
No description provided.