Skip to content

Commit

Permalink
Allow get_context before a backend is selected (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein authored Dec 9, 2024
1 parent 926c7cc commit 113e6e6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wgpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def rendercanvas_context_hook(canvas, present_methods):

backend_module = gpu.__module__
if backend_module in ("", "wgpu._classes"):
raise RuntimeError(
"A backend must be selected (e.g. with wgpu.gpu.request_adapter()) before canvas.get_context() can be called."
)
# Load backend now
from .backends import auto

backend_module = gpu.__module__

return sys.modules[backend_module].GPUCanvasContext(canvas, present_methods)

0 comments on commit 113e6e6

Please sign in to comment.