Skip to content
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
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ jobs:
python -m pip install --upgrade pip
pip install -e .
- name: Test imports
env:
WGPU_FORCE_OFFSCREEN: true
run: |
python -c "print('wgpu'); import wgpu; print(wgpu)"
python -c "print('wgpu.backends.wgpu_native'); import wgpu.backends.wgpu_native"
python -c "print('wgpu.gui.offscreen'); import wgpu.gui.offscreen"
python -c "print('wgpu.utils'); import wgpu.utils"

docs-build:
Expand Down Expand Up @@ -144,7 +141,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -U .
pip install -U pytest numpy psutil pyinstaller glfw
pip install -U pytest numpy psutil pyinstaller
- name: Test PyInstaller
run: |
pushd $HOME
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ API closely resembling the [WebGPU spec](https://gpuweb.github.io/gpuweb/).
## Installation

```
pip install wgpu glfw
# Just wgpu
pip install wgpu

# If you want to render to screen
pip install wgpu rendercanvas glfw
```

Linux users should make sure that **pip >= 20.3**. That should do the
Expand All @@ -80,16 +84,13 @@ import wgpu
To render to the screen you can use a variety of GUI toolkits:

```py
# The auto backend selects either the glfw, qt or jupyter backend
from wgpu.gui.auto import WgpuCanvas, run, call_later
# The rendercanvas auto backend selects either the glfw, qt, wx, or jupyter backend
from rendercanvas.auto import RenderCanvas, loop

# Visualizations can be embedded as a widget in a Qt application.
# Import PySide6, PyQt6, PySide2 or PyQt5 before running the line below.
# The code will detect and use the library that is imported.
from wgpu.gui.qt import WgpuCanvas

# Visualizations can be embedded as a widget in a wx application.
from wgpu.gui.wx import WgpuCanvas
from rendercanvas.qt import RenderCanvas
```

Some functions in the original `wgpu-native` API are async. In the Python API,
Expand Down Expand Up @@ -159,7 +160,7 @@ call it to see if an image is produced.

To support this type of testing, ensure the following requirements are met:

* The `WgpuCanvas` class is imported from the `wgpu.gui.auto` module.
* The `RenderCanvas` class is imported from the `rendercanvas.auto` module.
* The `canvas` instance is exposed as a global in the module.
* A rendering callback has been registered with `canvas.request_draw(fn)`.

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ROOT_DIR = os.path.abspath(os.path.join(__file__, "..", ".."))
sys.path.insert(0, ROOT_DIR)

os.environ["WGPU_FORCE_OFFSCREEN"] = "true"
os.environ["RENDERCANVAS_FORCE_OFFSCREEN"] = "true"


# Load wgpu so autodoc can query docstrings
Expand Down Expand Up @@ -99,7 +99,7 @@ def resolve_crossrefs(text):


# Tweak docstrings of classes and their methods
for module, hide_class_signature in [(wgpu.classes, True), (wgpu.gui, False)]:
for module, hide_class_signature in [(wgpu.classes, True)]:
for cls_name in module.__all__:
cls = getattr(module, cls_name)
# Class docstring
Expand Down
212 changes: 0 additions & 212 deletions docs/gui.rst

This file was deleted.

18 changes: 9 additions & 9 deletions docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Creating a canvas
+++++++++++++++++

If you want to render to the screen, you need a canvas. Multiple
GUI toolkits are supported, see the :doc:`gui`. In general, it's easiest to let ``wgpu`` select a GUI automatically:
GUI toolkits are supported, see https://rendercanvas.readthedocs.io/stable/backends.htm. In general, it's easiest to let ``rendercanvas`` select a GUI automatically:

.. code-block:: py

from wgpu.gui.auto import WgpuCanvas, run
from rendercanvas.auto import RenderCanvas, loop

canvas = WgpuCanvas(title="a wgpu example")
canvas = RenderCanvas(title="a wgpu example")


Next, we can setup the render context, which we will need later on.
Expand Down Expand Up @@ -94,21 +94,24 @@ the previous step.
render_pass.end()
device.queue.submit([command_encoder.finish()])

# If you want to draw continuously, request a new draw right now
# You can request a new draw when you know something has changed.
canvas.request_draw()

# Alternatively you can tell the canvas to draw continuously with
# canvas = RenderCanvas(update_mode='continuous')


Starting the event loop
+++++++++++++++++++++++


We can now pass the above render function to the canvas. The canvas will then
call the function whenever it (re)draws the window. And finally, we call ``run()`` to enter the mainloop.
call the function whenever it (re)draws the window. And finally, we call ``loop.run()`` to enter the mainloop.

.. code-block:: py

canvas.request_draw(draw_frame)
run()
loop.run()


Offscreen
Expand Down Expand Up @@ -247,8 +250,5 @@ In wgpu a PyInstaller-hook is provided to help simplify the freezing process
(it e.g. ensures that the wgpu-native DLL is included). This hook requires
PyInstaller version 4+.

Our hook also includes ``glfw`` when it is available, so code using ``wgpu.gui.auto``
should Just Work.

Note that PyInstaller needs ``wgpu`` to be installed in `site-packages` for
the hook to work (i.e. it seems not to work with a ``pip -e .`` dev install).
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Welcome to the wgpu-py docs!
guide
wgpu
backends
gui
utils


Expand Down
15 changes: 2 additions & 13 deletions docs/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@ Python 3.9 or higher is required. Pypy is supported.
pip install wgpu


Since most users will want to render something to screen, we recommend installing GLFW as well:
Since most users will want to render something to screen, we recommend installing `rendercanvas <https://github.com/pygfx/rendercanvas>`_ and `glfw <https://github.com/FlorianRhiem/pyGLFW>`_ as well:

.. code-block:: bash

pip install wgpu glfw


GUI libraries
-------------

Multiple GUI backends are supported, see :doc:`the GUI API <gui>` for details:

* `glfw <https://github.com/FlorianRhiem/pyGLFW>`_: a lightweight GUI for the desktop
* `jupyter_rfb <https://jupyter-rfb.readthedocs.io>`_: only needed if you plan on using wgpu in Jupyter
* qt (PySide6, PyQt6, PySide2, PyQt5)
* wx
pip install wgpu rendercanvas glfw


The wgpu-native library
Expand Down
Loading
Loading