good-web-game: The `snake` example segfaults

cargo run --example snake causes a segmentation fault.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (3 by maintainers)

Most upvoted comments

I also reproduce this crash on my laptops. Windows 10.

  • Intel HD Graphics 4000
  • Nvidia GeForce GT 650M
  • NVIDIA GeForce GTX 1050 Ti

astroblasto works, snake is crashed. But when I comment drawing of actors and one line of text (score or level) in astroblasto example, it also crashes.

Minimal case for crash on my machine:

extern crate good_web_game as ggez;
use ggez::{graphics, Context, GameResult};

struct GameState {}

impl ggez::event::EventHandler for GameState {
    fn update(&mut self, _ctx: &mut Context) -> GameResult {
        Ok(())
    }

    fn draw(&mut self, ctx: &mut Context) -> GameResult {
        graphics::clear(ctx, [0.1, 0.2, 0.3, 1.0].into());
        let rect = graphics::Mesh::new_rectangle(
            ctx, graphics::DrawMode::fill(),
            graphics::Rect::new(0.0, 0.0, 32.0, 32.0),
            [1.0, 1.0, 1.0, 1.0].into())?;
        graphics::draw(ctx, &rect, (cgmath::Point2::new(0.0, 0.0),))?;
        graphics::present(ctx)?;
        Ok(())
    }
}

pub fn main() -> GameResult {
    ggez::start(
        ggez::conf::Conf {
            ..Default::default()
        },
        |_| Box::new(GameState{}),
    )
}

I investigate the difference between OpenGL calls made from ggez and from good-web-game (I used CodeXL for that), and noticed that ggez made a call to glDeleteBuffers immediately after SwapBuffers, but good-web-game did it right after DrawElementsInstanced. I think this can be reason of crash.