aboutsummaryrefslogtreecommitdiffstats
path: root/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-06-09 00:42:41 +0200
committerSven Gothel <[email protected]>2011-06-09 00:42:41 +0200
commit423f5bf7f518433edcbf64accaf2cf5252cb4a63 (patch)
tree15b4278c893adc5f423a22b85b2b97c6b6cda010 /make/config/jogl/gl-impl-CustomJavaCode-embedded.java
parentf6bd208d8ef15769e13cb959e614349fd1e7cae1 (diff)
GLBuffers fix ; GL imageSizeInBytes fix / unit tests.
- Moved implementation of prev GL imageSizeInBytes(..) -> GLBuffers.sizeof() for all GL profiles - GLBuffers.*: Added missing formats and types (GL2.1, GL3.3 and GL4.1) - GLBuffers.sizeof(): Fail fast if format/type is unhandled, or alignment invalid - Added unit test for GLBuffers.sizeof()
Diffstat (limited to 'make/config/jogl/gl-impl-CustomJavaCode-embedded.java')
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-embedded.java41
1 files changed, 3 insertions, 38 deletions
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
index 0408c21a1..e1273e679 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
@@ -1,42 +1,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 rowLength, int imageHeight, int depth, boolean pack) {
- int alignment = 1;
+ private int[] imageSizeTemp = new int[1];
- if (pack) {
- glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- } else {
- glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
+ private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) {
+ return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ;
}
- // Try to deal somewhat correctly with potentially invalid values
- 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);
-
- int rowLengthInBytes = rowLength * bytesPerElement;
-
- if (alignment > 1) {
- int padding = rowLengthInBytes % alignment;
- if (padding > 0) {
- rowLengthInBytes += alignment - padding;
- }
- }
-
- /**
- * 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.
- */
- return
- ( depth - 1 ) * imageHeight * rowLengthInBytes + // whole images
- ( imageHeight - 1 ) * rowLengthInBytes + // lines with padding
- ( rowLength ) * bytesPerElement; // last line
-}