Skip to content
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

Screen Capturing #771

Merged
merged 20 commits into from
Nov 8, 2024
Merged

Screen Capturing #771

merged 20 commits into from
Nov 8, 2024

Conversation

hobnob
Copy link
Member

@hobnob hobnob commented Oct 23, 2024

Allows for capturing a screen using the context, fulfilling #735

Usage:

val screenshot: Asset.Image =
  context
      .captureScreen(
          ScreenCaptureConfig
              .default
              .withName("screenshot1")
              .withExcludeLayers(Batch(uiKey))
   )

Breaking Change:
Also adds an additional property to AssetEvent.AssetBatchLoaded detailing the assets that were loaded in the last AssetEvent.LoadAssetBatch event

@hobnob hobnob added the enhancement New feature or request label Oct 23, 2024
@hobnob hobnob linked an issue Oct 28, 2024 that may be closed by this pull request
Copy link
Member

@davesmith00000 davesmith00000 left a comment

Choose a reason for hiding this comment

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

Looks good. I've left some comments. I think the main one is about passing the renderer to the framecontext.

I think the solution you have here is probably as good a job as you can do without a deeper (and trickier!) integration with the renderer.

The alternative I'm thinking of wouldn't need you to retain the previous data because you'd render to two canvas's at once (if some flag was set), dropping the layers you wanted to skip. Don't know if it would work of course, because I haven't tried it!

@@ -1,16 +1,26 @@
package indigo.platform.renderer.webgl1

import indigo.AssetName
import indigo.AssetPath
import indigo.platform.assets.AtlasId
Copy link
Member

Choose a reason for hiding this comment

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

I'd be tempted to drop this from the WebGL1 implementation. WebGL1 is very limited - really only good enough to display a message saying "don't use this" - and I'd hope no-one is trying to build anything screen capture worthy in it. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think all the time we have a WebGL1 implementation we should support it.. It doesn't add much work in this case, so I think we should keep it

)
)
)
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks good. So if I'm reading correctly, the process is:

  1. Take the previous scene (so that you can filter out the layers people don't want to capture).
  2. Set up a new canvas.
  3. Re-render which effectively overwrites the usual canvas context.
  4. Grab it, and stuff it into the new canvas.
  5. Save it.

Have I got that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, that's pretty much the process 🙂

Copy link
Member

@davesmith00000 davesmith00000 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @hobnob. 🔥

@davesmith00000 davesmith00000 merged commit 21a1521 into main Nov 8, 2024
2 checks passed
@davesmith00000 davesmith00000 deleted the features/screengrab branch November 8, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Game screenshots for save game slots
2 participants