Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set OpenGL context 3.3 with SDL2 on mac, not working

I have tried setting the OpenGL context to v3.3 using the following code, it creates a 4.1 context.

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

Am I doing something wrong or is it a mac problem?

like image 757
Craig Bradley Avatar asked Dec 05 '25 11:12

Craig Bradley


1 Answers

OpenGL does not provide any guarantees that when you ask for an OpenGL X.Y context, that you get exactly an OpenGL X.Y context. It depends on the drivers you use.

  • On OS X, if you ask for a core context, you get the highest version supported on your hardware and operating system combination. If you ask for a compatibility context, you get 2.1.

  • On my Linux/Mesa system, I always get 3.0 compatibility contexts, and 3.3 core contexts.

  • On my Windows/AMD system, I get the exactly the version I ask for.

The 4.1 context should work fine for you if your code assumes that the context is 3.3. Just check that the GL version is >= the version you need, and check that you have a compatibility context if you need it.

like image 52
Dietrich Epp Avatar answered Dec 08 '25 04:12

Dietrich Epp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!