gpt4 book ai didi

rust - WindowCreationError "Failed to create input context"对 libEGL 和 ggez 意味着什么?

转载 作者:行者123 更新时间:2023-11-29 08:31:44 26 4
gpt4 key购买 nike

我在处理 ggez tutorial 时尝试用 Rust 编写游戏.这是我的代码(src/main.rs):

use ggez::*;

// game state information goes here
struct State {}

/* Context connects all of the low-level bits for us; GameResult
tells us if our game is borken */
impl ggez::event::EventHandler for State {
fn update(&mut self, ctx: &mut Context) -> GameResult<()> {
Ok(())
}

fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
Ok(())
}
}

fn main() {
let state = &mut State { };
println!("Hello, world!");
let c = conf::Conf::new();
let (ref mut ctx, ref mut event_loop) = ContextBuilder::new("ggez-0", "My Name")
.conf(c)
.build()
.unwrap();
event::run(ctx, event_loop, state).unwrap();
}

我希望编译器具有以下输出:

   Compiling ggez-0 v0.1.0 (/home/public/devel/rust/ggez-0)
warning: unused variable: `ctx`
--> src/main.rs:9:26
|
9 | fn update(&mut self, ctx: &mut Context) -> GameResult<()> {
| ^^^ help: consider prefixing with an underscore: `_ctx`
|
= note: #[warn(unused_variables)] on by default

warning: unused variable: `ctx`
--> src/main.rs:13:24
|
13 | fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
| ^^^ help: consider prefixing with an underscore: `_ctx`

Finished dev [unoptimized + debuginfo] target(s) in 17.55s
Running `target/debug/ggez-0`
Hello, world!

随后会弹出一个小的 GUI 窗口。

但是,当我运行代码时,我得到了这个输出:

   Compiling ggez-0 v0.1.0 (/home/public/devel/rust/ggez-0)
warning: unused variable: `ctx`
--> src/main.rs:9:26
|
9 | fn update(&mut self, ctx: &mut Context) -> GameResult<()> {
| ^^^ help: consider prefixing with an underscore: `_ctx`
|
= note: #[warn(unused_variables)] on by default

warning: unused variable: `ctx`
--> src/main.rs:13:24
|
13 | fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
| ^^^ help: consider prefixing with an underscore: `_ctx`

Finished dev [unoptimized + debuginfo] target(s) in 17.55s
Running `target/debug/ggez-0`
Hello, world!
libEGL warning: DRI3: failed to query the version
libEGL warning: DRI2: failed to authenticate
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: WindowCreationError(Window(OsError("Failed to create input context: XError(XError { description: \"BadRequest (invalid request code or no such operation)\", error_code: 1, request_code: 155, minor_code: 1 })")))', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

并且没有 GUI 窗口。谷歌搜索错误消息的逐字文本没有帮助,我不太明白它在说什么。到底是怎么回事?

我正在使用 1.34.0 版的 Rust 编译器,在 Ubuntu 18.10 上通过 SSH 使用选项 -XC 运行,这样我就可以获得 GUI 和其他 GUI 程序(如 Firefox、Writer等)对我来说很好用。一些论坛建议使用 sudo apt install mesa-utils-extra 来解决类似问题,但这对我来说没有任何改变。

最佳答案

运行 sudo apt-get install libglfw3-dev libgles2-mesa-dev freeglut3-dev 并再次运行程序解决了问题。

关于rust - WindowCreationError "Failed to create input context"对 libEGL 和 ggez 意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56046798/

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