-
Notifications
You must be signed in to change notification settings - Fork 57
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
simple wgpu example #191
base: master
Are you sure you want to change the base?
simple wgpu example #191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! 🙂
The issue of the surface size needing to be twice as big as the window size is a window scaling factor issue. You probably have a High-DPI monitor on your machine, but on my machine everything is off by a factor of 2.
To fix this you need to handle window resize events, which also carry the scaling factor. Currently in baseview
there is no way to get the actual window size at creation time, but a resize event will be fired right away which will give you all the information you need.
You can use the render_femtovg
example as a reference on how to handle those events and resize your rendering buffers when needed. 🙂
You're also recreating the whole vertex buffer on every mouse move, but I think it would be better to simply write the mouse position into a uniform buffer and handle the translation in the shader instead.
There's also a couple clippy warnings that need fixing, but nothing too bad. Nevermind, seems like you fixed those already! 👍
@prokopyl not sure what the weird clippy error is for the windows test, looks like its coming from the baseview source. everything else should be fixed though! |
fyi @andrew-r-thomas, i was able to get the latest version of wgpu working with your example, basically i remove the lifetime requirements, made |
sweet! I think there are a bunch of refactoring changes for baseview that are in progress that will allow for 0.6 to be more fully supported, but good to know that theres a fix in the meantime! |
this is a simple example using wgpu of a rainbow triangle that is centered at the mouse position.
it's probably not the cleanest way to do things on the wgpu side but it's a good starter example for people looking to use wgpu in baseview
some things to note:
HasRawWindowHandle
andHasRawDisplayHandle
from rwh