Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL 3.x context creation using SDL2 on OSX (Macbook Air 2012)

Tags:

macos

opengl

sdl

As far as I'm aware, the Macbook Air 2012 supports OpenGL 3.2. When using SDL 2.0 to create the OpenGL context, however, the context is only opengl version 2.1.

Is it possible for SDL 2.0 to create a GL 3.2 context?

like image 810
Captain Head Avatar asked Aug 14 '12 21:08

Captain Head


1 Answers

For everyone who still has this problem as of Wednesday, Oct 10th, SDL2 allows you to create an OpenGL 3.2 context on Macs running Mac OS X 10.7 (Lion) and up. You just need to add this code:

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

If you're running OS X 10.10, or the solution above still does not resolve the problem, changing the second line of the above example from

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

to

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

may work for you.

like image 120
David Greiner Avatar answered Sep 28 '22 10:09

David Greiner