Confused about what OpenGL context is being used with SDL

Hi all,
I have a question about SDL & OpenGL context creation. It may actually be a Linux question.

It relates to a thread I started on Stack Overflow here: Link.

I have an core i5 Dell laptop with a HD4000 GPU. glxinfo reports the following two OpenGL versions:

OpenGL3.3 and GLSL 3.3 as below…
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel® Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 17.0.3
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:

… and OpenGL 3.0 & GLSL 1.30
OpenGL version string: 3.0 Mesa 17.0.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)

If I use SDL to create a 3.2 or 3.3 context there are no errors. I then proceed to use #version 150 for the vertex and fragment shader code which throws a shader compilation error.

If I instead create a 3.0 context and use #version 130 for the shader code, there are no shader errors.

So it looks like SDL is using 3.0 Mesa 17.0.3 and not the Mesa DRI Intel® Ivybridge Mobile (3.3) for context creation. I’m confused why there are two driver paths?

BTW, by using GL3.2 and GLSL1.5 with the exact same source code on Win10 on the same hardware (Dual booting Win 10 and Ubuntu Gnome 17.04) it all works perfectly so it looks like a selected driver problem??

Can anyone shed some light on this?

Thanks in advance! :wink:


It looks like this got resolved on the stackoverflow question?

I think glxinfo shows you what OpenGL version you get if you request the core profile. They can be different because some vendors focus on the core and let the compatibility profile fall behind.

Oh, and SDL_GL_SetAttribute is indeed a no-op before any video driver got initialized. SDL_GL_GetAttribute even seems to crash before init. I’ll report this on the bug tracker.

Thank you for the clarification on the core/ compat versions.

So it looks like the reason I’m failing to get an OpenGL3.2 context then the subsquent GLSL 1.5 shader compilation failure because I’m setting the SDL_GL_SetAttribute before SDL_Init(). I will test this later and report back. :wink:

Yes, setting the GL attributes after SDL_Init fixed the problem. Thank you for your help!