[SDL] [SDL 1.3] Create Opengl Context without window?

Eric Wing ewmailing at gmail.com
Sun Feb 19 21:03:03 PST 2012


On Mac, I don't believe it is required to have a window to create an
OpenGL context. (But I don't know if SDL can be made to work with this
without modification.)

There are multiple ways to create an OpenGL context on Mac, none of
them actually deal at the window level. NSOpenGLView is the highest
level API which contains a NSOpenGLContext. You can instantiate the
latter yourself if you don't want to go through the NSOpenGLView
class. Nowhere do these APIs necessarily require you to create an
instance of NSWindow.

At the lowest level, you can also create a CGLContextObh via CGLCreateContext.

Somewhere in between the two is newer alternative offshoot  is
CAOpenGLLayer. It deals more directly with CGLContextObj.

In all cases, you may need to declare the *PixelFormat to use
offscreen renderers when creating the context.


On 2/15/12, mbentrup <matthias.bentrup at googlemail.com> wrote:
> Since OpenGL 3.x (or if GLX_ARB_create_context/WGL_ARB_create_context is
> supported) you can use an OpenGL context without a window resp. drawable by
> calling glxMakeCurrent with drawable = None, but you still need a window to
> create the context.
>
> With older OpenGL you have to bind the context to a pixmap or pbuffer, which
> aren't supported by SDL, so you have to use the platform-specific functions.
>
> But if you create your context with glx functions anyway, why do you want to
> tie it to SDL ? Just make it current in your thread using the glx functions
> and use it.
>
>
>
>
>


-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/



More information about the SDL mailing list