Jogamp
Don't utilize glPixelStorei's PACK/UNPACK IMAGE_HEIGHT and SKIP_IMAGES for Desktop...
authorSven Gothel <sgothel@jausoft.com>
Tue, 9 Sep 2014 17:58:47 +0000 (19:58 +0200)
committerSven Gothel <sgothel@jausoft.com>
Tue, 9 Sep 2014 18:04:45 +0000 (20:04 +0200)
Commit fc1e98790a02b4fa7922f3cdd9d437f87d7c99e5
added handling of PACK/UNPACK IMAGE_HEIGHT and SKIP_IMAGES in GLPixelStorageModes.

However, it has been overseen that the four states are not available in OpenGL 1.1.

Adding exclusion of the same if desktop GL < 1.2
and hence avoiding GL errors.

Same applies to GLBuffers.sizeof(..) method.

src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java

index 44be299..e3069c2 100644 (file)
@@ -46,6 +46,7 @@ import javax.media.opengl.GL2;
 import javax.media.opengl.GL2ES2;
 import javax.media.opengl.GL2ES3;
 import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLContext;
 import javax.media.opengl.GLES2;
 import javax.media.opengl.GLException;
 
@@ -376,7 +377,7 @@ public class GLBuffers extends Buffers {
               rowLength = glGetInteger(gl, GL2ES3.GL_PACK_ROW_LENGTH, tmp);
               skipRows = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_ROWS, tmp);
               skipPixels = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_PIXELS, tmp);
-              if (depth > 1) {
+              if (depth > 1 && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
                   imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp);
                   skipImages = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_IMAGES, tmp);
               }
@@ -387,7 +388,7 @@ public class GLBuffers extends Buffers {
               rowLength = glGetInteger(gl, GL2ES2.GL_UNPACK_ROW_LENGTH, tmp);
               skipRows = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_ROWS, tmp);
               skipPixels = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_PIXELS, tmp);
-              if (depth > 1) {
+              if (depth > 1 && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
                   imageHeight = glGetInteger(gl, GL2ES3.GL_UNPACK_IMAGE_HEIGHT, tmp);
                   skipImages = glGetInteger(gl, GL2ES3.GL_UNPACK_SKIP_IMAGES, tmp);
                }
index 52612d2..cef49d3 100644 (file)
@@ -171,7 +171,7 @@ public class GLPixelStorageModes {
      */
     public final void resetPack(final GL gl) {
         // Compared w/ ES2, ES3 and GL3-core spec
-        gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4);                        // es2, es3, gl3
+        gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4);                            // es2, es3, gl3
         if( gl.isGL2ES3() ) {
             gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0);                   // es3, gl3
             gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0);                    // es3, gl3
@@ -179,8 +179,10 @@ public class GLPixelStorageModes {
             if( gl.isGL2GL3() ) {
                 gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES,     GL.GL_FALSE); // gl3
                 gl.glPixelStorei(GL2GL3.GL_PACK_LSB_FIRST,      GL.GL_FALSE); // gl3
-                gl.glPixelStorei(GL2GL3.GL_PACK_IMAGE_HEIGHT,   0);           // gl3
-                gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_IMAGES,    0);           // gl3
+                if( gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
+                    gl.glPixelStorei(GL2GL3.GL_PACK_IMAGE_HEIGHT,   0);       // gl3, GL_VERSION_1_2
+                    gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_IMAGES,    0);       // gl3, GL_VERSION_1_2
+                }
             }
         }
     }
@@ -242,16 +244,21 @@ public class GLPixelStorageModes {
      */
     public final void resetUnpack(final GL gl) {
         // Compared w/ ES2, ES3 and GL3-core spec
-        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 4);                      // es2, es3, gl3
+        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 4);                          // es2, es3, gl3
         if( gl.isGL2ES3() ) {
             gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, 0);                 // es3, gl3
             gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, 0);                  // es3, gl3
             gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, 0);                // es3, gl3
-            gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0);               // es3, gl3
-            gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES,  0);               // es3, gl3
             if( gl.isGL2GL3() ) {
+                if( gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
+                    gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0);       // es3, gl3, GL_VERSION_1_2
+                    gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES,  0);       // es3, gl3, GL_VERSION_1_2
+                }
                 gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES,   GL.GL_FALSE); // gl3
                 gl.glPixelStorei(GL2GL3.GL_UNPACK_LSB_FIRST,    GL.GL_FALSE); // gl3
+            } else {
+                gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0);           // es3, gl3, GL_VERSION_1_2
+                gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES,  0);           // es3, gl3, GL_VERSION_1_2
             }
         }
     }
http://JogAmp.org git info: FAQ, tutorial and man pages.