piston_window
piston_window copied to clipboard
BindProgram error with some hardware
I'm getting an OpenGL error with some hardware, even though my program runs fine on others. I'm using OpenGL 3.3, MSVC windows version of rust. Windows 10.
The error I'm getting is:
thread 'main' panicked at 'Error after executing command BindProgram(0): InvalidOperation', C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\gfx_device_gl-0.11.2\src\lib.rs:287
stack backtrace: 0: 0x7ff6f54273cc - std::rt::lang_start::h162055cb2e4b9fe7 1: 0x7ff6f54269d9 - std::rt::lang_start::h162055cb2e4b9fe7 2: 0x7ff6f541852d - std::panicking::rust_panic_with_hook::hd7b83626099d3416 3: 0x7ff6f5429a0b - rust_begin_unwind 4: 0x7ff6f541941f - std::panicking::begin_panic_fmt::h30280d4dd3f149f5 5: 0x7ff6f534ac01 - check at C:\Users\Filip\Desktop\Joel\lgidcf
:8 6: 0x7ff6f5352a80 - process at C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\gfx_device_gl-0.11.2\src\lib.rs:703 7: 0x7ff6f534de00 - reset_state at C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\gfx_device_gl-0.11.2\src\lib.rs:382 8: 0x7ff6f5357a99 - submit at C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\gfx_device_gl-0.11.2\src\lib.rs:727 9: 0x7ff6f525a549 - flush<gfx_device_gl::Resources,gfx_device_gl::command::CommandBuffer,gfx_device_gl::Device> at C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\gfx-0.12.0\src\encoder.rs:108 10: 0x7ff6f5253e56 - draw_2d<glutin_window::GlutinWindow,input::event::Eventinput::Input,closure,()> at C:\Users\Filip.cargo\registry\src\github.com-1ecc6299db9ec823\piston_window-0.52.0\src\lib.rs:218 11: 0x7ff6f52213be - main at C:\Users\Filip\Desktop\Joel\lgidcf\src\main.rs:62 12: 0x7ff6f54263ac - std::rt::lang_start::h162055cb2e4b9fe7 13: 0x7ff6f5429aa1 - _rust_maybe_catch_panic 14: 0x7ff6f54260e4 - std::rt::lang_start::h162055cb2e4b9fe7 15: 0x7ff6f528fc39 - main 16: 0x7ff6f5436278 - __scrt_common_main_seh at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253 17: 0x7ffe9d5c8363 - BaseThreadInitThunk error: Process didn't exit successfully: target\debug\lgidcf.exe
(exit code: 101)
main.rs line 62 is the first line of the closure i send to the draw function of PistonWindow. It doen't seem to matter what the closure does - it crashes when it tries to execute it.
The program manages to draw some of the scene before crashing. I don't know if it is able to draw an entire frame or if it crashed mid-frame.
I would appreciate any help trying to narrow down and solve this issue. Thanks!
It seems that the program is able to draw one frame, and then crashes when it has just drawn the second frame. It goes like this:
Draw event Started draw closure Finished draw closure Finished draw event
Update event Finished update event
Update event Finished update event
Draw event Started draw closure Finished draw closure CRASH! with the BindError above.
So something goes wrong inside window.draw_2d
after it successfully executes the draw closure, but before returning to the caller.
So, it might be the call to self.encoder.flush()
or self.g2d.draw()
inside PistonWindow, or something else entirely. Anyone with more experience know what might be going on?
I have been able to reproduce the issue with this minimal program:
[package]
name = "test"
version = "0.1.0"
authors = ["Joel"]
[[bin]]
name = "test"
[dependencies]
piston = "*"
piston2d-graphics = "*"
piston2d-opengl_graphics = "*"
piston_window = "*"
rand = "*"
extern crate piston_window;
extern crate piston;
extern crate rand;
extern crate graphics;
use piston_window::*;
use rand::Rng;
fn main() {
const SIZE: [u32; 2] = [600,600];
const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0];
const NUM: u32 = 500; //change this to change number of polygons
const SQUARESIZE: f64 = 10.0;
let mut window: PistonWindow = WindowSettings::new(
"test",
SIZE
)
.opengl(OpenGL::V3_3)
.vsync(true)
.exit_on_esc(true)
.build()
.unwrap();
if cfg!(debug_assertions) {
println!("Created window");
}
let mut frames = 0;
let mut rng = rand::thread_rng();
while let Some(e) = window.next() {
window.draw_2d(&e,|c, g| {
clear(GREEN, g);
for i in 0..NUM {
//setting up so that it looks pretty
let x = (i % SIZE[0]) as f64;
let y = (i % SIZE[1]) as f64;
let fill = (x / (SIZE[0] as f64)) as f32;
let color: [f32; 4] = [fill,1.0-fill,fill,fill];
let x = rng.gen_range::<f64>(0.0,SIZE[0] as f64);
//draw a square
let square = rectangle::square(0.0, 0.0, SQUARESIZE);
let transform = c.transform.trans(x-SQUARESIZE/2.0,y-SQUARESIZE/2.0);
rectangle(color, square, transform, g);
}
frames+=1;
if cfg!(debug_assertions) {
println!("Finished drawing frame {}", frames);
}
});
}
}
I get a similar error:
[package]
name = "foo"
version = "0.1.0"
[dependencies]
piston_window = "0.61.0"
extern crate piston_window;
use piston_window::*;
fn main() {
let mut window: PistonWindow = WindowSettings::new("Hello Piston!", (640, 480))
.exit_on_esc(true)
.build()
.unwrap_or_else(|e| { panic!("Failed to build PistonWindow: {}", e) });
while let Some(e) = window.next() {
window.draw_2d(&e, |_c, g| {
clear([0.5, 1.0, 0.5, 1.0], g);
});
}
}
thread 'main' panicked at 'Error after executing command BindProgram(0): InvalidEnum', C:\Users\Gheorghe\.cargo\registry\src\github.com-1ecc6299db9ec823\gfx_device_gl-0.12.0\src\lib.rs:337
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\foo.exe` (exit code: 101)
I can't provide a backtrace at this time.