question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In a previous discussion (https://github.com/pygfx/pygfx/pull/371#discussion_r1014485572) I learned that you often don’t need to interact with the canvas object directly when using pygfx. There are, of course, exceptions when this can be advantageous, but in general this is not the case. Because of this, we have introduced renderer.request_draw which wraps canvas.request_draw.

Taking this thought and thinking it to its conclusion I think it would make sense to also see if we can avoid all calls to canvas by default so that we only have to instantiate it when needed. In particular, I was wondering if we could change

from wgpu.gui.auto import WgpuCanvas, run
import pygfx as gfx

renderer = gfx.renderers.WgpuRenderer(WgpuCanvas())

to

import pygfx as gfx, run 

renderer = gfx.renderers.WgpuRenderer()

and make wgpu.gui.auto.WgpuCanvas the default canvas. We would, of course, keep the parameter and allow users to set it manually if needed. My angle here is to see if we can reduce boilerplate code.

On the same token, we could wrap run and avoid the import of wgpu for minimal examples. It’s always nice to not have to import lower-level functionality when dealing with something on a more high level.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Korijncommented, Nov 8, 2022

That’s funny! Have a look at gfx.show, and the example.

0reactions
almarkleincommented, Nov 8, 2022

it would be nice if show could use a custom draw function

Could perhaps be an arg to show? But yeah, let’s discuss elsewhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - canvas default size
The canvas element has two attributes to control the size of the coordinate space: width and height. These attributes, when specified, must have...
Read more >
How do I set a default grade for an assignment in
If you want to set a default grade for a certain assignment, use the assignment drop-down menu. Default grades can either be applied...
Read more >
Canvas Course Default Settings
Courses are automatically created in Canvas for each semester. As part of this process there are default setting applied to each course.
Read more >
The Graphics Canvas element - HTML - MDN Web Docs
The width of the coordinate space in CSS pixels. Defaults to 300. Usage notes. Alternative content. You should provide alternate content inside ...
Read more >
What is a canvas | Search
The default canvas is based on the width and height of your monitor. This tends to be 1024 pixels x 1024 pixels. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found