diff options
author | Kenneth Russel <[email protected]> | 2006-02-24 10:14:36 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2006-02-24 10:14:36 +0000 |
commit | 492fe63d517b554cdf9f6ed355a71b5b18df2c97 (patch) | |
tree | b01f5a521b0319c1ef169fbd6846b5f7dd482596 /make/gl-impl-CustomJavaCode.java | |
parent | cb68a8fc740f4bba9130b0628cf0b016191e1d61 (diff) |
Optimized VBO/PBO checking routines in GLImpl. Now cache availability
of extensions in booleans rather than querying table each time.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@636 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/gl-impl-CustomJavaCode.java')
-rw-r--r-- | make/gl-impl-CustomJavaCode.java | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/make/gl-impl-CustomJavaCode.java b/make/gl-impl-CustomJavaCode.java index 210195dec..6d5f55159 100644 --- a/make/gl-impl-CustomJavaCode.java +++ b/make/gl-impl-CustomJavaCode.java @@ -149,16 +149,31 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d) { } private int[] bufTmp = new int[1]; -private void checkBufferObject(String extension1, - String extension2, +private boolean bufferObjectExtensionsInitialized = false; +private boolean haveARBPixelBufferObject; +private boolean haveEXTPixelBufferObject; +private boolean haveGL15; +private boolean haveARBVertexBufferObject; + +private void initBufferObjectExtensionChecks() { + if (bufferObjectExtensionsInitialized) + return; + bufferObjectExtensionsInitialized = true; + haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object"); + haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object"); + haveGL15 = isExtensionAvailable("GL_VERSION_1_5"); + haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object"); +} + +private void checkBufferObject(boolean extension1, + boolean extension2, boolean enabled, int state, String kind) { if (inBeginEndPair) { throw new GLException("May not call this between glBegin and glEnd"); } - boolean avail = ((extension1 != null && isExtensionAvailable(extension1)) || - (extension2 != null && isExtensionAvailable(extension2))); + boolean avail = (extension1 || extension2); if (!avail) { if (!enabled) return; @@ -177,32 +192,36 @@ private void checkBufferObject(String extension1, } private void checkUnpackPBODisabled() { - checkBufferObject("GL_ARB_pixel_buffer_object", - "GL_EXT_pixel_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveARBPixelBufferObject, + haveEXTPixelBufferObject, false, GL.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, "unpack pixel_buffer_object"); } private void checkUnpackPBOEnabled() { - checkBufferObject("GL_ARB_pixel_buffer_object", - "GL_EXT_pixel_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveARBPixelBufferObject, + haveEXTPixelBufferObject, true, GL.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, "unpack pixel_buffer_object"); } private void checkPackPBODisabled() { - checkBufferObject("GL_ARB_pixel_buffer_object", - "GL_EXT_pixel_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveARBPixelBufferObject, + haveEXTPixelBufferObject, false, GL.GL_PIXEL_PACK_BUFFER_BINDING_ARB, "pack pixel_buffer_object"); } private void checkPackPBOEnabled() { - checkBufferObject("GL_ARB_pixel_buffer_object", - "GL_EXT_pixel_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveARBPixelBufferObject, + haveEXTPixelBufferObject, true, GL.GL_PIXEL_PACK_BUFFER_BINDING_ARB, "pack pixel_buffer_object"); @@ -210,32 +229,36 @@ private void checkPackPBOEnabled() { private void checkArrayVBODisabled() { - checkBufferObject("GL_VERSION_1_5", - "GL_ARB_vertex_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, false, GL.GL_ARRAY_BUFFER_BINDING, "array vertex_buffer_object"); } private void checkArrayVBOEnabled() { - checkBufferObject("GL_VERSION_1_5", - "GL_ARB_vertex_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, true, GL.GL_ARRAY_BUFFER_BINDING, "array vertex_buffer_object"); } private void checkElementVBODisabled() { - checkBufferObject("GL_VERSION_1_5", - "GL_ARB_vertex_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, false, GL.GL_ELEMENT_ARRAY_BUFFER_BINDING, "element vertex_buffer_object"); } private void checkElementVBOEnabled() { - checkBufferObject("GL_VERSION_1_5", - "GL_ARB_vertex_buffer_object", + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, true, GL.GL_ELEMENT_ARRAY_BUFFER_BINDING, "element vertex_buffer_object"); |