-
Notifications
You must be signed in to change notification settings - Fork 8
Implement own context classes #127
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
base: main
Are you sure you want to change the base?
Conversation
|
How does it feel? Does it feel right to you to have this in this lib? |
Yes it does! I really think this is the way to go. Before this, when users used wgpu+rendercanvas, they interacted with But equally important, the logic for presenting a texture as a bitmap felt really out of place in wgpu-py. By putting it here it makes more sense, and its much easier to move it further (compression on GPU etc.). |
If you can point out to me where this resides in wgpu-py I'll take care of removing that in my PR. |
Let's rip that out in a next pr, just to be sure. It's a bit intertwined in the |
|
Interesting ... if we add edit: I mean the context API for rendercanvas, for wgpu-py we don't have to do that. |
|
@Korijn this is about ready in terms of API etc. I gave the context properties to get size info. I also added I still have to test it against your branch, and e.g. let wgpu-py expose a public function to get the CanvasContext class for the appropriate backend. Will do that tomorrow or so. |
Implement the context classes in
rendercanvasitself, and wrapwgpu.GPUCanvasContextinstead.In principle we are free to implement whatever API we want here. We could even merge the context API with the canvas object to obtain a simpler API. But in the end, the concept of a context object that provides a certain way to send the rendered result into the canvas, is actually quite nice. And scalable to other methods. Plus it is familiar to people who know JS.
Interestingly, the contexts here can be be much closer to the WebGPU API than that of
wgpu-py, because in this case we do have a 'fixed concept' of what a canvas is, and we automate theset_physical_sizeandpresentmethods.present_infonow.