Skip to content

Commit

Permalink
Allow get_context before a backend is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Dec 9, 2024
1 parent 1cc0e24 commit d101e33
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 d101e33

Please sign in to comment.