From 4e0a5af0b359b98b26ea3e961d023c658650be6c Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Sat, 1 Aug 2009 05:37:29 -0700
Subject: GL3 Related:
- Fix glGetStringi's return type to String
- Fix ExtensionAvailabilityCache:
GL3's glGetStringi for GL_EXTENSIONS
Ensure to add GL_VERSION_2_0 in case version >= 3.0
Ensure to not exceed version 3.0 for non GL3.1 context.
In case of GL 3.1, do not include GL_VERSIONS below 3.0,
since this is a forward compatible context.
- Add Prologue to glGetString, where the ExtensionCache is being
used for GL_EXTENSIONS - if already initialized.
This feature adds backward compatibility for GL3 context on GL_EXTENSION.
+++
General:
Add GLPipelineFactory, a convenient pipeline factory for Debug/Trace and custom ones ..
Change 'void setGL(GL)' to 'GL setGL(GL)', and let it return the successful set GL,
or null.
---
.../opengl/impl/ExtensionAvailabilityCache.java | 178 +++++++++++++++++----
1 file changed, 147 insertions(+), 31 deletions(-)
(limited to 'src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java')
diff --git a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
index eee308088..7931f791b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
@@ -65,7 +65,25 @@ public final class ExtensionAvailabilityCache {
*/
public void flush()
{
+ if(DEBUG) {
+ System.out.println("ExtensionAvailabilityCache: Flush availability OpenGL "+majorVersion+"."+minorVersion);
+ }
availableExtensionCache.clear();
+ initialized = false;
+ majorVersion = 1;
+ minorVersion = 0;
+ }
+
+ /**
+ * Flush the cache and rebuild the cache.
+ */
+ public void reset() {
+ flush();
+ initAvailableExtensions();
+ }
+
+ public boolean isInitialized() {
+ return initialized && !availableExtensionCache.isEmpty() ;
}
public boolean isExtensionAvailable(String glExtensionName) {
@@ -73,19 +91,101 @@ public final class ExtensionAvailabilityCache {
return availableExtensionCache.contains(mapGLExtensionName(glExtensionName));
}
- protected void initAvailableExtensions() {
+ public String getPlatformExtensionsString() {
+ initAvailableExtensions();
+ return glXExtensions;
+ }
+
+ public String getGLExtensions() {
+ initAvailableExtensions();
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: getGLExtensions() called");
+ }
+ return glExtensions;
+ }
+
+ public int getMajorVersion() {
+ initAvailableExtensions();
+ return majorVersion;
+ }
+
+ public int getMinorVersion() {
+ initAvailableExtensions();
+ return minorVersion;
+ }
+
+ private void initAvailableExtensions() {
// if hash is empty (meaning it was flushed), pre-cache it with the list
// of extensions that are in the GL_EXTENSIONS string
- if (availableExtensionCache.isEmpty()) {
+ if (availableExtensionCache.isEmpty() || !initialized) {
GL gl = context.getGL();
+
if (DEBUG) {
- System.err.println("!!! Pre-caching extension availability");
+ System.err.println("ExtensionAvailabilityCache: Pre-caching init "+gl+", GL_VERSION "+gl.glGetString(GL.GL_VERSION));
+ }
+
+ // Set version
+ Version version = new Version(gl.glGetString(GL.GL_VERSION));
+ if (version.isValid()) {
+ majorVersion = version.getMajor();
+ minorVersion = version.getMinor();
+
+ if( !gl.isGL3() &&
+ ( majorVersion > 3 ||
+ ( majorVersion == 3 && minorVersion >= 1 ) ) ) {
+ // downsize version to 3.0 in case we are not using GL3 (3.1)
+ majorVersion = 3;
+ minorVersion = 0;
+ }
}
- String allAvailableExtensions =
- gl.glGetString(GL.GL_EXTENSIONS) + " " + context.getPlatformExtensionsString();
+
+ boolean useGetStringi = false;
+
+ if ( majorVersion > 3 ||
+ ( majorVersion == 3 && minorVersion >= 0 ) ||
+ gl.isGL3() ) {
+ if ( ! gl.isGL2GL3() ) {
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no GL2GL3 interface: "+gl.getClass().getName());
+ }
+ } else if ( ! gl.isFunctionAvailable("glGetStringi") ) {
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no glGetStringi");
+ }
+ } else {
+ useGetStringi = true;
+ }
+ }
+
if (DEBUG) {
- System.err.println("!!! Available extensions: " + allAvailableExtensions);
- System.err.println("!!! GL vendor: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("ExtensionAvailabilityCache: Pre-caching extension availability OpenGL "+majorVersion+"."+minorVersion+
+ ", use "+ ( useGetStringi ? "glGetStringi" : "glGetString" ) );
+ }
+
+ StringBuffer sb = new StringBuffer();
+ if(useGetStringi) {
+ GL2GL3 gl2gl3 = gl.getGL2GL3();
+ int[] numExtensions = { 0 } ;
+ gl2gl3.glGetIntegerv(gl2gl3.GL_NUM_EXTENSIONS, numExtensions, 0);
+ for (int i = 0; i < numExtensions[0]; i++) {
+ sb.append(gl2gl3.glGetStringi(gl2gl3.GL_EXTENSIONS, i));
+ if(i < numExtensions[0]) {
+ sb.append(" ");
+ }
+ }
+ } else {
+ sb.append(gl.glGetString(GL.GL_EXTENSIONS));
+ }
+ glExtensions = sb.toString();
+ glXExtensions = context.getPlatformExtensionsString();
+
+ sb.append(" ");
+ sb.append(glXExtensions);
+
+ String allAvailableExtensions = sb.toString();
+ if (DEBUG_AVAILABILITY) {
+ System.err.println("ExtensionAvailabilityCache: Available extensions: " + allAvailableExtensions);
+ System.err.println("ExtensionAvailabilityCache: GL vendor: " + gl.glGetString(GL.GL_VENDOR));
}
StringTokenizer tok = new StringTokenizer(allAvailableExtensions);
while (tok.hasMoreTokens()) {
@@ -93,42 +193,53 @@ public final class ExtensionAvailabilityCache {
availableExt = availableExt.intern();
availableExtensionCache.add(availableExt);
if (DEBUG_AVAILABILITY) {
- System.err.println("!!! Available: " + availableExt);
+ System.err.println("ExtensionAvailabilityCache: Available: " + availableExt);
}
}
// Put GL version strings in the table as well
- Version version = new Version(gl.glGetString(GL.GL_VERSION));
- if (version.isValid()) {
- int major = version.getMajor();
- int minor = version.getMinor();
- // FIXME: this needs to be adjusted when the major rev changes
- // beyond the known ones
- while (major > 0) {
- while (minor >= 0) {
- availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
- if (DEBUG) {
- System.err.println("!!! Added GL_VERSION_" + major + "_" + minor + " to known extensions");
- }
- --minor;
+ // FIXME: this needs to be adjusted when the major rev changes
+ // beyond the known ones
+ int major = majorVersion;
+ int minor = minorVersion;
+ while (major > 0) {
+ while (minor >= 0) {
+ availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
+ if (DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions");
}
+ --minor;
+ }
- switch (major) {
- case 2:
- // Restart loop at version 1.5
- minor = 5;
- break;
- case 1:
- break;
+ switch (major) {
+ case 2:
+ if(gl.isGL3() && major==2) {
+ // GL3 is a GL 3.1 forward compatible context,
+ // hence no 2.0, 1.0 - 1.5 GL versions are supported.
+ major=0;
+ } else {
+ // make sure 2.0 is added ..
+ minor = 0;
+ availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
+ if (DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions");
+ }
}
-
- --major;
+ // Restart loop at version 1.5
+ minor = 5;
+ break;
+ case 1:
+ break;
}
+
+ --major;
}
// put a dummy var in here so that the cache is no longer empty even if
// no extensions are in the GL_EXTENSIONS string
availableExtensionCache.add("");
+
+ initialized = true;
}
}
@@ -146,6 +257,11 @@ public final class ExtensionAvailabilityCache {
// Internals only below this point
//
+ private boolean initialized = false;
+ private int majorVersion = 1;
+ private int minorVersion = 0;
+ private String glExtensions = null;
+ private String glXExtensions = null;
private HashSet availableExtensionCache = new HashSet(50);
private GLContextImpl context;
@@ -236,7 +352,7 @@ public final class ExtensionAvailabilityCache {
{
// FIXME: refactor desktop OpenGL dependencies and make this
// class work properly for OpenGL ES
- System.err.println("FunctionAvailabilityCache.Version.: "+e);
+ System.err.println("ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.: "+e);
major = 1;
minor = 0;
/*
--
cgit v1.2.3
From 91e2508661f8f922afad6379e8bcadee37900546 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Sun, 2 Aug 2009 04:30:53 -0700
Subject: Update documentation (OpenGL 3.0, 3.1 specifics); Fix
ExtensionAvailabilityCache: Add Version 2.1 in case of GL2/OpenGL 3.0
---
make/config/jogl/gl-common.cfg | 13 ++++++++++---
make/doc/jogl/spec-overview.html | 9 ++++++++-
.../com/sun/opengl/impl/ExtensionAvailabilityCache.java | 15 ++++++---------
3 files changed, 24 insertions(+), 13 deletions(-)
(limited to 'src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java')
diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg
index 3e38aa0da..7cf51fda5 100644
--- a/make/config/jogl/gl-common.cfg
+++ b/make/config/jogl/gl-common.cfg
@@ -585,7 +585,8 @@ ClassJavadoc GL2ES2 */
ClassJavadoc GL2GL3 /**
ClassJavadoc GL2GL3 *
-ClassJavadoc GL2GL3 * Interface containing the common subset of GL3 and GL2.
+ClassJavadoc GL2GL3 * Interface containing the common subset of GL3 (OpenGL 3.1+) and GL2 (OpenGL 3.0),
+ClassJavadoc GL2GL3 * also known as the OpenGL 3.0 forward compatible, non deprecated subset.
ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
ClassJavadoc GL2GL3 *
ClassJavadoc GL2GL3 */
@@ -596,15 +597,21 @@ ClassJavadoc GL2 * This interface contains all core desktop OpenGL methods thro
ClassJavadoc GL2 * version 3.0, inclusive, as well as most of it's extensions defined at the
ClassJavadoc GL2 * time of this specification. Early OpenGL extensions whose functionality
ClassJavadoc GL2 * was incorporated into core OpenGL by version 3.0, inclusive, are specifically
-ClassJavadoc GL2 * excluded.
+ClassJavadoc GL2 * excluded.
+ClassJavadoc GL2 * Note: OpenGL 3.0 is the last subsumed version in the specification.
+ClassJavadoc GL2 * You need to use a {@link GL3} OpenGL 3.1+ context to benefit
+ClassJavadoc GL2 * from new functionality and versions.
ClassJavadoc GL2 *
ClassJavadoc GL2 */
ClassJavadoc GL3 /**
ClassJavadoc GL3 *
ClassJavadoc GL3 * This interface contains all core desktop OpenGL methods starting from 3.1,
-ClassJavadoc GL3 * inclusive - forward compatible only, as well as most of it's extensions defined at the
+ClassJavadoc GL3 * inclusive - forward compatible, as well as most of it's extensions defined at the
ClassJavadoc GL3 * time of this specification.
+ClassJavadoc GL3 * Note: OpenGL 3.0 forward compatible, non deprecated functionality is included in the
+ClassJavadoc GL3 * 3.1 specification, hence the {@link GL2GL3} implemented interface.
+ClassJavadoc GL3 * Note: OpenGL 3.1 (forward compatible) no more includes fixed point functionality.
ClassJavadoc GL3 *
ClassJavadoc GL3 */
diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html
index f79e5ff23..6557e9f7a 100644
--- a/make/doc/jogl/spec-overview.html
+++ b/make/doc/jogl/spec-overview.html
@@ -55,6 +55,9 @@ version 3.0, inclusive, as well as most of it's extensions defined at the
time of this specification. Early OpenGL extensions whose functionality
was incorporated into core OpenGL by version 3.0, inclusive, are specifically
excluded.
+ Note: OpenGL 3.0 is the last subsumed version in the specification.
+ You need to use a {@link javax.media.opengl.GL3} OpenGL 3.1+ context to benefit
+ from new functionality and versions.
Future extensions will be added with a maintenance update
{@link javax.media.opengl.GL3 javax.media.opengl.GL3} interface
@@ -62,6 +65,9 @@ excluded.
This interface contains all core desktop OpenGL methods starting from 3.1,
inclusive - forward compatible only, as well as most of it's extensions defined at the
time of this specification.
+ Note: OpenGL 3.0 forward compatible, non deprecated functionality is included in the
+ 3.1 specification, hence the {@link javax.media.opengl.GL2GL3} implemented interface.
+ Note: OpenGL 3.1 (forward compatible) no more includes fixed point functionality.
Future extensions will be added with a maintenance update
{@link javax.media.opengl.GLES1 javax.media.opengl.GLES1} interface
@@ -105,7 +111,8 @@ time of this specification.
{@link javax.media.opengl.GL2GL3 javax.media.opengl.GL2GL3} interface
- Interface containing the common subset of GL3 and GL2.
+ Interface containing the common subset of GL3 (OpenGL 3.1+) and GL2 (OpenGL 2.0),
+ also known as the OpenGL 3.0 forward compatible, non deprecated subset.
This interface reflects only the programmable shader functionality of desktop OpenGL
diff --git a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
index 7931f791b..26072519e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
@@ -212,19 +212,16 @@ public final class ExtensionAvailabilityCache {
}
switch (major) {
- case 2:
- if(gl.isGL3() && major==2) {
+ case 3:
+ if(gl.isGL3()) {
// GL3 is a GL 3.1 forward compatible context,
// hence no 2.0, 1.0 - 1.5 GL versions are supported.
major=0;
- } else {
- // make sure 2.0 is added ..
- minor = 0;
- availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
- if (DEBUG) {
- System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions");
- }
}
+ // Restart loop at version 2.1
+ minor = 1;
+ break;
+ case 2:
// Restart loop at version 1.5
minor = 5;
break;
--
cgit v1.2.3