Skip to content

Commit

Permalink
Add doc for migrating from wgpu.gui (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein authored Dec 11, 2024
1 parent 62f807a commit 9fc9627
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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()
```

0 comments on commit 9fc9627

Please sign in to comment.