【发布时间】:2019-05-24 06:01:35
【问题描述】:
我在 Windows 上有一个最小的 Rust/OpenGL 应用程序。我正在使用 Visual Studio Code、LLDB 和 Glutin(类似于 GLFW 的库)。
通过cargo run 启动会打开一个空窗口,但是通过 LLDB 启动时,不会打开任何窗口。我已经在 LLDB 和println! 中确认正在调用上下文创建函数并且正在执行主循环。换句话说,我已经验证了所有代码行都已到达。无论是否在 VSCode 中运行都是如此。
我正在使用 32 位 Rust 工具链 stable-i686-pc-windows-gnu,因为 LLDB 不完全支持 64 位 Windows。除了这个问题,LLDB 似乎按预期工作。
下面是main.rs,改编自Glutin readme。 (Glutin 是一个类似于 GLFW 的 Rust 库。)除了打开窗口所需的必需品外,我已经删除了所有内容。
期望行为:当程序从 LLDB 启动时,窗口打开,与程序从 LLDB 外部启动时打开的窗口相同。
实际行为:当程序从 LLDB 启动时,窗口没有打开。
问题:什么可以解释这种行为差异? IE。为什么从终端打开时,窗口不会从 LLDB 打开?
extern crate gl;
extern crate glutin;
fn main() {
let events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new();
let context = glutin::ContextBuilder::new();
// When running outside LLDB, this line causes the window to appear.
// The let binding is necessary because without it, the value will be dropped
// and the window will close before the loop starts.
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
// Normally, we'd make the window current here. But it's not necessary
// to reproduce the problem.
loop {
// This is where we'd swap the buffers and clear. But it's not necessary
// to reproduce the problem.
}
}
【问题讨论】:
-
您没有寻找任何错误返回原因?那个基本的。
-
是的,你是对的——非常基本。如果有任何此类信息,我肯定会在我的问题中说明。