Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

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

This topic is 1024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!