diff options
9 files changed, 58 insertions, 93 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a93c2ed79..6fbba6adf 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,7 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -304,6 +304,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelGridAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -328,7 +329,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -384,7 +385,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 3f6eb01a0..d43da2c3e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -648,16 +648,19 @@ public abstract class GLContextImpl extends GLContext { } final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this); + final long shareWithHandle; if (null != shareWith) { shareWith.getDrawableImpl().lockSurface(); - // FIXME: - // Contemplate whether we shall 'fail' creating this context - // if 0==shareWith.getHandle(), since at this point - // both context are locked and current values are available. + shareWithHandle = shareWith.getHandle(); + if (0 == shareWithHandle) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context: "+this); + } + } else { + shareWithHandle = 0; } final boolean created; try { - created = createImpl(shareWith); // may throws exception if fails! + created = createImpl(shareWithHandle); // may throws exception if fails if( created && hasNoDefaultVAO() ) { final int[] tmp = new int[1]; final GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3(); @@ -748,13 +751,13 @@ public abstract class GLContextImpl extends GLContext { * @return the valid and current context if successful, or null * @throws GLException */ - protected abstract boolean createImpl(GLContextImpl sharedWith) throws GLException ; + protected abstract boolean createImpl(long sharedWithHandle) throws GLException ; /** * Platform dependent but harmonized implementation of the <code>ARB_create_context</code> * mechanism to create a context.<br> * - * This method is called from {@link #createContextARB}, {@link #createImpl(GLContextImpl)} .. {@link #makeCurrent()} .<br> + * This method is called from {@link #createContextARB}, {@link #createImpl(long)} .. {@link #makeCurrent()} .<br> * * The implementation shall verify this context with a * <code>MakeContextCurrent</code> call.<br> diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 2eb277f3f..903a4c461 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -155,12 +155,12 @@ public class EGLContext extends GLContextImpl { } @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { + protected boolean createImpl(final long shareWithHandle) throws GLException { final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); final long eglDisplay = config.getScreen().getDevice().getHandle(); final GLProfile glProfile = drawable.getGLProfile(); final long eglConfig = config.getNativeConfig(); - long shareWithHandle = EGL.EGL_NO_CONTEXT; + // 0 == EGL.EGL_NO_CONTEXT; if ( 0 == eglDisplay ) { throw new GLException("Error: attempted to create an OpenGL context without a display connection"); @@ -180,13 +180,6 @@ public class EGLContext extends GLContextImpl { } } - if (shareWith != null) { - shareWithHandle = shareWith.getHandle(); - if (shareWithHandle == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - } - final IntBuffer contextAttrsNIO; final int contextVersionReq, contextVersionAttr; { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 037aaca08..0d231b89d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -286,35 +286,19 @@ public class MacOSXCGLContext extends GLContextImpl return false; } - protected long createImplPreset(GLContextImpl shareWith) throws GLException { - long share = 0; - if (shareWith != null) { - // Change our OpenGL mode to match that of any share context before we create ourselves - setOpenGLMode(((MacOSXCGLContext)shareWith).getOpenGLMode()); - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned a NULL OpenGL context"); - } - } - - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); - GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - GLProfile glp = capabilitiesChosen.getGLProfile(); + @Override + protected boolean createImpl(final long shareWithHandle) throws GLException { + final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final GLProfile glp = capabilitiesChosen.getGLProfile(); if( glp.isGLES1() || glp.isGLES2() || glp.isGLES3() || ( glp.isGL3() && !isLionOrLater ) || ( glp.isGL4() && !isMavericksOrLater ) ) { throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp); } - - if (DEBUG) { - System.err.println("Share context is " + toHexString(share) + " for " + this); + if( 0 != shareWithHandle && GLBackendType.NSOPENGL != getOpenGLMode() ) { + throw new GLException("Context sharing only supported in mode "+GLBackendType.NSOPENGL+": "+this); } - return share; - } - - @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { - long share = createImplPreset(shareWith); - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); return 0 != contextHandle; } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index bb36a7219..448e3e221 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -84,7 +84,10 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { // GLPbuffer, a GLJPanel and a GLCanvas simultaneously) but should // be enough to get things off the ground. public enum GLBackendType { - NSOPENGL(0), CGL(1); + /** Default OpenGL Backend */ + NSOPENGL(0), + /** Alternative OpenGL Backend, only used for external context! */ + CGL(1); public final int id; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 5d036d45a..ebb0fc6d1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -50,7 +50,6 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import jogamp.nativewindow.WrappedSurface; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -118,7 +117,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { } @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { + protected boolean createImpl(final long shareWithHandle) throws GLException { return true; } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index b1e41624d..b214252c1 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -268,7 +268,7 @@ public class WindowsWGLContext extends GLContextImpl { * called by {@link #makeCurrentImpl()}. */ @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(long shareWithHandle) { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); @@ -278,18 +278,7 @@ public class WindowsWGLContext extends GLContextImpl { isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable if (DEBUG) { - System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+shareWith); - } - - // Windows can set up sharing of display lists after creation time - long share; - if ( null != shareWith ) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - } else { - share = 0; + System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+toHexString(shareWithHandle)); } boolean createContextARBTried = false; @@ -300,17 +289,17 @@ public class WindowsWGLContext extends GLContextImpl { if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { throw new GLException("Could not make Shared Context current: "+sharedContext); } - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); sharedContext.release(); if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); } } else { - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); } createContextARBTried = true; if ( DEBUG && 0 != contextHandle ) { - System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share); + System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+toHexString(shareWithHandle)); } } @@ -343,17 +332,17 @@ public class WindowsWGLContext extends GLContextImpl { } if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); createContextARBTried=true; if (DEBUG) { if( 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); } else { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); } } } else if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+ + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } @@ -362,7 +351,7 @@ public class WindowsWGLContext extends GLContextImpl { } if( 0 != contextHandle ) { - share = 0; // mark as shared thx to the ARB create method + shareWithHandle = 0; // mark as shared thx to the ARB create method if( 0 != temp_ctx ) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); @@ -387,16 +376,17 @@ public class WindowsWGLContext extends GLContextImpl { WGL.wglDeleteContext(contextHandle); throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); } - if( 0 != share ) { + if( 0 != shareWithHandle ) { + // Windows can set up sharing of display lists after creation time if using GDI // Only utilize the classic GDI 'wglShareLists' shared context method // for traditional non ARB context. - if ( !WGL.wglShareLists(share, contextHandle) ) { - throw new GLException("wglShareLists(" + toHexString(share) + + if ( !WGL.wglShareLists(shareWithHandle, contextHandle) ) { + throw new GLException("wglShareLists(" + toHexString(shareWithHandle) + ", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError()); } } if (DEBUG) { - System.err.println(getThreadName() + ": createImpl: OK (old) share "+share); + System.err.println(getThreadName() + ": createImpl: OK (old) share "+toHexString(shareWithHandle)); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 9b7b0f5ae..ff9363ca0 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -51,7 +51,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.nativewindow.WrappedSurface; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import com.jogamp.common.nio.Buffers; @@ -114,7 +113,7 @@ public class X11ExternalGLXContext extends X11GLXContext { } @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(final long shareWithHandle) { return true; } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 10f21f0c3..94620c4fc 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -283,7 +283,7 @@ public class X11GLXContext extends GLContextImpl { } @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(final long shareWithHandle) { boolean direct = true; // try direct always isDirect = false; // fall back @@ -293,15 +293,8 @@ public class X11GLXContext extends GLContextImpl { final X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContext(device); long display = device.getHandle(); - final long share; - if ( null != shareWith ) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - direct = GLX.glXIsDirect(display, share); - } else { - share = 0; + if ( 0 != shareWithHandle ) { + direct = GLX.glXIsDirect(display, shareWithHandle); } final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); @@ -313,7 +306,7 @@ public class X11GLXContext extends GLContextImpl { if(glp.isGL3()) { throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context"); } - contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct); + contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), shareWithHandle, direct); if ( 0 == contextHandle ) { throw new GLException(getThreadName()+": Unable to create context(0)"); } @@ -325,7 +318,7 @@ public class X11GLXContext extends GLContextImpl { } isDirect = GLX.glXIsDirect(display, contextHandle); if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct); + System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+toHexString(shareWithHandle)+", direct "+isDirect+"/"+direct); } return true; } @@ -334,10 +327,10 @@ public class X11GLXContext extends GLContextImpl { // utilize the shared context's GLXExt in case it was using the ARB method and it already exists if( null != sharedContext && sharedContext.isCreatedWithARBMethod() ) { - contextHandle = createContextARB(share, direct); + contextHandle = createContextARB(shareWithHandle, direct); createContextARBTried = true; if ( DEBUG && 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+toHexString(shareWithHandle)); } } @@ -345,7 +338,7 @@ public class X11GLXContext extends GLContextImpl { if( 0 == contextHandle ) { // To use GLX_ARB_create_context, we have to make a temp context current, // so we are able to use GetProcAddress - temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct); + temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, shareWithHandle, direct); if ( 0 == temp_ctx ) { throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)"); } @@ -360,17 +353,17 @@ public class X11GLXContext extends GLContextImpl { final boolean isExtARBCreateContextAvailable = isExtensionAvailable("GLX_ARB_create_context"); if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation - contextHandle = createContextARB(share, direct); + contextHandle = createContextARB(shareWithHandle, direct); createContextARBTried=true; if (DEBUG) { if( 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); } else { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); } } } else if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+ + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } @@ -404,7 +397,7 @@ public class X11GLXContext extends GLContextImpl { throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+toHexString(shareWithHandle)); } } isDirect = GLX.glXIsDirect(display, contextHandle); |