PistonDevelopers / PistonDevelopers/piston

error when learning piston with roguelike tutorial

Open
#1,397 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.7k
Forks
235
Avg merge
1m
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Rust example in the issue, then inspect piston2d-opengl_graphics-0.83.0/src/back_end.rs at line 457 and the window setup in main. Done means the tutorial program creates its window, renders the red frame, and exits without the OpenGL function-pointer panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.