ggez: WindowError(SdlError("Could not create GL context"))
I compiled this code (the example from the website),
extern crate ggez;
use ggez::conf;
use ggez::event;
use ggez::{GameResult, Context};
use ggez::graphics;
use ggez::graphics::{Color, DrawMode, Point};
use std::time::Duration;
struct MainState {
pos_x: f32,
}
impl MainState {
fn new(ctx: &mut Context) -> GameResult<MainState> {
let s = MainState { pos_x: 0.0 };
Ok(s)
}
}
impl event::EventHandler for MainState {
fn update(&mut self, _ctx: &mut Context, _dt: Duration) -> GameResult<()> {
self.pos_x = self.pos_x % 800.0 + 1.0;
Ok(())
}
fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
graphics::clear(ctx);
graphics::circle(ctx, DrawMode::Fill, Point { x: self.pos_x, y: 380.0 }, 100.0, 32)?;
graphics::present(ctx);
Ok(())
}
}
pub fn main() {
let c = conf::Conf::new();
let ctx = &mut Context::load_from_conf("super_simple", "ggez", c).unwrap();
let state = &mut MainState::new(ctx).unwrap();
event::run(ctx, state).unwrap();
}
and it compiles fine, but when I try to run it, I get the following error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: WindowError(SdlError("Could not create GL context"))', /checkout/src/libcore/result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
I have tried a bunch of different examples and nothing seems to run. This seems to be related to #143 but I’m running on a pretty new machine, specs bellow.
OS: Arch Linux
Kernel: x86_64 Linux 4.13.7-1-ARCH
WM: i3
CPU: Intel Core i5-7200U @ 4x 3.1GHz [40.0°C]
GPU: Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2)
RAM: 2119MiB / 7856MiB
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 48 (27 by maintainers)
Commits related to this issue
- Updated FAQ and docs a lot Should close issue #217 and #194 — committed to ggez/ggez by icefoxen 7 years ago
FINALLY we got mesa 18.0 which should include a fix for this bug. Looking forward to mesa 18.0 hitting all the distros, then this issue should be history.
This sounds very much like a known regression of the intel i965 MESA driver from the 17.1 branch to the 17.2 branch. See my comment for the piston engine for more: https://github.com/PistonDevelopers/piston/issues/1202#issuecomment-338330125
For the users I suggest to obtain MESA 17.1 (e.g. by compiling it yourself). For the maintainers of ggez I suggest to add a non-srgb mode to work on intel hardware on MESA 17.2. Don’t please ping the MESA developers, they are already aware of the bug!
@cider-teeworlds If I started a patreon with the promise that I would work on making ggez support older hardware if people donated, would you donate? 😄
@AaronM04 the workaround that I apply is to downgrade to mesa 17.1: https://github.com/PistonDevelopers/piston/issues/1202#issuecomment-338331123
The 17.2 series has the bug as well as the 17.3 series. One has to wait for Mesa 18.0 to come out or compile mesa master 😕. But in order to get it working with mesa master you need to update the kernel component as well, for which the steps described in my post above are not enough.
I have the exact same problem but I don’t believe @FuzzyLitchi 's problem come from lack of openGL 3.3 support. Indeed my
glxinfo | grep -i openglreadsThe line that indicates the opengl version is
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.2.3, notOpenGL version string: 3.0 Mesa 17.2.3.Moreover the following code runs fine:
with the 0.29.1 version of the sdl2 crate.
This is another common question that needs to be documented somewhere well; we need an FAQ or such.
If you aren’t feeling adventerous enough to use bleeding-edge mesa, I was able to get the patch to apply against mesa 17.2.2 (the one in Ubuntu 17.10). I don’t recall every step of the process, but it went something like this:
srgba.patch.txt
I had to remove one hunk out of the upstream’s patch since it didn’t make sense in 17.2.
After doing that and rebooting, I was able to get a sample app running. So far my laptop hasn’t caught fire or anything so it’s probably OK 😃
You are optimistic about whether people check the issue tracker before posting things! But, can’t hurt.
Another one solution for Arch/Manjaro user’s:
/etc/pacman.conffile and enable mesa-git custom repository :sudo pacman -Syu mesa-git lib32-mesa-gitThis specific bug has little to do with the provided OpenGL version but rather with sRGB support. That’s it.
I solved this issue by upgrading mesa 17.2 to mesa 17.4 through oibaf’s PPA. This may not be as good as downgrading to mesa 17.1 because I’m running bleeding-edge code hot off the mesa git repo:
See https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers
This bug is fixed for me (and for everyone I hope) in Mesa master. So this issue should be closed.
A lot of the innards have been reworked in commit 83561845a53667fae2611bf14b799654b0235a76 and the few previous ones. It might still take some rearranging, and it will definitely involve an API break.
GraphicsContextneeds to be generic on the color type, since it has to store the surface format information somewhere and it has to be known at compile time for many of gfx-rs’s functions, and the ability to go from compile-time to run-time and back is still rather awkward.What we probably have to do is either make
Contextgeneric on the color format, which seems somewhat silly and means you are going to have to do extra work to choose which color format to use at runtime, or to makeGraphicsContexta trait object, which is somewhat more work but makes it easier to choose at runtime.This seems to have been fixed with the latest
mesa 18.*. See https://github.com/PistonDevelopers/piston/issues/1202 for more information.@bestouff
Long story short, it’s not currently designed to be modified, hardcoding a different value would be Incorrect, and I’m not yet sure how to redesign it to be easily modified.
You’re right though, this is a setting that should be able to be toggled. #299 has been created.
I also ran into this issue. It would be great to have a way in
confto specify that an advanced graphics mode isn’t needed; my current project just needs to draw pixels, rectangles, and text on the screen, and it would be great to be able to signal that to GGEZ so I can fall back to basics in terms of OpenGL.In any case, many thanks for all the help on this project.
@ibrokemypie Yeah, looks like it. So that confirms that Mesa 17.3 has this issue as well… 😦