piston icon indicating copy to clipboard operation
piston copied to clipboard

error when learning piston with roguelike tutorial

Open ourabigdev opened this issue 2 years ago • 0 comments

`use piston::{WindowSettings, RenderEvent, EventSettings}; use glutin_window::GlutinWindow; use opengl_graphics::GlGraphics; use opengl_graphics::OpenGL;

fn main() { //opengl setup let opengl = OpenGL::V4_5; let mut gl = GlGraphics::new(opengl);

//colors
let RED =[1.0, 0.0, 0.0, 1.0];
let GREEN = [0.0, 1.0, 0.0, 1.0];
let BLUE = [0.0, 0.0, 1.0, 1.0];
let WHITE = [1.0;4];

let settings = 
    WindowSettings::new("hello window" , [800f64, 600f64])
    .exit_on_esc(true);

let mut window: GlutinWindow = settings.build()
                .expect("Could not create window");

let sets = EventSettings::new();

let mut events = piston::Events::new(sets);

while let Some(e)  = events.next(&mut window){
    if let Some(r) = e.render_args(){
        gl.draw(r.viewport(), |_c, g|{
            graphics::clear(RED, g);
        });
    }
}  

} `

`thread 'main' panicked at C:\Users\ourabig.cargo\registry\src\index.crates.io-6f17d22bba15001f\piston2d-opengl_graphics-0.83.0\src\back_end.rs:457:9:

OpenGL function pointers must be loaded before creating the `Gl` backend!    For more info, see the following issue on GitHub:
https://github.com/PistonDevelopers/opengl_graphics/issues/103

note: run with RUST_BACKTRACE=1 environment variable to display a backtraceerror: process didn't exit successfully: target\debug\piston-learn.exe (exit code: 101)`

ourabigdev avatar Dec 10 '23 15:12 ourabigdev