diff options
author | Kenneth Russel <[email protected]> | 2005-07-08 16:02:53 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-08 16:02:53 +0000 |
commit | c6d6bcbcaceaa229944f380437a28af3a84f1dcd (patch) | |
tree | 5415f8a6a956de81ffe7abd01451f99c76f23824 | |
parent | 0fa2740c8c186b0908baa5b7629bef657fe38527 (diff) |
Fixed Windows port after changes to GlueGen to include array offsets.
Ported all demos to new API. Temporarily added back in GLU entry
points taking primitive arrays as the underlying APIs (in particular,
glTexImage2D) do not yet support non-direct Buffers. Changed C code
generation to only add in array offset if array is non-null. Fixed bug
in GLU tesselator demo's vertex callback.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@318 232f8b59-042b-4e1e-8c03-345bb8c30851
7 files changed, 478 insertions, 23 deletions
diff --git a/make/glu-impl-common-CustomJavaCode.java b/make/glu-impl-common-CustomJavaCode.java index 07041b45d..34b777cdd 100644 --- a/make/glu-impl-common-CustomJavaCode.java +++ b/make/glu-impl-common-CustomJavaCode.java @@ -424,16 +424,45 @@ public int gluScaleImageJava( int format, int widthin, int heightin, ByteBuffer out = null; if( datain instanceof ByteBuffer ) { in = (ByteBuffer)datain; + } else if( datain instanceof byte[] ) { + in = ByteBuffer.allocateDirect( ((byte[])datain).length ).order( ByteOrder.nativeOrder() ); + in.put((byte[]) datain).rewind(); + } else if( datain instanceof short[] ) { + in = ByteBuffer.allocateDirect( ((byte[])datain).length * 2 ).order( ByteOrder.nativeOrder() ); + in.asShortBuffer().put((short[]) datain).rewind(); + } else if( datain instanceof int[] ) { + in = ByteBuffer.allocateDirect( ((byte[])datain).length * 4 ).order( ByteOrder.nativeOrder() ); + in.asIntBuffer().put((int[]) datain).rewind(); + } else if( datain instanceof float[] ) { + in = ByteBuffer.allocateDirect( ((byte[])datain).length * 4 ).order( ByteOrder.nativeOrder() ); + in.asFloatBuffer().put((float[]) datain).rewind(); } else { - throw new IllegalArgumentException( "Input data must be a ByteBuffer" ); + throw new IllegalArgumentException( "Input data must be a primitive array or a ByteBuffer" ); } if( dataout instanceof ByteBuffer ) { out = (ByteBuffer)dataout; + } else if( dataout instanceof byte[] ) { + out = ByteBuffer.wrap( ((byte[])dataout) ); + } else if( dataout instanceof short[] ) { + out = ByteBuffer.allocate( ((short[])dataout).length * 2 ); + } else if( dataout instanceof int[] ) { + out = ByteBuffer.allocate( ((int[])dataout).length * 4 ); + } else if( dataout instanceof float[] ) { + out = ByteBuffer.allocate( ((float[])dataout).length * 4 ); } else { - throw new IllegalArgumentException( "Output data must be a ByteBuffer" ); + throw new IllegalArgumentException( "Output data must be a primitive array or a ByteBuffer" ); } int errno = Mipmap.gluScaleImage( gl, format, widthin, heightin, typein, in, widthout, heightout, typeout, out ); + if( errno == 0 ) { + if( dataout instanceof short[] ) { + out.asShortBuffer().get( (short[])dataout ); + } else if( dataout instanceof int[] ) { + out.asIntBuffer().get( (int[])dataout ); + } else if( dataout instanceof float[] ) { + out.asFloatBuffer().get( (float[])dataout ); + } + } return( errno ); } @@ -444,8 +473,20 @@ public int gluBuild1DMipmapLevelsJava( int target, int internalFormat, int width ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; + } else if( data instanceof byte[] ) { + buffer = ByteBuffer.allocateDirect( ((byte[])data).length ).order( ByteOrder.nativeOrder() ); + buffer.put( (byte[])data ); + } else if( data instanceof short[] ) { + buffer = ByteBuffer.allocateDirect( ((short[])data).length * 2 ).order( ByteOrder.nativeOrder() ); + buffer.asShortBuffer().put( (short[])data ); + } else if( data instanceof int[] ) { + buffer = ByteBuffer.allocateDirect( ((int[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asIntBuffer().put( (int[])data ); + } else if( data instanceof float[] ) { + buffer = ByteBuffer.allocateDirect( ((float[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asFloatBuffer().put( (float[])data ); } else { - throw new IllegalArgumentException( "Input data must be a ByteBuffer" ); + throw new IllegalArgumentException( "Input data must be a primitive array or a ByteBuffer" ); } return( Mipmap.gluBuild1DMipmapLevels( gl, target, internalFormat, width, format, type, userLevel, baseLevel, maxLevel, buffer ) ); @@ -457,6 +498,18 @@ public int gluBuild1DMipmapsJava( int target, int internalFormat, int width, ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; + } else if( data instanceof byte[] ) { + buffer = ByteBuffer.allocateDirect( ((byte[])data).length ).order( ByteOrder.nativeOrder() ); + buffer.put( (byte[])data ); + } else if( data instanceof short[] ) { + buffer = ByteBuffer.allocateDirect( ((short[])data).length * 2 ).order( ByteOrder.nativeOrder() ); + buffer.asShortBuffer().put( (short[])data ); + } else if( data instanceof int[] ) { + buffer = ByteBuffer.allocateDirect( ((int[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asIntBuffer().put( (int[])data ); + } else if( data instanceof float[] ) { + buffer = ByteBuffer.allocateDirect( ((float[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asFloatBuffer().put( (float[])data ); } else { throw new IllegalArgumentException( "Input data must be a primitive array or a ByteBuffer" ); } @@ -484,6 +537,18 @@ public int gluBuild3DMipmapLevelsJava( int target, int internalFormat, int width ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; + } else if( data instanceof byte[] ) { + buffer = ByteBuffer.allocateDirect( ((byte[])data).length ).order( ByteOrder.nativeOrder() ); + buffer.put( (byte[])data ); + } else if( data instanceof short[] ) { + buffer = ByteBuffer.allocateDirect( ((short[])data).length * 2 ).order( ByteOrder.nativeOrder() ); + buffer.asShortBuffer().put( (short[])data ); + } else if( data instanceof int[] ) { + buffer = ByteBuffer.allocateDirect( ((int[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asIntBuffer().put( (int[])data ); + } else if( data instanceof float[] ) { + buffer = ByteBuffer.allocateDirect( ((float[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asFloatBuffer().put( (float[])data ); } else { throw new IllegalArgumentException( "Input data must be a primitive array or a ByteBuffer" ); } @@ -496,6 +561,18 @@ public int gluBuild3DMipmapsJava( int target, int internalFormat, int width, ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; + } else if( data instanceof byte[] ) { + buffer = ByteBuffer.allocateDirect( ((byte[])data).length ).order( ByteOrder.nativeOrder() ); + buffer.put( (byte[])data ); + } else if( data instanceof short[] ) { + buffer = ByteBuffer.allocateDirect( ((short[])data).length * 2 ).order( ByteOrder.nativeOrder() ); + buffer.asShortBuffer().put( (short[])data ); + } else if( data instanceof int[] ) { + buffer = ByteBuffer.allocateDirect( ((int[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asIntBuffer().put( (int[])data ); + } else if( data instanceof float[] ) { + buffer = ByteBuffer.allocateDirect( ((float[])data).length * 4 ).order( ByteOrder.nativeOrder() ); + buffer.asFloatBuffer().put( (float[])data ); } else { throw new IllegalArgumentException( "Input data must be a primitive array or a ByteBuffer" ); } @@ -510,6 +587,42 @@ public int gluBuild3DMipmapsJava( int target, int internalFormat, int width, // +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, short[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, int[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, float[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + /* Todo travis: change 0 to offset for buffer here */ /** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data) { @@ -520,8 +633,81 @@ public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int } } +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, short[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, int[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, float[] data) { + if (useJavaMipmapCode) { + return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, short[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, int[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, float[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} /** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data) { @@ -533,6 +719,44 @@ public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int } +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, short[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, int[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, float[] data) { + if (useJavaMipmapCode) { + return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} /** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data) { @@ -544,9 +768,46 @@ public int gluBuild2DMipmaps(int target, int internalFormat, int width, int heig } +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, short[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, int[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} /** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, float[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, java.nio.Buffer data) { if (useJavaMipmapCode) { return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data); @@ -556,6 +817,44 @@ public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int } +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, byte[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, short[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, int[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, float[] data) { + if (useJavaMipmapCode) { + return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} /** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data) { @@ -567,7 +866,44 @@ public int gluBuild3DMipmaps(int target, int internalFormat, int width, int heig } +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, byte[] dataIn, int wOut, int hOut, int typeOut, byte[] dataOut) { + if (useJavaMipmapCode) { + return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, short[] dataIn, int wOut, int hOut, int typeOut, short[] dataOut) { + if (useJavaMipmapCode) { + return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, int[] dataIn, int wOut, int hOut, int typeOut, int[] dataOut) { + if (useJavaMipmapCode) { + return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, float[] dataIn, int wOut, int hOut, int typeOut, float[] dataOut) { + if (useJavaMipmapCode) { + return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut); + } else { + throw new GLException("Primitive array data no longer supported by C GLU implementation"); + } +} /** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ public int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut) { diff --git a/make/glu-interface-common-CustomJavaCode.java b/make/glu-interface-common-CustomJavaCode.java index 850d7f65c..829d9d3f9 100644 --- a/make/glu-interface-common-CustomJavaCode.java +++ b/make/glu-interface-common-CustomJavaCode.java @@ -816,20 +816,91 @@ public void gluTessVertex(GLUtesselator tesselator, double[] coords, int coords_ /** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data); +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, byte[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, short[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, int[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, float[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, byte[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, short[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, int[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, float[] data); /** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data); /** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, byte[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, short[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, int[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, float[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */ public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data); /** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, byte[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, short[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, int[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ +public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, float[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */ public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, java.nio.Buffer data); /** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, byte[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, short[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, int[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ +public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, float[] data); + +/** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */ public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data); /** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, byte[] dataIn, int wOut, int hOut, int typeOut, byte[] dataOut); + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, short[] dataIn, int wOut, int hOut, int typeOut, short[] dataOut); + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, int[] dataIn, int wOut, int hOut, int typeOut, int[] dataOut); + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ +public int gluScaleImage(int format, int wIn, int hIn, int typeIn, float[] dataIn, int wOut, int hOut, int typeOut, float[] dataOut); + +/** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */ public int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut); diff --git a/src/net/java/games/gluegen/CMethodBindingEmitter.java b/src/net/java/games/gluegen/CMethodBindingEmitter.java index 0c41d3aa2..5cf2833d9 100644 --- a/src/net/java/games/gluegen/CMethodBindingEmitter.java +++ b/src/net/java/games/gluegen/CMethodBindingEmitter.java @@ -702,9 +702,19 @@ public class CMethodBindingEmitter extends FunctionEmitter } // end of data copy if (EMIT_NULL_CHECKS) { - writer.println(" }"); - } + writer.print(" }"); + if (needsDataCopy) { + writer.println(); + } else { + // Zero out array offset in the case of a null pointer + // being passed down to prevent construction of arbitrary + // pointers + writer.println(" else {"); + writer.println(" " + binding.getArgumentName(i) + "_offset = 0;"); + writer.println(" }"); + } + } } else if (javaArgType.isString()) { if (emittingPrimitiveArrayCritical) { continue; diff --git a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java index 1790207a8..922f60794 100644 --- a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java +++ b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java @@ -148,7 +148,7 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter } else if (javaType.isArray() && !javaType.isNIOBufferArray() &&!javaType.isStringArray()) { String argName = binding.getArgumentName(i); String offsetArg = argName + "_offset"; - writer.println(" if(" + argName + ".length <= " + offsetArg + ")"); + writer.println(" if(" + argName + " != null && " + argName + ".length <= " + offsetArg + ")"); writer.print(" throw new " + getRuntimeExceptionType()); writer.println("(\"array offset argument \\\"" + offsetArg + "\\\" equals or exceeds array length\");"); } diff --git a/src/net/java/games/jogl/impl/mipmap/Mipmap.java b/src/net/java/games/jogl/impl/mipmap/Mipmap.java index 052d39fa2..8b697f37c 100644 --- a/src/net/java/games/jogl/impl/mipmap/Mipmap.java +++ b/src/net/java/games/jogl/impl/mipmap/Mipmap.java @@ -642,7 +642,26 @@ public class Mipmap { ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - } + } else if( data instanceof byte[] ) { + byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + } else if( data instanceof short[] ) { + short[] array = (short[])data; + buffer = ByteBuffer.allocateDirect( array.length * 2 ); + ShortBuffer sb = buffer.asShortBuffer(); + sb.put( array ); + } else if( data instanceof int[] ) { + int[] array = (int[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + IntBuffer ib = buffer.asIntBuffer(); + ib.put( array ); + } else if( data instanceof float[] ) { + float[] array = (float[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + FloatBuffer fb = buffer.asFloatBuffer(); + fb.put( array ); + } return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, width, height, format, type, userLevel, baseLevel, @@ -678,7 +697,26 @@ public class Mipmap { ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - } + } else if( data instanceof byte[] ) { + byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + } else if( data instanceof short[] ) { + short[] array = (short[])data; + buffer = ByteBuffer.allocateDirect( array.length * 2 ); + ShortBuffer sb = buffer.asShortBuffer(); + sb.put( array ); + } else if( data instanceof int[] ) { + int[] array = (int[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + IntBuffer ib = buffer.asIntBuffer(); + ib.put( array ); + } else if( data instanceof float[] ) { + float[] array = (float[])data; + buffer = ByteBuffer.allocateDirect( array.length * 4 ); + FloatBuffer fb = buffer.asFloatBuffer(); + fb.put( array ); + } return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0, diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index e838c68aa..e938c8023 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -394,11 +394,11 @@ public abstract class WindowsGLContext extends GLContext { int[] pformats = new int[MAX_PFORMATS]; int[] numFormatsTmp = new int[1]; if (dummyGL.wglChoosePixelFormatARB(hdc, - iattributes, - fattributes, + iattributes, 0, + fattributes, 0, MAX_PFORMATS, - pformats, - numFormatsTmp)) { + pformats, 0, + numFormatsTmp, 0)) { numFormats = numFormatsTmp[0]; if (numFormats > 0) { // Remove one-basing of pixel format (added on later) @@ -434,7 +434,7 @@ public abstract class WindowsGLContext extends GLContext { // window, to a pbuffer, or to a pixmap) niattribs = 0; iattributes[0] = GL.WGL_NUMBER_PIXEL_FORMATS_ARB; - if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, iresults)) { + if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) { numFormats = iresults[0]; // Should we be filtering out the pixel formats which aren't // applicable, as we are doing here? @@ -463,7 +463,7 @@ public abstract class WindowsGLContext extends GLContext { availableCaps = new GLCapabilities[numFormats]; for (int i = 0; i < numFormats; i++) { - if (!dummyGL.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, iresults)) { + if (!dummyGL.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) { throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context"); } availableCaps[i] = iattributes2GLCapabilities(iattributes, iresults, niattribs, true); diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java index 1d5d78296..26108a5cd 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java @@ -261,11 +261,11 @@ public class WindowsPbufferGLContext extends WindowsGLContext { int nformats; int[] nformatsTmp = new int[1]; if (!gl.wglChoosePixelFormatARB(parentHdc, - iattributes, - fattributes, + iattributes, 0, + fattributes, 0, MAX_PFORMATS, - pformats, - nformatsTmp)) { + pformats, 0, + nformatsTmp, 0)) { throw new GLException("pbuffer creation error: wglChoosePixelFormatARB() failed"); } nformats = nformatsTmp[0]; @@ -287,7 +287,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { iattributes[8] = GL.WGL_DRAW_TO_PBUFFER_ARB; int[] ivalues = new int[9]; for (int i = 0; i < nformats; i++) { - if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, ivalues)) { + if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, 0, ivalues, 0)) { throw new GLException("Error while querying pixel format " + pformats[i] + "'s (index " + i + "'s) capabilities for debugging"); } @@ -349,7 +349,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { iattributes[niattribs++] = 0; - tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes); + tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes, 0); ++whichFormat; } while ((tmpBuffer == 0) && (whichFormat < nformats)); @@ -372,9 +372,9 @@ public class WindowsPbufferGLContext extends WindowsGLContext { // Determine the actual width and height we were able to create. int[] tmp = new int[1]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp ); + gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); width = tmp[0]; - gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp ); + gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); height = tmp[0]; if (DEBUG) { @@ -431,7 +431,7 @@ public class WindowsPbufferGLContext extends WindowsGLContext { textureTarget = GL.GL_TEXTURE_2D; } int[] tmp = new int[1]; - gl.glGenTextures(1, tmp); + gl.glGenTextures(1, tmp, 0); texture = tmp[0]; gl.glBindTexture(textureTarget, texture); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); |