diff options
author | Sven Gothel <[email protected]> | 2012-02-13 23:17:56 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-02-13 23:17:56 +0100 |
commit | 0da7eeff106c1a2bf9e730c504a09e38360f141e (patch) | |
tree | 3af86256e48a5fbda6b362aebf457e11fcb71538 /src/jogl/classes/jogamp/opengl/GLContextImpl.java | |
parent | 5aff72256a49af51c002a07526174b23cc040b6e (diff) |
Enhance ExtensionAvailabilityCache ; Expose extension count in GLContext (and clean up)
- GLContext
- Expose isFunctionAvailable(), isExtensionAvailable(),
getPlatformExtensionCount(), getGLExtensionCount()
- sort methods a bit
ExtensionAvailabilityCache:
- Favor StringBuilder instead of StringBuffer (faster)
- Resuse set's
- Hold dedicated counts of extensions, platform and GL
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 7766214b4..f33c2bdb1 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -996,7 +996,7 @@ public abstract class GLContextImpl extends GLContext { if(null != eCache) { extensionAvailability = eCache; if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+toHexString(eCache.hashCode()) + " - entries: "+eCache.getSize()); + System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+toHexString(eCache.hashCode()) + " - entries: "+eCache.getTotalExtensionCount()); } } else { extensionAvailability = new ExtensionAvailabilityCache(this); @@ -1004,7 +1004,7 @@ public abstract class GLContextImpl extends GLContext { synchronized(mappedContextTypeObjectLock) { mappedExtensionAvailabilityCache.put(contextFQN, extensionAvailability); if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+toHexString(extensionAvailability.hashCode()) + " - entries: "+extensionAvailability.getSize()); + System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+toHexString(extensionAvailability.hashCode()) + " - entries: "+extensionAvailability.getTotalExtensionCount()); } } } @@ -1047,19 +1047,8 @@ public abstract class GLContextImpl extends GLContext { */ protected abstract void updateGLXProcAddressTable(); - protected abstract StringBuffer getPlatformExtensionsStringImpl(); + protected abstract StringBuilder getPlatformExtensionsStringImpl(); - /** - * Returns true if the specified OpenGL core- or extension-function can be - * successfully called using this GL context given the current host (OpenGL - * <i>client</i>) and display (OpenGL <i>server</i>) configuration. - * - * See {@link GL#isFunctionAvailable(String)} for more details. - * - * @param glFunctionName the name of the OpenGL function (e.g., use - * "glPolygonOffsetEXT" or "glPolygonOffset" to check if the {@link - * javax.media.opengl.GL#glPolygonOffset(float,float)} is available). - */ public final boolean isFunctionAvailable(String glFunctionName) { // Check GL 1st (cached) ProcAddressTable pTable = getGLProcAddressTable(); // null if ctx not created once @@ -1098,16 +1087,6 @@ public abstract class GLContextImpl extends GLContext { return false; } - /** - * Returns true if the specified OpenGL extension can be - * successfully called using this GL context given the current host (OpenGL - * <i>client</i>) and display (OpenGL <i>server</i>) configuration. - * - * See {@link GL#isExtensionAvailable(String)} for more details. - * - * @param glExtensionName the name of the OpenGL extension (e.g., - * "GL_VERTEX_PROGRAM_ARB"). - */ public boolean isExtensionAvailable(String glExtensionName) { if(null!=extensionAvailability) { return extensionAvailability.isExtensionAvailable(mapToRealGLExtensionName(glExtensionName)); @@ -1115,6 +1094,10 @@ public abstract class GLContextImpl extends GLContext { return false; } + public final int getPlatformExtensionCount() { + return null != extensionAvailability ? extensionAvailability.getPlatformExtensionCount() : 0; + } + public final String getPlatformExtensionsString() { if(null!=extensionAvailability) { return extensionAvailability.getPlatformExtensionsString(); @@ -1122,6 +1105,10 @@ public abstract class GLContextImpl extends GLContext { return null; } + public final int getGLExtensionCount() { + return null != extensionAvailability ? extensionAvailability.getGLExtensionCount() : 0; + } + public final String getGLExtensionsString() { if(null!=extensionAvailability) { return extensionAvailability.getGLExtensionsString(); @@ -1135,7 +1122,7 @@ public abstract class GLContextImpl extends GLContext { } return false; } - + protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT ; // remove non-key value return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); |