-
Hey all, First of all thanks for the great library! I have a beginner question related to the example with egui : https://github.com/parasyte/pixels/tree/main/examples/minimal-egui If you run the example, you can see the square bouncing around and going under the top panel of the UI. My question is essentially, how would I proceed to have the rectangle only bounce around the visible area? As I understand it the One possible solution would obviously be to hardcode a margin at the top and adapt the square bouncing logic to bounce at the margin. However, if the UI changes, the logic has to be adapted again. Would you see a cleaner solution? I was thinking of ideally having an egui frame which could be drawn into by pixels. However, I'm not sure if that's possible since pixels draws directly into a window. Any conceptual perspective is appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Hey! I have been wanting to update the egui example to address this. Right now I'm blocked waiting on You can create an egui image with You don't need to call This is pretty hard to follow, sorry about that. I could update the example without replacing |
Beta Was this translation helpful? Give feedback.
-
An example would be very helpful! |
Beta Was this translation helpful? Give feedback.
-
I've come across this problem also. I've tried altering the ScalingRenderer to move the non-egui output (i.e. just where the pixels in Pixels get drawn) to below the bottom of the egui menu. You can get the bottom of the egui menu by passing it out from the egui prepare method. I then pass this in in to the ScalingRenderer. I'm able to move the pixels down easily enough by altering the Here's a super minimal change to demonstrate: main...anacrolix:pixels:scale-below-egui-menu. It would be amazing if someone could point out what I need to get it to fit correctly, I might be able to then generalize it to the Pixels API properly and make a PR (basically to have Pixels write its pixel frame to a specific region of the surface). |
Beta Was this translation helpful? Give feedback.
Hey! I have been wanting to update the egui example to address this. Right now I'm blocked waiting on
egui-wgpu
not supporting wgpu textures in 0.18. (It's available in the main branch, but currently unreleased.) You can still use the olderegui_wgpu_backend
like the example, though.You can create an egui image with
egui_texture_from_wgpu_texture()
, and the wgpu texture can be retrieved withPixels::texture()
. You'll have to create a texture view for it. Once you have the eguiTextureId
, just callui.image()
and it will draw just like any egui widget.You don't need to call
ScalingRenderer::render
if you are doing this. And because the scaling renderer is not used, you won't get any of t…