Get OpenGL Context Handle?
Get OpenGL Context Handle?
Is it possible to get the OpenGL context handle for a given OpenGlGadget? Is this what is returned by GadgetID() for an OpenGLGadget? I want to pass the context's handle for a specific OpenGLGadget to OpenGL code in a DLL (in a different language).
Re: Get OpenGL Context Handle?
if you're on Windows then you can use:
Code: Select all
SetGadgetAttribute(myGLgadget, #PB_OpenGL_SetContext, #True)
myContext = wglGetCurrentContext_()
Re: Get OpenGL Context Handle?
Thanks! I had seen that in various places; was wondering if I was missing something. Any cross-platform (or even platform-specific) code for the others anyone is aware of.
Anyone an OpenGL expert? Is it even necessary if the PB code and foreign (DLL) code are executing in the same thread? Seems contexts are specific to a thread, and only one can be current at a time? Can I just make the gadget's context current and then call the DLL function that will generate a frame?
Anyone an OpenGL expert? Is it even necessary if the PB code and foreign (DLL) code are executing in the same thread? Seems contexts are specific to a thread, and only one can be current at a time? Can I just make the gadget's context current and then call the DLL function that will generate a frame?
Re: Get OpenGL Context Handle?
I've not used it, but linux uses a glx prefix, so glxGetCurrentContext would be my guess.
The article here: https://www.khronos.org/opengl/wiki/Ope ... ithreading is on opengl & multi-threading that may be of some use.
The article here: https://www.khronos.org/opengl/wiki/Ope ... ithreading is on opengl & multi-threading that may be of some use.
Re: Get OpenGL Context Handle?
Thanks again! Browsing the khronos site, my understanding is that any OpenGL calls made in the current thread, regardless of whether the code is called in a DLL, will act on the current context, so I shouldn't need the handle. I'll give it a try.