aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/scripts/java-run-all.sh1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java44
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java4
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java37
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java30
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java132
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java70
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java11
-rwxr-xr-xsrc/newt/native/WindowsWindow.c2
10 files changed, 228 insertions, 105 deletions
diff --git a/make/scripts/java-run-all.sh b/make/scripts/java-run-all.sh
index de4fdc3fe..9c3fbed03 100755
--- a/make/scripts/java-run-all.sh
+++ b/make/scripts/java-run-all.sh
@@ -36,6 +36,7 @@ uname -a | grep -i Darwin && MOSX=1
# D_ARGS="-Dnativewindow.debug.X11Util=true -Djogl.debug.GLDrawableFactory=true"
# D_ARGS="-Dnativewindow.debug.X11Util=true"
# D_ARGS="-Dnewt.debug=all"
+# D_ARGS="-Djogl.debug=all"
echo java $X_ARGS $D_ARGS $* 2>&1 | tee java-run.log
java $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index e5f8211c3..91530e078 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -438,6 +438,7 @@ public abstract class GLContextImpl extends GLContext {
private void createContextARBMapVersionsAvailable(int reqMajor, boolean compat)
{
long _context;
+ int reqProfile = compat ? CTX_PROFILE_COMPAT : CTX_PROFILE_CORE ;
int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default
if(compat) {
ctp &= ~CTX_PROFILE_CORE ;
@@ -495,7 +496,7 @@ public abstract class GLContextImpl extends GLContext {
}
if(0!=_context) {
destroyContextARBImpl(_context);
- mapVersionAvailable(reqMajor, compat, major[0], minor[0], ctp);
+ mapVersionAvailable(reqMajor, reqProfile, major[0], minor[0], ctp);
}
}
@@ -532,8 +533,7 @@ public abstract class GLContextImpl extends GLContext {
*/
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;
+ throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
}
if(major>0 || minor>0) {
if (!GLContext.isValidGLVersion(major, minor)) {
@@ -543,7 +543,7 @@ public abstract class GLContextImpl extends GLContext {
ctxMajorVersion = major;
ctxMinorVersion = minor;
ctxOptions = ctp;
- ctxVersionString = getGLVersion(gl, ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION));
+ ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION));
return;
}
@@ -560,46 +560,12 @@ public abstract class GLContextImpl extends GLContext {
ctxMajorVersion = version.getMajor();
ctxMinorVersion = version.getMinor();
- ctxVersionString = getGLVersion(gl, ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr);
+ ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr);
return;
}
}
}
- private static boolean appendString(StringBuffer sb, String string, boolean needColon, boolean condition) {
- if(condition) {
- if(needColon) {
- sb.append(", ");
- }
- sb.append(string);
- needColon=true;
- }
- return needColon;
- }
-
- protected static String getGLVersion(GL gl, int major, int minor, int ctp, String gl_version) {
- boolean needColon = false;
- StringBuffer sb = new StringBuffer();
- sb.append(major);
- sb.append(".");
- sb.append(minor);
- sb.append(" (");
- needColon = appendString(sb, "ES", needColon, null!=gl && gl.isGLES());
- needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
- needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
- needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
- needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp ));
- needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
- needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp ));
- sb.append(") - ");
- if(null!=gl_version) {
- sb.append(gl_version);
- } else {
- sb.append("n/a");
- }
- return sb.toString();
- }
-
//----------------------------------------------------------------------
// Helpers for various context implementations
//
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 144c4692e..95301b9d0 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
@@ -116,7 +116,7 @@ public abstract class EGLContext extends GLContextImpl {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_OPTION_ANY);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
@@ -226,7 +226,7 @@ public abstract class EGLContext extends GLContextImpl {
throw new GLException("Error making context 0x" +
Long.toHexString(eglContext) + " current: error code " + EGL.eglGetError());
}
- setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
+ setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_OPTION_ANY);
}
public boolean isCreated() {
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 5a8454ea7..b289aa9ce 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, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY);
+ setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|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/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index b59cb7940..489e4c860 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
@@ -143,46 +143,49 @@ public class WindowsWGLContext extends GLContextImpl {
long _context=0;
+ final int idx_flags = 4;
+ final int idx_profile = 6;
+
+ /* WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, */
+
int attribs[] = {
/* 0 */ WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, major,
/* 2 */ WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, minor,
- /* 4 */ WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, // default
- /* 6 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0,
- /* 8 */ 0, 0,
- /* 10 */ 0
+ /* 4 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0,
+ /* 6 */ 0, 0,
+ /* 8 */ 0
};
if ( major > 3 || major == 3 && minor >= 2 ) {
// FIXME: Verify with a None drawable binding (default framebuffer)
- attribs[8+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB;
+ attribs[idx_profile+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB;
if( ctBwdCompat ) {
- attribs[8+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+ attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
} else {
- attribs[8+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+ attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
}
}
if ( major >= 3 ) {
if( !ctBwdCompat && ctFwdCompat ) {
- attribs[6+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[idx_flags+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
}
if( ctDebug) {
- attribs[6+1] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB;
+ attribs[idx_flags+1] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB;
}
}
_context = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), share, attribs, 0);
- if(0==_context) {
- if(DEBUG) {
- System.err.println("WindowsWGLContext.createContextARB couldn't create "+getGLVersion(null, major, minor, ctp, "@creation"));
- }
- } else {
+ if(DEBUG) {
+ System.err.println("WindowsWGLContext.createContextARB success: "+(0!=_context)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat);
+ }
+ if(0!=_context) {
// In contrast to GLX no verification with a drawable binding, ie default framebuffer, is necessary,
// if no 3.2 is available creation fails already!
// Nevertheless .. we do it ..
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), _context)) {
if(DEBUG) {
- System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(null, major, minor, ctp, "@creation"));
+ System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
}
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(_context);
@@ -270,10 +273,10 @@ public class WindowsWGLContext extends GLContextImpl {
if(glCaps.getGLProfile().isGL3()) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
- throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")+", ");
+ throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", ");
}
if(DEBUG) {
- System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation"));
+ System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation"));
}
// continue with temp context for GL < 3.0
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 cdb7931d1..9c3efea2e 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
@@ -148,6 +148,9 @@ public abstract class X11GLXContext extends GLContextImpl {
long _context=0;
+ final int idx_flags = 6;
+ final int idx_profile = 8;
+
int attribs[] = {
/* 0 */ GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, major,
/* 2 */ GLX.GLX_CONTEXT_MINOR_VERSION_ARB, minor,
@@ -159,20 +162,20 @@ public abstract class X11GLXContext extends GLContextImpl {
if ( major > 3 || major == 3 && minor >= 2 ) {
// FIXME: Verify with a None drawable binding (default framebuffer)
- attribs[8+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB;
+ attribs[idx_profile+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB;
if( ctBwdCompat ) {
- attribs[8+1] = GLX.GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+ attribs[idx_profile+1] = GLX.GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
} else {
- attribs[8+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+ attribs[idx_profile+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
}
}
if ( major >= 3 ) {
if( !ctBwdCompat && ctFwdCompat ) {
- attribs[6+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[idx_flags+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
}
if( ctDebug) {
- attribs[6+1] |= GLX.GLX_CONTEXT_DEBUG_BIT_ARB;
+ attribs[idx_flags+1] |= GLX.GLX_CONTEXT_DEBUG_BIT_ARB;
}
}
@@ -180,21 +183,20 @@ public abstract class X11GLXContext extends GLContextImpl {
_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"));
+ System.err.println("X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(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(DEBUG) {
+ System.err.println("X11GLXContext.createContextARB success: "+(0!=_context)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat);
+ }
+ if(0!=_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"));
+ System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
}
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, _context);
@@ -312,10 +314,10 @@ public abstract class X11GLXContext extends GLContextImpl {
if(glp.isGL3()) {
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")+", ");
+ throw new GLException("X11GLXContext.createContext failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", ");
}
if(DEBUG) {
- System.err.println("X11GLXContext.createContext failed, fall back to !ARB context "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation"));
+ System.err.println("X11GLXContext.createContext failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation"));
}
// continue with temp context for GL <= 3.0
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c07bbeaf4..37172e370 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -300,6 +300,8 @@ public abstract class GLContext {
public final int getGLVersionMajor() { return ctxMajorVersion; }
public final int getGLVersionMinor() { return ctxMinorVersion; }
public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
+ public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); }
+ public final boolean isGLEmbeddedProfile() { return ( 0 != ( CTX_PROFILE_ES & ctxOptions ) ); }
public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
@@ -355,7 +357,7 @@ public abstract class GLContext {
protected static final int CTX_PROFILE_COMPAT = 1 << 1;
/** <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 */
+ /** <code>ARB_create_context</code> related: ES profile */
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;
@@ -366,23 +368,23 @@ public abstract class GLContext {
public final boolean isGL4bc() {
- return ctxMajorVersion>=4 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=4 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL4() {
- return ctxMajorVersion>=4 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ return ctxMajorVersion>=4 && 0!=(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE));
}
public final boolean isGL3bc() {
- return ctxMajorVersion>=3 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=3 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL3() {
- return ctxMajorVersion>=3 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ return ctxMajorVersion>=3 && 0!=(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE));
}
public final boolean isGL2() {
- return ctxMajorVersion>=1 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ return ctxMajorVersion>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT);
}
public final boolean isGL2GL3() {
@@ -390,15 +392,15 @@ public abstract class GLContext {
}
public final boolean isGLES1() {
- return ctxMajorVersion==1 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return ctxMajorVersion==1 && 0!=(ctxOptions & CTX_PROFILE_ES);
}
public final boolean isGLES2() {
- return ctxMajorVersion==2 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return ctxMajorVersion==2 && 0!=(ctxOptions & CTX_PROFILE_ES);
}
public final boolean isGLES() {
- return CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ return isGLEmbeddedProfile();
}
public final boolean isGL2ES1() {
@@ -456,16 +458,79 @@ public abstract class GLContext {
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;
+ /**
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ */
+ public static final String getGLVersionAvailable(int major, int profile) {
+ int _major[] = { 0 };
+ int _minor[] = { 0 };
+ int _ctp[] = { 0 };
+ if(getGLVersionAvailable(major, profile, _major, _minor, _ctp)) {
+ return getGLVersion(_major[0], _minor[0], _ctp[0], null);
+ }
+ return null;
+ }
+
+ /**
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @param major if not null, returns the used major version
+ * @param minor if not null, returns the used minor version
+ * @param ctp if not null, returns the used context profile
+ */
+ public static final boolean getGLVersionAvailable(int reqMajor, int reqProfile, int[] major, int minor[], int ctp[]) {
+ int key = compose8bit(reqMajor, reqProfile, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ if(val<=0) {
+ return false;
+ }
+ if(null!=major) {
+ major[0] = getComposed8bit(val, 1);
+ }
+ if(null!=minor) {
+ minor[0] = getComposed8bit(val, 2);
+ }
+ if(null!=ctp) {
+ ctp[0] = getComposed8bit(val, 3);
+ }
+ return true;
+ }
+
+ /**
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ */
+ public static final boolean isGLVersionAvailable(int major, int profile) {
+ return getGLVersionAvailable(major, profile, null, null, null);
+ }
+ public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, CTX_PROFILE_COMPAT); }
+ public static final boolean isGL4Available() { return isGLVersionAvailable(4, CTX_PROFILE_CORE); }
+ public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, CTX_PROFILE_COMPAT); }
+ public static final boolean isGL3Available() { return isGLVersionAvailable(3, CTX_PROFILE_CORE); }
+ public static final boolean isGL2Available() { return isGLVersionAvailable(2, CTX_PROFILE_COMPAT); }
+
+ public static String getGLVersion(int major, int minor, int ctp, String gl_version) {
+ boolean needColon = false;
+ StringBuffer sb = new StringBuffer();
+ sb.append(major);
+ sb.append(".");
+ sb.append(minor);
+ sb.append(" (");
+ needColon = appendString(sb, "ES", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
+ needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
+ needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
+ needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
+ needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp ));
+ needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
+ needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp ));
+ sb.append(")");
+ if(null!=gl_version) {
+ sb.append(" - ");
+ sb.append(gl_version);
+ }
+ return sb.toString();
}
- 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;
@@ -478,16 +543,32 @@ public abstract class GLContext {
mappedVersionsAvailable.setKeyNotFoundValue(-1);
}
+ private static void validateProfileBits(int bits, String argName) {
+ int num = 0;
+ if( 0 != ( CTX_PROFILE_COMPAT & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_CORE & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_ES & bits ) ) { num++; }
+ if(1!=num) {
+ throw new GLException("Internal Error: "+argName+": 1 != num-profiles: "+num);
+ }
+ }
+
/**
* 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.
*
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+
* @see #createContextARBMapVersionsAvailable
*/
- protected static void mapVersionAvailable(int reqMajor, boolean reqCompat, int resMajor, int resMinor, int resCtp)
+ protected static void mapVersionAvailable(int reqMajor, int profile, int resMajor, int resMinor, int resCtp)
{
- int key = compose8bit(reqMajor, reqCompat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ validateProfileBits(profile, "profile");
+ validateProfileBits(resCtp, "resCtp");
+
+ int key = compose8bit(reqMajor, profile, 0, 0);
int val = compose8bit(resMajor, resMinor, resCtp, 0);
mappedVersionsAvailable.put( key, val );
}
@@ -532,5 +613,16 @@ public abstract class GLContext {
return "0x" + Long.toHexString(hex);
}
+ private static boolean appendString(StringBuffer sb, String string, boolean needColon, boolean condition) {
+ if(condition) {
+ if(needColon) {
+ sb.append(", ");
+ }
+ sb.append(string);
+ needColon=true;
+ }
+ return needColon;
+ }
+
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 7b8ac6c2a..6b49b24df 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -72,26 +72,76 @@ public class GLProfile implements Cloneable {
public static final boolean isGL2ES1Available() { return null != mappedProfiles.get(GL2ES1); }
public static final boolean isGL2ES2Available() { return null != mappedProfiles.get(GL2ES2); }
+ private static final void glAvailabilityToString(StringBuffer sb, int major, int profile) {
+ String str = GLContext.getGLVersionAvailable(major, profile);
+ if(null==str) {
+ throw new GLException("Internal Error");
+ }
+ sb.append("[");
+ sb.append(str);
+ sb.append("]");
+ }
+
public static final String glAvailabilityToString() {
+ boolean avail;
+ String str;
StringBuffer sb = new StringBuffer();
+
sb.append("GLAvailability[Native[GL4bc ");
- sb.append(isGL4bcAvailable());
+ avail=isGL4bcAvailable();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 4, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL4 ");
- sb.append(isGL4Available());
+ avail=isGL4Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 4, GLContext.CTX_PROFILE_CORE);
+ }
+
sb.append(", GL3bc ");
- sb.append(isGL3bcAvailable());
+ avail=isGL3bcAvailable();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 3, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL3 ");
- sb.append(isGL3Available());
+ avail=isGL3Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 3, GLContext.CTX_PROFILE_CORE);
+ }
+
sb.append(", GL2 ");
- sb.append(isGL2Available());
+ avail=isGL2Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 2, GLContext.CTX_PROFILE_COMPAT);
+ }
+
sb.append(", GL2ES1 ");
sb.append(isGL2ES1Available());
+
sb.append(", GLES1 ");
- sb.append(isGLES1Available());
+ avail=isGLES1Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 1, GLContext.CTX_PROFILE_ES);
+ }
+
sb.append(", GL2ES2 ");
sb.append(isGL2ES2Available());
+
sb.append(", GLES2 ");
- sb.append(isGLES2Available());
+ avail=isGLES2Available();
+ sb.append(avail);
+ if(avail) {
+ glAvailabilityToString(sb, 2, GLContext.CTX_PROFILE_ES);
+ }
+
sb.append("], Profiles[");
for(Iterator i=mappedProfiles.values().iterator(); i.hasNext(); ) {
sb.append(((GLProfile)i.next()).toString());
@@ -910,7 +960,7 @@ public class GLProfile implements Cloneable {
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);
+ GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_COMPAT, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
if(!hasNativeOSFactory) {
@@ -957,7 +1007,7 @@ public class GLProfile implements Cloneable {
}
hasGLES2Impl = btest;
if(hasGLES2Impl) {
- GLContext.mapVersionAvailable(2, false, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ GLContext.mapVersionAvailable(2, GLContext.CTX_PROFILE_ES, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
}
btest = false;
@@ -983,7 +1033,7 @@ public class GLProfile implements Cloneable {
}
hasGLES1Impl = btest;
if(hasGLES1Impl) {
- GLContext.mapVersionAvailable(1, false, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY);
+ GLContext.mapVersionAvailable(1, GLContext.CTX_PROFILE_ES, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
}
mappedProfiles = computeProfileMap();
diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
index 742b8d5e8..1652acd82 100755
--- a/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
+++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestAWT01GLn.java
@@ -43,6 +43,7 @@ import java.awt.Frame;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Test;
@@ -50,6 +51,11 @@ public class TestAWT01GLn {
Frame frame=null;
GLCanvas glCanvas=null;
+ @BeforeClass
+ public static void startup() {
+ System.out.println("GLProfile <static> "+GLProfile.glAvailabilityToString());
+ }
+
@Before
public void init() {
frame = new Frame("Texture Test");
@@ -93,13 +99,16 @@ public class TestAWT01GLn {
@Test
public void test01GLDefault() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLProfile glp = GLProfile.getDefault();
+ System.out.println("GLProfile Default: "+glp);
+ GLCapabilities caps = new GLCapabilities(glp);
runTestGL(caps);
}
@Test
public void test03GLMaxFixed() throws InterruptedException {
GLProfile maxFixed = GLProfile.getMaxFixedFunc();
+ System.out.println("GLProfile MaxFixed: "+maxFixed);
GLCapabilities caps = new GLCapabilities(maxFixed);
try {
runTestGL(caps);
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index b500e3217..29b8f4691 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -98,7 +98,7 @@
#include "NewtCommon.h"
-#define VERBOSE_ON 1
+// #define VERBOSE_ON 1
// #define DEBUG_KEYS 1
#ifdef VERBOSE_ON