Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when learning piston with roguelike tutorial #1397

Open
ourabigdev opened this issue Dec 10, 2023 · 0 comments
Open

error when learning piston with roguelike tutorial #1397

ourabigdev opened this issue Dec 10, 2023 · 0 comments

Comments

@ourabigdev
Copy link

`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)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant