Request specific OpenGL version?


#1

On Mac I’m trying to request a specific version of OpenGL before they deprecated client side vertex arrays (before 3.2 core) but I always get back version 4.1 from SDL. How can this be achieved?

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);	

SDL_CreateWindow(...)
SDL_GL_CreateContext(...)

writeln('OpenGL Version: ', glGetString(GL_VERSION));
writeln('GLSL Version: ', glGetString(GL_SHADING_LANGUAGE_VERSION));

Prints:

OpenGL Version: 4.1 INTEL-10.28.26
GLSL Version: 4.10


#2

On macOS, AFAIK you either get OpenGL 2.1, or a core profile with all of the deprecated stuff removed.
Just comment out your SDL_GL_SetAttribute calls and you should get 2.1.


#3

There’s no way to get 3.x on Mac? Why not, is it a bug or just a Mac thing? If I remove those I get GLSL 1.2 which is hard to even learn because it’s so old and unsupported. I wanted to use GL 3.1 so I could use client side arrays and make ported some code easier but if I go above 3.1 it’s deprecated and removed.


#4

It’s by design, AFAIK. For 3.x they only implement core profiles. Here is an explanation I found on reddit:


#5

I see, thanks Eric. It just so happens 3.2 deprecated client side vertex arrays so I need to go legacy (which means I can’t use shaders for GLES) or go full 4.x . That sucks but I need to bite the bullet and upgrade everything now.