summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-24 12:21:36 +0200
committerSven Gothel <[email protected]>2011-04-24 12:21:36 +0200
commit6c0ad949be979d5fed95a1166d59100f7bf5580f (patch)
treed69242fabf1f066d43418612209597616fba6cdd /src/jogl/classes/jogamp/opengl
parentea819ff768d507c37a981c1ab0bdc0cad32c6a87 (diff)
Add unified support for GL_ARB_debug_output and GL_AMD_debug_output.
If GL_ARB_debug_output is not available, but GL_AMD_debug_output exist, fallback to the latter, offering generic aliased methods translating the delta (AMD category <-> ARB source/type). Generic aliased methods reside in GLContext* Enable/Disable via GLContext and GLAutoDrawable. To enable the GLDebugOutput feature GLContext.enableGLDebugMessage(true) or GLContext.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG) shall be called _before_ context creation via GLContext.makeCurrent()! In case GLAutoDrawable is being used, GLAutoDrawable.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG) shall be issued before context creation via GLContext.makeCurrent()!. After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method. Verify both unit tests for usability.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java95
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java260
-rw-r--r--src/jogl/classes/jogamp/opengl/GLPbufferImpl.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java79
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java11
6 files changed, 452 insertions, 19 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index dcd42a3b4..167d4c64b 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -41,6 +41,7 @@
package jogamp.opengl;
import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -58,6 +59,8 @@ import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDebugListener;
+import javax.media.opengl.GLDebugMessage;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLException;
import javax.media.opengl.GLPipelineFactory;
@@ -87,7 +90,10 @@ public abstract class GLContextImpl extends GLContext {
private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet
private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker();
private GLStateTracker glStateTracker = new GLStateTracker();
-
+ /** currently only {@link GLContext#CTX_OPTION_DEBUG} is supported */
+ private int additionalCtxCreationFlags = 0;
+ private GLDebugMessageHandler glDebugHandler = null;
+
protected GLDrawableImpl drawable;
protected GLDrawableImpl drawableRead;
@@ -115,6 +121,8 @@ public abstract class GLContextImpl extends GLContext {
this.drawable = drawable;
this.drawableRead = drawable;
+
+ this.glDebugHandler = new GLDebugMessageHandler(this);
}
protected void resetStates() {
@@ -139,6 +147,7 @@ public abstract class GLContextImpl extends GLContext {
glProcAddressTable = null;
gl = null;
contextFQN = null;
+ additionalCtxCreationFlags = 0;
super.resetStates();
}
@@ -233,7 +242,10 @@ public abstract class GLContextImpl extends GLContext {
public final void destroy() {
if ( lock.isOwner() ) {
- // release current context
+ // release current context
+ if(null != glDebugHandler) {
+ glDebugHandler.enable(false);
+ }
release();
}
@@ -267,6 +279,7 @@ public abstract class GLContextImpl extends GLContext {
try {
destroyImpl();
contextHandle = 0;
+ glDebugHandler = null;
GLContextShareSet.contextDestroyed(this);
} finally {
drawable.unlockSurface();
@@ -385,6 +398,7 @@ public abstract class GLContextImpl extends GLContext {
if (res == CONTEXT_NOT_CURRENT) {
lock.unlock();
} else {
+ setCurrent(this);
if(res == CONTEXT_CURRENT_NEW) {
// check if the drawable's and the GL's GLProfile are equal
// throws an GLException if not
@@ -396,8 +410,8 @@ public abstract class GLContextImpl extends GLContext {
if(TRACE_GL) {
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) );
}
+ glDebugHandler.init(0 != (additionalCtxCreationFlags & GLContext.CTX_OPTION_DEBUG));
}
- setCurrent(this);
/* FIXME: refactor dependence on Java 2D / JOGL bridge
@@ -520,8 +534,7 @@ public abstract class GLContextImpl extends GLContext {
* @see #createContextARBImpl
* @see #destroyContextARBImpl
*/
- protected final long createContextARB(long share, boolean direct,
- int major[], int minor[], int ctp[])
+ protected final long createContextARB(long share, boolean direct)
{
AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice device = config.getScreen().getDevice();
@@ -554,6 +567,7 @@ public abstract class GLContextImpl extends GLContext {
if( GLContext.getAvailableGLVersion(device, reqMajor, compat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE,
_major, _minor, _ctp)) {
+ _ctp[0] |= additionalCtxCreationFlags;
_ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]);
if(0!=_ctx) {
setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0]);
@@ -1067,5 +1081,76 @@ public abstract class GLContextImpl extends GLContext {
public boolean hasWaiters() {
return lock.getWaitingThreadQueueSize()>0;
}
+
+ //---------------------------------------------------------------------------
+ // GL_ARB_debug_output, GL_AMD_debug_output helpers
+ //
+ public final String getGLDebugMessageExtension() {
+ return glDebugHandler.getExtension();
+ }
+
+ public final boolean isGLDebugMessageEnabled() {
+ return glDebugHandler.isEnabled();
+ }
+
+ public int getContextCreationFlags() {
+ return additionalCtxCreationFlags;
+ }
+
+ public void setContextCreationFlags(int flags) {
+ if(!isCreated()) {
+ additionalCtxCreationFlags = flags & GLContext.CTX_OPTION_DEBUG;
+ }
+ }
+
+ public void enableGLDebugMessage(boolean enable) throws GLException {
+ if(!isCreated()) {
+ if(enable) {
+ additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG;
+ } else {
+ additionalCtxCreationFlags &= ~GLContext.CTX_OPTION_DEBUG;
+ }
+ } else if(0 != (additionalCtxCreationFlags & GLContext.CTX_OPTION_DEBUG) &&
+ null != getGLDebugMessageExtension()) {
+ glDebugHandler.enable(enable);
+ }
+ }
+
+ public void addGLDebugListener(GLDebugListener listener) {
+ glDebugHandler.addListener(listener);
+ }
+
+ public void removeGLDebugListener(GLDebugListener listener) {
+ glDebugHandler.removeListener(listener);
+ }
+
+ public int getGLDebugListenerSize() {
+ return glDebugHandler.listenerSize();
+ }
+
+ public void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled) {
+ if(glDebugHandler.isExtensionARB()) {
+ gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, enabled);
+ } else if(glDebugHandler.isExtensionAMD()) {
+ gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, enabled);
+ }
+ }
+
+ public void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled) {
+ if(glDebugHandler.isExtensionARB()) {
+ gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, ids_offset, enabled);
+ } else if(glDebugHandler.isExtensionAMD()) {
+ gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, ids_offset, enabled);
+ }
+ }
+
+ public void glDebugMessageInsert(int source, int type, int id, int severity, int length, String buf) {
+ if(glDebugHandler.isExtensionARB()) {
+ gl.getGL2GL3().glDebugMessageInsertARB(source, type, id, severity, length, buf);
+ } else if(glDebugHandler.isExtensionAMD()) {
+ if(0>length) { length = 0; }
+ gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, length, buf);
+ }
+ }
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
new file mode 100644
index 000000000..70f523156
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
@@ -0,0 +1,260 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.opengl;
+
+import java.util.ArrayList;
+
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLDebugListener;
+import javax.media.opengl.GLDebugMessage;
+import javax.media.opengl.GLException;
+
+import com.jogamp.gluegen.runtime.ProcAddressTable;
+import jogamp.opengl.gl4.GL4bcProcAddressTable;
+
+/**
+ * The GLDebugMessageHandler, handling <i>GL_ARB_debug_output</i> or <i>GL_AMD_debug_output</i>
+ * debug messages.<br>
+ *
+ * <p>An instance must be bound to the current thread's GLContext to achieve thread safety.</p>
+ *
+ * <p>A native callback function is registered at {@link #enable(boolean) enable(true)},
+ * which forwards received messages to the added {@link GLDebugListener} directly.
+ * Hence the {@link GLDebugListener#messageSent(GLDebugMessage)} implementation shall
+ * return as fast as possible.</p>
+ *
+ * <p>In case no <i>GL_ARB_debug_output</i> is available, but <i>GL_AMD_debug_output</i>,
+ * the messages are translated to <i>ARB</i> {@link GLDebugMessage}, using {@link GLDebugMessage#translateAMDEvent(javax.media.opengl.GLContext, long, int, int, int, String)}.</p>
+ */
+public class GLDebugMessageHandler {
+ /** Extension <i>GL_ARB_debug_output</i> implementing GLDebugMessage */
+ public static final String GL_ARB_debug_output = "GL_ARB_debug_output".intern();
+
+ /** Extension <i>GL_AMD_debug_output</i> implementing GLDebugMessage */
+ public static final String GL_AMD_debug_output = "GL_AMD_debug_output".intern();
+
+ private static final boolean DEBUG = Debug.debug("GLDebugMessageHandler");
+
+ private static final int EXT_ARB = 1;
+ private static final int EXT_AMD = 2;
+
+ static {
+ if ( !initIDs0() ) {
+ throw new NativeWindowException("Failed to initialize GLDebugMessageHandler jmethodIDs");
+ }
+ }
+
+ private final GLContextImpl ctx;
+ private final ListenerSyncedImplStub<GLDebugListener> listenerImpl;
+
+ // licefycle: init - EOL
+ private String extName;
+ private int extType;
+ private long glDebugMessageCallbackProcAddress;
+ private boolean extAvailable;
+
+ // licefycle: enable - disable/EOL
+ private long handle;
+
+ /**
+ * @param ctx the associated GLContext
+ * @param glDebugExtension chosen extension to use
+ */
+ public GLDebugMessageHandler(GLContextImpl ctx) {
+ this.ctx = ctx;
+ this.listenerImpl = new ListenerSyncedImplStub<GLDebugListener>();
+ this.glDebugMessageCallbackProcAddress = 0;
+ this.extName = null;
+ this.extType = 0;
+ this.extAvailable = false;
+ this.handle = 0;
+ }
+
+ public void init(boolean enable) {
+ init();
+ if(isAvailable()) {
+ enableImpl(enable);
+ }
+ }
+
+ public void init() {
+ ctx.validateCurrent();
+ if( isAvailable()) {
+ return;
+ }
+
+ if( ctx.isExtensionAvailable(GL_ARB_debug_output) ) {
+ extName = GL_ARB_debug_output;
+ extType = EXT_ARB;
+ } else if( ctx.isExtensionAvailable(GL_AMD_debug_output) ) {
+ extName = GL_AMD_debug_output;
+ extType = EXT_AMD;
+ }
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: Using extension: <"+extName+">");
+ }
+
+ if(0 == extType) {
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: No extension available!");
+ }
+ return;
+ }
+
+ final ProcAddressTable procAddressTable = ctx.getGLProcAddressTable();
+ if( procAddressTable instanceof GL4bcProcAddressTable) {
+ final GL4bcProcAddressTable desktopProcAddressTable = (GL4bcProcAddressTable)procAddressTable;
+ switch(extType) {
+ case EXT_ARB:
+ glDebugMessageCallbackProcAddress = desktopProcAddressTable._addressof_glDebugMessageCallbackARB;
+ break;
+ case EXT_AMD:
+ glDebugMessageCallbackProcAddress = desktopProcAddressTable._addressof_glDebugMessageCallbackAMD;
+ break;
+ }
+ } else {
+ if(DEBUG) {
+ System.err.println("Non desktop context not supported");
+ }
+ }
+ extAvailable = 0 < extType && null != extName && 0 != glDebugMessageCallbackProcAddress;
+
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: extAvailable: "+extAvailable+", glDebugMessageCallback* : 0x"+Long.toHexString(glDebugMessageCallbackProcAddress));
+ }
+
+ if(!extAvailable) {
+ glDebugMessageCallbackProcAddress = 0;
+ }
+
+ handle = 0;
+ }
+
+ public final boolean isAvailable() { return extAvailable; }
+
+ /**
+ * @return The extension implementing the GLDebugMessage feature,
+ * either {@link #GL_ARB_debug_output} or {@link #GL_AMD_debug_output}.
+ * If unavailable <i>null</i> is returned.
+ */
+ public final String getExtension() {
+ return extName;
+ }
+
+ public final boolean isExtensionARB() {
+ return extName == GL_ARB_debug_output;
+ }
+
+ public final boolean isExtensionAMD() {
+ return extName == GL_AMD_debug_output;
+ }
+
+ /**
+ * @throws GLException if context not current or callback registration failed (enable)
+ */
+ public final void enable(boolean enable) throws GLException {
+ ctx.validateCurrent();
+ if(!isAvailable()) {
+ return;
+ }
+ enableImpl(enable);
+ }
+ final void enableImpl(boolean enable) throws GLException {
+ if(enable) {
+ if(0 == handle) {
+ handle = register0(glDebugMessageCallbackProcAddress, extType);
+ if(0 == handle) {
+ throw new GLException("Failed to register via \"glDebugMessageCallback*\" using "+extName);
+ }
+ }
+ } else {
+ if(0 != handle) {
+ unregister0(glDebugMessageCallbackProcAddress, handle);
+ handle = 0;
+ }
+ }
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: enable("+enable+") -> 0x" + Long.toHexString(handle));
+ }
+ }
+
+ public final boolean isEnabled() { return 0 != handle; }
+
+ public final int listenerSize() {
+ return listenerImpl.size();
+ }
+
+ public final void addListener(GLDebugListener listener) {
+ listenerImpl.addListener(-1, listener);
+ }
+
+ public final void addListener(int index, GLDebugListener listener) {
+ listenerImpl.addListener(index, listener);
+ }
+
+ public final void removeListener(GLDebugListener listener) {
+ listenerImpl.removeListener(listener);
+ }
+
+ private final void sendMessage(GLDebugMessage msg) {
+ synchronized(listenerImpl) {
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: "+msg);
+ }
+ final ArrayList<GLDebugListener> listeners = listenerImpl.getListeners();
+ for(int i=0; i<listeners.size(); i++) {
+ listeners.get(i).messageSent(msg);
+ }
+ }
+ }
+
+ //
+ // native -> java
+ //
+
+ protected final void glDebugMessageARB(int source, int type, int id, int severity, String msg) {
+ final GLDebugMessage event = new GLDebugMessage(ctx, System.currentTimeMillis(), source, type, id, severity, msg);
+ sendMessage(event);
+ }
+
+ protected final void glDebugMessageAMD(int id, int category, int severity, String msg) {
+ final GLDebugMessage event = GLDebugMessage.translateAMDEvent(ctx, System.currentTimeMillis(), id, category, severity, msg);
+ sendMessage(event);
+ }
+
+ //
+ // java -> native
+ //
+
+ private static native boolean initIDs0();
+ private native long register0(long glDebugMessageCallbackProcAddress, int extType);
+ private native void unregister0(long glDebugMessageCallbackProcAddress, long handle);
+}
+
+
diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
index 671390fbb..1d52bedbb 100644
--- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
@@ -64,6 +64,7 @@ public class GLPbufferImpl implements GLPbuffer {
private GLContextImpl context;
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
private int floatMode;
+ private int additionalCtxCreationFlags = 0;
public GLPbufferImpl(GLDrawableImpl pbufferDrawable,
GLContext parentContext) {
@@ -177,6 +178,9 @@ public class GLPbufferImpl implements GLPbuffer {
public void setContext(GLContext ctx) {
context=(GLContextImpl)ctx;
+ if(null != context) {
+ context.setContextCreationFlags(additionalCtxCreationFlags);
+ }
}
public GLContext getContext() {
@@ -207,6 +211,17 @@ public class GLPbufferImpl implements GLPbuffer {
invokeGL(swapBuffersAction);
}
+ public void setContextCreationFlags(int flags) {
+ additionalCtxCreationFlags = flags;
+ if(null != context) {
+ context.setContextCreationFlags(additionalCtxCreationFlags);
+ }
+ }
+
+ public int getContextCreationFlags() {
+ return additionalCtxCreationFlags;
+ }
+
public void bindTexture() {
// Doesn't make much sense to try to do this on the event dispatch
// thread given that it has to be called while the context is current
diff --git a/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java b/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java
new file mode 100644
index 000000000..1cde551be
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl;
+
+import java.util.ArrayList;
+
+/**
+ * Simple locked listener implementation stub to be used for listener handler,
+ * synchronized on it's instance.
+ *
+ * <p>Utilizing simple locking via synchronized.</p>
+ *
+ * @param <E> The listener type
+ */
+public class ListenerSyncedImplStub<E> {
+ private ArrayList<E> listeners;
+
+ public ListenerSyncedImplStub() {
+ reset();
+ }
+
+ public synchronized final void reset() {
+ listeners = new ArrayList<E>();
+ }
+
+ public synchronized final void destroy() {
+ listeners.clear();
+ listeners = null;
+ }
+
+ public synchronized final int size() {
+ return listeners.size();
+ }
+
+ public synchronized final void addListener(E listener) {
+ addListener(-1, listener);
+ }
+
+ public synchronized final void addListener(int index, E listener) {
+ if(0>index) {
+ index = listeners.size();
+ }
+ listeners.add(index, listener);
+ }
+
+ public synchronized final void removeListener(E listener) {
+ listeners.remove(listener);
+ }
+
+ public final ArrayList<E> getListeners() {
+ return listeners;
+ }
+}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 91a907a09..55e2e478c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -273,14 +273,11 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
- int minor[] = new int[1];
- int major[] = new int[1];
- int ctp[] = new int[1];
boolean createContextARBTried = false;
// 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, true, major, minor, ctp);
+ contextHandle = createContextARB(share, true);
createContextARBTried = true;
if (DEBUG && 0!=contextHandle) {
System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share);
@@ -306,7 +303,7 @@ public class WindowsWGLContext extends GLContextImpl {
if(isCreateContextAttribsARBAvailable &&
isExtensionAvailable("WGL_ARB_create_context") ) {
// initial ARB context creation
- contextHandle = createContextARB(share, true, major, minor, ctp);
+ contextHandle = createContextARB(share, true);
createContextARBTried=true;
if (DEBUG) {
if(0!=contextHandle) {
@@ -334,10 +331,10 @@ public class WindowsWGLContext extends GLContextImpl {
if(glCaps.getGLProfile().isGL3()) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_ctx);
- throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", ");
+ throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion()+", ");
}
if(DEBUG) {
- System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation"));
+ System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion());
}
// continue with temp context for GL < 3.0
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 119886838..9f6a5cd1a 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -318,14 +318,11 @@ public abstract class X11GLXContext extends GLContextImpl {
return true;
}
- int minor[] = new int[1];
- int major[] = new int[1];
- int ctp[] = new int[1];
boolean createContextARBTried = false;
// 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, major, minor, ctp);
+ contextHandle = createContextARB(share, direct);
createContextARBTried = true;
if (DEBUG && 0!=contextHandle) {
System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+share);
@@ -351,7 +348,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if ( isCreateContextAttribsARBAvailable &&
isExtensionAvailable("GLX_ARB_create_context") ) {
// initial ARB context creation
- contextHandle = createContextARB(share, direct, major, minor, ctp);
+ contextHandle = createContextARB(share, direct);
createContextARBTried=true;
if (DEBUG) {
if(0!=contextHandle) {
@@ -378,10 +375,10 @@ public abstract class X11GLXContext extends GLContextImpl {
if(glp.isGL3()) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
- throw new GLException("X11GLXContext.createContextImpl failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", ");
+ throw new GLException("X11GLXContext.createContextImpl failed, but context > GL2 requested "+getGLVersion()+", ");
}
if(DEBUG) {
- System.err.println("X11GLXContext.createContextImpl failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation"));
+ System.err.println("X11GLXContext.createContextImpl failed, fall back to !ARB context "+getGLVersion());
}
// continue with temp context for GL <= 3.0