-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
API: Window.takeScreenshot #185
Comments
Guess I'll take this over since I'm already pretty familiar with the API. Want anything specific for the example code? |
Awesome, thanks @OhadRau ! Regarding example - good question. Hmm, perhaps we could add a |
Nice catch! That's interesting that it's inverted - and looks like the red/blue color channels are inverted for the background. But strange that the logo doesn't seem impacted by the color switch... |
Yep. Just the type of bug that's a pain to catch while testing with a cube lol. The upside down part is related to how glReadPixels returns the framebuffer upside down. Thought it would be right because I basically copied the TGA encoding from an example I saw online, but it seems like their code had this same issue. Not entirely sure how the color relates to this all yet |
@bryphe So I finally actually sat down and started working on this. The issue has to do with little-endianness causing the color bits to be reversed. Kind of an architectural question for reason-glfw, but would you say to swap these bits inside of glReadPixels or inside of Image.save? Or should I write a separate function for that maybe? |
Everything is working well for me now on native with this, but note that reason-fontkit is still depending on an old reason-glfw so this is gonna be blocked on that. However I'm actually having some trouble getting this to give the right result in browser--seems to always give an all white image when I'm working in revery, even though it looked okay on the reason-glfw example when I tested it in the browser. Really confused about what's causing that to happen, so I'll have to debug this a little bit. Not sure about any ETA since I start classes again tomorrow, so no need to push ahead a reason-fontkit release just to get the version bump in. @bryphe |
Ran through this in the Chrome debugger and I think the issue that's causing this is https://stackoverflow.com/questions/7156971/webgl-readpixels-is-always-returning-0-0-0-0. I want to avoid turning on |
Building off the excellent work that @OhadRau did in bryphe/reason-glfw#72 - exposing the
glReadPixels
API + screenshots in all the platforms, I think it makes sense to have this be a first-class API on ourWindow
object.Proposal
We add a
Window.takeScreenshot(w: Window.t, fileName: string)
API.This would:
glReadPixels
into a newImage
, and callImage.save
. These would be synchronous operationsThis code that @OhadRau added in the reason-glfw example basically does all of this already - just about wrapping it up in an API:
Use Cases
The text was updated successfully, but these errors were encountered: