Friday, November 22, 2024

graphics – How to get Apple Silicon to recognize GL Legacy (OpenGL 2.1) extensions?

I’m porting a project from Linux/Windows to macOS and successfully patched it enough to get the final executable compiled on macOS Sonoma 14.6.1 on a M1 MacBookPro.

The program is probing for four OpenGL extensions: GL_ARB_shader_objects, GL_ARB_shading_language_100, GL_ARB_vertex_shader and GL_ARB_fragment_shader and throws an error.

I did some research and if I understand this page correctly, it is probing for OpenGL 2.1

I downloaded an app called GLview pro and confirmed 3 contexts are available: GL Legacy GL Core 3 and GL Core 4 (the last two might be one considering they both resolve to OpenGL 4.1)

I am under the assumption my code is executing in the OpenGL 4.1 context and this is the reason I am getting an error during the probe.

I understand I can specify using a “compatibility profile” so I tried the following at the top of the init code:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

but the following statement still throws an error:

        if (!SDL_GL_ExtensionSupported("GL_ARB_shader_objects"))
        {
            LOG(LogError) << "GL Extensions not supported. GL_ARB_shader_objects";
            return false;
        }

First question I have: it my assumption correct in that I need to change profiles to access OpenGL 2.1 extensions?

Second question: What else can I do to help troubleshoot this issue?

Related Articles

Latest Articles