summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-16 03:51:00 +0200
committerSven Gothel <[email protected]>2010-04-16 03:51:00 +0200
commitbb028021be2714e66d9b1062298a3e308c649c56 (patch)
treed20a568ae0d7da2b9f600464a5bc18d88edb1b89 /src/jogl/classes/javax
parentbd4904fb04ab2168aeaf76e74385b3991429289a (diff)
JOGL GL4 preperation:
- Re-Enable GL3bc native library build, works .. - Adding all the is/get GL4/GL4bc stubs .. - Adding dummy interface GL4 and GL4bc, will be removed when done - Context creation refactoring: - Move Version information to GLContext - Determine version by creation if possible (ARB_create_context), only use the unreliable GL_VERSION string if necessary. - Offering an almost platform independent ARB_create_context path: - createContextARBImpl - platform dependent GLX calls - createContextARB - platform independent setup and version loop
Diffstat (limited to 'src/jogl/classes/javax')
-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/GLBase.java28
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java68
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java120
5 files changed, 202 insertions, 24 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GL4.java b/src/jogl/classes/javax/media/opengl/GL4.java
new file mode 100644
index 000000000..29a316333
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GL4.java
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 000000000..be1131e91
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GL4bc.java
@@ -0,0 +1,5 @@
+package javax.media.opengl;
+
+public interface GL4bc extends GL4 {
+}
+
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index 369907c22..5ba410a61 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -64,6 +64,20 @@ public interface GLBase {
public boolean isGL();
/**
+ * Indicates whether this GL object conforms to the GL4 compatibility profile.
+ * The GL4 compatibility profile merges the GL2 profile and GL4 core profile.
+ * @return whether this GL object conforms to the GL4 compatibility profile
+ */
+ public boolean isGL4bc();
+
+ /**
+ * Indicates whether this GL object conforms to the GL4 core profile.
+ * The GL4 core profile reflects OpenGL versions greater or equal 3.1
+ * @return whether this GL object conforms to the GL4 core profile
+ */
+ public boolean isGL4();
+
+ /**
* Indicates whether this GL object conforms to the GL3 compatibility profile.
* The GL3 compatibility profile merges the GL2 profile and GL3 core profile.
* @return whether this GL object conforms to the GL3 compatibility profile
@@ -131,6 +145,20 @@ public interface GLBase {
public GL getGL() throws GLException;
/**
+ * Casts this object to the GL4bc interface.
+ * @return this object cast to the GL4bc interface
+ * @throws GLException if this GLObject is not a GL4bc implementation
+ */
+ public GL4bc getGL4bc() throws GLException;
+
+ /**
+ * Casts this object to the GL4 interface.
+ * @return this object cast to the GL4 interface
+ * @throws GLException if this GLObject is not a GL4 implementation
+ */
+ public GL4 getGL4() throws GLException;
+
+ /**
* Casts this object to the GL3bc interface.
* @return this object cast to the GL3bc interface
* @throws GLException if this GLObject is not a GL3bc implementation
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 1e52c2a65..a8dbf9213 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -260,7 +260,9 @@ public abstract class GLContext {
public final String toString() {
StringBuffer sb = new StringBuffer();
sb.append(getClass().getName());
- sb.append(" [");
+ sb.append(" [OpenGL ");
+ sb.append(getGLVersion());
+ sb.append(", ");
sb.append(getGL());
if(getGLDrawable()!=getGLDrawableRead()) {
sb.append(",\n\tDrawable Read : ");
@@ -280,4 +282,68 @@ public abstract class GLContext {
GLX) extensions. Can only be called while this context is
current. */
public abstract String getPlatformExtensionsString();
+
+ public final int getGLVersionMajor() { return ctxMajorVersion; }
+ public final int getGLVersionMinor() { return ctxMajorVersion; }
+ public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
+ public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
+
+ /**
+ * Returns a valid OpenGL version string, ie
+ * <code>major.minor ([option]?[options,]*) - gl-version</code>
+ *
+ * <ul>
+ * <li> options
+ * <ul>
+ * <li> <code>old</code> refers to the non ARB_create_context created context
+ * <li> <code>new</code> refers to the ARB_create_context created context
+ * <li> <code>compatible profile</code>
+ * <li> <code>core profile</code>
+ * <li> <code>forward compatible</code>
+ * <li> <code>any</code> refers to the non forward compatible context
+ * <li> <code>ES</code> refers to the GLES context variant
+ * </ul>
+ * <li> <i>gl-version</i> the GL_VERSION string
+ * </ul>
+ *
+ * e.g.:
+ * <table border="0">
+ * <tr> <td></td> <td></td> </tr>
+ * <tr>
+ * <td>row 2, cell 1</td>
+ * <td>row 2, cell 2</td>
+ * </tr>
+ * </table>
+ *
+ * <table border="0">
+ * <tr><td></td> <td>ES2</td> <td><code>2.0 (ES, any, new) - 2.0 ES Profile</code></td></tr>
+ * <tr><td>ATI</td><td>GL2</td> <td><code>3.0 (compatibility profile, any, new) - 3.2.9704 Compatibility Profile Context</code></td></tr>
+ * <tr><td>ATI</td><td>GL3</td> <td><code>3.3 (core profile, any, new) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr>
+ * <tr><td>ATI</td><td>GL3bc</td><td><code>3.3 (compatibility profile, any, new) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr>
+ * <tr><td>NV</td><td>GL2</td> <td><code>3.0 (compatibility profile, any, new) - 3.0.0 NVIDIA 195.36.07.03</code></td></tr>
+ * <tr><td>NV</td><td>GL3</td> <td><code>3.3 (core profile, any, new) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr>
+ * <tr><td>NV</td><td>GL3bc</td> <td><code>3.3 (compatibility profile, any, new) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr>
+ * </table>
+ */
+ public final String getGLVersion() {
+ return ctxVersionString;
+ }
+
+ protected int ctxMajorVersion=-1;
+ protected int ctxMinorVersion=-1;
+ protected int ctxOptions=0;
+ protected String ctxVersionString=null;
+
+ /** <code>ARB_create_context</code> related: created via ARB_create_context */
+ protected static final int CTX_IS_ARB_CREATED = 1 << 0;
+ /** <code>ARB_create_context</code> related: compatibility profile */
+ 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 */
+ protected static final int CTX_OPTION_FORWARD = 1 << 3;
+ /** <code>ARB_create_context</code> related: not flag forward compatible */
+ protected static final int CTX_OPTION_ANY = 1 << 4;
+ /** <code>ARB_create_context</code> related: flag debug */
+ protected static final int CTX_OPTION_DEBUG = 1 << 5;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 755fae73d..231faab8c 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -62,6 +62,13 @@ public class GLProfile implements Cloneable {
// Public (user-visible) profiles
//
+ /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br>
+ <code>bc</code> stands for backward compatibility. */
+ public static final String GL4bc = "GL4bc";
+
+ /** The desktop OpenGL core profile 4.x, with x >= 0 */
+ public static final String GL4 = "GL4";
+
/** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br>
<code>bc</code> stands for backward compatibility. */
public static final String GL3bc = "GL3bc";
@@ -90,12 +97,12 @@ public class GLProfile implements Cloneable {
/**
* All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3bc, GL3 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL4bc, GL3bc, GL4, GL3 };
/**
* All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
*/
- public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL3bc, GL3 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL4bc, GL3bc, GL4, GL3 };
/**
* All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1
@@ -193,7 +200,11 @@ public class GLProfile implements Cloneable {
}
private static final String getGLImplBaseClassName(String profileImpl) {
- if(GL3bc.equals(profileImpl)) {
+ if(GL4bc.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";
@@ -254,19 +265,29 @@ public class GLProfile implements Cloneable {
return profileImpl;
}
+ /** Indicates whether this profile is capable of GL4bc. */
+ public final boolean isGL4bc() {
+ return GL4bc.equals(profile);
+ }
+
+ /** Indicates whether this profile is capable of GL4. */
+ public final boolean isGL4() {
+ return isGL4bc() || GL4.equals(profile);
+ }
+
/** Indicates whether this profile is capable of GL3bc. */
public final boolean isGL3bc() {
- return GL3bc.equals(profile);
+ return isGL4bc() || GL3bc.equals(profile);
}
/** Indicates whether this profile is capable of GL3. */
public final boolean isGL3() {
- return isGL3bc() || GL3.equals(profile);
+ return isGL4() || isGL3bc() || GL3.equals(profile);
}
/** Indicates whether this profile is capable of GL2. */
public final boolean isGL2() {
- return GL2.equals(profile);
+ return isGL3bc() || GL2.equals(profile);
}
/** Indicates whether this profile is capable of GLES1. */
@@ -294,24 +315,14 @@ public class GLProfile implements Cloneable {
return GL2GL3.equals(profile) || isGL2() || isGL3() ;
}
- /** Indicates whether this profile uses the native OpenGL ES1 implementations. */
- public final boolean usesNativeGLES1() {
- return GLES1.equals(profileImpl);
+ /** 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 OpenGL ES2 implementations. */
- public final boolean usesNativeGLES2() {
- return GLES2.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses either of the native OpenGL ES implementations. */
- public final boolean usesNativeGLES() {
- return usesNativeGLES2() || usesNativeGLES1();
- }
-
- /** 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 GL4 implementations. */
+ public final boolean usesNativeGL4() {
+ return usesNativeGL4bc() || GL4.equals(profileImpl);
}
/** Indicates whether this profile uses the native desktop OpenGL GL3bc implementations. */
@@ -324,9 +335,29 @@ public class GLProfile implements Cloneable {
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() ;
+ return usesNativeGL2() || usesNativeGL3() || usesNativeGL4();
+ }
+
+ /** Indicates whether this profile uses the native OpenGL ES1 implementations. */
+ public final boolean usesNativeGLES1() {
+ return GLES1.equals(profileImpl);
+ }
+
+ /** Indicates whether this profile uses the native OpenGL ES2 implementations. */
+ public final boolean usesNativeGLES2() {
+ return GLES2.equals(profileImpl);
+ }
+
+ /** Indicates whether this profile uses either of the native OpenGL ES implementations. */
+ public final boolean usesNativeGLES() {
+ return usesNativeGLES2() || usesNativeGLES1();
}
/** Indicates whether this profile supports GLSL. */
@@ -634,6 +665,49 @@ 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";