Initialize OpenGL 4.x without ToolKit


I’ve converted from DirectX 11 to OpenGL on OS X. Is there a way to initialize OpenGL without GLUT or without some other toolkit? I would like to initialize OpenGL on OS X using just the GL library. Is that possible? Ive searched couple days now and MAC world seems to use a toolkit.

I have installed and running XCode, using the GL framework on OS X 10.9.5.

I would like to initialize OpenGL on OS X using just the GL library.

That’s not possible. OpenGL defines the behavior of the OpenGL system. It does not describe how to initialize it. That’s done by platform-specific code.

You don’t have to use FreeGLUT specifically (no matter what, don’t use the regular GLUT. It’s way out of date). Nor do you have to use GLFW or some other library. But if you don’t use a platform-neutral abstraction library, then you’re going to have to use platform specific code to do it.

thx, that makes sense. I guess what I am looking for is how to define the attributes and create a window which is not part of the OpenGL role. I am looking in the wrong location and should be addressing this issue with the XCode group. I don’t mind so much using GLFW as Ive done this on linux. Maybe will have to go that route.

You can use the same mechanisms as those toolkits use. In general, the only libraries which you can’t realistically replace with your own equivalent code are those which form part of the OS itself.

Creating the window is done using Carbon or Cocoa. Creating and managing OpenGL contexts is done using either the AGL functions (for Carbon) or NSOpenGLContext etc (for Cocoa).

If you want the details, look at the source code for GLUT/GLFW/SDL/SFML or a GUI toolkit (Qt, GTK, wxWidgets, etc) which includes OpenGL support.

The main advantage of using a toolkit is that it makes it easy to write cross-platform code. While OpenGL itself is highly platform-independent, window/context handling is quite the opposite.