diff options
author | Sven Gothel <sgothel@jausoft.com> | 2009-10-17 13:44:12 -0700 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2009-10-17 13:44:12 -0700 |
commit | 4d493ac36bd5d763d2af3243e799bbaef3679594 (patch) | |
tree | 3017bab34a8824f706e3ba63f835aaffd3317222 | |
parent | 5ae314adc19c660f26f32839b2cc224cdccfbb59 (diff) |
All tracker are aggregated in the GLContext now
and used within the GL*Impl.
New GLStateTracker:
- Tracking client/server states
- Currently supports PixelStorei
- Prologued in glPixelStorei and glGetIntegerv,
the latter will return the tracked state if available
and not call the GL method.
Impacts performance and ES1 compatibility (supports ALIGNMENT).
Fixed 'imageSizeInBytes' calculation:
- skipPixels and skipRows is a static one time offset
20 files changed, 195 insertions, 91 deletions
diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 4d3a05d63..a1414f0ad 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -408,7 +408,9 @@ JavaEpilogue glEnd inBeginEndPair = false; JavaEpilogue glBindBuffer bufferStateTracker.setBoundBufferObject({0}, {1}); JavaEpilogue glBindBufferARB bufferStateTracker.setBoundBufferObject({0}, {1}); JavaEpilogue glPushClientAttrib bufferStateTracker.clearBufferObjectState(); +JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask); JavaEpilogue glPopClientAttrib bufferStateTracker.clearBufferObjectState(); +JavaEpilogue glPopClientAttrib glStateTracker.popAttrib(); JavaEpilogue glBufferData bufferSizeTracker.setBufferSize(bufferStateTracker, {0}, this, {1}); BufferObjectKind Array glColorPointer diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg index 35ea7f0ce..867ef8a83 100755 --- a/make/config/jogl/gl-es1.cfg +++ b/make/config/jogl/gl-es1.cfg @@ -54,6 +54,18 @@ TagNativeBinding true IgnoreExtension GL_OES_fixed_point IgnoreExtension GL_OES_single_precision +# Add PixelStorei StateTracker +# +# Add input validation to glPixelStorei, just to be sure. +CustomJavaCode GLES1Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { +JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname)); +JavaPrologue glPixelStorei } +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + CustomJavaCode GLES1Impl public void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val) { CustomJavaCode GLES1Impl glOrtho((float) left, (float) right, (float) bottom, (float) top, (float) near_val, (float) far_val); } diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg index 6a81c9376..f78001dee 100755 --- a/make/config/jogl/gl-es2.cfg +++ b/make/config/jogl/gl-es2.cfg @@ -44,6 +44,18 @@ LocalProcAddressCallingConvention __ALL__ GL_APIENTRY # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true +# Add PixelStorei StateTracker +# +# Add input validation to glPixelStorei, just to be sure. +CustomJavaCode GLES2Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { +JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname)); +JavaPrologue glPixelStorei } +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + IncludeAs CustomJavaCode GLES2 gl-if-CustomJavaCode-gles2.java CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in diff --git a/make/config/jogl/gl-gl2.cfg b/make/config/jogl/gl-gl2.cfg index 50574598a..820243ff5 100644 --- a/make/config/jogl/gl-gl2.cfg +++ b/make/config/jogl/gl-gl2.cfg @@ -40,6 +40,14 @@ TagNativeBinding true # Ignore extensions that are already picked up via the GL2ES1 interface IgnoreExtension GL_EXT_point_parameters +# Add PixelStorei StateTracker +# +CustomJavaCode GL2Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + CustomJavaCode GL2 public boolean glIsPBOPackEnabled(); CustomJavaCode GL2 public boolean glIsPBOUnpackEnabled(); diff --git a/make/config/jogl/gl-gl2es12.cfg b/make/config/jogl/gl-gl2es12.cfg index 9e36da2ea..232116a61 100644 --- a/make/config/jogl/gl-gl2es12.cfg +++ b/make/config/jogl/gl-gl2es12.cfg @@ -49,12 +49,19 @@ TagNativeBinding true Ignore glGetTexImage Ignore glPixelStoref +# Add PixelStorei StateTracker +# # Add input validation to glPixelStorei to make sure that, even if we # are running on top of desktop OpenGL, parameters not exposed in # OpenGL ES can not be changed +CustomJavaCode GL2ES12Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { -JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(param)); +JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname)); JavaPrologue glPixelStorei } +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } CustomJavaCode GL2ES12Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { CustomJavaCode GL2ES12Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } diff --git a/make/config/jogl/gl-gl3.cfg b/make/config/jogl/gl-gl3.cfg index 576cd7cad..9f0ea05a8 100644 --- a/make/config/jogl/gl-gl3.cfg +++ b/make/config/jogl/gl-gl3.cfg @@ -43,6 +43,14 @@ LocalProcAddressCallingConvention __ALL__ APIENTRY # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true +# Add PixelStorei StateTracker +# +CustomJavaCode GL3Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + CustomJavaCode GL3Impl public void glClearDepthf(float depth) { CustomJavaCode GL3Impl glClearDepth((double)depth); } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java index 0d01aaec4..bd4659b88 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java @@ -3,7 +3,7 @@ private int[] imageSizeTemp = new int[1]; /** Helper for more precise computation of number of bytes that will be touched by a pixel pack or unpack operation. */ private int imageSizeInBytes(int bytesPerElement, - int w, int h, int d, + int width, int height, int depth, int dimensions, boolean pack) { int rowLength = 0; @@ -45,14 +45,16 @@ private int imageSizeInBytes(int bytesPerElement, } } // Try to deal somewhat correctly with potentially invalid values - rowLength = Math.max(0, rowLength); + height = Math.max(0, height); skipRows = Math.max(0, skipRows); skipPixels = Math.max(0, skipPixels); alignment = Math.max(1, alignment); imageHeight = Math.max(0, imageHeight); skipImages = Math.max(0, skipImages); - rowLength = Math.max(rowLength, w + skipPixels); + + rowLength = Math.max(Math.max(0, rowLength), width); // > 0 && >= width int rowLengthInBytes = rowLength * bytesPerElement; + if (alignment > 1) { int modulus = rowLengthInBytes % alignment; if (modulus > 0) { @@ -60,15 +62,19 @@ private int imageSizeInBytes(int bytesPerElement, } } - int size = 0; - if (dimensions == 1) { - return (w + skipPixels) * bytesPerElement; - } else { - int size2D = ((skipRows + h - 1) * rowLengthInBytes) + (w + skipPixels) * bytesPerElement; - if (dimensions == 2) { - return size2D; - } - int imageSizeInBytes = imageHeight * rowLength; - return ((skipImages + d - 1) * imageSizeInBytes) + size2D; + /** + * skipPixels and skipRows is a static one time offset + * + * rowlenght is the actual repeating offset + * from line-start to the next line-start. + */ + int size = height * rowLengthInBytes; // height == 1 for 1D + if(dimensions==3) { + size *= (skipImages + depth); } + + int skipOffset = skipPixels * bytesPerElement + + skipRows * rowLengthInBytes; + + return size + skipOffset; } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java index 2d4cd1372..c803a06a4 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java @@ -3,10 +3,10 @@ private int[] imageSizeTemp = new int[1]; /** Helper for more precise computation of number of bytes that will be touched by a pixel pack or unpack operation. */ private int imageSizeInBytes(int bytesPerElement, - int w, int h, int d, + int width, int height, int depth, int dimensions, boolean pack) { - int rowLength = w; + int rowLength; int alignment = 1; if (pack) { @@ -17,10 +17,12 @@ private int imageSizeInBytes(int bytesPerElement, alignment = imageSizeTemp[0]; } // Try to deal somewhat correctly with potentially invalid values - rowLength = Math.max(0, rowLength); + height = Math.max(0, height); alignment = Math.max(1, alignment); - h = Math.max(0, h); + + rowLength = Math.max(0, width); // > 0 && >= width int rowLengthInBytes = rowLength * bytesPerElement; + if (alignment > 1) { int modulus = rowLengthInBytes % alignment; if (modulus > 0) { @@ -28,10 +30,10 @@ private int imageSizeInBytes(int bytesPerElement, } } - int size = 0; - if (dimensions == 1) { - return rowLengthInBytes; - } else { - return h * rowLengthInBytes; + int size = height * rowLengthInBytes; // height == 1 for 1D + if(dimensions==3) { + size *= depth; } + + return size; } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2.java index 5928b3a0b..587bb6738 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2.java @@ -18,7 +18,9 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL2Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); this.glProfile = glp; } @@ -231,8 +233,9 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d, return imageSizeInBytes(elements * esize, w, h, d, dimensions, pack); } -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private GLBufferStateTracker bufferStateTracker; +private GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java index 3dfcf5908..8e9c8bf01 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java @@ -17,7 +17,9 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL2ES12Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); this.isGL2ES2 = glp.isGL2ES2(); this.glProfile = glp; } @@ -203,8 +205,9 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d, return imageSizeInBytes(elements * esize, w, h, d, dimensions, pack); } -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private GLBufferStateTracker bufferStateTracker; +private GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveGL15; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java b/make/config/jogl/gl-impl-CustomJavaCode-gl3.java index 9123f35c8..b69188c73 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl3.java @@ -17,7 +17,9 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL3Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); this.glProfile = glp; } @@ -222,8 +224,9 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d, return imageSizeInBytes(elements * esize, w, h, d, dimensions, pack); } -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private GLBufferStateTracker bufferStateTracker; +private GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index c5831f426..4e46f076b 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -1,6 +1,8 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); this.glProfile = glp; } @@ -167,8 +169,9 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d, return imageSizeInBytes(elements * esize, w, h, d, dimensions, pack); } -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private GLBufferStateTracker bufferStateTracker; +private GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index 7e9b786b0..97a0dbd27 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -4,7 +4,9 @@ private boolean inBeginEndPair; public GLES2Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); this.glProfile = glp; } @@ -177,8 +179,9 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d, return imageSizeInBytes(elements * esize, w, h, d, dimensions, pack); } -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private GLBufferStateTracker bufferStateTracker; +private GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java b/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java index ddc82eba2..c61d3602d 100755 --- a/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java @@ -45,10 +45,8 @@ import javax.media.opengl.*; /** * Tracks as closely as possible which OpenGL buffer object is bound * to which binding target in the current OpenGL context. - * GLBufferStateTracker objects are allocated on a per-GLImpl basis, - * which is basically identical to a per-OpenGL-context basis - * (assuming correct usage of the GLImpl objects, which is checked by - * the DebugGL). This class is used to verify that e.g. the vertex + * GLBufferStateTracker objects are allocated on a per-OpenGL-context basis. + * This class is used to verify that e.g. the vertex * buffer object extension is in use when the glVertexPointer variant * taking a long as argument is called. <P> * @@ -101,8 +99,7 @@ public class GLBufferStateTracker { } public void setBoundBufferObject(int target, int buffer) { - Integer key = box(target); - bindingMap.put(key, box(buffer)); + bindingMap.put(box(target), box(buffer)); } /** Note: returns an unspecified value if the binding for the @@ -110,8 +107,7 @@ public class GLBufferStateTracker { You must use isBoundBufferObjectKnown() to see whether the return value is valid. */ public int getBoundBufferObject(int target, GL caller) { - Integer key = box(target); - Integer value = (Integer) bindingMap.get(key); + Integer value = (Integer) bindingMap.get(box(target)); if (value == null) { // User probably either called glPushClientAttrib / // glPopClientAttrib or is querying an unknown target. See diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java index 343ca7efe..97100208d 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java @@ -71,7 +71,9 @@ public abstract class GLContextImpl extends GLContext { // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations - private GLBufferSizeTracker bufferSizeTracker; + private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet + private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); + private GLStateTracker glStateTracker = new GLStateTracker(); protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; @@ -232,6 +234,14 @@ public abstract class GLContextImpl extends GLContext { if (bufferSizeTracker != null) { bufferSizeTracker.clearCachedBufferSizes(); } + + if (bufferStateTracker != null) { + bufferStateTracker.clearBufferObjectState(); + } + + if (glStateTracker != null) { + glStateTracker.clearStates(); + } destroyImpl(); } finally { @@ -512,6 +522,14 @@ public abstract class GLContextImpl extends GLContext { return bufferSizeTracker; } + public GLBufferStateTracker getBufferStateTracker() { + return bufferStateTracker; + } + + public GLStateTracker getGLStateTracker() { + return glStateTracker; + } + //--------------------------------------------------------------------------- // Helpers for context optimization where the last context is left // current on the OpenGL worker thread diff --git a/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java b/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java index 997951faf..698d20c47 100755 --- a/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java @@ -52,22 +52,6 @@ import javax.media.opengl.*; public class GLStateTracker { private static final boolean DEBUG = Debug.debug("GLStateTracker"); - private static final Integer GL_PACK_ALIGNMENT = new Integer(GL.GL_PACK_ALIGNMENT); - private static final Integer GL_PACK_ROW_LENGTH = new Integer(GL2.GL_PACK_ROW_LENGTH); - private static final Integer GL_PACK_SKIP_ROWS = new Integer(GL2.GL_PACK_SKIP_ROWS); - private static final Integer GL_PACK_SKIP_PIXELS = new Integer(GL2.GL_PACK_SKIP_PIXELS); - private static final Integer GL_PACK_IMAGE_HEIGHT = new Integer(GL2.GL_PACK_IMAGE_HEIGHT); - private static final Integer GL_PACK_SKIP_IMAGES = new Integer(GL2.GL_PACK_SKIP_IMAGES); - - private static final Integer GL_UNPACK_ALIGNMENT = new Integer(GL.GL_UNPACK_ALIGNMENT); - private static final Integer GL_UNPACK_ROW_LENGTH = new Integer(GL2.GL_UNPACK_ROW_LENGTH); - private static final Integer GL_UNPACK_SKIP_ROWS = new Integer(GL2.GL_UNPACK_SKIP_ROWS); - private static final Integer GL_UNPACK_SKIP_PIXELS = new Integer(GL2.GL_UNPACK_SKIP_PIXELS); - private static final Integer GL_UNPACK_IMAGE_HEIGHT = new Integer(GL2.GL_UNPACK_IMAGE_HEIGHT); - private static final Integer GL_UNPACK_SKIP_IMAGES = new Integer(GL2.GL_UNPACK_SKIP_IMAGES); - - private static final Integer zero = new Integer(0); - private boolean enabled = true; private Map/*<Integer,Integer>*/ pixelStateMap = new HashMap/*<Integer,Integer>*/(); @@ -91,24 +75,6 @@ public class GLStateTracker { resetStates(); } - public void resetStates() { - pixelStateMap.clear(); - - pixelStateMap.put(GL_PACK_ALIGNMENT, new Integer(4)); - pixelStateMap.put(GL_PACK_ROW_LENGTH, zero); - pixelStateMap.put(GL_PACK_SKIP_ROWS, zero); - pixelStateMap.put(GL_PACK_SKIP_PIXELS, zero); - pixelStateMap.put(GL_PACK_IMAGE_HEIGHT, zero); - pixelStateMap.put(GL_PACK_SKIP_IMAGES, zero); - - pixelStateMap.put(GL_UNPACK_ALIGNMENT, new Integer(4)); - pixelStateMap.put(GL_UNPACK_ROW_LENGTH, zero); - pixelStateMap.put(GL_UNPACK_SKIP_ROWS, zero); - pixelStateMap.put(GL_UNPACK_SKIP_PIXELS, zero); - pixelStateMap.put(GL_UNPACK_IMAGE_HEIGHT, zero); - pixelStateMap.put(GL_UNPACK_SKIP_IMAGES, zero); - } - public void clearStates() { pixelStateMap.clear(); } @@ -155,7 +121,7 @@ public class GLStateTracker { public void pushAttrib(int flags) { if(enabled) { SavedState state = new SavedState(); - if( 0 != (flags&GL_CLIENT_PIXEL_STORE_BIT) ) { + if( 0 != (flags&GL2.GL_CLIENT_PIXEL_STORE_BIT) ) { state.putPixelStateMap(pixelStateMap); } stack.add(0, state); @@ -180,30 +146,78 @@ public class GLStateTracker { } } + private static final Integer GL_PACK_SWAP_BYTES = new Integer(GL2GL3.GL_PACK_SWAP_BYTES); + private static final Integer GL_PACK_LSB_FIRST = new Integer(GL2GL3.GL_PACK_LSB_FIRST); + private static final Integer GL_PACK_ROW_LENGTH = new Integer(GL2GL3.GL_PACK_ROW_LENGTH); + private static final Integer GL_PACK_SKIP_ROWS = new Integer(GL2GL3.GL_PACK_SKIP_ROWS); + private static final Integer GL_PACK_SKIP_PIXELS = new Integer(GL2GL3.GL_PACK_SKIP_PIXELS); + private static final Integer GL_PACK_ALIGNMENT = new Integer(GL.GL_PACK_ALIGNMENT); + private static final Integer GL_PACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_PACK_IMAGE_HEIGHT); + private static final Integer GL_PACK_SKIP_IMAGES = new Integer(GL2GL3.GL_PACK_SKIP_IMAGES); + + private static final Integer GL_UNPACK_SWAP_BYTES = new Integer(GL2GL3.GL_UNPACK_SWAP_BYTES); + private static final Integer GL_UNPACK_LSB_FIRST = new Integer(GL2GL3.GL_UNPACK_LSB_FIRST); + private static final Integer GL_UNPACK_ROW_LENGTH = new Integer(GL2GL3.GL_UNPACK_ROW_LENGTH); + private static final Integer GL_UNPACK_SKIP_ROWS = new Integer(GL2GL3.GL_UNPACK_SKIP_ROWS); + private static final Integer GL_UNPACK_SKIP_PIXELS = new Integer(GL2GL3.GL_UNPACK_SKIP_PIXELS); + private static final Integer GL_UNPACK_ALIGNMENT = new Integer(GL.GL_UNPACK_ALIGNMENT); + private static final Integer GL_UNPACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_UNPACK_IMAGE_HEIGHT); + private static final Integer GL_UNPACK_SKIP_IMAGES = new Integer(GL2GL3.GL_UNPACK_SKIP_IMAGES); + + private static final Integer zero = new Integer(0); + private static final Integer one = new Integer(1); + private static Integer boxKey(int key) { switch (key) { case 0: return zero; - case GL.GL_PACK_ALIGNMENT: return GL_PACK_ALIGNMENT; - case GL2.GL_PACK_ROW_LENGTH: return GL_PACK_ROW_LENGTH; - case GL2.GL_PACK_SKIP_ROWS: return GL_PACK_SKIP_ROWS; - case GL2.GL_PACK_SKIP_PIXELS: return GL_PACK_SKIP_PIXELS; - case GL2.GL_PACK_IMAGE_HEIGHT: return GL_PACK_IMAGE_HEIGHT; - case GL2.GL_PACK_SKIP_IMAGES: return GL_PACK_SKIP_IMAGES; - - case GL.GL_UNPACK_ALIGNMENT: return GL_UNPACK_ALIGNMENT; - case GL2.GL_UNPACK_ROW_LENGTH: return GL_UNPACK_ROW_LENGTH; - case GL2.GL_UNPACK_SKIP_ROWS: return GL_UNPACK_SKIP_ROWS; - case GL2.GL_UNPACK_SKIP_PIXELS: return GL_UNPACK_SKIP_PIXELS; - case GL2.GL_UNPACK_IMAGE_HEIGHT: return GL_UNPACK_IMAGE_HEIGHT; - case GL2.GL_UNPACK_SKIP_IMAGES: return GL_UNPACK_SKIP_IMAGES; + case GL2GL3.GL_PACK_SWAP_BYTES: return GL_PACK_SWAP_BYTES; + case GL2GL3.GL_PACK_LSB_FIRST: return GL_PACK_LSB_FIRST; + case GL2GL3.GL_PACK_ROW_LENGTH: return GL_PACK_ROW_LENGTH; + case GL2GL3.GL_PACK_SKIP_ROWS: return GL_PACK_SKIP_ROWS; + case GL2GL3.GL_PACK_SKIP_PIXELS: return GL_PACK_SKIP_PIXELS; + case GL.GL_PACK_ALIGNMENT: return GL_PACK_ALIGNMENT; + case GL2GL3.GL_PACK_IMAGE_HEIGHT: return GL_PACK_IMAGE_HEIGHT; + case GL2GL3.GL_PACK_SKIP_IMAGES: return GL_PACK_SKIP_IMAGES; + + case GL2GL3.GL_UNPACK_SWAP_BYTES: return GL_UNPACK_SWAP_BYTES; + case GL2GL3.GL_UNPACK_LSB_FIRST: return GL_UNPACK_LSB_FIRST; + case GL2GL3.GL_UNPACK_ROW_LENGTH: return GL_UNPACK_ROW_LENGTH; + case GL2GL3.GL_UNPACK_SKIP_ROWS: return GL_UNPACK_SKIP_ROWS; + case GL2GL3.GL_UNPACK_SKIP_PIXELS: return GL_UNPACK_SKIP_PIXELS; + case GL.GL_UNPACK_ALIGNMENT: return GL_UNPACK_ALIGNMENT; + case GL2GL3.GL_UNPACK_IMAGE_HEIGHT: return GL_UNPACK_IMAGE_HEIGHT; + case GL2GL3.GL_UNPACK_SKIP_IMAGES: return GL_UNPACK_SKIP_IMAGES; default: return null; } } + public void resetStates() { + pixelStateMap.clear(); + + pixelStateMap.put(GL_PACK_SWAP_BYTES, zero /* GL_FALSE */); + pixelStateMap.put(GL_PACK_LSB_FIRST, zero /* GL_FALSE */); + pixelStateMap.put(GL_PACK_ROW_LENGTH, zero); + pixelStateMap.put(GL_PACK_SKIP_ROWS, zero); + pixelStateMap.put(GL_PACK_SKIP_PIXELS, zero); + pixelStateMap.put(GL_PACK_ALIGNMENT, new Integer(4)); + pixelStateMap.put(GL_PACK_IMAGE_HEIGHT, zero); + pixelStateMap.put(GL_PACK_SKIP_IMAGES, zero); + + pixelStateMap.put(GL_UNPACK_SWAP_BYTES, zero /* GL_FALSE */); + pixelStateMap.put(GL_UNPACK_LSB_FIRST, zero /* GL_FALSE */); + pixelStateMap.put(GL_UNPACK_ROW_LENGTH, zero); + pixelStateMap.put(GL_UNPACK_SKIP_ROWS, zero); + pixelStateMap.put(GL_UNPACK_SKIP_PIXELS, zero); + pixelStateMap.put(GL_UNPACK_ALIGNMENT, new Integer(4)); + pixelStateMap.put(GL_UNPACK_IMAGE_HEIGHT, zero); + pixelStateMap.put(GL_UNPACK_SKIP_IMAGES, zero); + } + private static Integer boxInt(int value) { switch (value) { - case 0: return zero; + case 0: return zero; + case 1: return one; default: return new Integer(value); } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java index 1635e8d63..86c82396e 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java @@ -48,6 +48,7 @@ public class EGLExternalContext extends EGLContext { super(null, null); GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false); + getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } public int makeCurrent() throws GLException { diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java index 03116f6bd..0e468e5c5 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java @@ -57,6 +57,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { this.nsContext = nsContext; GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false); + getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } protected static MacOSXExternalCGLContext create(GLDrawableFactory factory, GLProfile glp) { diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java index 31e65fc8c..b433b6b38 100755 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java @@ -60,6 +60,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false); cfg.updateCapabilitiesByWGL(this); + getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) { diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java index b509447f7..7e3755870 100755 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java @@ -56,6 +56,7 @@ public class X11ExternalGLXContext extends X11GLXContext { this.context = context; GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false); + getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } protected static X11ExternalGLXContext create(GLDrawableFactory factory, GLProfile glp) { |