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

Add doc for migrating from wgpu.gui #47

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ See how the two windows above look the same? That's the idea; they also look the
same to the code that renders to them. Yet, the GUI systems are very different
(Qt vs glfw in this case). Now that's a powerful abstraction!

Coming from `wgpu.gui`? Check [from_wgpu_canvas.md](from_wgpu_canvas.md).


## Purpose

Expand Down
48 changes: 48 additions & 0 deletions from_wgpu_canvas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Migrating from wgpu.gui.WgpuCanvas

This project was spun out of wgpu-py, and has evolved to meet our requirements for update-propagation and more.
This document lists all the changes w.r.t. the last version of the canvas in wgpu-py.

## Changes

*Let me know if I missed any!*

* `WgpuCanvas` -> `RenderCanvas`.
* `run` -> `loop.run()`.
* `call_later` -> `loop.call_later`.
* `canvas.is_closed()` -> `canvas.get_closed()`.
* The `canvas.get_context()` must be called with an arg: `canvas.get_context("wgpu")`.


## Improvements

* Overall cleaner code, more tests, better docs.
* Support for contexts other than wgpu.
* Bitmap rendering via builtin`canvas.get_context("bitmap")`.
* Handling of sigint (ctrl+c).
* Support for Trio.
* Support for async event handlers.
* Support for running async functions via `loop.add_task()`.
* Simpler Qt lib selection with `from rendercanvas.pyside6 import RenderCanvas`.
* Generic scheduling system with modes "ondemand", "continious", "fastest".


## By example

In wgpu-py:
```py
from wgpu.gui.auto import WgpuCanvas, run

...

run()
```

In rendercanvas:
```py
from rendercanvas.auto import RenderCanvas, loop

...

loop.run()
```
Loading