diff options
-rw-r--r-- | make/config/jogl/gl-common.cfg | 26 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-desktop.java | 42 | ||||
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-embedded.java | 29 |
3 files changed, 50 insertions, 47 deletions
diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index a1414f0ad..37c030cb5 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -519,20 +519,20 @@ JavaPrologue glGetTexImage depth = tmp[0]; JavaPrologue glGetTexImage } # Range check directives for various image-related routines -RangeCheckBytes glColorTable 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , 1, false) -RangeCheckBytes glColorTableEXT 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , 1, false) -RangeCheckBytes glConvolutionFilter1D 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , 1, false) -RangeCheckBytes glConvolutionFilter2D 6 imageSizeInBytes({4}, {5}, {2} , {3} , 1 , 2, false) -RangeCheckBytes glDrawPixels 4 imageSizeInBytes({2}, {3}, {0} , {1} , 1 , 2, false) -RangeCheckBytes glReadPixels 6 imageSizeInBytes({4}, {5}, {2} , {3} , 1 , 2, true) -RangeCheckBytes glTexImage1D 7 imageSizeInBytes({5}, {6}, {3} , 1 , 1 , 1, false) -RangeCheckBytes glTexImage2D 8 imageSizeInBytes({6}, {7}, {3} , {4} , 1 , 2, false) -RangeCheckBytes glTexImage3D 9 imageSizeInBytes({7}, {8}, {3} , {4} , {5} , 3, false) -RangeCheckBytes glTexSubImage1D 6 imageSizeInBytes({4}, {5}, {3} , 1 , 1 , 1, false) -RangeCheckBytes glTexSubImage2D 8 imageSizeInBytes({6}, {7}, {4} , {5} , 1 , 2, false) -RangeCheckBytes glTexSubImage3D 10 imageSizeInBytes({8}, {9}, {5} , {6} , {7} , 3, false) +RangeCheckBytes glColorTable 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , false) +RangeCheckBytes glColorTableEXT 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , false) +RangeCheckBytes glConvolutionFilter1D 5 imageSizeInBytes({3}, {4}, {2} , 1 , 1 , false) +RangeCheckBytes glConvolutionFilter2D 6 imageSizeInBytes({4}, {5}, {2} , {3} , 1 , false) +RangeCheckBytes glDrawPixels 4 imageSizeInBytes({2}, {3}, {0} , {1} , 1 , false) +RangeCheckBytes glReadPixels 6 imageSizeInBytes({4}, {5}, {2} , {3} , 1 , true) +RangeCheckBytes glTexImage1D 7 imageSizeInBytes({5}, {6}, {3} , 1 , 1 , false) +RangeCheckBytes glTexImage2D 8 imageSizeInBytes({6}, {7}, {3} , {4} , 1 , false) +RangeCheckBytes glTexImage3D 9 imageSizeInBytes({7}, {8}, {3} , {4} , {5} , false) +RangeCheckBytes glTexSubImage1D 6 imageSizeInBytes({4}, {5}, {3} , 1 , 1 , false) +RangeCheckBytes glTexSubImage2D 8 imageSizeInBytes({6}, {7}, {4} , {5} , 1 , false) +RangeCheckBytes glTexSubImage3D 10 imageSizeInBytes({8}, {9}, {5} , {6} , {7} , false) # This may produce wrong answers for 1D textures -RangeCheckBytes glGetTexImage 4 imageSizeInBytes({2}, {3}, width , height , depth, ((depth > 1) ? 3 : 2), true) +RangeCheckBytes glGetTexImage 4 imageSizeInBytes({2}, {3}, width , height , depth, true) # Note we don't support glTexImage4DSGIS / glTexSubImage4DSGIS # FIXME: add the following unpack operations: # glBitmap, glPolygonStipple diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java index bd4659b88..fb06aa4ae 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java @@ -3,9 +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 width, int height, int depth, - int dimensions, - boolean pack) { + int width, int height, int depth, boolean pack) { int rowLength = 0; int skipRows = 0; int skipPixels = 0; @@ -22,7 +20,7 @@ private int imageSizeInBytes(int bytesPerElement, skipPixels = imageSizeTemp[0]; glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0); alignment = imageSizeTemp[0]; - if (dimensions > 2) { + if (depth > 1) { glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0); imageHeight = imageSizeTemp[0]; glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0); @@ -37,7 +35,7 @@ private int imageSizeInBytes(int bytesPerElement, skipPixels = imageSizeTemp[0]; glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0); alignment = imageSizeTemp[0]; - if (dimensions > 2) { + if (depth > 1) { glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0); imageHeight = imageSizeTemp[0]; glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0); @@ -45,36 +43,40 @@ private int imageSizeInBytes(int bytesPerElement, } } // Try to deal somewhat correctly with potentially invalid values - height = Math.max(0, height); + width = Math.max(0, width ); + height = Math.max(1, height); // min 1D + depth = Math.max(1, depth ); // min 1 * imageSize 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(Math.max(0, rowLength), width); // > 0 && >= width + imageHeight = ( imageHeight > 0 ) ? imageHeight : height; + rowLength = ( rowLength > 0 ) ? rowLength : width; + int rowLengthInBytes = rowLength * bytesPerElement; if (alignment > 1) { - int modulus = rowLengthInBytes % alignment; - if (modulus > 0) { - rowLengthInBytes += alignment - modulus; + int padding = rowLengthInBytes % alignment; + if (padding > 0) { + rowLengthInBytes += alignment - padding; } } /** - * skipPixels and skipRows is a static one time offset + * skipPixels and skipRows is a static one time offset. + * + * skipImages and depth are in multiples of image size. * * rowlenght is the actual repeating offset - * from line-start to the next line-start. + * to go from line n to line n+1 at the same x-axis position. */ - int size = height * rowLengthInBytes; // height == 1 for 1D - if(dimensions==3) { - size *= (skipImages + depth); - } + int imageSize = imageHeight * rowLengthInBytes; - int skipOffset = skipPixels * bytesPerElement + - skipRows * rowLengthInBytes; + int skipOffset = skipImages * imageSize + + skipRows * rowLengthInBytes + + skipPixels * bytesPerElement; - return size + skipOffset; + return skipOffset + imageSize * depth; } + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java index c803a06a4..ae90a42a0 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java @@ -3,10 +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 width, int height, int depth, - int dimensions, - boolean pack) { - int rowLength; + int rowLength, int imageHeight, int depth, boolean pack) { int alignment = 1; if (pack) { @@ -17,23 +14,27 @@ private int imageSizeInBytes(int bytesPerElement, alignment = imageSizeTemp[0]; } // Try to deal somewhat correctly with potentially invalid values - height = Math.max(0, height); + rowLength = Math.max(0, rowLength ); + imageHeight = Math.max(1, imageHeight); // min 1D + depth = Math.max(1, depth ); // min 1 * imageSize alignment = Math.max(1, alignment); - rowLength = Math.max(0, width); // > 0 && >= width int rowLengthInBytes = rowLength * bytesPerElement; if (alignment > 1) { - int modulus = rowLengthInBytes % alignment; - if (modulus > 0) { - rowLengthInBytes += alignment - modulus; + int padding = rowLengthInBytes % alignment; + if (padding > 0) { + rowLengthInBytes += alignment - padding; } } - int size = height * rowLengthInBytes; // height == 1 for 1D - if(dimensions==3) { - size *= depth; - } + /** + * depth is in multiples of image size. + * + * rowlenght is the actual repeating offset + * to go from line n to line n+1 at the same x-axis position. + */ + int imageSize = imageHeight * rowLengthInBytes; - return size; + return imageSize * depth; } |