Repository navigation
Take screenshots from an off-screen framebuffer - #379
Closed
HennesHajduk wants to merge 1 commit into
Closed
HennesHajduk wants to merge 1 commit into
HennesHajduk wants to merge 1 commit into
Conversation
Contributor
|
Hi @HennesHajduk , have you tried the headless rendering feature of GLVis? It is intended exactly for such situations when you do not want to pull up the window and only render a picture from a script. There is a command for it: |
Author
I wasn't aware of that. Thanks @najlkin! Yes, if I compile GLVis with GLVIS_USE_EGL=YES, then it does the trick. Closing the PR therefore. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On X11, the contents of a window framebuffer are undefined wherever the window
is not visible on screen (pixel ownership test). Window managers that unmap
windows on non-current workspaces — Marco/MATE, among others — therefore make
Screenshot()read undefined data: every PNG written while the user is onanother workspace comes out black. This breaks batch rendering via
glvis -run script.glvis, which is otherwise meant to run in the background.This patch renders the scene into an application-created FBO (RGBA8 color +
DEPTH24 renderbuffer at the current draw size) and reads the image back from
there. FBO attachments belong to the GL context rather than to the window
system, so they stay valid regardless of window visibility. If framebuffer
objects are unavailable (legacy GL context), the previous back/front buffer
path is used unchanged.
Two supporting changes are needed for this to work:
MeshRenderergains a configurable target framebuffer. The MSAA resolve steppreviously hardcoded
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0), which wouldsend the antialiased image back to the window instead of the off-screen
target.
framebuffer. The resolve FBO is deleted when
render()returns, which resetsthe read binding to the default framebuffer; reading from it afterwards
raises
GL_INVALID_OPERATIONand yields the window contents again.Verified on Marco/MATE with an NVIDIA GL driver, using a script that writes a
series of PNGs while the GLVis window is moved to another workspace, unmapped,
and left visible. Before: all frames taken while the window was hidden are
black. After: all frames are correct and match the frames rendered with the
window visible.
This fix was generated with Claude Code. I don't understand much of what is going
on here, since GL internals are not my area of expertise — please review
accordingly.