Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wgpu custom rendering example #1003

Closed
wants to merge 1 commit into from

Conversation

mvilim
Copy link

@mvilim mvilim commented Aug 20, 2021

wgpu custom rendered widget example

Hi! I am returning to #903, and I realized that the existing layout information is sufficient to appropriately locate a custom render pass with the rest of the UI. I have put together this PR with an example that demonstrates a custom rendered widget.

This solution is effectively option 4 from #903; it's just that necessary information was already mostly exposed. It's a bit hacky, since it captures the contents of the layout argument to the widget draw call. It's only possible in projects that directly integrate with wgpu (such as the integration_wgpu example, from which my example is derived), and such projects already want to have fine control over their rendering.

Despite its slight hackiness, this seems like a perfectly sufficient solution for my use case. Do you think this example is worth including in the repo? If the overall approach is appropriate, but the particular method of extracting the layout from the draw call is too hacky, then perhaps I can instead make some extensions to iced so that the layout of a given widget can be queried.

) -> (Primitive, mouse::Interaction) {
// We update the current bounds of this custom widget, so that the custom rendering
// step will render it in the correct spot
self.bounds.replace(layout.bounds());
Copy link
Author

Choose a reason for hiding this comment

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

Although the full example is pretty long, this is the key point, where the layout is extracted to locate the custom render pass.

@hecrj hecrj force-pushed the master branch 2 times, most recently from e6ab610 to 8b0f2e6 Compare January 19, 2022 15:04
@hecrj
Copy link
Member

hecrj commented Sep 21, 2022

While using a completely new render pass on top of the GUI can work for most cases, I don't think we should officially recommend it since it can easily break overlays.

For this reason, I think it's best to wait until a proper 3D widget lands (see #343)!

@hecrj hecrj closed this Sep 21, 2022
@hecrj hecrj added this to the 0.5.0 milestone Sep 21, 2022
@mvilim
Copy link
Author

mvilim commented Sep 21, 2022

Okay, no problem! Thanks for taking the time to review.

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.

2 participants