Re: New tutorial on AWT/SWT/Swing/GLJPanel/GLCanvas
Posted by
Wade Walker on
Feb 12, 2011; 6:31am
URL: https://forum.jogamp.org/New-tutorial-on-AWT-SWT-Swing-GLJPanel-GLCanvas-tp2363921p2478777.html
Sven Gothel wrote
Hence it 'breaks' the contract of providing a current _and_ usable HDC via wglGetCurrentDC().
Maybe this was never the contract?

JOGL 1 never uses any DC in GLDrawableFactory.createExternalGLContext(), which implies that it wasn't considered available. ExternalGLContext was purely a wrapper for the GLContext, without much extra info.
Also, I can't think how to make my example cross-platform. The hack I showed before:
int hDC = OS.GetDC( glcanvas.handle );
GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
OS.ReleaseDC(glcanvas.handle, hDC);
is Windows-only, since SWT GLCanvas doesn't contain a handle on Mac or Linux. The handle is actually supposed to be a private member, but SWT had to make it public to share it inside SWT's own packages.
My hack is also 32-bit only, since on 64-bit Windows the handle is a "long" instead of an "int". This is transparent inside SWT, but if you try to use the handle outside SWT, you expose that platform dependence. SWT actually modifies their source code at compile time to differentiate the 32-bit and 64-bit cases and create two separate JARs