You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time I try to run the example code. The application runs for a bit then dies, I then get this error message:
thread 'main' panicked at 'attempted to leave type \`platform::platform::x11::util::input::PointerState\` uninitialized, which is invalid
Here is my Cargo.toml:
[package]
name = "game_of_life"version = "0.1.0"authors = ["Nathan Hare <[email protected]>"]
edition = "2018"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
piston = "0.52.0"piston2d-graphics = "0.39.0"pistoncore-glutin_window = "0.67.0"piston2d-opengl_graphics = "0.76.0"
And main.rs:
externcrate glutin_window;externcrate graphics;externcrate opengl_graphics;externcrate piston;use glutin_window::GlutinWindowasWindow;use opengl_graphics::{GlGraphics,OpenGL};use piston::event_loop::{EventSettings,Events};use piston::input::{RenderArgs,RenderEvent,UpdateArgs,UpdateEvent};use piston::window::WindowSettings;pubstructApp{gl:GlGraphics,// OpenGL drawing backend.rotation:f64,// Rotation for the square.}implApp{fnrender(&mutself,args:&RenderArgs){use graphics::*;constGREEN:[f32;4] = [0.0,1.0,0.0,1.0];constRED:[f32;4] = [1.0,0.0,0.0,1.0];let square = rectangle::square(0.0,0.0,50.0);let rotation = self.rotation;let(x, y) = (args.window_size[0] / 2.0, args.window_size[1] / 2.0);self.gl.draw(args.viewport(), |c, gl| {// Clear the screen.clear(GREEN, gl);let transform = c
.transform.trans(x, y).rot_rad(rotation).trans(-25.0, -25.0);// Draw a box rotating around the middle of the screen.rectangle(RED, square, transform, gl);});}fnupdate(&mutself,args:&UpdateArgs){// Rotate 2 radians per second.self.rotation += 2.0* args.dt;}}fnmain(){// Change this to OpenGL::V2_1 if not working.let opengl = OpenGL::V3_2;// Create an Glutin window.letmut window:Window = WindowSettings::new("spinning-square",[200,200]).graphics_api(opengl).exit_on_esc(true).build().unwrap();// Create a new game and run it.letmut app = App{gl:GlGraphics::new(opengl),rotation:0.0,};letmut events = Events::new(EventSettings::new());whileletSome(e) = events.next(&mut window){ifletSome(args) = e.render_args(){
app.render(&args);}ifletSome(args) = e.update_args(){
app.update(&args);}}}
Every time I try to run the example code. The application runs for a bit then dies, I then get this error message:
Here is my
Cargo.toml
:And
main.rs
:I am using:
The text was updated successfully, but these errors were encountered: