Login  Register

Re: New tutorial on AWT/SWT/Swing/GLJPanel/GLCanvas

Posted by Sven Gothel on Feb 12, 2011; 8:56am
URL: https://forum.jogamp.org/New-tutorial-on-AWT-SWT-Swing-GLJPanel-GLCanvas-tp2363921p2479153.html

On Saturday, February 12, 2011 07:31:29 Wade Walker [via jogamp] wrote:
>
> 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(),
JOGL1 is hardly the reference here :)

But the semantics of MakeCurrent(context, drawable) for EGL, WGL, XGL, CGL ..
which imply a valid accessible drawable until release.
This is mentioned the the email I referenced ..

So Windows goes around this, render it somehow invalid, an SWT hack
to not have to release it later on - well :)

> which implies that it wasn't
> considered available. ExternalGLContext was purely a wrapper for the
> GLContext, without much extra info.

how to makecurrent/release w/o it ?

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

well, it is the platform's window handle, so its all cool.

>
> 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
autch :)

and I was wondering what that means .. /* long */ :)

hmm, so even we would need to use reflection for this one
to allow our code to stay platform independent.

well, I try with WindowFromDC(hdc) 1st as an attempt to fix this in the external context.

the right fix, real SWT binding later.

thank you for doing this with me, very helpful.

Cheers, Sven