diff options
author | Kenneth Russel <[email protected]> | 2009-06-15 22:57:38 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-06-15 22:57:38 +0000 |
commit | a959c53b7ac91e489bf0959391e892790b9ff248 (patch) | |
tree | 4664742a4f9f6daa694364292e376ad2e6ee97d1 /make/config/jogl/gl-impl-CustomJavaCode-embedded.java | |
parent | 506b634b780dcd23aa61015c2ceba3e687196abf (diff) |
Copied JOGL_2_SANDBOX r1957 on to trunk; JOGL_2_SANDBOX branch is now closed
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1959 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/config/jogl/gl-impl-CustomJavaCode-embedded.java')
-rw-r--r-- | make/config/jogl/gl-impl-CustomJavaCode-embedded.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java new file mode 100644 index 000000000..2d4cd1372 --- /dev/null +++ b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java @@ -0,0 +1,37 @@ +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 dimensions, + boolean pack) { + int rowLength = w; + int alignment = 1; + + if (pack) { + glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0); + alignment = imageSizeTemp[0]; + } else { + glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0); + alignment = imageSizeTemp[0]; + } + // Try to deal somewhat correctly with potentially invalid values + rowLength = Math.max(0, rowLength); + alignment = Math.max(1, alignment); + h = Math.max(0, h); + int rowLengthInBytes = rowLength * bytesPerElement; + if (alignment > 1) { + int modulus = rowLengthInBytes % alignment; + if (modulus > 0) { + rowLengthInBytes += alignment - modulus; + } + } + + int size = 0; + if (dimensions == 1) { + return rowLengthInBytes; + } else { + return h * rowLengthInBytes; + } +} |