aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/ExtensionAvailabilityCache.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java489
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/NativeLibLoader.java)13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java11
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java10
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java12
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java12
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java19
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java11
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java11
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java16
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java52
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java13
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java121
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java52
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java29
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/GL4.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/GL4bc.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java187
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java62
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java534
32 files changed, 1052 insertions, 660 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/ExtensionAvailabilityCache.java b/src/jogl/classes/com/jogamp/opengl/impl/ExtensionAvailabilityCache.java
index 082f006e8..1ed0396a9 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/ExtensionAvailabilityCache.java
@@ -174,12 +174,12 @@ public final class ExtensionAvailabilityCache {
major[0] = 3;
minor[0] = 0;
}
- while (GLProfile.isValidGLVersion(major[0], minor[0])) {
+ while (GLContext.isValidGLVersion(major[0], minor[0])) {
availableExtensionCache.add("GL_VERSION_" + major[0] + "_" + minor[0]);
if (DEBUG) {
System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major[0] + "_" + minor[0] + " to known extensions");
}
- if(!GLProfile.decrementGLVersion(major, minor)) break;
+ if(!GLContext.decrementGLVersion(major, minor)) break;
}
// put a dummy var in here so that the cache is no longer empty even if
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 8c5890d1e..3abb69a7f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -45,9 +45,10 @@ import java.util.*;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
-import com.jogamp.nativewindow.impl.NWReflection;
import com.jogamp.gluegen.runtime.*;
import com.jogamp.gluegen.runtime.opengl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.ReflectionUtil;
public abstract class GLContextImpl extends GLContext {
protected GLContextLock lock = new GLContextLock();
@@ -123,108 +124,137 @@ public abstract class GLContextImpl extends GLContext {
return (GLDrawableImpl) getGLDrawable();
}
- /**
- * Platform dependent but harmonized implementation of the <code>ARB_create_context</code>
- * mechanism to create a context.<br>
- * The implementation shall verify this context, ie issue a
- * <code>MakeCurrent</code> call if necessary.<br>
- *
- * @param share the shared context or null
- * @param direct flag if direct is requested
- * @param ctxOptionFlags <code>ARB_create_context</code> related, see references below
- * @param major major number
- * @param minor minor number
- * @return the valid context if successfull, or null
- *
- * @see #CTX_PROFILE_COMPAT
- * @see #CTX_OPTION_FORWARD
- * @see #CTX_OPTION_DEBUG
- */
- protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags,
- int major, int minor);
+ public final GL getGL() {
+ return gl;
+ }
- private long createContextARB(long share, boolean direct, int ctxOptionFlags,
- int majorMax, int minorMax,
- int majorMin, int minorMin,
- int major[], int minor[]) {
- major[0]=majorMax;
- minor[0]=minorMax;
- long _context=0;
+ public GL setGL(GL gl) {
+ if(DEBUG) {
+ String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("<null>");
+ String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():new String("<null>");
+ Exception e = new Exception("setGL (OpenGL "+getGLVersion()+"): "+Thread.currentThread()+", "+sgl1+" -> "+sgl2);
+ e.printStackTrace();
+ }
+ this.gl = gl;
+ return gl;
+ }
- while ( 0==_context &&
- GLProfile.isValidGLVersion(major[0], minor[0]) &&
- ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) {
+ // This is only needed for Mac OS X on-screen contexts
+ protected void update() throws GLException { }
- _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]);
+ public boolean isSynchronized() {
+ return !lock.getFailFastMode();
+ }
- if(0==_context) {
- if(!GLProfile.decrementGLVersion(major, minor)) break;
- }
+ public void setSynchronized(boolean isSynchronized) {
+ lock.setFailFastMode(!isSynchronized);
+ }
+
+ public abstract Object getPlatformGLExtensions();
+
+ public void release() throws GLException {
+ if (!lock.isHeld()) {
+ throw new GLException("Context not current on current thread");
+ }
+ setCurrent(null);
+ try {
+ releaseImpl();
+ } finally {
+ lock.unlock();
}
- return _context;
}
- /**
- * Platform independent part of using the <code>ARB_create_context</code>
- * mechanism to create a context.<br>
- */
- protected long createContextARB(long share, boolean direct,
- int major[], int minor[], int ctp[])
- {
- AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
- GLProfile glp = glCaps.getGLProfile();
- long _context = 0;
+ protected abstract void releaseImpl() throws GLException;
- ctp[0] = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default
- boolean isBackwardCompatibility = glp.isGL2() || glp.isGL3bc() || glp.isGL4bc() ;
- int majorMin, minorMin;
- int majorMax, minorMax;
- if( glp.isGL4() ) {
- // ?? majorMax=GLProfile.getMaxMajor(); minorMax=GLProfile.getMaxMinor(majorMax);
- majorMax=4; minorMax=GLProfile.getMaxMinor(majorMax);
- majorMin=4; minorMin=0;
- } else if( glp.isGL3() ) {
- majorMax=3; minorMax=GLProfile.getMaxMinor(majorMax);
- majorMin=3; minorMin=1;
- } else /* if( glp.isGL2() ) */ {
- majorMax=3; minorMax=0;
- majorMin=1; minorMin=1; // our minimum desktop OpenGL runtime requirements
+ public void destroy() {
+ if (lock.isHeld()) {
+ // release current context
+ release();
}
- // Try the requested ..
- if(isBackwardCompatibility) {
- ctp[0] &= ~CTX_PROFILE_CORE ;
- ctp[0] |= CTX_PROFILE_COMPAT ;
- }
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
-
- if(0==_context && !isBackwardCompatibility) {
- ctp[0] &= ~CTX_PROFILE_COMPAT ;
- ctp[0] |= CTX_PROFILE_CORE ;
- ctp[0] &= ~CTX_OPTION_ANY ;
- ctp[0] |= CTX_OPTION_FORWARD ;
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
- if(0==_context) {
- // Try a compatible one .. even though not requested .. last resort
- ctp[0] &= ~CTX_PROFILE_CORE ;
- ctp[0] |= CTX_PROFILE_COMPAT ;
- ctp[0] &= ~CTX_OPTION_FORWARD ;
- ctp[0] |= CTX_OPTION_ANY ;
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
- }
+
+ // Must hold the lock around the destroy operation to make sure we
+ // don't destroy the context out from under another thread rendering to it
+ lock.lock();
+ try {
+ /* FIXME: refactor dependence on Java 2D / JOGL bridge
+ if (tracker != null) {
+ // Don't need to do anything for contexts that haven't been
+ // created yet
+ if (isCreated()) {
+ // If we are tracking creation and destruction of server-side
+ // OpenGL objects, we must decrement the reference count of the
+ // GLObjectTracker upon context destruction.
+ //
+ // Note that we can only eagerly delete these server-side
+ // objects if there is another context currrent right now
+ // which shares textures and display lists with this one.
+ tracker.unref(deletedObjectTracker);
+ }
+ }
+ */
+
+ // Because we don't know how many other contexts we might be
+ // sharing with (and it seems too complicated to implement the
+ // GLObjectTracker's ref/unref scheme for the buffer-related
+ // optimizations), simply clear the cache of known buffers' sizes
+ // when we destroy contexts
+ if (bufferSizeTracker != null) {
+ bufferSizeTracker.clearCachedBufferSizes();
+ }
+
+ if (bufferStateTracker != null) {
+ bufferStateTracker.clearBufferObjectState();
+ }
+
+ if (glStateTracker != null) {
+ glStateTracker.clearStates(false);
+ }
+
+ destroyImpl();
+ } finally {
+ lock.unlock();
}
- return _context;
}
+ protected abstract void destroyImpl() throws GLException;
+
+ //----------------------------------------------------------------------
+ //
+
+ /**
+ * MakeCurrent functionality, which also issues the creation of the actual OpenGL context.<br>
+ * The complete callgraph for general OpenGL context creation is:<br>
+ * <ul>
+ * <li> {@link #makeCurrent} <i>GLContextImpl</i>
+ * <li> {@link #makeCurrentImpl} <i>Platform Implementation</i>
+ * <li> {@link #create} <i>Platform Implementation</i>
+ * <li> If <code>ARB_create_context</code> is supported:
+ * <ul>
+ * <li> {@link #createContextARB} <i>GLContextImpl</i>
+ * <li> {@link #createContextARBImpl} <i>Platform Implementation</i>
+ * </ul>
+ * </ul><br>
+ *
+ * Once at startup, ie triggered by the singleton {@link GLDrawableImpl} constructor,
+ * calling {@link #createContextARB} will query all available OpenGL versions:<br>
+ * <ul>
+ * <li> <code>FOR ALL GL* DO</code>:
+ * <ul>
+ * <li> {@link #createContextARBMapVersionsAvailable}
+ * <ul>
+ * <li> {@link #createContextARBVersions}
+ * </ul>
+ * <li> {@link #mapVersionAvailable}
+ * </ul>
+ * </ul><br>
+ *
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #mapVersionAvailable
+ * @see #destroyContextARBImpl
+ */
public int makeCurrent() throws GLException {
// Support calls to makeCurrent() over and over again with
// different contexts without releasing them
@@ -287,103 +317,206 @@ public abstract class GLContextImpl extends GLContext {
return res;
}
+ /**
+ * @see #makeCurrent
+ */
protected abstract int makeCurrentImpl() throws GLException;
- public void release() throws GLException {
- if (!lock.isHeld()) {
- throw new GLException("Context not current on current thread");
- }
- setCurrent(null);
- try {
- releaseImpl();
- } finally {
- lock.unlock();
- }
- }
+ /**
+ * @see #makeCurrent
+ */
+ protected abstract void create() throws GLException ;
- protected abstract void releaseImpl() throws GLException;
+ /**
+ * Platform dependent but harmonized implementation of the <code>ARB_create_context</code>
+ * mechanism to create a context.<br>
+ *
+ * This method is called from {@link #createContextARB}.<br>
+ *
+ * The implementation shall verify this context with a
+ * <code>MakeContextCurrent</code> call.<br>
+ *
+ * @param share the shared context or null
+ * @param direct flag if direct is requested
+ * @param ctxOptionFlags <code>ARB_create_context</code> related, see references below
+ * @param major major number
+ * @param minor minor number
+ * @return the valid context if successfull, or null
+ *
+ * @see #makeCurrent
+ * @see #CTX_PROFILE_COMPAT
+ * @see #CTX_OPTION_FORWARD
+ * @see #CTX_OPTION_DEBUG
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags,
+ int major, int minor);
- public void destroy() {
- if (lock.isHeld()) {
- // release current context
- release();
- }
+ /**
+ * Destroy the context created by {@link #createContextARBImpl}.
+ *
+ * @see #makeCurrent
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected abstract void destroyContextARBImpl(long context);
- // Must hold the lock around the destroy operation to make sure we
- // don't destroy the context out from under another thread rendering to it
- lock.lock();
- try {
- /* FIXME: refactor dependence on Java 2D / JOGL bridge
- if (tracker != null) {
- // Don't need to do anything for contexts that haven't been
- // created yet
- if (isCreated()) {
- // If we are tracking creation and destruction of server-side
- // OpenGL objects, we must decrement the reference count of the
- // GLObjectTracker upon context destruction.
- //
- // Note that we can only eagerly delete these server-side
- // objects if there is another context currrent right now
- // which shares textures and display lists with this one.
- tracker.unref(deletedObjectTracker);
+ /**
+ * Platform independent part of using the <code>ARB_create_context</code>
+ * mechanism to create a context.<br>
+ *
+ * The implementation of {@link #create} shall use this protocol in case the platform supports <code>ARB_create_context</code>.<br>
+ *
+ * This method may call {@link #createContextARBImpl} and {@link #destroyContextARBImpl}. <br>
+ *
+ * This method will also query all available native OpenGL context when first called,<br>
+ * usually the first call should happen with the shared GLContext of the DrawableFactory.<br>
+ *
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected long createContextARB(long share, boolean direct,
+ int major[], int minor[], int ctp[])
+ {
+ AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ GLProfile glp = glCaps.getGLProfile();
+ long _context = 0;
+
+ if( !mappedVersionsAvailableSet ) {
+ synchronized(mappedVersionsAvailableLock) {
+ if( !mappedVersionsAvailableSet ) {
+ createContextARBMapVersionsAvailable(4, false /* compat */); // GL4
+ createContextARBMapVersionsAvailable(4, true /* compat */); // GL4bc
+ createContextARBMapVersionsAvailable(3, false /* compat */); // GL3
+ createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc
+ createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
+ mappedVersionsAvailableSet=true;
+ }
}
- }
- */
-
- // Because we don't know how many other contexts we might be
- // sharing with (and it seems too complicated to implement the
- // GLObjectTracker's ref/unref scheme for the buffer-related
- // optimizations), simply clear the cache of known buffers' sizes
- // when we destroy contexts
- if (bufferSizeTracker != null) {
- bufferSizeTracker.clearCachedBufferSizes();
- }
+ }
- if (bufferStateTracker != null) {
- bufferStateTracker.clearBufferObjectState();
- }
-
- if (glStateTracker != null) {
- glStateTracker.clearStates(false);
- }
-
- destroyImpl();
- } finally {
- lock.unlock();
+ int reqMajor;
+ if(glp.isGL4()) {
+ reqMajor=4;
+ } else if (glp.isGL3()) {
+ reqMajor=3;
+ } else /* if (glp.isGL2()) */ {
+ reqMajor=2;
}
+ boolean compat = glp.isGL2(); // incl GL3bc and GL4bc
+
+ int key = compose8bit(reqMajor, compat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ long _ctx = 0;
+ if(val>0) {
+ int _major = getComposed8bit(val, 1);
+ int _minor = getComposed8bit(val, 2);
+ int _ctp = getComposed8bit(val, 3);
+
+ _ctx = createContextARBImpl(share, direct, _ctp, _major, _minor);
+ if(0!=_ctx) {
+ setGLFunctionAvailability(true, _major, _minor, _ctp);
+ }
+ }
+ return _ctx;
}
- protected abstract void destroyImpl() throws GLException;
+ private void createContextARBMapVersionsAvailable(int reqMajor, boolean compat)
+ {
+ long _context;
+ int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default
+ if(compat) {
+ ctp &= ~CTX_PROFILE_CORE ;
+ ctp |= CTX_PROFILE_COMPAT ;
+ }
- // This is only needed for Mac OS X on-screen contexts
- protected void update() throws GLException {
+ // FIXME GL3GL4:
+ // To avoid OpenGL implementation bugs and raise compatibility
+ // within JOGL, we map to the proper GL version.
+ // This may change later when GL3 and GL4 drivers become more mature!
+ // Bug: To ensure GL profile compatibility within the JOGL application
+ // Bug: we always try to map against the highest GL version,
+ // Bug: so the use can always cast to a higher one
+ // Bug: int majorMax=GLContext.getMaxMajor();
+ // Bug: int minorMax=GLContext.getMaxMinor(majorMax);
+ int majorMax, minorMax;
+ int majorMin, minorMin;
+ int major[] = new int[1];
+ int minor[] = new int[1];
+ if( 4 == reqMajor ) {
+ majorMax=4; minorMax=GLContext.getMaxMinor(majorMax);
+ majorMin=4; minorMin=0;
+ } else if( 3 == reqMajor ) {
+ majorMax=3; minorMax=GLContext.getMaxMinor(majorMax);
+ majorMin=3; minorMin=1;
+ } else /* if( glp.isGL2() ) */ {
+ majorMax=3; minorMax=0;
+ majorMin=1; minorMin=1; // our minimum desktop OpenGL runtime requirements
+ }
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+
+ if(0==_context && !compat) {
+ ctp &= ~CTX_PROFILE_COMPAT ;
+ ctp |= CTX_PROFILE_CORE ;
+ ctp &= ~CTX_OPTION_ANY ;
+ ctp |= CTX_OPTION_FORWARD ;
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+ if(0==_context) {
+ // Try a compatible one .. even though not requested .. last resort
+ ctp &= ~CTX_PROFILE_CORE ;
+ ctp |= CTX_PROFILE_COMPAT ;
+ ctp &= ~CTX_OPTION_FORWARD ;
+ ctp |= CTX_OPTION_ANY ;
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+ }
+ }
+ if(0!=_context) {
+ destroyContextARBImpl(_context);
+ mapVersionAvailable(reqMajor, compat, major[0], minor[0], ctp);
+ }
}
- public boolean isSynchronized() {
- return !lock.getFailFastMode();
- }
+ private long createContextARBVersions(long share, boolean direct, int ctxOptionFlags,
+ int majorMax, int minorMax,
+ int majorMin, int minorMin,
+ int major[], int minor[]) {
+ major[0]=majorMax;
+ minor[0]=minorMax;
+ long _context=0;
- public void setSynchronized(boolean isSynchronized) {
- lock.setFailFastMode(!isSynchronized);
- }
+ while ( 0==_context &&
+ GLContext.isValidGLVersion(major[0], minor[0]) &&
+ ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) {
- public final GL getGL() {
- return gl;
- }
+ _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]);
- public GL setGL(GL gl) {
- if(DEBUG) {
- String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("<null>");
- String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():new String("<null>");
- Exception e = new Exception("setGL (OpenGL "+getGLVersion()+"): "+Thread.currentThread()+", "+sgl1+" -> "+sgl2);
- e.printStackTrace();
+ if(0==_context) {
+ if(!GLContext.decrementGLVersion(major, minor)) break;
+ }
}
- this.gl = gl;
- return gl;
+ return _context;
}
- public abstract Object getPlatformGLExtensions();
-
//----------------------------------------------------------------------
// Managing the actual OpenGL version, usually figured at creation time.
// As a last resort, the GL_VERSION string may be used ..
@@ -395,7 +528,15 @@ public abstract class GLContextImpl extends GLContext {
* Otherwise .. don't touch ..
*/
protected void setContextVersion(int major, int minor, int ctp) {
+ if (0==ctp) {
+ GLException e = new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
+ throw e;
+ }
if(major>0 || minor>0) {
+ if (!GLContext.isValidGLVersion(major, minor)) {
+ GLException e = new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
+ throw e;
+ }
ctxMajorVersion = major;
ctxMinorVersion = minor;
ctxOptions = ctp;
@@ -408,6 +549,7 @@ public abstract class GLContextImpl extends GLContext {
if(null==versionStr) {
throw new GLException("GL_VERSION is NULL: "+this);
}
+ ctxOptions = ctp;
// Set version
Version version = new Version(versionStr);
@@ -460,7 +602,10 @@ public abstract class GLContextImpl extends GLContext {
//
private Object createInstance(GLProfile glp, String suffix, Class[] cstrArgTypes, Object[] cstrArgs) {
- return NWReflection.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs);
+ try {
+ return ReflectionUtil.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs);
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
+ return null;
}
/** Create the GL for this context. */
@@ -697,10 +842,6 @@ public abstract class GLContextImpl extends GLContext {
return Thread.currentThread().getName();
}
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
//----------------------------------------------------------------------
// Helpers for buffer object optimizations
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 0cc10b35e..cdf5beb24 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -42,8 +42,8 @@ package com.jogamp.opengl.impl;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.jogamp.common.util.*;
import com.jogamp.gluegen.runtime.*;
-import com.jogamp.nativewindow.impl.NWReflection;
import java.lang.reflect.*;
/** Extends GLDrawableFactory with a few methods for handling
@@ -183,6 +183,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected abstract NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser,
int width, int height);
+ protected abstract GLDrawableImpl getSharedDrawable();
+ protected abstract GLContextImpl getSharedContext();
+
protected GLDrawableFactoryImpl() {
super();
isValid = true;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index 04114a445..2fef8fd80 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -88,7 +88,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
protected abstract void swapBuffersImpl();
public static String toHexString(long hex) {
- return GLContextImpl.toHexString(hex);
+ return "0x" + Long.toHexString(hex);
}
public GLProfile getGLProfile() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/NativeLibLoader.java b/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java
index b6024f240..7747b014b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/NativeLibLoader.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java
@@ -46,9 +46,9 @@ import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashSet;
-import com.jogamp.nativewindow.impl.NativeLibLoaderBase;
+import com.jogamp.common.jvm.JNILibLoaderBase;
-public class NativeLibLoader extends NativeLibLoaderBase {
+public class GLJNILibLoader extends JNILibLoaderBase {
public static void loadNEWT() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -67,15 +67,6 @@ public class NativeLibLoader extends NativeLibLoaderBase {
});
}
- public static void loadGLDesktopES12() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibrary("jogl_gl2es12", nativeOSPreload, true);
- return null;
- }
- });
- }
-
public static void loadES2() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java
index b32ed51b6..1a68f38d4 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java
@@ -37,8 +37,9 @@ import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import javax.media.nativewindow.NativeWindowFactory;
-import com.jogamp.nativewindow.impl.NWReflection;
import javax.media.opengl.GLException;
/** Implementation of the {@link javax.media.opengl.Threading} class. */
@@ -71,8 +72,8 @@ public class ThreadingImpl {
// while holding the AWT lock. The optimization of
// makeCurrent / release calls isn't worth these stability
// problems.
- hasAWT = NWReflection.isClassAvailable("java.awt.Canvas") &&
- NWReflection.isClassAvailable("javax.media.opengl.awt.GLCanvas");
+ hasAWT = ReflectionUtil.isClassAvailable("java.awt.Canvas") &&
+ ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas");
String osType = NativeWindowFactory.getNativeWindowType(false);
_isX11 = NativeWindowFactory.TYPE_X11.equals(osType);
@@ -102,8 +103,8 @@ public class ThreadingImpl {
Object threadingPluginObj=null;
// try to fetch the AWTThreadingPlugin
try {
- threadingPluginObj = NWReflection.createInstance("com.jogamp.opengl.impl.awt.AWTThreadingPlugin");
- } catch (Throwable t) { }
+ threadingPluginObj = ReflectionUtil.createInstance("com.jogamp.opengl.impl.awt.AWTThreadingPlugin");
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
return threadingPluginObj;
}
});
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
index 8c3e9a1c4..48f80977c 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
@@ -95,11 +95,11 @@ public abstract class EGLContext extends GLContextImpl {
boolean created = false;
if (eglContext == 0) {
create();
+ created = true;
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created GL context 0x" +
Long.toHexString(eglContext) + " for " + getClass().getName());
}
- created = true;
}
if (EGL.eglGetCurrentContext() != eglContext) {
if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
@@ -112,7 +112,7 @@ public abstract class EGLContext extends GLContextImpl {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
@@ -153,6 +153,10 @@ public abstract class EGLContext extends GLContextImpl {
return 0; // FIXME
}
+ protected void destroyContextARBImpl(long _context) {
+ // FIXME
+ }
+
protected void create() throws GLException {
long eglDisplay = ((EGLDrawable)drawable).getDisplay();
EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration();
@@ -218,7 +222,7 @@ public abstract class EGLContext extends GLContextImpl {
throw new GLException("Error making context 0x" +
Long.toHexString(eglContext) + " current: error code " + EGL.eglGetError());
}
- setGLFunctionAvailability(true, contextAttrs[1], 0, CTX_IS_ARB_CREATED|CTX_PROFILE_CORE|CTX_OPTION_ANY);
+ setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
}
public boolean isCreated() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index 5a193b2ff..4fccf22f8 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -37,8 +37,10 @@ package com.jogamp.opengl.impl.egl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.*;
+import com.jogamp.nativewindow.impl.NullWindow;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
@@ -50,8 +52,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// Check for other underlying stuff ..
if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) {
try {
- NWReflection.createInstance("com.jogamp.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory");
- } catch (Throwable t) {}
+ ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory");
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
}
}
@@ -59,6 +61,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
+
+ protected final GLDrawableImpl getSharedDrawable() { return null; }
+ protected final GLContextImpl getSharedContext() { return null; }
+
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
index 70f0540bf..9e34dc9e9 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
@@ -64,9 +64,9 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
EGLDynamicLookupHelper tmp=null;
try {
tmp = new EGLES1DynamicLookupHelper();
- } catch (Throwable t) {
+ } catch (GLException gle) {
if(DEBUG) {
- t.printStackTrace();
+ gle.printStackTrace();
}
}
eglES1DynamicLookupHelper = tmp;
@@ -74,9 +74,9 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
tmp=null;
try {
tmp = new EGLES2DynamicLookupHelper();
- } catch (Throwable t) {
+ } catch (GLException gle) {
if(DEBUG) {
- t.printStackTrace();
+ gle.printStackTrace();
}
}
eglES2DynamicLookupHelper = tmp;
@@ -191,9 +191,9 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
}
if (esProfile==2) {
- NativeLibLoader.loadES2();
+ GLJNILibLoader.loadES2();
} else if (esProfile==1) {
- NativeLibLoader.loadES1();
+ GLJNILibLoader.loadES1();
} else {
throw new GLException("Unsupported: ES"+esProfile);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
index 0adede4ea..5a8454ea7 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
@@ -47,7 +47,7 @@ public class EGLExternalContext extends EGLContext {
public EGLExternalContext(AbstractGraphicsScreen screen) {
super(null, null);
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, 0);
+ setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index 9182a71de..ebefaf466 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -88,11 +88,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl
protected Map/*<String, String>*/ getExtensionNameMap() { return null; }
- protected abstract boolean create();
+ protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
+ return 0; // FIXME
+ }
- protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
- return 0; // FIXME
- }
+ protected void destroyContextARBImpl(long _context) {
+ // FIXME
+ }
/**
* Creates and initializes an appropriate OpenGl nsContext. Should only be
@@ -154,7 +156,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (!CGL.makeCurrentContext(nsContext)) {
throw new GLException("Error making nsContext current");
}
- setGLFunctionAvailability(true, 0, 0, 0);
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
GLContextShareSet.contextCreated(this);
return true;
}
@@ -165,13 +167,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
boolean created = false;
if ( 0 == cglContext && 0 == nsContext) {
- if (!create()) {
+ create();
+ created = 0 != cglContext || 0 != nsContext ;
+ if(!created) {
return CONTEXT_NOT_CURRENT;
}
if (DEBUG) {
System.err.println("!!! Created OpenGL context " + toHexString(nsContext) + " for " + getClass().getName());
}
- created = true;
}
if ( 0 != cglContext ) {
@@ -185,7 +188,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 906088642..d10434252 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -43,8 +43,10 @@ import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.*;
+import com.jogamp.nativewindow.impl.NullWindow;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
public MacOSXCGLDrawableFactory() {
@@ -55,11 +57,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
new MacOSXCGLGraphicsConfigurationFactory();
try {
- NWReflection.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
+ ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
new Object[] {});
- } catch (Throwable t) { }
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
}
+ protected final GLDrawableImpl getSharedDrawable() { return null; }
+ protected final GLContextImpl getSharedContext() { return null; }
+
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
index 248bbb4d6..eba3cf50e 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -56,7 +56,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
this.cglContext = cglContext;
this.nsContext = nsContext;
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, 0);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
@@ -110,8 +110,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
}
}
- protected boolean create() {
- return true;
+ protected void create() {
}
public int makeCurrent() throws GLException {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
index 4c64864fa..c4eaee489 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -115,8 +115,8 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
CGL.updateContext(nsContext);
}
- protected boolean create() {
- return create(false, false);
+ protected void create() {
+ create(false, false);
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index 5844b8edd..e90672a1d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -59,13 +59,14 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
boolean created = false;
if (nsContext == 0) {
- if (!create()) {
+ create();
+ created = 0 != nsContext ;
+ if(!created) {
return CONTEXT_NOT_CURRENT;
}
if (DEBUG) {
System.err.println("!!! Created OpenGL context " + toHexString(nsContext) + " for " + getClass().getName());
}
- created = true;
}
if (!impl.makeCurrent(nsContext)) {
@@ -73,7 +74,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
// Initialize render-to-texture support if requested
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
@@ -134,7 +135,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return GLPbuffer.APPLE_FLOAT;
}
- protected boolean create() {
+ protected void create() {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
@@ -152,9 +153,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
if (!impl.makeCurrent(nsContext)) {
throw new GLException("Error making nsContext current");
}
- setGLFunctionAvailability(true, 0, 0, 0);
-
- return true;
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
}
//---------------------------------------------------------------------------
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 9189b41f3..97a1435bc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -73,7 +73,9 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
protected int makeCurrentImpl() throws GLException {
boolean created = false;
if (nsContext == 0) {
- if (!create()) {
+ create();
+ created = 0 != nsContext ;
+ if(!created) {
return CONTEXT_NOT_CURRENT;
}
if (DEBUG) {
@@ -87,13 +89,13 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
}
- protected boolean create() {
+ protected void create() {
// Find and configure share context
MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
long share = 0;
@@ -119,11 +121,10 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
long ctx = Java2D.createOGLContextOnSurface(graphics, share);
if (ctx == 0) {
- return false;
+ return;
}
// FIXME: think about GLContext sharing
nsContext = ctx;
- return true;
}
protected void releaseImpl() throws GLException {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index aae376a6c..e712d8568 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -56,7 +56,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
System.err.println(getThreadName() + ": !!! Created external OpenGL context " + toHexString(hglrc) + " for " + this);
}
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, 0);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
cfg.updateCapabilitiesByWGL(this);
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 95706a7a1..0f1f9813f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -122,13 +122,18 @@ public class WindowsWGLContext extends GLContextImpl {
protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
+ protected void destroyContextARBImpl(long context) {
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(context);
+ }
+
protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
WGLExt wglExt;
if(null==factory.getSharedContext()) {
wglExt = getWGLExt();
} else {
- wglExt = factory.getSharedContext().getWGLExt();
+ wglExt = ((WindowsWGLContext)factory.getSharedContext()).getWGLExt();
}
boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
@@ -235,7 +240,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
- setGLFunctionAvailability(true, 0, 0, 0);
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
if( createContextARBTried ||
!isFunctionAvailable("wglCreateContextAttribsARB") ||
@@ -257,9 +262,6 @@ public class WindowsWGLContext extends GLContextImpl {
if(0!=hglrc) {
share = 0; // mark as shared ..
- // need to update the GL func table ..
- setGLFunctionAvailability(true, major[0], minor[0], ctp[0]);
-
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
@@ -302,10 +304,10 @@ public class WindowsWGLContext extends GLContextImpl {
boolean created = false;
if (hglrc == 0) {
create();
+ created = true;
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
}
- created = true;
}
if (WGL.wglGetCurrentContext() != hglrc) {
@@ -320,7 +322,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
WindowsWGLGraphicsConfiguration config =
(WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index bc99338ab..a4bf89b81 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -45,8 +45,9 @@ import java.util.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.windows.*;
import javax.media.opengl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.NWReflection;
import com.jogamp.nativewindow.impl.NullWindow;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
@@ -66,40 +67,38 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
// The act of constructing them causes them to be registered
new WindowsWGLGraphicsConfigurationFactory();
try {
- NWReflection.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
+ ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
new Object[] {});
- } catch (Throwable t) { }
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
loadOpenGL32Library();
+
+ sharedDrawable = new WindowsDummyWGLDrawable(this, null);
+ WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
+ ctx.makeCurrent();
+ canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer");
+ ctx.release();
+ sharedContext = ctx;
+ if(null==sharedContext) {
+ throw new GLException("Couldn't init shared resources");
+ }
+ if (DEBUG) {
+ System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer);
+ }
}
WindowsDummyWGLDrawable sharedDrawable=null;
WindowsWGLContext sharedContext=null;
boolean canCreateGLPbuffer = false;
- // package private ..
- final WindowsWGLContext getSharedContext() {
+ protected final GLDrawableImpl getSharedDrawable() {
validate();
- return sharedContext;
+ return sharedDrawable;
}
- void initShared() {
- if(null==sharedDrawable) {
- sharedDrawable = new WindowsDummyWGLDrawable(this, null);
- WindowsWGLContext _sharedContext = (WindowsWGLContext) sharedDrawable.createContext(null);
- {
- _sharedContext.makeCurrent();
- canCreateGLPbuffer = _sharedContext.getGL().isExtensionAvailable("GL_ARB_pbuffer");
- _sharedContext.release();
- }
- _sharedContext = _sharedContext;
- if (DEBUG) {
- System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer);
- }
- if(null==sharedContext) {
- throw new GLException("Couldn't init shared resources");
- }
- }
+ protected final GLContextImpl getSharedContext() {
+ validate();
+ return sharedContext;
}
public void shutdown() {
@@ -124,7 +123,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
return new WindowsOnscreenWGLDrawable(this, target);
}
@@ -133,13 +131,11 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
return new WindowsOffscreenWGLDrawable(this, target);
}
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
validate();
- initShared(); // setup canCreateGLPBuffer
return canCreateGLPbuffer;
}
@@ -148,7 +144,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
final List returnList = new ArrayList();
final GLDrawableFactory factory = this;
final WindowsWGLContext _sharedContext = sharedContext;
@@ -180,7 +175,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
validate();
- initShared();
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
NullWindow nw = new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capabilities, chooser, screen) );
@@ -190,7 +184,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
public GLContext createExternalGLContext() {
validate();
- initShared();
return WindowsExternalWGLContext.create(this, null);
}
@@ -201,7 +194,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
public GLDrawable createExternalGLDrawable() {
validate();
- initShared();
return WindowsExternalWGLDrawable.create(this, null);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index c9805fef1..ab3227257 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -135,7 +135,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
// Produce a recommended pixel format selection for the GLCapabilitiesChooser.
// Use wglChoosePixelFormatARB if user requested multisampling and if we have it available
- factory.initShared();
factory.sharedContext.makeCurrent();
WGLExt wglExt = factory.sharedContext.getWGLExt();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
index a865e91e8..1f148bead 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
@@ -42,7 +42,7 @@ import com.jogamp.nativewindow.impl.x11.*;
public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
- // private long dummyWindow = 0;
+ private long dummyWindow = 0;
/**
* Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277,
@@ -62,17 +62,15 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice();
long dpy = device.getHandle();
int scrn = screen.getIndex();
- // long visualID = config.getVisualID();
- // System.out.println("X11DummyGLXDrawable: dpy "+toHexString(dpy)+", scrn "+scrn+", visualID "+toHexString(visualID));
+ long visualID = config.getVisualID();
X11Lib.XLockDisplay(dpy);
try{
- nw.setSurfaceHandle( X11Lib.RootWindow(dpy, scrn) );
- // dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
- // nw.setSurfaceHandle( dummyWindow );
+ dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
} finally {
X11Lib.XUnlockDisplay(dpy);
}
+ nw.setSurfaceHandle( dummyWindow );
}
public void setSize(int width, int height) {
@@ -87,11 +85,10 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
}
public void destroy() {
- /**
if(0!=dummyWindow) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
long dpy = config.getScreen().getDevice().getHandle();
X11Lib.DestroyDummyWindow(dpy, dummyWindow);
- } */
+ }
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
index b8f25aad7..139c0deed 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
@@ -55,7 +55,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
super(drawable, null);
this.context = context;
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, 0);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index f5e291c5f..7d907bf28 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -103,12 +103,31 @@ public abstract class X11GLXContext extends GLContextImpl {
protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
- /** Helper routine which usually just turns around and calls
- * createContext (except for pbuffers, which use a different context
- * creation mechanism). Should only be called by {@link
- * makeCurrentImpl()}.
- */
- protected abstract void create();
+ protected boolean glXMakeContextCurrent(long dpy, long writeDrawable, long readDrawable, long ctx) {
+ boolean res = false;
+
+ try {
+ res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
+ } catch (RuntimeException re) {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+
+ "dpy "+toHexString(dpy)+
+ ", write "+toHexString(writeDrawable)+
+ ", read "+toHexString(readDrawable)+
+ ", ctx "+toHexString(ctx));
+ re.printStackTrace();
+ }
+ }
+ return res;
+ }
+
+ protected void destroyContextARBImpl(long _context) {
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ long display = config.getScreen().getDevice().getHandle();
+
+ glXMakeContextCurrent(display, 0, 0, 0);
+ GLX.glXDestroyContext(display, _context);
+ }
protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
@@ -119,7 +138,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(null==factory.getSharedContext()) {
glXExt = getGLXExt();
} else {
- glXExt = factory.getSharedContext().getGLXExt();
+ glXExt = ((X11GLXContext)factory.getSharedContext()).getGLXExt();
}
boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
@@ -156,20 +175,27 @@ public abstract class X11GLXContext extends GLContextImpl {
}
}
- _context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
+ try {
+ _context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
+ } catch (RuntimeException re) {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(null, major, minor, ctp, "@creation"));
+ re.printStackTrace();
+ }
+ }
if(0==_context) {
if(DEBUG) {
System.err.println("X11GLXContext.createContextARB couldn't create "+getGLVersion(null, major, minor, ctp, "@creation"));
}
} else {
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- _context)) {
+ if (!glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ _context)) {
if(DEBUG) {
System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(null, major, minor, ctp, "@creation"));
}
- GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, _context);
_context = 0;
}
@@ -179,7 +205,7 @@ public abstract class X11GLXContext extends GLContextImpl {
/**
* Creates and initializes an appropriate OpenGL context. Should only be
- * called by {@link create()}.
+ * called by {@link #create()}.
* Note: The direct parameter may be overwritten by the direct state of a shared context.
*/
protected void createContext(boolean direct) {
@@ -213,13 +239,13 @@ public abstract class X11GLXContext extends GLContextImpl {
if (context == 0) {
throw new GLException("Unable to create context(0)");
}
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- context)) {
+ if (!glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ context)) {
throw new GLException("Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(context)+", drawable "+drawable);
}
- setGLFunctionAvailability(true, 0, 0, 0); // use GL_VERSION
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
return;
}
@@ -245,21 +271,21 @@ public abstract class X11GLXContext extends GLContextImpl {
if (temp_context == 0) {
throw new GLException("Unable to create temp OpenGL context(1)");
}
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- temp_context)) {
+ if (!glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ temp_context)) {
throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(context)+", drawable "+drawable);
}
- setGLFunctionAvailability(true, 0, 0, 0); // use GL_VERSION
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
if( createContextARBTried ||
!isFunctionAvailable("glXCreateContextAttribsARB") ||
!isExtensionAvailable("GLX_ARB_create_context") ) {
if(glp.isGL3()) {
- GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- throw new GLException("Unable to create OpenGL >= 3.1 context (no GLX_ARB_create_context)");
+ throw new GLException("Unable to create OpenGL >= 3.1 context (failed GLX_ARB_create_context), GLProfile "+glp+", Drawable "+drawable);
}
// continue with temp context for GL < 3.0
@@ -271,22 +297,19 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if(0!=context) {
- // need to update the GL func table ..
- setGLFunctionAvailability(true, major[0], minor[0], ctp[0]);
-
if(0!=temp_context) {
- GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- context)) {
+ if (!glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ context)) {
throw new GLException("Cannot make previous verified context current");
}
}
} else {
if(!glp.isGL2()) {
- GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
throw new GLException("X11GLXContext.createContext failed, but context > GL2 requested "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")+", ");
}
@@ -296,11 +319,11 @@ public abstract class X11GLXContext extends GLContextImpl {
// continue with temp context for GL <= 3.0
context = temp_context;
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- context)) {
- GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ if (!glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ context)) {
+ glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
throw new GLException("Error making context(1) current: display "+toHexString(display)+", context "+toHexString(context)+", drawable "+drawable);
}
@@ -349,19 +372,19 @@ public abstract class X11GLXContext extends GLContextImpl {
boolean created = false;
if (context == 0) {
create();
+ created = true;
GLContextShareSet.contextCreated(this);
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
}
- created = true;
}
if (GLX.glXGetCurrentContext() != context) {
- if (!GLX.glXMakeContextCurrent(dpy,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- context)) {
+ if (!glXMakeContextCurrent(dpy,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
+ context)) {
throw new GLException("Error making context current: "+this);
}
if (DEBUG && (VERBOSE || created)) {
@@ -374,7 +397,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
@@ -386,7 +409,7 @@ public abstract class X11GLXContext extends GLContextImpl {
protected void releaseImplAfterLock() throws GLException {
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
- if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
+ if (!glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
throw new GLException("Error freeing OpenGL context");
}
} finally {
@@ -494,6 +517,10 @@ public abstract class X11GLXContext extends GLContextImpl {
private int hasSwapIntervalSGI = 0;
protected void setSwapIntervalImpl(int interval) {
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ if(!glCaps.isOnscreen()) return;
+
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
GLXExt glXExt = getGLXExt();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 0d74bb791..f331ad2a2 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -43,8 +43,9 @@ import javax.media.nativewindow.x11.*;
import javax.media.opengl.*;
import com.jogamp.gluegen.runtime.opengl.*;
import com.jogamp.opengl.impl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.nativewindow.impl.NullWindow;
-import com.jogamp.nativewindow.impl.NWReflection;
import com.jogamp.nativewindow.impl.x11.*;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
@@ -58,9 +59,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
// The act of constructing them causes them to be registered
new X11GLXGraphicsConfigurationFactory();
try {
- NWReflection.createInstance("com.jogamp.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
+ ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
new Object[] {});
- } catch (Throwable t) { }
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.createThreadLocalDisplay(null));
vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
@@ -70,9 +71,20 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
X11Util.markGlobalDisplayUndeletable(sharedDevice.getHandle()); // ATI hack ..
}
sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
+ X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, this, null);
+ X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
+ ctx.makeCurrent();
+ ctx.release();
+ sharedContext = ctx;
+ X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
+ if(null==sharedContext) {
+ throw new GLException("Couldn't init shared resources");
+ }
if (DEBUG) {
System.err.println("!!! Vendor: "+vendorName+", ATI: "+isVendorATI+", NV: "+isVendorNVIDIA);
System.err.println("!!! SharedScreen: "+sharedScreen);
+ System.err.println("!!! SharedContext: "+sharedContext);
}
}
@@ -88,30 +100,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
private X11DummyGLXDrawable sharedDrawable=null;
private X11GLXContext sharedContext=null;
- // package private ..
- final X11GLXContext getSharedContext() {
+ protected final GLDrawableImpl getSharedDrawable() {
validate();
- return sharedContext;
+ return sharedDrawable;
}
- private void initShared() {
- if(null==sharedDrawable) {
- X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, this, null);
- X11GLXContext _sharedContext = (X11GLXContext) sharedDrawable.createContext(null);
- {
- _sharedContext.makeCurrent();
- _sharedContext.release();
- }
- sharedContext = _sharedContext;
- X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
- if (DEBUG) {
- System.err.println("!!! SharedContext: "+sharedContext);
- }
- if(null==sharedContext) {
- throw new GLException("Couldn't init shared resources");
- }
- }
+ protected final GLContextImpl getSharedContext() {
+ validate();
+ return sharedContext;
}
public void shutdown() {
@@ -145,7 +141,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
if( isVendorATI() ) {
X11Util.markGlobalDisplayUndeletable(target.getDisplayHandle()); // ATI hack ..
}
@@ -157,11 +152,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
if( isVendorATI() ) {
X11Util.markGlobalDisplayUndeletable(target.getDisplayHandle()); // ATI hack ..
}
- initShared();
return new X11OffscreenGLXDrawable(this, target);
}
@@ -203,7 +196,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
GLDrawableImpl pbufferDrawable;
@@ -234,7 +226,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
validate();
- initShared();
X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
@@ -244,19 +235,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
public GLContext createExternalGLContext() {
validate();
- initShared();
return X11ExternalGLXContext.create(this, null);
}
public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
validate();
- initShared();
return canCreateGLPbuffer(device);
}
public GLDrawable createExternalGLDrawable() {
validate();
- initShared();
return X11ExternalGLXDrawable.create(this, null);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
index e0993abc3..1b70adf6b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
@@ -68,33 +68,6 @@ public class X11PbufferGLXContext extends X11GLXContext {
}
protected void create() {
- if (DEBUG) {
- System.err.println("Creating context for pbuffer " + drawable.getWidth() +
- " x " + drawable.getHeight());
- }
-
- // Create a gl context for the p-buffer.
- X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)
- getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-
- context = GLX.glXCreateNewContext(drawable.getNativeWindow().getDisplayHandle(),
- config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, true);
- if (context == 0) {
- throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
- }
- GLContextShareSet.contextCreated(this);
-
- if (DEBUG) {
- System.err.println("Created context for pbuffer " + drawable.getWidth() +
- " x " + drawable.getHeight());
- }
+ createContext(true);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index ad230a415..04b994198 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -1,9 +1,9 @@
package com.jogamp.opengl.util;
+import com.jogamp.common.util.*;
import javax.media.opengl.*;
import javax.media.opengl.fixedfunc.*;
-import com.jogamp.nativewindow.impl.NWReflection;
import java.nio.*;
import java.util.Iterator;
import java.util.ArrayList;
@@ -341,9 +341,9 @@ public class ImmModeSink {
} else {
Class clazz = indices.getClass();
int type=-1;
- if(NWReflection.instanceOf(clazz, ByteBuffer.class.getName())) {
+ if(ReflectionUtil.instanceOf(clazz, ByteBuffer.class.getName())) {
type = GL.GL_UNSIGNED_BYTE;
- } else if(NWReflection.instanceOf(clazz, ShortBuffer.class.getName())) {
+ } else if(ReflectionUtil.instanceOf(clazz, ShortBuffer.class.getName())) {
type = GL.GL_UNSIGNED_SHORT;
}
if(0>type) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
index f00357bfb..7ec4ac50e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
@@ -28,7 +28,7 @@ public class FixedFuncUtil {
gl.getContext().setGL(impl);
return impl;
}
- throw new GLException("GL Object is neither GL2ES1 nor GL2ES2");
+ throw new GLException("GL Object is neither GL2ES1 nor GL2ES2: "+gl.getContext());
}
/**
diff --git a/src/jogl/classes/javax/media/opengl/GL4.java b/src/jogl/classes/javax/media/opengl/GL4.java
deleted file mode 100644
index 29a316333..000000000
--- a/src/jogl/classes/javax/media/opengl/GL4.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package javax.media.opengl;
-
-public interface GL4 extends GLBase {
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GL4bc.java b/src/jogl/classes/javax/media/opengl/GL4bc.java
deleted file mode 100644
index be1131e91..000000000
--- a/src/jogl/classes/javax/media/opengl/GL4bc.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package javax.media.opengl;
-
-public interface GL4bc extends GL4 {
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 833ebf192..e5b499af9 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -40,6 +40,7 @@
package javax.media.opengl;
import java.util.HashMap;
+import com.jogamp.common.util.IntIntHashMap;
/** Abstraction for an OpenGL rendering context. In order to perform
OpenGL rendering, a context must be "made current" on the current
@@ -261,6 +262,12 @@ public abstract class GLContext {
StringBuffer sb = new StringBuffer();
sb.append(getClass().getName());
sb.append(" [OpenGL ");
+ sb.append(getGLVersionMajor());
+ sb.append(".");
+ sb.append(getGLVersionMinor());
+ sb.append(", options 0x");
+ sb.append(Integer.toHexString(ctxOptions));
+ sb.append(", ");
sb.append(getGLVersion());
sb.append(", ");
sb.append(getGL());
@@ -284,7 +291,7 @@ public abstract class GLContext {
public abstract String getPlatformExtensionsString();
public final int getGLVersionMajor() { return ctxMajorVersion; }
- public final int getGLVersionMinor() { return ctxMajorVersion; }
+ public final int getGLVersionMinor() { return ctxMinorVersion; }
public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
@@ -342,9 +349,181 @@ public abstract class GLContext {
/** <code>ARB_create_context</code> related: core profile */
protected static final int CTX_PROFILE_CORE = 1 << 2;
/** <code>ARB_create_context</code> related: flag forward compatible */
- protected static final int CTX_OPTION_FORWARD = 1 << 3;
+ 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 */
- protected static final int CTX_OPTION_ANY = 1 << 4;
+ 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 << 5;
+ protected static final int CTX_OPTION_DEBUG = 1 << 6;
+
+
+ public final boolean isGL4bc() {
+ return ctxMajorVersion>=4 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL4() {
+ return ctxMajorVersion>=4 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL3bc() {
+ return ctxMajorVersion>=3 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL3() {
+ return ctxMajorVersion>=3 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL2() {
+ return ctxMajorVersion>=1 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGLES1() {
+ return ctxMajorVersion==1 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGLES2() {
+ return ctxMajorVersion==2 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGLES() {
+ return CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGL2ES1() {
+ return isGL2() || isGLES1() ;
+ }
+
+ public final boolean isGL2ES2() {
+ return isGL2() || isGL3() || isGLES2() ;
+ }
+
+ public final boolean isGL2GL3() {
+ return isGL2() || isGL3();
+ }
+
+ public final boolean hasGLSL() {
+ return isGL2ES2() ;
+ }
+
+ public static final int GL_VERSIONS[][] = {
+ /* 0.*/ { -1 },
+ /* 1.*/ { 0, 1, 2, 3, 4, 5 },
+ /* 2.*/ { 0, 1 },
+ /* 3.*/ { 0, 1, 2, 3 },
+ /* 4.*/ { 0 } };
+
+ public static final int getMaxMajor() {
+ return GL_VERSIONS.length-1;
+ }
+
+ public static final int getMaxMinor(int major) {
+ if(1>major || major>=GL_VERSIONS.length) return -1;
+ return GL_VERSIONS[major].length-1;
+ }
+
+ public static final boolean isValidGLVersion(int major, int minor) {
+ if(1>major || major>=GL_VERSIONS.length) return false;
+ if(0>minor || minor>=GL_VERSIONS[major].length) return false;
+ return true;
+ }
+
+ public static final boolean decrementGLVersion(int major[], int minor[]) {
+ if(null==major || major.length<1 ||null==minor || minor.length<1) {
+ throw new GLException("invalid array arguments");
+ }
+ int m = major[0];
+ int n = minor[0];
+ if(!isValidGLVersion(m, n)) return false;
+
+ // decrement ..
+ n -= 1;
+ if(n < 0) {
+ m -= 1;
+ n = GL_VERSIONS[m].length-1;
+ }
+ if(!isValidGLVersion(m, n)) return false;
+ major[0]=m;
+ minor[0]=n;
+
+ return true;
+ }
+
+ public static final boolean isGLVersionAvailable(int major, boolean compatibility) {
+ int key = compose8bit(major, compatibility?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ return val>0;
+ }
+ public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, true); }
+ public static final boolean isGL4Available() { return isGLVersionAvailable(4, false); }
+ public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, true); }
+ public static final boolean isGL3Available() { return isGLVersionAvailable(3, false); }
+ public static final boolean isGL2Available() { return isGLVersionAvailable(2, true); }
+
+ protected static final IntIntHashMap mappedVersionsAvailable;
+ protected static volatile boolean mappedVersionsAvailableSet;
+ protected static Object mappedVersionsAvailableLock;
+
+ static {
+ mappedVersionsAvailableLock = new Object();
+ mappedVersionsAvailableSet = false;
+ mappedVersionsAvailable = new IntIntHashMap();
+ mappedVersionsAvailable.setKeyNotFoundValue(-1);
+ }
+
+ /**
+ * Called by {@link GLContextImpl#createContextARBMapVersionsAvailable} not intendet to be used by
+ * implementations. However, if {@link #createContextARB} is not being used within the
+ * {@link GLDrawableImpl} constructor, GLProfile has to map the available versions.
+ *
+ * @see #createContextARBMapVersionsAvailable
+ */
+ protected static void mapVersionAvailable(int reqMajor, boolean reqCompat, int resMajor, int resMinor, int resCtp)
+ {
+ int key = compose8bit(reqMajor, reqCompat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = compose8bit(resMajor, resMinor, resCtp, 0);
+ mappedVersionsAvailable.put( key, val );
+ }
+
+ protected static int compose8bit(int one, int two, int three, int four) {
+ return ( ( one & 0x000000FF ) << 24 ) |
+ ( ( two & 0x000000FF ) << 16 ) |
+ ( ( three & 0x000000FF ) << 8 ) |
+ ( ( four & 0x000000FF ) ) ;
+ }
+
+ protected static int getComposed8bit(int bits32, int which ) {
+ switch (which) {
+ case 1: return ( bits32 & 0xFF000000 ) >> 24 ;
+ case 2: return ( bits32 & 0x00FF0000 ) >> 16 ;
+ case 3: return ( bits32 & 0x0000FF00 ) >> 8 ;
+ case 4: return ( bits32 & 0xFF0000FF ) ;
+ }
+ throw new GLException("argument which out of range: "+which);
+ }
+
+ protected static String composed8BitToString(int bits32, boolean hex1, boolean hex2, boolean hex3, boolean hex4) {
+ int a = getComposed8bit(bits32, 1);
+ int b = getComposed8bit(bits32, 2);
+ int c = getComposed8bit(bits32, 3);
+ int d = getComposed8bit(bits32, 4);
+ return "["+toString(a, hex1)+", "+toString(b, hex2)+", "+toString(c, hex3)+", "+toString(d, hex4)+"]";
+ }
+
+ protected static String toString(int val, boolean hex) {
+ if(hex) {
+ return "0x" + Integer.toHexString(val);
+ }
+ return String.valueOf(val);
+ }
+
+ protected static String toHexString(int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ protected static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
}
+
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 80c2c10e2..b02bffb61 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -42,8 +42,9 @@ package javax.media.opengl;
import javax.media.nativewindow.*;
import java.security.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.NWReflection;
/** <P> Provides a virtual machine- and operating system-independent
mechanism for creating {@link GLDrawable}s. </P>
@@ -96,51 +97,50 @@ public abstract class GLDrawableFactory {
static {
GLDrawableFactory tmp = null;
try {
- tmp = (GLDrawableFactory) NWReflection.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory");
- } catch (Throwable t) {
+ tmp = (GLDrawableFactory) ReflectionUtil.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory");
+ } catch (JogampRuntimeException jre) {
if (GLProfile.DEBUG) {
System.err.println("GLDrawableFactory.static - EGLDrawableFactory - not available");
- t.printStackTrace();
+ jre.printStackTrace();
}
}
eglFactory = tmp;
nativeOSType = NativeWindowFactory.getNativeWindowType(true);
- String factoryClassName = null;
tmp = null;
- try {
- factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext());
- if (null == factoryClassName) {
- if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) {
- factoryClassName = "com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory";
- } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) {
- factoryClassName = "com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory";
- } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) {
- if(NWReflection.isClassAvailable(macosxFactoryClassNameAWTCGL)) {
- factoryClassName = macosxFactoryClassNameAWTCGL;
- } else {
- factoryClassName = macosxFactoryClassNameCGL;
- }
+ String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext());
+ if (null == factoryClassName) {
+ if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) {
+ factoryClassName = "com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory";
+ } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) {
+ factoryClassName = "com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory";
+ } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) {
+ if(ReflectionUtil.isClassAvailable(macosxFactoryClassNameAWTCGL)) {
+ factoryClassName = macosxFactoryClassNameAWTCGL;
} else {
- // may use egl*Factory ..
- if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - No native OS Factory for: "+nativeOSType+"; May use EGLDrawableFactory, if available." );
- }
+ factoryClassName = macosxFactoryClassNameCGL;
}
- }
- if (null != factoryClassName) {
+ } else {
+ // may use egl*Factory ..
if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName);
+ System.err.println("GLDrawableFactory.static - No native OS Factory for: "+nativeOSType+"; May use EGLDrawableFactory, if available." );
}
- tmp = (GLDrawableFactory) NWReflection.createInstance(factoryClassName);
- }
- } catch (Throwable t) {
- if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName);
- t.printStackTrace();
}
}
+ if (null != factoryClassName) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName);
+ }
+ try {
+ tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName);
+ } catch (JogampRuntimeException jre) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName);
+ jre.printStackTrace();
+ }
+ }
+ }
nativeOSFactory = tmp;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index e1fc9f53f..9e3a532e6 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -36,12 +36,13 @@
package javax.media.opengl;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.DRIHack;
import com.jogamp.opengl.impl.Debug;
-import com.jogamp.opengl.impl.NativeLibLoader;
-import com.jogamp.nativewindow.impl.NWReflection;
-import com.jogamp.nativewindow.impl.jvm.JVMUtil;
+import com.jogamp.opengl.impl.GLJNILibLoader;
+import com.jogamp.common.jvm.JVMUtil;
import java.util.HashMap;
+import java.util.Iterator;
import java.security.AccessControlContext;
import java.security.AccessController;
import javax.media.opengl.fixedfunc.GLPointerFunc;
@@ -59,6 +60,45 @@ public class GLProfile implements Cloneable {
public static final boolean DEBUG = Debug.debug("GLProfile");
//
+ // Query platform available OpenGL implementation
+ //
+
+ public static final boolean isGL4bcAvailable() { return hasGL4bcImpl; }
+ public static final boolean isGL4Available() { return hasGL4Impl; }
+ public static final boolean isGL3bcAvailable() { return hasGL3bcImpl; }
+ public static final boolean isGL3Available() { return hasGL3Impl; }
+ public static final boolean isGL2Available() { return hasGL2Impl; }
+ public static final boolean isGLES2Available() { return hasGLES2Impl; }
+ public static final boolean isGLES1Available() { return hasGLES1Impl; }
+ public static final String glAvailabilityToString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("GLAvailability[Native[GL4bc ");
+ sb.append(hasGL4bcImpl);
+ sb.append(", GL4 ");
+ sb.append(hasGL4Impl);
+ sb.append(", GL3bc ");
+ sb.append(hasGL3bcImpl);
+ sb.append(", GL3 ");
+ sb.append(hasGL3Impl);
+ sb.append(", GL2 ");
+ sb.append(hasGL2Impl);
+ sb.append(", GLES1 ");
+ sb.append(hasGLES1Impl);
+ sb.append(", GLES2 ");
+ sb.append(hasGLES2Impl);
+ sb.append("], Profiles[");
+ for(Iterator i=mappedProfiles.values().iterator(); i.hasNext(); ) {
+ sb.append(((GLProfile)i.next()).toString());
+ sb.append(", ");
+ }
+ sb.append(", default ");
+ sb.append(defaultGLProfile);
+ sb.append("]]");
+
+ return sb.toString();
+ }
+
+ //
// Public (user-visible) profiles
//
@@ -95,22 +135,92 @@ public class GLProfile implements Cloneable {
public static final String GL2GL3 = "GL2GL3";
/**
- * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3
+ * All GL Profiles in the order of default detection.
+ * Desktop compatibility profiles (the one with fixed function pipeline) comes first.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2
+ * <li> GL3bc
+ * <li> GL4bc
+ * <li> GL2GL3
+ * <li> GL3
+ * <li> GL4
+ * <li> GL2ES2
+ * <li> GLES2
+ * <li> GL2ES1
+ * <li> GLES1
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL4bc, GL3bc, GL4, GL3 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL3bc, GL4bc, GL2GL3, GL3, GL4, GL2ES2, GLES2, GL2ES1, GLES1 };
/**
- * All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
+ * Order of maximum fixed function profiles
+ *
+ * <ul>
+ * <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 };
+
+ /**
+ * Order of maximum programmable shader profiles
+ *
+ * <ul>
+ * <li> GL4
+ * <li> GL4bc
+ * <li> GL3
+ * <li> GL3bc
+ * <li> GL2
+ * <li> GL2ES2
+ * <li> GLES2
+ * </ul>
+ *
+ */
+ public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4, GL4bc, GL3, GL3bc, GL2, GL2ES2, GLES2 };
+
+ /**
+ * All GL2ES2 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2ES2
+ * <li> GL2
+ * <li> GL3
+ * <li> GL4
+ * <li> GLES2
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL4bc, GL3bc, GL4, GL3 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GL3, GL4, GLES2 };
/**
- * All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1
+ * All GL2ES1 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ * <ul>
+ * <li> GL2ES1
+ * <li> GL2
+ * <li> GL3bc
+ * <li> GL4bc
+ * <li> GLES1
+ * </ul>
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GL3bc, GL4bc, GLES1 };
/** Returns a default GLProfile object, reflecting the best for the running platform.
* It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
+ * @see #GL_PROFILE_LIST_ALL
*/
public static final GLProfile getDefault() {
if(null==defaultGLProfile) {
@@ -119,22 +229,30 @@ public class GLProfile implements Cloneable {
return defaultGLProfile;
}
- /** Returns a GLProfile object.
- * Verfifies the given profile and chooses an apropriate implementation.
- * A generic value of <code>null</code> or <code>GL</code> will result in
- * the default profile.
+ /**
+ * Returns the highest profile, implementing the fixed function pipeline
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_FIXEDFUNC}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
*/
- public static final GLProfile get(String profile)
+ public static final GLProfile getMaxFixedFunc()
throws GLException
{
- if(null==profile || profile.equals("GL")) return getDefault();
- GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
- if(null==glProfile) {
- throw new GLException("No implementation for profile "+profile+" available");
- }
- return glProfile;
+ return get(GL_PROFILE_LIST_MAX_FIXEDFUNC);
+ }
+
+ /**
+ * Returns the highest profile, implementing the programmable shader pipeline.
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER}
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_PROGSHADER
+ */
+ public static final GLProfile getMaxProgrammable()
+ throws GLException
+ {
+ return get(GL_PROFILE_LIST_MAX_PROGSHADER);
}
/**
@@ -142,6 +260,7 @@ public class GLProfile implements Cloneable {
* It selects the first 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 final GLProfile getGL2ES1()
throws GLException
@@ -154,6 +273,7 @@ public class GLProfile implements Cloneable {
* It selects the first 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 final GLProfile getGL2ES2()
throws GLException
@@ -161,6 +281,24 @@ public class GLProfile implements Cloneable {
return get(GL_PROFILE_LIST_GL2ES2);
}
+ /** Returns a GLProfile object.
+ * Verfifies the given profile and chooses an apropriate implementation.
+ * A generic value of <code>null</code> or <code>GL</code> will result in
+ * the default profile.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile get(String profile)
+ throws GLException
+ {
+ if(null==profile || profile.equals("GL")) return getDefault();
+ GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
+ if(null==glProfile) {
+ throw new GLException("No implementation for profile "+profile+" available");
+ }
+ return glProfile;
+ }
+
/**
* Returns the first profile from the given list,
* where an implementation is available.
@@ -200,18 +338,12 @@ public class GLProfile implements Cloneable {
}
private static final String getGLImplBaseClassName(String profileImpl) {
- if(GL4bc.equals(profileImpl)) {
+ if ( GL4bc.equals(profileImpl) ||
+ GL4.equals(profileImpl) ||
+ GL3bc.equals(profileImpl) ||
+ GL3.equals(profileImpl) ||
+ GL2.equals(profileImpl) ) {
return "com.jogamp.opengl.impl.gl4.GL4bc";
- } else if(GL4.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl4.GL4";
- } else if(GL3bc.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl3.GL3bc";
- } else if(GL3.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl3.GL3";
- } else if(GL2.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl2.GL2";
- } else if(GL2ES12.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl2es12.GL2ES12";
} else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) {
return "com.jogamp.opengl.impl.es1.GLES1";
} else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) {
@@ -285,7 +417,7 @@ public class GLProfile implements Cloneable {
return isGL4() || isGL3bc() || GL3.equals(profile);
}
- /** Indicates whether this profile is capable of GL2. */
+ /** Indicates whether this context is a GL2 context */
public final boolean isGL2() {
return isGL3bc() || GL2.equals(profile);
}
@@ -315,34 +447,9 @@ public class GLProfile implements Cloneable {
return GL2GL3.equals(profile) || isGL2() || isGL3() ;
}
- /** Indicates whether this profile uses the native desktop OpenGL GL4bc implementations. */
- public final boolean usesNativeGL4bc() {
- return GL4bc.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL4 implementations. */
- public final boolean usesNativeGL4() {
- return usesNativeGL4bc() || GL4.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3bc implementations. */
- public final boolean usesNativeGL3bc() {
- return GL3bc.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3 implementations. */
- public final boolean usesNativeGL3() {
- return usesNativeGL3bc() || GL3.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL2 implementations. */
- public final boolean usesNativeGL2() {
- return GL2.equals(profileImpl) || GL2ES12.equals(profileImpl) ;
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL2 or GL3 implementations. */
- public final boolean usesNativeGL2GL3() {
- return usesNativeGL2() || usesNativeGL3() || usesNativeGL4();
+ /** Indicates whether this profile supports GLSL. */
+ public final boolean hasGLSL() {
+ return isGL2ES2() ;
}
/** Indicates whether this profile uses the native OpenGL ES1 implementations. */
@@ -360,11 +467,6 @@ public class GLProfile implements Cloneable {
return usesNativeGLES2() || usesNativeGLES1();
}
- /** Indicates whether this profile supports GLSL. */
- public final boolean hasGLSL() {
- return isGL2ES2() ;
- }
-
/**
* General validation if type is a valid GL data type
* for the current profile
@@ -665,70 +767,23 @@ public class GLProfile implements Cloneable {
return "GLProfile[" + profile + "/" + profileImpl + "]";
}
- public static final int GL_VERSIONS[][] = {
- /* 0.*/ { -1 },
- /* 1.*/ { 0, 1, 2, 3, 4, 5 },
- /* 2.*/ { 0, 1 },
- /* 3.*/ { 0, 1, 2, 3 },
- /* 4.*/ { 0 } };
-
- public static final int getMaxMajor() {
- return GL_VERSIONS.length-1;
- }
-
- public static final int getMaxMinor(int major) {
- if(1>major || major>=GL_VERSIONS.length) return -1;
- return GL_VERSIONS[major].length-1;
- }
-
- public static final boolean isValidGLVersion(int major, int minor) {
- if(1>major || major>=GL_VERSIONS.length) return false;
- if(0>minor || minor>=GL_VERSIONS[major].length) return false;
- return true;
- }
-
- public static final boolean decrementGLVersion(int major[], int minor[]) {
- if(null==major || major.length<1 ||null==minor || minor.length<1) {
- throw new GLException("invalid array arguments");
- }
- int m = major[0];
- int n = minor[0];
- if(!isValidGLVersion(m, n)) return false;
-
- // decrement ..
- n -= 1;
- if(n < 0) {
- m -= 1;
- n = GL_VERSIONS[m].length-1;
- }
- if(!isValidGLVersion(m, n)) return false;
- major[0]=m;
- minor[0]=n;
-
- return true;
- }
-
- // The intersection between desktop OpenGL and the union of the OpenGL ES profiles
- // This is here only to avoid having separate GL2ES1Impl and GL2ES2Impl classes
- private static final String GL2ES12 = "GL2ES12";
-
private static final boolean isAWTAvailable;
private static final boolean isAWTJOGLAvailable;
- private static final boolean hasGL4bcImpl;
- private static final boolean hasGL4Impl;
- private static final boolean hasGL3bcImpl;
- private static final boolean hasGL3Impl;
- private static final boolean hasGL2Impl;
- private static final boolean hasGL2ES12Impl;
- private static final boolean hasGLES2Impl;
- private static final boolean hasGLES1Impl;
+ private static /*final*/ boolean hasGL234Impl;
+ private static /*final*/ boolean hasGL4bcImpl;
+ private static /*final*/ boolean hasGL4Impl;
+ private static /*final*/ boolean hasGL3bcImpl;
+ private static /*final*/ boolean hasGL3Impl;
+ private static /*final*/ boolean hasGL2Impl;
+ private static /*final*/ boolean hasGLES2Impl;
+ private static /*final*/ boolean hasGLES1Impl;
/** The JVM/process wide default GL profile **/
- private static GLProfile defaultGLProfile;
+ private static /*final*/ GLProfile defaultGLProfile;
/** All GLProfiles */
- private static final HashMap/*<String, GLProfile>*/ mappedProfiles;
+ private static /*final*/ HashMap/*<String, GLProfile>*/ mappedProfiles;
/**
* Tries the profiles implementation and native libraries.
@@ -740,119 +795,174 @@ public class GLProfile implements Cloneable {
AccessControlContext acc = AccessController.getContext();
isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
- NWReflection.isClassAvailable("java.awt.Component") ;
+ ReflectionUtil.isClassAvailable("java.awt.Component") ;
isAWTJOGLAvailable = isAWTAvailable &&
- NWReflection.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow
- NWReflection.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
+ ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow
+ ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
boolean hasDesktopGL = false;
- boolean hasDesktopGLES12 = false;
boolean hasNativeOSFactory = false;
-
+ Throwable t;
+
+ //
+ // First iteration of desktop GL availability detection
+ // - native libs exist
+ // - class exists
+ //
+ t=null;
try {
// See DRIHack.java for an explanation of why this is necessary
DRIHack.begin();
- NativeLibLoader.loadGLDesktop();
+ GLJNILibLoader.loadGLDesktop();
DRIHack.end();
hasDesktopGL = true;
- } catch (Throwable t) {
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(null!=t) {
if (DEBUG) {
System.err.println("GLProfile.static Desktop GL Library not available");
t.printStackTrace();
}
}
- try {
- // See DRIHack.java for an explanation of why this is necessary
- DRIHack.begin();
- NativeLibLoader.loadGLDesktopES12();
- DRIHack.end();
- hasDesktopGLES12 = true;
- } catch (Throwable t) {
- if (DEBUG) {
- System.err.println("GLProfile.static Desktop GL ES12 Library not available");
- t.printStackTrace();
+ hasGL234Impl = hasDesktopGL && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl");
+ hasGL4bcImpl = hasGL234Impl;
+ hasGL4Impl = hasGL234Impl;
+ hasGL3bcImpl = hasGL234Impl;
+ hasGL3Impl = hasGL234Impl;
+ hasGL2Impl = hasGL234Impl;
+ mappedProfiles = computeProfileMap();
+
+ //
+ // Second iteration of desktop GL availability detection
+ // utilizing the detected GL version in the shared context.
+ //
+ // - Instantiate GLDrawableFactory incl its shared dummy drawable/context,
+ // which will register at GLContext ..
+ //
+
+ if(hasDesktopGL) {
+ // if successfull it has a shared dummy drawable and context created
+ try {
+ hasNativeOSFactory = null != GLDrawableFactory.getFactoryImpl(GL2);
+ } catch (RuntimeException re) {
+ System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
+ re.printStackTrace();
}
}
- if(hasDesktopGL||hasDesktopGLES12) {
- try {
- hasNativeOSFactory = null!=GLDrawableFactory.getFactoryImpl(GL2);
- } catch (Throwable t) {
- if (DEBUG) {
- System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
- t.printStackTrace();
- }
- }
+ if(hasNativeOSFactory && !GLContext.mappedVersionsAvailableSet) {
+ // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
+ // so we have to add the usual suspect
+ GLContext.mapVersionAvailable(2, true, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
if(!hasNativeOSFactory) {
- hasDesktopGLES12=false;
- hasDesktopGL=false;
+ hasDesktopGL = false;
+ hasGL234Impl = false;
+ hasGL4bcImpl = false;
+ hasGL4Impl = false;
+ hasGL3bcImpl = false;
+ hasGL3Impl = false;
+ hasGL2Impl = false;
+ } else {
+ hasGL4bcImpl = GLContext.isGL4bcAvailable();
+ hasGL4Impl = GLContext.isGL4Available();
+ hasGL3bcImpl = GLContext.isGL3bcAvailable();
+ hasGL3Impl = GLContext.isGL3Available();
+ hasGL2Impl = GLContext.isGL2Available();
}
- // FIXME: check for real GL3 availability .. ?
- hasGL4bcImpl = hasDesktopGL && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl");
- hasGL4Impl = hasDesktopGL && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4Impl");
- hasGL3bcImpl = hasDesktopGL && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl3.GL3bcImpl");
- hasGL3Impl = hasDesktopGL && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl3.GL3Impl");
- hasGL2Impl = hasDesktopGL && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl2.GL2Impl");
-
- hasGL2ES12Impl = hasDesktopGLES12 && NWReflection.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl");
-
boolean btest = false;
- boolean hasEGLDynLookup = NWReflection.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper");
+ boolean hasEGLDynLookup = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper");
boolean hasEGLDrawableFactory = false;
+ t=null;
try {
if(hasEGLDynLookup) {
hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2);
- btest = hasEGLDrawableFactory &&
- NWReflection.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") &&
- null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2);
+ try {
+ btest = hasEGLDrawableFactory &&
+ ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") &&
+ null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2);
+ } catch (GLException gle) {
+ // n/a ..
+ }
}
- } catch (Throwable t) {
+ } catch (UnsatisfiedLinkError ule) {
+ t=ule;
+ } catch (SecurityException se) {
+ t=se;
+ } catch (NullPointerException npe) {
+ t=npe;
+ } catch (RuntimeException re) {
+ t=re;
+ }
+ if(null!=t) {
if (DEBUG) {
System.err.println("GLProfile.static - GL ES2 Factory/Library not available");
t.printStackTrace();
}
}
hasGLES2Impl = btest;
+ if(hasGLES2Impl) {
+ GLContext.mapVersionAvailable(2, false, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ }
btest = false;
- try {
- if(hasEGLDynLookup) {
+ if(hasEGLDynLookup) {
+ try {
btest = hasEGLDrawableFactory &&
- NWReflection.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") &&
+ ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") &&
null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1);
- }
- } catch (Throwable t) {
- if (DEBUG) {
- System.err.println("GLProfile.static - GL ES1 Factory/Library not available");
- t.printStackTrace();
+ } catch (GLException jre) {
+ /* just not available .. */
}
}
hasGLES1Impl = btest;
+ if(hasGLES1Impl) {
+ GLContext.mapVersionAvailable(1, false, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ }
+
+ mappedProfiles = computeProfileMap();
+ if(null==defaultGLProfile) {
+ throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL));
+ }
if (DEBUG) {
System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.static isAWTJOGLAvailable "+isAWTJOGLAvailable);
System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory);
- System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL);
- System.err.println("GLProfile.static hasGL4bcImpl "+hasGL4bcImpl);
- System.err.println("GLProfile.static hasGL4Impl "+hasGL4Impl);
- System.err.println("GLProfile.static hasGL3bcImpl "+hasGL3bcImpl);
- System.err.println("GLProfile.static hasGL3Impl "+hasGL3Impl);
- System.err.println("GLProfile.static hasGL2Impl "+hasGL2Impl);
- System.err.println("GLProfile.static hasGL2ES12Impl "+hasGL2ES12Impl);
System.err.println("GLProfile.static hasEGLDynLookup "+hasEGLDynLookup);
System.err.println("GLProfile.static hasEGLDrawableFactory "+hasEGLDrawableFactory);
- System.err.println("GLProfile.static hasGLES2Impl "+hasGLES2Impl);
- System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl);
+ System.err.println("GLProfile.static hasGL234Impl "+hasGL234Impl);
+ System.err.println("GLProfile.static "+glAvailabilityToString());
+ }
+ }
+
+ private static final String list2String(String[] list) {
+ StringBuffer msg = new StringBuffer();
+ msg.append("[");
+ for (int i = 0; i < list.length; i++) {
+ if (i > 0)
+ msg.append(", ");
+ msg.append(list[i]);
}
+ msg.append("]");
+ return msg.toString();
+ }
+ private static HashMap computeProfileMap() {
+ defaultGLProfile=null;
HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length);
for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) {
String profile = GL_PROFILE_LIST_ALL[i];
@@ -875,73 +985,55 @@ public class GLProfile implements Cloneable {
}
}
}
- mappedProfiles = _mappedProfiles; // final ..
- if(null==defaultGLProfile) {
- throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL));
- }
- }
-
- private static final String list2String(String[] list) {
- StringBuffer msg = new StringBuffer();
- msg.append("[");
- for (int i = 0; i < list.length; i++) {
- if (i > 0)
- msg.append(", ");
- msg.append(list[i]);
- }
- msg.append("]");
- return msg.toString();
+ return _mappedProfiles;
}
/**
* Returns the profile implementation
*/
private static String computeProfileImpl(String profile) {
- // FIXME Order of return profiles, after we can test their availability
if (GL2ES1.equals(profile)) {
- if(hasGL2ES12Impl) {
- return GL2ES12;
- } else if(hasGL2Impl) {
+ if(hasGL2Impl) {
return GL2;
+ } else if(hasGL3bcImpl) {
+ return GL3bc;
+ } else if(hasGL4bcImpl) {
+ return GL4bc;
} else if(hasGLES1Impl) {
return GLES1;
}
} else if (GL2ES2.equals(profile)) {
- if(hasGL2ES12Impl) {
- return GL2ES12;
- } else if(hasGL2Impl) {
+ if(hasGL2Impl) {
return GL2;
} else if(hasGL3Impl) {
return GL3;
- } else if(hasGL3bcImpl) {
- return GL3bc;
} else if(hasGL4Impl) {
return GL4;
- } else if(hasGL4bcImpl) {
- return GL4bc;
} else if(hasGLES2Impl) {
return GLES2;
}
- } else if(GL4bc.equals(profile) && hasGL4bcImpl) {
- return GL4bc;
- } else if(GL4.equals(profile)) {
- if(hasGL4Impl) {
- return GL4;
+ } else if(GL2GL3.equals(profile)) {
+ if(hasGL2Impl) {
+ return GL2;
+ } else if(hasGL3bcImpl) {
+ return GL3bc;
} else if(hasGL4bcImpl) {
return GL4bc;
+ } else if(hasGL3Impl) {
+ return GL3;
+ } else if(hasGL4Impl) {
+ return GL4;
}
+ } else if(GL4bc.equals(profile) && hasGL4bcImpl) {
+ return GL4bc;
+ } else if(GL4.equals(profile) && hasGL4Impl) {
+ return GL4;
} else if(GL3bc.equals(profile) && hasGL3bcImpl) {
return GL3bc;
- } else if(GL3.equals(profile)) {
- if(hasGL3Impl) {
- return GL3;
- } else if(hasGL3bcImpl) {
- return GL3bc;
- }
+ } else if(GL3.equals(profile) && hasGL3Impl) {
+ return GL3;
} else if(GL2.equals(profile) && hasGL2Impl) {
return GL2;
- } else if(GL2GL3.equals(profile) && hasGL2Impl) {
- return GL2;
} else if(GLES2.equals(profile) && hasGLES2Impl) {
return GLES2;
} else if(GLES1.equals(profile) && hasGLES1Impl) {