rust-windowing/glutin

Initializing specific OpenGL version (2.1)

HaronK opened this issue · 12 comments

HaronK commented

Hi, I'm trying to create an OpenGL context for the version 2.1 but always get 4.6. What parameters should I use?
My current code:

let context_attributes = ContextAttributesBuilder::new()
     .with_context_api(ContextApi::OpenGl(Some(Version::new(2, 1))))
     .build(raw_window_handle);

Do I need to set some additional parameters?

Are you using mesa? I've seen an issue like that as well and I'm not sure how to deal with it unless you set env variable in mesa yourself.

However what you're asking is just 2,1 version. You'd likely need a legacy profile because of that. Core can only go above 3, 1, iirc and mesa tends to pick the highest available one until you override version.

Will close since it's not a real issue.

The only thing I can imagine doing is to try apply legacy profile if the version is below lower boundary for core? If that's the thing you want I can add something like that, but with a new issue.

HaronK commented

Hi, thanks for the quick reply.
I'm on Linux (Manjaro) with proprietary NVidia drivers.

Do you mean GlProfile::Compatibility by legacy profile? I tried it and it didn't help.
Or do you talk about new Legacy variant in GlProfile enum?

Yeah, this thing. (sorry, it's indeed called compat, always forget the name for it)

Unfortunately, drivers tend to pick the version they want. I know that with mesa has a env variable just for that purpose to pick a version lower than you ask for with https://docs.mesa3d.org/envvars.html#envvar-MESA_GL_VERSION_OVERRIDE .

Also, picking 2,1 with compat profile is fine(if you even end up picking version higher) if you know that your app can run on 2, 1 version.

You could also try EGL if you just want to test whether 2,1 works or maybe you have some settings for the nvidia driver similar to mesa one I've linked.

HaronK commented

Do you mean Gles? That's the only other variant in ContextApi.
Tried it with version 2.1 and compatibility profile - same result :(

Hm, yeah, that's sad. I'd suggest EGL and if it doesn't work then you need to ask nvidia how to pick lower profile for testing...

I know that even if I ask for (3, 3) profile, mesa gives me 4.6. But gles works and I used to test on a gles 2.0 hardware like pinephone that things actually work...

If you could find how to do that with nvidia. We should probably live docs on how to try to force lower version than your drivers support. Since it's sometimes needed to test whether the app actually works.

HaronK commented

I have switched to open source driver and now everything works. It still shows version 4.3 but it also supports 2.1.

The only thing I'm doubting is that SDL version of my code is working perfectly with nvidia driver...

I never looked into how SDL does things when it asks to asking for a context. You could probably compare the FFI calls we do, since it's all about the FFI in the end.

The only difference iirc is basically Core vs Compat profile, and the shader version you're compiling.

@HaronK you could limit open source drivers with the MESA_GLES_VERSION_OVERRIDE="2.0" MESA_GL_VERSION_OVERRIDE="2.0" (or just keep the GL variable).

Whether it'll be able to actually use what you want is GPU dependant. You could try though LIBGL_ALWAYS_SOFTWARE=1 which forces llvmpipe and I think it has basically everything.

HaronK commented

Software drivers are definitely not an option.
For now it works good enough so I can concentrate on other parts.
I'll check this again when I'll start graphics subsystem refactoring.
Thanks for the help @kchibisov !

I thought that you simply wanted to test whether it works or not at all. I don't suggest to actually always use it for anything besides OpenGL testing.