我正在尝试使用锈蚀跟踪创建我的第一个Vulkan应用程序
当我进入承诺1.2.1时,我注意到他正在为Windows创建winit窗口。
因为我是在我的Linux-system上开发应用程序的,所以我决定离开预先编写脚本的路径,尝试自己实现窗口部分。
所以我偶然发现了灰窗箱,它给了我一个需要window-handle作为参数的create-surface()方法。
我的问题如下:
我无法从winit窗口调用原始窗口句柄函数,尽管温特博士建议Window实现该,据我所知,这将公开上述函数。
我试图像这样创建KHRSurface:
let window = WindowBuilder::new().build(&events_loop).unwrap();;
let surface_khr = unsafe { create_surface(&entry, &instance, &window.raw_window_handle(), None).unwrap(); };生锈编译器抱怨道:
error[E0277]: the trait bound `RawWindowHandle: HasRawWindowHandle` is not satisfied
--> src/main.rs:46:70
|
46 | let surface_khr = unsafe { create_surface(&entry, &instance, &window.raw_window_handle(), None).unwrap(); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasRawWindowHandle` is not implemented for `RawWindowHandle`
|
= note: required for the cast to the object type `dyn HasRawWindowHandle`由于我对Rust编程语言非常陌生,所以我不太熟悉的特性的概念,因此任何帮助都会非常感谢。
发布于 2021-06-21 18:07:09
欢迎来到StackOverflow。
window确实实现了HasRawWindowHandle特性,create_surface函数希望传递一个实现此特性的窗口对象。
这告诉我们,在create_surface的某个地方,它将调用该对象上的raw_window_handle。
但是在您的代码中,您已经掌握了window的raw_window_handle并将其传递到函数中。
所以现在create_surface想要得到你的raw_window_handle.的raw_window_handle
长话短说,只需尝试传入&window而不是&window.raw_window_handle()。
https://stackoverflow.com/questions/68071959
复制相似问题