aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-01-24 17:24:22 +0100
committerSven Gothel <[email protected]>2013-01-24 17:24:22 +0100
commitb738983638703bb721ee4c9820c8ef43e2252e73 (patch)
tree5543e1be50c497619b6902676e7f66fdfaea78cd /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parent85d70b7d38885fa8ba6374aa790d5a296acc8ec1 (diff)
Bug 665 (part 1) - Allow dis-association of GLContext's GLDrawable ..
Changes allowing re-association (incl. null) of GLContext/GLDrawable: - GLAutoDrawable: Refine API doc 'setContext(..)' - GLContext: Refine API doc: 'setGLDrawable(..)' 'getGLDrawable()' - GLContextImpl.setGLDrawable(): Handle null drawable - GLAutoDrawableDelegate/GLAutoDrawableBase: Allow null GLContext - GLDrawableHelper.switchContext(..)/recreateGLDrawable(): Balance GLContext.setGLDrawable(..) calls - New GLEventListenerState, holding state vector [GLEventListener, GLContext, .. ] impl. relocation of all components from/to GLAutoDrawable. - GLDrawableUtil - Using GLEventListenerState for swapGLContextAndAllGLEventListener(..) +++ NEWT Window*: - getDisplayHandle() is 'final', no more 'shortcut' code allowed due to re-association incl. display handle. - close*: - close config's device (was missing) - null config +++ Changes allowing reconfig of Display handle as required to re-associate pre-existing GLContext to a 'window': - AbstractGraphicsDevice: Add isHandleOwner() / clearHandleOwner() - Impl. in X11GraphicsDevice and EGLGraphicsDevice, NOP in DefaultGraphicsDevice - DefaultGraphicsConfiguration add 'setScreen(..)' - MutableGraphicsConfiguration - Make DefaultGraphicsConfiguration.setScreen(..) public - NativeWindowFactory add 'createScreen(String type, AbstractGraphicsDevice device, int screen)' - Refactored from SWTAccessor - NativeWindow x11ErrorHandler: Dump Stack Trace in DEBUG mode, always.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index f2c2cfada..2a2b6a8fd 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -203,8 +203,8 @@ public abstract class GLContextImpl extends GLContext {
@Override
public final GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly) {
- if(null==readWrite) {
- throw new GLException("Null read/write drawable not allowed");
+ if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) {
+ return drawable; // no change.
}
final boolean lockHeld = lock.isOwner(Thread.currentThread());
if(lockHeld) {
@@ -212,16 +212,20 @@ public abstract class GLContextImpl extends GLContext {
} else if(lock.isLockedByOtherThread()) { // still could glitch ..
throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed.");
}
- if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable
+ if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable
drawableRead = (GLDrawableImpl) readWrite;
}
final GLDrawableImpl old = drawable;
- old.associateContext(this, false);
- drawableRetargeted = null != drawable;
+ if( null != old ) {
+ old.associateContext(this, false);
+ }
+ drawableRetargeted |= null != drawable && readWrite != drawable;
drawable = (GLDrawableImpl) readWrite ;
- drawable.associateContext(this, true);
- if(lockHeld) {
- makeCurrent();
+ if( null != drawable ) {
+ drawable.associateContext(this, true);
+ if( lockHeld ) {
+ makeCurrent();
+ }
}
return old;
}
@@ -334,7 +338,7 @@ public abstract class GLContextImpl extends GLContext {
", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
}
if (contextHandle != 0) {
- int lockRes = drawable.lockSurface();
+ final int lockRes = drawable.lockSurface();
if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) {
// this would be odd ..
throw new GLException("Surface not ready to lock: "+drawable);
@@ -408,7 +412,7 @@ public abstract class GLContextImpl extends GLContext {
throw new GLException("Destination OpenGL context has not been created");
}
- int lockRes = drawable.lockSurface();
+ final int lockRes = drawable.lockSurface();
if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) {
// this would be odd ..
throw new GLException("Surface not ready to lock");