gpt4 book ai didi

rust - 无法在WindowBuild对象上调用build_vk_surface()

转载 作者:行者123 更新时间:2023-12-03 11:44:25 25 4
gpt4 key购买 nike

我正在按照vulkano教程打开一个窗口,并使用vulkano-win创建一个曲面。
到目前为止,大多数教程都已经过时了,但是到目前为止,我还没有找到解决方案。
当前,当我调用let window = WindowBuilder::new().build_vk_surface(&events_loop, instance.clone())时收到以下错误error[E0599]: no method named build_vk_surface found for struct winit::window::WindowBuilder in the current scope我已经检查了vulkano_win的库和版本,并且似乎正确扩展了WindowBuilder,我将在下面的Cargo.toml中发布依赖项。

[dependencies]
vulkano = "0.19"
vulkano-shaders = "0.18"
winit = "0.23"
vulkano-win = "0.19"
image = "0.23"
P.S. -这是旧版本(2年以前)上的 vulkano_win版本的遗留实例。我怀疑这是已解决的,因为我已经检查了 vulkano_win库的依赖关系,并且他们在那里使用了较新的和重组的 winit版本:
https://github.com/vulkano-rs/vulkano/issues/943

最佳答案

I have checked the library and the version of vulkano_win and it seems to properly extend WindowBuilder I will post the dependencies in my Cargo.toml below.


简而言之,您是正确的。问题是 VkSurfaceBuild特性是为winit 0.22的 WindowBuilder而不是winit 0.23的 WindowBuilder实现的。
因此,要解决您的问题,您需要更新Cargo.toml以使用winit 0.22而不是0.23。
例子:
[dependencies]
vulkano = "0.19"
vulkano-shaders = "0.19"
vulkano-win = "0.19"
winit = "0.22"

此外,您的困惑可能来自浏览存储库。
在存储库中, vulkano-winexamples都使用winit 0.23。
但是,请记住,存储库的当前状态不一定与0.19中发布的状态相同。
在GitHub上,您可以选择标签,并查看 0.19 release的提交。
如果再查看 vulkano-winexamples,您会发现它们都使用winit 0.22。
repo
如果您真的想使用winit 0.23。然后,您可以直接依赖存储库。像这样:
[dependencies]
vulkano = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-win = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano" }
winit = "0.23"
但是,对存储库进行的一项重大更改可能会破坏您的构建。因此,请谨慎使用。

How were able to determine how that trait was implemented over the 0.22 WindowBuilder but not the 0.23 WindowBuilder?


不确定是否有花哨的方法,但是一种简单的方法是转到 VkSurfaceBuild on docs.rs,然后单击“ WindowBuilder”,在“外国类型的实现”处,然后将其重定向到 winit 0.22.2 docs
另外,您也可以检查 Cargo.lock。如果尝试使用 winit 0.23,则您的 Cargo.lock将包含两个 winit版本:
[[package]]
name = "winit"
version = "0.22.2"
...

[[package]]
name = "winit"
version = "0.23.0"
...
如果然后查看 vulkano-win,那么可以看到它使用了 winit 0.22.2:
[[package]]
name = "vulkano-win"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b9a02addddf5532396d11dbb822f77d87ca17a00c918e4c8a0a125d6c207e2b"
dependencies = [
"cocoa 0.20.2",
"metal",
"objc",
"vulkano",
"winit 0.22.2",
]
如果没有重复的版本,它将像其他版本一样说 "winit"

关于rust - 无法在WindowBuild对象上调用build_vk_surface(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64776095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com