Skip to content

Make the triangle example simpler#810

Open
Vipitis wants to merge 9 commits into
pygfx:mainfrom
Vipitis:minimal-example
Open

Make the triangle example simpler#810
Vipitis wants to merge 9 commits into
pygfx:mainfrom
Vipitis:minimal-example

Conversation

@Vipitis

@Vipitis Vipitis commented May 28, 2026

Copy link
Copy Markdown
Contributor

closes #809

a few open questions:

  • do we use the shared global device for convenience?
  • should we stick with the colorful triangle or simplify to the red triangle seen in the other hello triangle examples
  • the hdr example broke, should we just make the cube example also take the format arg?
  • do we want a few more comments to make it a bit of a guide too?

(I don't expect to have any time over the weekend but will find a bit of free space next week)

@almarklein

Copy link
Copy Markdown
Member

do we use the shared global device for convenience?

If different code/libraries in an application use the same device, they can share buffers and textures. E.g. a lib doing compute can visualize the result with a viz library without having to move the data to the CPU. Therefore I want to promote the global device, especially for libraries. Maybe keep it straightforward but mention the global device briefly in a comment?

should we stick with the colorful triangle or simplify to the red triangle seen in the other hello triangle examples

I liked that it was a bit more colorful, and it demonstrates varyings nicely with a few extra lines in the shader.

the hdr example broke, should we just make the cube example also take the format arg?

yeah, if that fixes the hdr example, let's do that.

do we want a few more comments to make it a bit of a guide too?

Sounds good! I think we're aiming for an example for ppl to explore to understand wgpu, so any comments that help understand what happens is good!

Comment thread examples/gui_auto.py

"""

# test_example = true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disabled this and removed the screenshot. Since we get one for cube and one for triangle anyway. Perhaps not the best idea as we could miss problems

Comment thread examples/offscreen_hdr.py
from rendercanvas.offscreen import RenderCanvas

try:
from .triangle import setup_drawing_sync

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and problems we missed. I ran this locally and got a messed up image. As I was on main for rendercanvas I had to go back to v2.5.0 to get it to work again. Didn't bisect it fully but between v2.5.0 and v2.6.0 is what I could find on the quick.

I suspect something about the bitorder might be wrong:

Image

I will check the rendercanvas code when I find time. Maybe a numpy kwargs is all we need

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe width/height reversed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't it. I tried around with different shapes and all. But the individual pixel values don't make sense. I think it's somewhere in the new bitmapcontext in rendercanvas. I had a quick glance and it looked like it always writes bytes as uint8... so it could also be a platform specific problem with order across bytes.

I will try some variations and file this for rendercanvas hopefully in a few days.

@Vipitis Vipitis marked this pull request as ready for review May 31, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide minimal example?

2 participants