-
Notifications
You must be signed in to change notification settings - Fork 923
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
NSGraphicsContext::currentContext not accessible from redraw handler on macOS #1605
Comments
I'm working on a 2D framebuffer crate as well and it seems that this isn't an issue. The Mac OS code in my crate gets the graphics context in the same way, but there's another issue. Perhaps you can help with this? I'd very much like there to be a working GPU-less 2D framebuffer crate for winit. To address the issue that you had the EDIT: I didn't notice that you were the same person at first, sorry. I think that I have a lead to fix this, though. Thanks for linking me here! |
Okay, so it turns out that RedrawRequested in winit isn't always called from draw_rect. Specifically, it isn't when it happens due to a requested repaint. If instead of requesting the repaint from winit, I send |
Can you push the updated version of |
I made the setNeedsDisplay change not in softbuffer but in one of the examples (the animation one, the only one that is broken on mac os as the others just display a static image). I did so in a quick and dirty testing way (I just added the setNeedsDisplay call directly in the example, so it won't compile on anything except Mac OS). Nonetheless, it should be sufficient to demonstrate the issue, so I've uploaded it as a zip here. I didn't want to push such a quick and dirty version to the main repo. The correct place to put the setNeedsDisplay call is in winit, and I didn't want to dig through it to figure out exactly where and deal with a non-standard version for testing when it might not even work. Of course, if this ever works, I'll submit a PR to winit to add it in. To reproduce the issue, run the |
It turned out that I had missed something obvious in my testing of |
Calling
msg_send![class![NSGraphicsContext], currentContext]
returns null when called from the winit event loop. I suspect this is because the currentContext is only valid while drawRect is being called.Not being able to get the currentContext makes winit unusable for drawing on macOS unless OpenGL or Metal is used.
The text was updated successfully, but these errors were encountered: