PDA

View Full Version : Sharing a GL texture between DLLs



lostsoul
06-20-2004, 02:53 PM
I have a 2D GUI that renders windows in orthomode,
and this class is in it's own DLL. Now i want
to make a 3D-renderer, put it in a separete DLL,
render all 3D-stuff to a GL texture and then
draw the texture in one of my GUI windows
(or maybe give the position and size of the
window to the renderer and let it draw to the
destination directly, doesn't matter).
Is this possible? It's easy to do this if
the 2D GUI and the 3D-renderer are in the same
DLL, but i don't how to do this when they are
separetad. If i glBindTexture(0); in the
GUI DLL, is it the same texture if
i glBindTexture(0); in the renderer DLL?

(And when i say GUI i mean my own GUI rendered in
OpenGL, not X11, Win32 et.c. )

jwatte
06-20-2004, 04:43 PM
There is no special context per DLL in OpenGL. The only state that's stored is in the currently active context for the thread.

lostsoul
06-20-2004, 04:50 PM
So everything i do in one DLL affects all the
other DLLs?

plasmonster
06-20-2004, 08:06 PM
Sounds like what you want to do is simply share a render context between 2 dlls. Dll data aren't shared by default, for that you need to declare data in a special segment. I don't think this is what you need, though, as this is process related. You could simply pass around a pointer to a current context that anyone can render to. You could create this context in dll A, then pass it to dll B for rendering, for example.

edit:

various tweankies

lostsoul
06-21-2004, 05:24 AM
Thanks for the reply!
But how do i do that? Do i need to
wglMakeCurrent(hDC,hRC) every time i want a
DLL to render some stuff? Anything more i need
to do?

plasmonster
06-21-2004, 07:31 PM
I don't have enough information about your design to give you a good answer. Obviously, you will want to minimize context switching, but how you do this will depend on your design, perhaps even guide it (a topic for another forum).

Creating and rendering to a context created in a dll is a snap, nothing to it. Just treat the context the same way you'd treat any context, with love and tenderness.