A fork of libsdl-1.2.15 that adds support for creating OpenGL Core Profile contexts on OSX.
Mac OS X 10.8 (Mountain Lion) implements the OpenGL 3.2 Core profile. The way to access this feature, however, is by creating a forward-compatible-only OpenGL Context when the application creates its window.
Some popular libraries, like SDL in its version 1.2, do not include the ability to request the Operating System to create forward-compatible OpenGL profiles. The next major release of SDL (2.0) will address this problem, however, some toolkits built on SDL 1.2 may not transition instantly to 2.0.
This project adds SDL 1.2 the ability to create OpenGL Core profiles under Mac OS X. The aim for the future is to add support for other platforms such as Windows (though WGL) and Linux (through GLX).
Modern Mac OS X versions do not ship with X, therefore you might want to configure SDL to be built without X.
In order to do this, first create a directory where the build files are to be created (for instance "build"), then cd into that directory and run configure with the following options:
../configure --prefix=<build destination> --disable-video-x11 --disable-x11-shared --without-x
Once configured, just type make && make install
to install to your specified build destination.
The new SDL_OPENGLCORE
macro has been defined to create an OpenGL Core Profile Context. The following program creates a window with a backing OpenGL Core Profile context, prints the OpenGL Version and quits:
#include <SDL.h>
#include <stdio.h>
#include <OpenGL/gl.h>
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface* pSurface = SDL_SetVideoMode(600, 600, 32, SDL_OPENGL|SDL_OPENGLCORE);
printf("GL Version:%s\n", glGetString(GL_VERSION));
SDL_Quit();
return 0;
}
Note: remember to compile and link against your recently built SDL and not the standard 1.2 SDL.
If SDL was installed correctly and your system supports OpenGL 3.2, that is the version that should be printed by this program.
If you omit the SDL_OPENGLCORE
flag, SDL will by default create a legacy context, and the OpenGL version reported will be 2.1.
The SDK for Mac OS X 10.8 is required in order to build this library with OpenGL Core Profile Context support. Older SDKs do not include the flags needed to request such profile to be created.
If this case is detected, a #warning message will be printed while compiling the library and all OpenGL contexts created will be legacy, even if the SDL_OPENGLCORE flag is specified.
This library is distributed under a GNU LGPL v2 license. libsdl is property of the SDL team. Visit their site at libsdl.org.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.