SDL: How do I get a native handle to the OpenGL context

Started by
1 comment, last by blueshogun96 8 years, 1 month ago

My engine is using SDL2, and per platform, I'll need to do some OS specific tasks. Sometimes I'll be required to get the native handle to the OpenGL context directly, especially when it's necessary to access non-portable functionality. Example, for MacOSX (please don't troll) the accurate way to enumerate GPUs and their features is to use the low level APIs. For iOS, sometimes I need to do similar things.

So, is there a way to get a handle to the native OpenGL context for SDL 2.x? I tried googling, but I guess I haven't used the right keywords so far. Thanks.

Shogun.

Advertisement
Isn’t the SDL_GLContext object returned by SDL_GL_CreateContext() a direct OpenGL context object typdef’ed to a new type?


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Yes, I just figured that out last night. After looking through SDL's source code, it was quite blatant that for OSX, it just essentially casted it to void*.

Either way, I didn't realize that I could simply get the current context by calling this:


NSOpenGLContext* context = [NSOpenGLContext currentContext];

Live and learn.

Shogun.

This topic is closed to new replies.

Advertisement