-
-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove transparent backgrounds from screenshots #5660
Remove transparent backgrounds from screenshots #5660
Conversation
This fixes pioneerspacesim#4671 Also, somewhat more optimal and safer, given the old code appears to be copying most bytes 3/4 times and then copying 2/3 bytes off the end of the image, if I read it correctly. As a side effect screenshot images are a bit smaller now too.
Not quite sure what to do about the commented out alternative path, or if the optimal path is really required, go for simplicity, leave as it or something else? |
I'm not a great fan of the built-in screenshot functionality, but I can see the argument for having it, especially with the existence and quality of screenshot functionality varying wildly between OS brand and distribution. I'd recommend paring down the write_png function to only what's absolutely necessary for taking screenshots / dumping the backbuffer; other uses for the function should either go through a "real" PNG library for e.g. editor asset management or be implemented as an in-process tool for e.g. inspecting intermediate render targets. If possible, I'd highly recommend all or almost all code for "taking a screenshot" be moved into the PngWriter file and decoupled from the rest of the code; as of the last time I worked on it, we have to link the savegame dump command line utility against SDL2_Image because PngWriter is a transitive dependency somewhere and somehow. |
Hi @Web-eWorks , I'm not quite sure what you're suggesting. I can see 3 places that use this
Are you suggesting moving the fragments of code in the first two cases into And/or are you suggesting we remove the dependency on SDL to save png files? This could be achieved, for example, by adding a dependency on libpng and does seem a better solution. This is something I could do, it's been years since I looked at libpng but I'd wager it hasn't changed much. However, I think that's out of the scope of this PR. It seems like the |
This is fine - if there's duplicated functionality between the three paths then coalesce them; otherwise it's not a huge exposure. I'd probably suggest removing the GasGiant.cpp codepath entirely, as the need to dump the texture is completely obviated by the in-process texture cache explorer via the Ctrl+I menu.
No, I don't think that's necessary - I apologize for the wild goose chase I've inadvertently led you down. I have a distinct memory from 3 or 4 years gone of setting up one of the CLI executable targets and it requiring a linkage against SDL_Image for very very non-obvious reasons connected to the screenshot functionality, but it's very possible it's been "fixed at a distance" in the intervening time and I've simply not noticed the knock-on effect.
I'd rather not pull any additional libraries in for the purpose of writing out screenshots on the command line. If we introduce a resource loading system of some sort I'd be happy to revisit the question but I think SDL_Image is a fine (and small) enough dependency for the purpose.
Excellent news - if that also builds on the CI machines then I'll consider the whole mess resolved. 😄 |
...this would be because I in fact was the one to fix everything in the world linking against PngWriter - it used to be linked into If interested, this is the commit responsible for fixing the dependency on PngWriter 6a19458 - it seems I simply forgot to remove the linkage against SDL_Image in the |
Nice :-) No worries, I only spent about 15 mins looking at this; no wild geese involved. I'll remove the |
Bump @JonBooth78 - I'd like to merge this ahead of Pioneer Day if your schedule permits making the needed changes in that timeframe 😄 |
This helps us tidy up the screenshot code and simplify it for pioneerspacesim#4671
…mbedded within We were changing the buffer we read from to the front buffer, rather than the back buffer and not setting it back. At the same time, modify that code to not try and do anything clever with stride as it's not needed and also to not grab the aplha channel as again, it's not needed.
It looks like it may be buggy as it was specifying `glPixelStorei(GL_PACK_ALIGNMENT, 4)` but doing nothing to ensure the stride of the image stored into had a 4 byte alignment for each row.
Hi @Web-eWorks , I've done all the tidy up required and then fixed another bug I had (when taking screenshots my F3 view with the ship stopped showing the ship, instead a picture in picture of itself). I also stripped out a dead function in the renderer that would need to be considered if we ever put video recording back into the game. I added a comment by the |
"Does your graphics driver support multisample anti-aliasing?\n" | ||
"If this issue persists, try setting AntiAliasingMode=0 in your config file.\n", | ||
"Does your graphics driver support multisample anti-aliasing?\n" | ||
"If this issue persists, try setting AntiAliasingMode=0 in your config file.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh... clang-format constantly tries to squirrel its way into aligning arguments or parameters in an incorrect way. Nothing you need to address here, but I'll have to review the clang-format file again, for the Nth time.
This fixes #4671
Also, somewhat more optimal and safer, given the old code appears to be copying most bytes 3/4 times and then copying 2/3 bytes off the end of the image, if I read it correctly.
As a side effect screenshot images are a bit smaller now too.