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 941 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!