aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/FPSCounter.java117
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAnimatorControl.java42
-rw-r--r--src/jogl/classes/javax/media/opengl/GLArrayData.java37
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAutoDrawable.java23
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java149
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDebugListener.java44
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDebugMessage.java248
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java106
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java18
11 files changed, 676 insertions, 131 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index 9352ad4f3..52628f6fa 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -230,7 +230,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
// Don't substitute a positive score for a smaller negative score
if ((scoreClosestToZero == NO_SCORE) ||
(Math.abs(score) < Math.abs(scoreClosestToZero) &&
- ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
+ ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
scoreClosestToZero = score;
chosenIndex = i;
}
diff --git a/src/jogl/classes/javax/media/opengl/FPSCounter.java b/src/jogl/classes/javax/media/opengl/FPSCounter.java
new file mode 100644
index 000000000..9c07b58e4
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/FPSCounter.java
@@ -0,0 +1,117 @@
+/**
+ * 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 java.io.PrintStream;
+
+/**
+ * FPSCounter feature.<br>
+ * An implementation initially has the FPSCounter feature disabled.<br>
+ * Use {@link #setUpdateFPSFrames(int, PrintStream)} to enable and disable the FPSCounter feature.
+ */
+public interface FPSCounter {
+ public static final int DEFAULT_FRAMES_PER_INTERVAL = 5*60;
+
+ /**
+ * @param frames Update interval in frames.<br> At every rendered <i>frames</i> interval the currentTime and fps values are updated.
+ * If the <i>frames</i> interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose {@link #DEFAULT_FRAMES_PER_INTERVAL}.
+ * @param out optional print stream where the fps values gets printed if not null at every <i>frames</i> interval
+ */
+ void setUpdateFPSFrames(int frames, PrintStream out);
+
+ /**
+ * Reset all performance counter (startTime, currentTime, frame number)
+ */
+ void resetFPSCounter();
+
+ /**
+ * @return update interval in frames
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ */
+ int getUpdateFPSFrames();
+
+ /**
+ * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.<br>
+ * This value is reset via {@link #resetFPSCounter()}.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getFPSStartTime();
+
+ /**
+ * Returns the time of the last update interval in milliseconds, if this feature is enabled via {@link #setUpdateFPSFrames(int, PrintStream)}.<br>
+ * This value is reset via {@link #resetFPSCounter()}.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getLastFPSUpdateTime();
+
+ /**
+ * @return Duration of the last update interval in milliseconds.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getLastFPSPeriod();
+
+ /**
+ * @return Last update interval's frames per seconds, {@link #getUpdateFPSFrames()} / {@link #getLastFPSPeriod()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ float getLastFPS();
+
+ /**
+ * @return Number of frame rendered since {@link #getFPSStartTime()} up to {@link #getLastFPSUpdateTime()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ int getTotalFPSFrames();
+
+ /**
+ * @return Total duration in milliseconds, {@link #getLastFPSUpdateTime()} - {@link #getFPSStartTime()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getTotalFPSDuration();
+
+
+ /**
+ * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ float getTotalFPS();
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
index 2c8c7cca3..83e9e22c4 100644
--- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
+++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
@@ -32,47 +32,7 @@ package javax.media.opengl;
* An animator control interface,
* which implementation may drive a {@link javax.media.opengl.GLAutoDrawable} animation.
*/
-public interface GLAnimatorControl {
-
- /**
- * @return Time of the first display call in milliseconds.
- * This value is reset if started or resumed.
- *
- * @see #start()
- * @see #resume()
- */
- long getStartTime();
-
- /**
- * @return Time of the last display call in milliseconds.
- * This value is reset if started or resumed.
- *
- * @see #start()
- * @see #resume()
- */
- long getCurrentTime();
-
- /**
- * @return Duration <code>getCurrentTime() - getStartTime()</code>.
- *
- * @see #getStartTime()
- * @see #getCurrentTime()
- */
- long getDuration();
-
-
- /**
- * @return Number of frame cycles displayed
- * since the first display call, ie <code>getStartTime()</code>.
- * This value is reset if started or resumed.
- *
- * @see #start()
- * @see #resume()
- */
- int getTotalFrames();
-
- /** Reset all performance counter (startTime, currentTime, frame number) */
- public void resetCounter();
+public interface GLAnimatorControl extends FPSCounter {
/**
* Indicates whether this animator is running, ie. has been started and not stopped.
diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java
index 6c8122f27..448ddd10c 100644
--- a/src/jogl/classes/javax/media/opengl/GLArrayData.java
+++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java
@@ -37,7 +37,6 @@ import java.nio.*;
*
*/
public interface GLArrayData {
-
/**
* Returns true if this data set is intended for a GLSL vertex shader attribute,
* otherwise false, ie intended for fixed function vertex pointer
@@ -76,28 +75,41 @@ public interface GLArrayData {
* Sets the determined location of the shader attribute
* This is usually done within ShaderState.
*
- * @see com.jogamp.opengl.util.glsl.ShaderState#glVertexAttribPointer(GL2ES2, GLArrayData)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#vertexAttribPointer(GL2ES2, GLArrayData)
*/
public void setLocation(int v);
/**
- * Determines wheather the data is server side (VBO),
+ * Determines whether the data is server side (VBO) and enabled,
* or a client side array (false).
*/
public boolean isVBO();
/**
- * The offset, if it's an VBO, otherwise -1
+ * The VBO buffer offset or -1 if not a VBO
*/
- public long getOffset();
+ public long getVBOOffset();
/**
- * The VBO name, if it's an VBO, otherwise -1
+ * The VBO name or -1 if not a VBO
*/
public int getVBOName();
/**
- * The Buffer holding the data, may be null in case of VBO
+ * The VBO usage or -1 if not a VBO
+ * @return -1 if not a GPU buffer, otherwise {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
+ */
+ public int getVBOUsage();
+
+ /**
+ * The VBO target or -1 if not a VBO
+ * @return -1 if not a GPU buffer, otherwise {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ */
+ public int getVBOTarget();
+
+
+ /**
+ * The Buffer holding the data, may be null if a GPU buffer without client bound data
*/
public Buffer getBuffer();
@@ -112,14 +124,21 @@ public interface GLArrayData {
public int getComponentType();
/**
- * The components size in bytes
+ * The component's size in bytes
*/
public int getComponentSize();
/**
- * Return the number of elements.
+ * The current number of used elements.<br>
+ * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
*/
public int getElementNumber();
+
+ /**
+ * The current number of used bytes.<br>
+ * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
+ */
+ public int getByteSize();
/**
* True, if GL shall normalize fixed point data while converting
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index cf24d1028..90290d882 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -185,14 +185,14 @@ public interface GLAutoDrawable extends GLDrawable {
* Enqueues a one-shot {@link javax.media.opengl.GLRunnable},
* which will be executed with the next {@link #display()} call.</p>
* <p>
- * If a {@link javax.media.opengl.GLAnimatorControl} is registered, or if it's not animating, the default situation,<br>
+ * If no {@link javax.media.opengl.GLAnimatorControl} is registered, or if it is not animating, the default situation,<br>
* or if the current thread is the animator thread,<br>
- * a {@link #display()} call has to be issued after enqueue the <code>GLRunnable</code>.<br>
- * No extra synchronization must be performed in case <code>wait</code> is true, since it is executed in the current thread.</p>
+ * a {@link #display()} call is issued after enqueue the <code>GLRunnable</code>.<br>
+ * No extra synchronization is performed in case <code>wait</code> is true, since it is executed in the current thread.</p>
* <p>
* If {@link javax.media.opengl.GLAnimatorControl} is registered and is animating,<br>
- * no call of {@link #display()} must be issued, since the animator thread will performs it.<br>
- * If <code>wait</code> is true, the implementation must wait until the <code>GLRunnable</code> is executed.<br>
+ * no {@link #display()} call is issued, since the animator thread performs it.<br>
+ * If <code>wait</code> is true, the implementation waits until the <code>GLRunnable</code> is executed.<br>
* </p><br>
*
* @see #setAnimator(javax.media.opengl.GLAnimatorControl)
@@ -255,6 +255,19 @@ public interface GLAutoDrawable extends GLDrawable {
drawable. See {@link #setAutoSwapBufferMode}. */
public boolean getAutoSwapBufferMode();
+ /**
+ * @param flags Additional context creation flags.
+ *
+ * @see GLContext#setContextCreationFlags(int)
+ * @see GLContext#enableGLDebugMessage(boolean)
+ */
+ public void setContextCreationFlags(int flags);
+
+ /**
+ * @return Additional context creation flags
+ */
+ public int getContextCreationFlags();
+
/** Returns the {@link GL} pipeline object this GLAutoDrawable uses.
If this method is called outside of the {@link
GLEventListener}'s callback methods (init, display, etc.) it may
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index f5d47d27c..08bbcbb96 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -40,9 +40,13 @@
package javax.media.opengl;
+import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.HashSet;
import javax.media.nativewindow.AbstractGraphicsDevice;
+
+import com.jogamp.common.util.IntObjectHashMap;
+
import jogamp.opengl.Debug;
import jogamp.opengl.GLContextImpl;
@@ -81,19 +85,20 @@ public abstract class GLContext {
protected static final int CTX_PROFILE_ES = 1 << 3;
/** <code>ARB_create_context</code> related: flag forward compatible */
protected static final int CTX_OPTION_FORWARD = 1 << 4;
- /** <code>ARB_create_context</code> related: not flag forward compatible */
+ /** <code>ARB_create_context</code> related: flag not forward compatible */
protected static final int CTX_OPTION_ANY = 1 << 5;
/** <code>ARB_create_context</code> 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;
/** GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL hardware implementation */
protected static final int CTX_IMPL_ACCEL_HARD = 1 << 1;
- private static ThreadLocal currentContext = new ThreadLocal();
+ private static ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>();
- private HashMap/*<int, Object>*/ attachedObjects = new HashMap();
+ private HashMap<String, Object> attachedObjectsByString = new HashMap<String, Object>();
+ private IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap();
/** The underlying native OpenGL context */
protected long contextHandle;
@@ -112,9 +117,8 @@ public abstract class GLContext {
ctxMinorVersion=-1;
ctxOptions=0;
ctxVersionString=null;
- if(null!=attachedObjects) {
- attachedObjects.clear();
- }
+ attachedObjectsByString.clear();
+ attachedObjectsByInt.clear();
contextHandle=0;
}
@@ -248,7 +252,7 @@ public abstract class GLContext {
* is current.
*/
public static GLContext getCurrent() {
- return (GLContext) currentContext.get();
+ return currentContext.get();
}
/**
@@ -259,6 +263,15 @@ public abstract class GLContext {
}
/**
+ * @throws GLException if this GLContext is not current on this thread
+ */
+ public final void validateCurrent() throws GLException {
+ if(getCurrent() != this) {
+ throw new GLException("Given GL context not current");
+ }
+ }
+
+ /**
* Sets the thread-local variable returned by {@link #getCurrent}
* and has no other side-effects. For use by third parties adding
* new GLContext implementations; not for use by end users.
@@ -314,32 +327,40 @@ public abstract class GLContext {
* Returns the attached user object for the given name to this GLContext.
*/
public final Object getAttachedObject(int name) {
- return attachedObjects.get(new Integer(name));
+ return attachedObjectsByInt.get(name);
}
/**
* Returns the attached user object for the given name to this GLContext.
*/
public final Object getAttachedObject(String name) {
- return attachedObjects.get(name);
+ return attachedObjectsByString.get(name);
}
/**
* Sets the attached user object for the given name to this GLContext.
* Returns the previously set object or null.
*/
- public final Object putAttachedObject(int name, Object obj) {
- return attachedObjects.put(new Integer(name), obj);
+ public final Object attachObject(int name, Object obj) {
+ return attachedObjectsByInt.put(name, obj);
}
+ public final Object detachObject(int name) {
+ return attachedObjectsByInt.remove(name);
+ }
+
/**
* Sets the attached user object for the given name to this GLContext.
* Returns the previously set object or null.
*/
- public final Object putAttachedObject(String name, Object obj) {
- return attachedObjects.put(name, obj);
+ public final Object attachObject(String name, Object obj) {
+ return attachedObjectsByString.put(name, obj);
}
+ public final Object detachObject(String name) {
+ return attachedObjectsByString.remove(name);
+ }
+
/**
* Classname, GL, GLDrawable
*/
@@ -399,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<br>
* <pre>
@@ -496,6 +531,87 @@ public abstract class GLContext {
return isGL2ES2() ;
}
+ /**
+ * @return The extension implementing the GLDebugOutput feature,
+ * either <i>GL_ARB_debug_output</i> or <i>GL_AMD_debug_output</i>.
+ * If unavailable or called before initialized via {@link #makeCurrent()}, <i>null</i> 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 <i>GL_ARB_debug_output</i>
+ * or <i>GL_AMD_debug_output</i>, if available.
+ *
+ * <p>To enable the GLDebugOutput feature {@link #enableGLDebugMessage(boolean) enableGLDebugMessage(true)}
+ * or {@link #setContextCreationFlags(int) setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
+ * shall be called <b>before</b> context creation via {@link #makeCurrent()}!</p>
+ *
+ * <p>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()}!</p>
+ *
+ * <p>After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method.</p>
+ *
+ * @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}.<br>
+ *
+ * @param listener {@link GLDebugListener} handling {@GLDebugMessage}s
+ * @see #enableGLDebugMessage(boolean)
+ * @see #removeGLDebugListener(GLDebugListener)
+ */
+ public abstract void addGLDebugListener(GLDebugListener listener);
+
+ /**
+ * Remove {@link GLDebugListener}.<br>
+ *
+ * @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 },
@@ -730,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);
@@ -739,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 ));
@@ -765,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.
+ *
+ * <p>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.
+ *
+ * <p>Since this method is invoked directly by the GL implementation, it shall
+ * return as fast as possible.</p>
+ */
+ 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/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 17313f770..1921d117b 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -353,22 +353,23 @@ public class GLProfile {
* All GL Profiles in the order of default detection.
* Desktop compatibility profiles (the one with fixed function pipeline) comes first
* from highest to lowest version.
+ * <p> This includes the generic subset profiles GL2GL3, GL2ES2 and GL2ES1.</p>
*
* <ul>
* <li> GL4bc
* <li> GL3bc
* <li> GL2
- * <li> GL2GL3
* <li> GL4
* <li> GL3
- * <li> GL2ES2
+ * <li> GL2GL3
* <li> GLES2
- * <li> GL2ES1
+ * <li> GL2ES2
* <li> GLES1
+ * <li> GL2ES1
* </ul>
*
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL2GL3, GL4, GL3, GL2ES2, GLES2, GL2ES1, GLES1 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 };
/**
* Order of maximum profiles.
@@ -379,15 +380,12 @@ public class GLProfile {
* <li> GL3bc
* <li> GL3
* <li> GL2
- * <li> GL2GL3
- * <li> GL2ES2
* <li> GLES2
- * <li> GL2ES1
* <li> GLES1
* </ul>
*
*/
- public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL2ES2, GLES2, GL2ES1, GLES1 };
+ public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2, GLES1 };
/**
* Order of minimum original desktop profiles.
@@ -410,56 +408,40 @@ public class GLProfile {
* <li> GL4bc
* <li> GL3bc
* <li> GL2
- * <li> GL2ES1
* <li> GLES1
* </ul>
*
*/
- public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GL2ES1, GLES1 };
+ public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GLES1 };
/**
* Order of maximum programmable shader profiles
*
* <ul>
- * <li> GL4
* <li> GL4bc
- * <li> GL3
+ * <li> GL4
* <li> GL3bc
+ * <li> GL3
* <li> GL2
- * <li> GL2ES2
* <li> GLES2
* </ul>
*
*/
- public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GL2ES2, GLES2 };
+ public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2 };
/**
* All GL2ES2 Profiles in the order of default detection.
*
- * <ul>
- * <li> GL2ES2
- * <li> GL2
- * <li> GL3
- * <li> GL4
- * <li> GLES2
- * </ul>
- *
+ * @see #GL_PROFILE_LIST_MAX_PROGSHADER
*/
- public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL4, GL3, GL2, GLES2 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = GL_PROFILE_LIST_MAX_PROGSHADER;
/**
* All GL2ES1 Profiles in the order of default detection.
*
- * <ul>
- * <li> GL2ES1
- * <li> GL2
- * <li> GL3bc
- * <li> GL4bc
- * <li> GLES1
- * </ul>
- *
+ * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
*/
- public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL4bc, GL3bc, GL2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_GL2ES1 = GL_PROFILE_LIST_MAX_FIXEDFUNC;
/**
* All GLES Profiles in the order of default detection.
@@ -568,9 +550,9 @@ public class GLProfile {
}
/**
- * Returns a profile, implementing the interface GL2ES1.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}
- *
+ * Returns an available GL2ES1 compatible profile.
+ * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}.
+ *
* @throws GLException if no implementation for the given profile is found.
* @see #GL_PROFILE_LIST_GL2ES1
*/
@@ -580,7 +562,13 @@ public class GLProfile {
return get(device, GL_PROFILE_LIST_GL2ES1);
}
- /** Uses the default device */
+ /**
+ * Returns an available GL2ES1 compatible profile.
+ * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES1
+ */
public static GLProfile getGL2ES1()
throws GLException
{
@@ -588,8 +576,8 @@ public class GLProfile {
}
/**
- * Returns a profile, implementing the interface GL2ES2.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}
+ * Returns an available GL2ES2 compatible profile.
+ * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}.
*
* @throws GLException if no implementation for the given profile is found.
* @see #GL_PROFILE_LIST_GL2ES2
@@ -600,7 +588,13 @@ public class GLProfile {
return get(device, GL_PROFILE_LIST_GL2ES2);
}
- /** Uses the default device */
+ /**
+ * Returns an available GL2ES2 compatible profile
+ * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES2
+ */
public static GLProfile getGL2ES2()
throws GLException
{
@@ -1458,7 +1452,7 @@ public class GLProfile {
System.err.println("GLProfile.init map "+device.getConnection()+", desktopCtxUndef "+desktopCtxUndef+", eglCtxUndef "+eglCtxUndef);
}
GLProfile defaultGLProfile = null;
- HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */);
+ HashMap<String, GLProfile> _mappedProfiles = new HashMap<String, GLProfile>(GL_PROFILE_LIST_ALL.length + 1 /* default */);
for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) {
String profile = GL_PROFILE_LIST_ALL[i];
String profileImpl = computeProfileImpl(device, profile, desktopCtxUndef, eglCtxUndef);
@@ -1493,12 +1487,12 @@ public class GLProfile {
private static String computeProfileImpl(AbstractGraphicsDevice device, String profile, boolean desktopCtxUndef, boolean eglCtxUndef) {
if (GL2ES1.equals(profile)) {
if(hasGL234Impl) {
- if(desktopCtxUndef || GLContext.isGL2Available(device)) {
- return GL2;
+ if(GLContext.isGL4bcAvailable(device)) {
+ return GL4bc;
} else if(GLContext.isGL3bcAvailable(device)) {
return GL3bc;
- } else if(GLContext.isGL4bcAvailable(device)) {
- return GL4bc;
+ } else if(desktopCtxUndef || GLContext.isGL2Available(device)) {
+ return GL2;
}
}
if(hasGLES1Impl && ( eglCtxUndef || GLContext.isGLES1Available(device))) {
@@ -1506,12 +1500,16 @@ public class GLProfile {
}
} else if (GL2ES2.equals(profile)) {
if(hasGL234Impl) {
- if(desktopCtxUndef || GLContext.isGL2Available(device)) {
- return GL2;
- } else if(GLContext.isGL3Available(device)) {
- return GL3;
+ if(GLContext.isGL4bcAvailable(device)) {
+ return GL4bc;
} else if(GLContext.isGL4Available(device)) {
return GL4;
+ } else if(GLContext.isGL3bcAvailable(device)) {
+ return GL3bc;
+ } else if(GLContext.isGL3Available(device)) {
+ return GL3;
+ } else if(desktopCtxUndef || GLContext.isGL2Available(device)) {
+ return GL2;
}
}
if(hasGLES2Impl && ( eglCtxUndef || GLContext.isGLES2Available(device))) {
@@ -1519,16 +1517,16 @@ public class GLProfile {
}
} else if(GL2GL3.equals(profile)) {
if(hasGL234Impl) {
- if(desktopCtxUndef || GLContext.isGL2Available(device)) {
- return GL2;
+ if(GLContext.isGL4bcAvailable(device)) {
+ return GL4bc;
+ } else if(GLContext.isGL4Available(device)) {
+ return GL4;
} else if(GLContext.isGL3bcAvailable(device)) {
return GL3bc;
- } else if(GLContext.isGL4bcAvailable(device)) {
- return GL4bc;
} else if(GLContext.isGL3Available(device)) {
return GL3;
- } else if(GLContext.isGL4Available(device)) {
- return GL4;
+ } else if(desktopCtxUndef || GLContext.isGL2Available(device)) {
+ return GL2;
}
}
} else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device))) {
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 4076dac54..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();
}
@@ -745,9 +758,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
@Override
public String toString() {
- final int dw = (null!=drawable) ? drawable.getWidth() : -1;
- final int dh = (null!=drawable) ? drawable.getHeight() : -1;
-
+ final int dw = (null!=drawable) ? drawable.getWidth() : -1;
+ final int dh = (null!=drawable) ? drawable.getHeight() : -1;
+
return "AWT-GLCanvas[Realized "+isRealized()+
",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+
",\n\tRealized "+isRealized()+
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) {