aboutsummaryrefslogtreecommitdiffstats
path: root/make/config
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
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')
-rw-r--r--make/config/jogl/gl-es1.cfg1
-rw-r--r--make/config/jogl/gl-es2.cfg1
-rw-r--r--make/config/jogl/gl-gl4bc.cfg1
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-desktop.java77
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-embedded.java41
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java92
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles1.java54
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles2.java60
8 files changed, 8 insertions, 319 deletions
diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg
index 5c69be9b7..88ce09569 100644
--- a/make/config/jogl/gl-es1.cfg
+++ b/make/config/jogl/gl-es1.cfg
@@ -98,3 +98,4 @@ Import javax.media.opengl.GLES1
Import javax.media.opengl.GLES2
Import javax.media.opengl.GL2
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg
index dcdc39b29..f529ddbf7 100644
--- a/make/config/jogl/gl-es2.cfg
+++ b/make/config/jogl/gl-es2.cfg
@@ -85,5 +85,6 @@ Import javax.media.opengl.GL2
Import javax.media.opengl.GLArrayData
Import javax.media.opengl.GLUniformData
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
Import java.io.PrintStream
diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg
index aafb9166b..6833d24d5 100644
--- a/make/config/jogl/gl-gl4bc.cfg
+++ b/make/config/jogl/gl-gl4bc.cfg
@@ -105,4 +105,5 @@ Import javax.media.opengl.GL3
Import javax.media.opengl.GL3bc
Import javax.media.opengl.GL4
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
Import java.io.PrintStream
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
index 93a275269..4edb28272 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
@@ -1,80 +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 width, int height, int depth, boolean pack) {
- int rowLength = 0;
- int skipRows = 0;
- int skipPixels = 0;
- int alignment = 1;
- int imageHeight = 0;
- int skipImages = 0;
-
- if (pack) {
- glGetIntegerv(GL_PACK_ROW_LENGTH, imageSizeTemp, 0);
- rowLength = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_ROWS, imageSizeTemp, 0);
- skipRows = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_PIXELS, imageSizeTemp, 0);
- skipPixels = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- if (depth > 1) {
- glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0);
- imageHeight = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0);
- skipImages = imageSizeTemp[0];
- }
- } else {
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, imageSizeTemp, 0);
- rowLength = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, imageSizeTemp, 0);
- skipRows = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, imageSizeTemp, 0);
- skipPixels = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- if (depth > 1) {
- glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0);
- imageHeight = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0);
- skipImages = imageSizeTemp[0];
- }
- }
- // Try to deal somewhat correctly with potentially invalid values
- 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);
- skipImages = Math.max(0, skipImages);
-
- imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
- rowLength = ( rowLength > 0 ) ? rowLength : width;
-
- int rowLengthInBytes = rowLength * bytesPerElement;
-
- if (alignment > 1) {
- int padding = rowLengthInBytes % alignment;
- if (padding > 0) {
- rowLengthInBytes += alignment - padding;
- }
- }
-
- /**
- * skipPixels and skipRows is a static one time offset.
- *
- * skipImages and depth are 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
- ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // whole images
- ( skipRows + height - 1 ) * rowLengthInBytes + // lines with padding
- ( skipPixels + width ) * bytesPerElement; // last line
+ 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) ;
}
public final boolean isGL4bc() {
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
-}
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
index dbfa3ef4d..e977204e3 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
@@ -35,98 +35,6 @@ public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2,
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- elements = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- elements = 4;
- break;
- /* FIXME ??
- case GL_HILO_NV:
- elements = 2;
- break; */
- default:
- return 0;
- }
- switch (type) {
- case GL_BITMAP:
- if (format == GL_COLOR_INDEX) {
- return (d * (h * ((w+7)/8)));
- } else {
- return 0;
- }
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- esize = 1;
- elements = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- esize = 4;
- elements = 1;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
index 0a0f87897..98ec4e550 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
@@ -98,60 +98,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_ALPHA:
- case GL_LUMINANCE:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- elements = 3;
- break;
- case GL_RGBA:
- elements = 4;
- break;
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- esize = 2;
- elements = 1;
- break;
- case GL_FLOAT:
- esize = 4;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
index e096d2185..760ec375e 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
@@ -102,66 +102,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- elements = 3;
- break;
- case GL_RGBA:
- elements = 4;
- break;
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;