cristicbz / rust-doom

A Doom Renderer written in Rust.
Apache License 2.0
2.34k stars 96 forks source link

"Could not create GL context" error on startup for GL 3.0 #58

Closed edward-san closed 8 years ago

edward-san commented 8 years ago

Since commit 65dbb735249badebce7298ba97a8490d2bc20506 , when I try to run rs_doom, compiled with nightly rustc (1.6.0-nightly (8ca0acc25 2015-10-28)), I get this message:

$ target/debug/rs_doom
rs_doom: graphics error: SDL: SDL error: Could not create GL context

I'm on Ubuntu 14.04 x86_64, running on this laptop with the following specs:

CPU: Intel Core i3-2328M GPU: Intel Sandybridge Mobile

the mesa driver supports Opengl 3.0 and 3.1(core profile), if it might help.

cristicbz commented 8 years ago

I was worried about this; I did a little compatibility survey on #rust-gamedev and it seemed fine though. I bumped the OpenGL requirement to 3.3, but I guess I shouldn't have.

The reason I had to do this was because I'm using a BUFFER_TEXTURE instead of a uniform array in static.vert because glium doesn't support uniform arrays (they're slightly obsolete in a sense, thanks to uniform blocks and buffer textures).

I should try switching back to a uniform array with a glium workaround. I'll have a look tonight, sorry about the breakage! :(

cristicbz commented 8 years ago

Hi @edward-san ! Sorry it took me a while to get to this; I merged #64 which (since you mention your drivers support 3.1 core), should make it work on your machine again. Could you please try and let me know? Thanks!

edward-san commented 8 years ago

Yes, it opens fine, but the rendering is now different from before. See this screenshot:

rust-doom_wrong_gamma

cristicbz commented 8 years ago

Is the problem that 'washed-out'-ness? Can't easily tell from the screenshot.

cristicbz commented 8 years ago

Would you mind checking out the old version (say git checkout 151b93a2d92c46aa8002edf69970dbe54c1f7637) and send me a comparison screenshot, please?

edward-san commented 8 years ago

Oops, sorry for that. Here:

rust_doom_before_glium

cristicbz commented 8 years ago

Thanks a lot @edward-san ! Good news is I managed to reproduce this by using my laptop's nvidia card instead of the integrated one. I'll try to find what's happening; working theory: BUFFER_TEXTURE is used to just store numbers, but it is a texture so sRGB correction hits somewhere where it didn't used to, muddling everything up.

MagaTailor commented 8 years ago

Is there a way to disable the shader stuff so it could be run on OpenGL 1.x?

This way it could even start working on GLES arm devices using the glshim wrapper.

cristicbz commented 8 years ago

@petevine In short, not easily: glium (the library used for OpenGL calls) doesn't support the fixed function pipeline and even if it did it's not clear that it would be easy to achieve all the effects needed using it. You're better off with a software renderer at that point. If you have some ideas or want to discuss this further, could you please file a different issue?

cristicbz commented 8 years ago

Regarding this actual issue. Having investigated more, it seems to be entirely unrelated to the buffer texture thing: even just clearing the screen looks different. The bug is triggered only by running the glium version with the nvidia card. Switching to the pre-glium version of the code or to the integrated gpu both fix it.

New theory: something in the initialisation of glium messes with gamma/brightness somehow.

cristicbz commented 8 years ago

OK so the issue was that if the device is SRGB capable, then glium assumes an SRGB framebuffer by default. I had to change everything to use SRGB everywhere and that seems to have fixed it on my nvidia card.

@edward-san Could you please check whether this works for you now?

edward-san commented 8 years ago

@cristicbz yes, it fixed the issue.

cristicbz commented 8 years ago

Yay, great, thanks for filing and being patient!