From 6c0ad949be979d5fed95a1166d59100f7bf5580f Mon Sep 17 00:00:00 2001
From: Sven Gothel
- * If a {@link javax.media.opengl.GLAnimatorControl} is registered, or if it's not animating, the default situation,
+ * If no {@link javax.media.opengl.GLAnimatorControl} is registered, or if it is not animating, the default situation,
* or if the current thread is the animator thread,
- * a {@link #display()} call has to be issued after enqueue the GLRunnable
.
- * No extra synchronization must be performed in case wait
is true, since it is executed in the current thread.
GLRunnable
.wait
is true, since it is executed in the current thread.
*
* If {@link javax.media.opengl.GLAnimatorControl} is registered and is animating,
- * no call of {@link #display()} must be issued, since the animator thread will performs it.
- * If wait
is true, the implementation must wait until the GLRunnable
is executed.
+ * no {@link #display()} call is issued, since the animator thread performs it.
+ * If wait
is true, the implementation waits until the GLRunnable
is executed.
*
ARB_create_context
related: flag forward compatible */
protected static final int CTX_OPTION_FORWARD = 1 << 4;
- /** ARB_create_context
related: not flag forward compatible */
+ /** ARB_create_context
related: flag not forward compatible */
protected static final int CTX_OPTION_ANY = 1 << 5;
/** ARB_create_context
related: flag debug */
- protected static final int CTX_OPTION_DEBUG = 1 << 6;
+ public static final int CTX_OPTION_DEBUG = 1 << 6;
/** GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL software implementation */
protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 0;
@@ -419,6 +420,20 @@ public abstract class GLContext {
public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
+ /**
+ * @return Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
+ */
+ public abstract int getContextCreationFlags();
+
+ /**
+ * @param flags Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
+ * Unsupported flags are masked out.
+ * Only affects this context state if not created yet via {@link #makeCurrent()}.
+ * @see #enableGLDebugMessage(boolean)
+ * @see GLAutoDrawable#setContextCreationFlags(int)
+ */
+ public abstract void setContextCreationFlags(int flags);
+
/**
* Returns a valid OpenGL version string, ie@@ -516,6 +531,87 @@ public abstract class GLContext { return isGL2ES2() ; } + /** + * @return The extension implementing the GLDebugOutput feature, + * either GL_ARB_debug_output or GL_AMD_debug_output. + * If unavailable or called before initialized via {@link #makeCurrent()}, null is returned. + */ + public abstract String getGLDebugMessageExtension(); + + /** + * @return true if the GLDebugOutput feature is enabled or not. + */ + public abstract boolean isGLDebugMessageEnabled(); + + /** + * Enables or disables the GLDebugOutput feature of extension GL_ARB_debug_output + * or GL_AMD_debug_output, if available. + * + *To enable the GLDebugOutput feature {@link #enableGLDebugMessage(boolean) enableGLDebugMessage(true)} + * or {@link #setContextCreationFlags(int) setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG}) + * shall be called before context creation via {@link #makeCurrent()}!
+ * + *In case {@link GLAutoDrawable} are being used, + * {@link GLAutoDrawable#setContextCreationFlags(int) glAutoDrawable.setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG}) + * shall be issued before context creation via {@link #makeCurrent()}!
+ * + *After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method.
+ * + * @param enable If true enables, otherwise disables the GLDebugOutput feature. + * + * @throws GLException if this context is not current or GLDebugOutput registration failed (enable) + * + * @see #setContextCreationFlags(int) + * @see #addGLDebugListener(GLDebugListener) + * @see GLAutoDrawable#setContextCreationFlags(int) + */ + public abstract void enableGLDebugMessage(boolean enable) throws GLException; + + /** + * Add {@link GLDebugListener}.
+ * + * @param listener {@link GLDebugListener} handling {@GLDebugMessage}s + * @see #enableGLDebugMessage(boolean) + * @see #removeGLDebugListener(GLDebugListener) + */ + public abstract void addGLDebugListener(GLDebugListener listener); + + /** + * Remove {@link GLDebugListener}.
+ * + * @param listener {@link GLDebugListener} handling {@GLDebugMessage}s + * @see #enableGLDebugMessage(boolean) + * @see #addGLDebugListener(GLDebugListener) + */ + public abstract void removeGLDebugListener(GLDebugListener listener); + + /** + * @return number of added {@link GLDebugListener}. If > 0, the GLDebugFeature is turned on, otherwise off. + * @see #enableGLDebugMessage(boolean) + */ + public abstract int getGLDebugListenerSize(); + + /** + * Generic entry for {@link GL2GL3#glDebugMessageControlARB(int, int, int, int, IntBuffer, boolean)} + * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean)} of the GLDebugOutput feature. + * @see #enableGLDebugMessage(boolean) + */ + public abstract void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled); + + /** + * Generic entry for {@link GL2GL3#glDebugMessageControlARB(int, int, int, int, int[], int, boolean)} + * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, int[], int, boolean)} of the GLDebugOutput feature. + * @see #enableGLDebugMessage(boolean) + */ + public abstract void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled); + + /** + * Generic entry for {@link GL2GL3#glDebugMessageInsertARB(int, int, int, int, int, String)} + * and {@link GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String)} of the GLDebugOutput feature. + * @see #enableGLDebugMessage(boolean) + */ + public abstract void glDebugMessageInsert(int source, int type, int id, int severity, int length, String buf); + public static final int GL_VERSIONS[][] = { /* 0.*/ { -1 }, /* 1.*/ { 0, 1, 2, 3, 4, 5 }, @@ -750,7 +846,7 @@ public abstract class GLContext { public static String getGLVersion(int major, int minor, int ctp, String gl_version) { boolean needColon = false; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(major); sb.append("."); sb.append(minor); @@ -759,6 +855,7 @@ public abstract class GLContext { needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp )); needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp )); + needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp )); needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp )); needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp )); @@ -785,7 +882,7 @@ public abstract class GLContext { return "0x" + Long.toHexString(hex); } - private static boolean appendString(StringBuffer sb, String string, boolean needColon, boolean condition) { + private static boolean appendString(StringBuilder sb, String string, boolean needColon, boolean condition) { if(condition) { if(needColon) { sb.append(", "); diff --git a/src/jogl/classes/javax/media/opengl/GLDebugListener.java b/src/jogl/classes/javax/media/opengl/GLDebugListener.java new file mode 100644 index 000000000..8887d022a --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLDebugListener.java @@ -0,0 +1,44 @@ +/** + * 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 javax.media.opengl; + +/** + * Listener for {@link GLDebugMessage}s. + * + *One can enable GLDebugOutput via {@link GLContext#enableGLDebugMessage(boolean)} + * and add listeners via {@link GLContext#addGLDebugListener(GLDebugListener)}. + */ +public interface GLDebugListener { + /** + * Handle {@link GLDebugMessage} message sent from native GL implementation. + * + *
Since this method is invoked directly by the GL implementation, it shall + * return as fast as possible.
+ */ + void messageSent(GLDebugMessage event); +} diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java new file mode 100644 index 000000000..3ab0683c6 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -0,0 +1,248 @@ +/** + * 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 javax.media.opengl; + +import com.jogamp.common.os.Platform; + +public class GLDebugMessage { + final GLContext source; + final long when; + final int dbgSource; + final int dbgType; + final int dbgId; + final int dbgSeverity; + final String dbgMsg; + + /** + * @param source The source of the event + * @param when The time of the event + * @param dbgSource The ARB source + * @param dbgType The ARB type + * @param dbgId The ARB id + * @param dbgSeverity The ARB severity level + * @param dbgMsg The debug message + */ + public GLDebugMessage(GLContext source, long when, int dbgSource, int dbgType, int dbgId, int dbgSeverity, String dbgMsg) { + this.source = source; + this.when = when; + this.dbgSource = dbgSource; + this.dbgType = dbgType; + this.dbgId = dbgId; + this.dbgSeverity = dbgSeverity; + this.dbgMsg = dbgMsg; + } + + /** + * + * @param source + * @param when + * @param dbgId + * @param amdDbgCategory + * @param dbgSeverity AMD severity level equals ARB severity level (value and semantic) + * @param dbgMsg + * @return + */ + public static GLDebugMessage translateAMDEvent(GLContext source, long when, int dbgId, int amdDbgCategory, int dbgSeverity, String dbgMsg) { + int dbgSource, dbgType; + + // AMD category == ARB source/type + switch(amdDbgCategory) { + case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_API_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR_ARB; + break; + + // + // def source / other type + // + + case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + break; + + case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + break; + + case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + break; + + + // + // other source / def type + // + + case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB; + break; + + case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB; + break; + + case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB; + break; + + case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: + default: + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + } + + return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); + } + + public static int translateARB2AMDCategory(int dbgSource, int dbgType) { + switch (dbgSource) { + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; + + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD; + + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD; + } + + switch(dbgType) { + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD; + + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD; + + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: + return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD; + } + + return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD; + } + + public GLContext getSource() { + return source; + } + + public long getWhen() { + return when; + } + + public int getDbgSource() { + return dbgSource; + } + + public int getDbgType() { + return dbgType; + } + + public int getDbgId() { + return dbgId; + } + + public int getDbgSeverity() { + return dbgSeverity; + } + + public String getDbgMsg() { + return dbgMsg; + } + + public StringBuilder toString(StringBuilder sb) { + final String crtab = Platform.getNewline()+"\t"; + if(null==sb) { + sb = new StringBuilder(); + } + sb.append("GLDebugEvent[ id "); + toHexString(sb, dbgId) + .append(crtab).append("type ").append(getDbgTypeString(dbgType)) + .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity)) + .append(crtab).append("source ").append(getDbgSourceString(dbgSource)) + .append(crtab).append("msg ").append(dbgMsg) + .append(crtab).append("when ").append(when); + if(null != source) { + sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode())); + } + sb.append("]"); + return sb; + } + + public String toString() { + return toString(null).toString(); + } + + public static String getDbgSourceString(int dbgSource) { + switch(dbgSource) { + case GL2GL3.GL_DEBUG_SOURCE_API_ARB: return "GL API"; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: return "GLSL or extension compiler"; + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: return "Native Windowing binding"; + case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY_ARB: return "Third party"; + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: return "Application"; + case GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB: return "generic"; + default: return "Unknown (" + toHexString(dbgSource) + ")"; + } + } + + public static String getDbgTypeString(int dbgType) { + switch(dbgType) { + case GL2GL3.GL_DEBUG_TYPE_ERROR_ARB: return "Error"; + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: return "Warning: marked for deprecation"; + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: return "Warning: undefined behavior"; + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: return "Warning: implementation dependent performance"; + case GL2GL3.GL_DEBUG_TYPE_PORTABILITY_ARB: return "Warning: vendor-specific extension use"; + case GL2GL3.GL_DEBUG_TYPE_OTHER_ARB: return "Warning: generic"; + default: return "Unknown (" + toHexString(dbgType) + ")"; + } + } + + public static String getDbgSeverityString(int dbgSeverity) { + switch(dbgSeverity) { + case GL2GL3.GL_DEBUG_SEVERITY_HIGH_ARB: return "High: dangerous undefined behavior"; + case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB: return "Medium: Severe performance/deprecation/other warnings"; + case GL2GL3.GL_DEBUG_SEVERITY_LOW_ARB: return "Low: Performance warnings (redundancy/undefined)"; + default: return "Unknown (" + toHexString(dbgSeverity) + ")"; + } + } + + public static StringBuilder toHexString(StringBuilder sb, int i) { + if(null==sb) { + sb = new StringBuilder(); + } + return sb.append("0x").append(Integer.toHexString(i)); + } + public static String toHexString(int i) { + return "0x"+Integer.toHexString(i); + } + +} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index dc439f334..160cdce51 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -152,7 +152,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // copy of the cstr args, mainly for recreation private GLCapabilitiesImmutable capsReqUser; private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private GLContext shareWith; + private int additionalCtxCreationFlags = 0; private GraphicsDevice device; private AWTWindowClosingProtocol awtWindowClosingProtocol = @@ -525,6 +526,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing .createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig)); context = (GLContextImpl) drawable.createContext(shareWith); context.setSynchronized(true); + context.setContextCreationFlags(additionalCtxCreationFlags); } // before native peer is valid: X11 @@ -660,6 +662,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void setContext(GLContext ctx) { context=(GLContextImpl)ctx; + if(null != context) { + context.setContextCreationFlags(additionalCtxCreationFlags); + } } public GLContext getContext() { @@ -696,6 +701,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction); } + public void setContextCreationFlags(int flags) { + additionalCtxCreationFlags = flags; + } + + public int getContextCreationFlags() { + return additionalCtxCreationFlags; + } + public GLProfile getGLProfile() { return capsReqUser.getGLProfile(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index d58ad0304..2d58584f7 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -136,6 +136,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GLDrawableFactoryImpl factory; private GLCapabilitiesChooser chooser; private GLContext shareWith; + private int additionalCtxCreationFlags = 0; + // Width of the actual GLJPanel private int panelWidth = 0; private int panelHeight = 0; @@ -488,6 +490,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (backend == null) { return; } + if(null != ctx) { + ctx.setContextCreationFlags(additionalCtxCreationFlags); + } backend.setContext(ctx); } @@ -531,7 +536,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Swing portion of the GLJPanel in any of the rendering paths. return true; } - + public void swapBuffers() { // In the current implementation this is a no-op. Both the pbuffer // and pixmap based rendering paths use a single-buffered surface @@ -540,6 +545,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Swing portion of the GLJPanel in any of the rendering paths. } + public void setContextCreationFlags(int flags) { + additionalCtxCreationFlags = flags; + } + + public int getContextCreationFlags() { + return additionalCtxCreationFlags; + } + /** For a translucent GLJPanel (one for which {@link #setOpaque setOpaque}(false) has been called), indicates whether the application should preserve the OpenGL color buffer @@ -1023,6 +1036,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing Math.max(1, panelHeight)); offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith); offscreenContext.setSynchronized(true); + offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); + isInitialized = true; } @@ -1108,6 +1123,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing pbufferWidth, pbufferHeight, shareWith); + pbuffer.setContextCreationFlags(additionalCtxCreationFlags); pbuffer.addGLEventListener(updater); isInitialized = true; } catch (GLException e) { 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 GL_ARB_debug_output or GL_AMD_debug_output + * debug messages.
+ * + *An instance must be bound to the current thread's GLContext to achieve thread safety.
+ * + *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.
+ * + *In case no GL_ARB_debug_output is available, but GL_AMD_debug_output, + * the messages are translated to ARB {@link GLDebugMessage}, using {@link GLDebugMessage#translateAMDEvent(javax.media.opengl.GLContext, long, int, int, int, String)}.
+ */ +public class GLDebugMessageHandler { + /** Extension GL_ARB_debug_output implementing GLDebugMessage */ + public static final String GL_ARB_debug_output = "GL_ARB_debug_output".intern(); + + /** Extension GL_AMD_debug_output 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 ListenerSyncedImplStublistenerImpl; + + // 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 (); + 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 null 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 listeners = listenerImpl.getListeners(); + for(int i=0; i 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. + * + * Utilizing simple locking via synchronized.
+ * + * @paramThe listener type + */ +public class ListenerSyncedImplStub { + private ArrayList listeners; + + public ListenerSyncedImplStub() { + reset(); + } + + public synchronized final void reset() { + listeners = new ArrayList (); + } + + 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 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 -- cgit v1.2.3