aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/glu/mipmap
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-08 22:10:03 +0200
committerSven Gothel <[email protected]>2014-07-08 22:10:03 +0200
commitde53d193c86a02a3cdc46c5c8758192d957d1c67 (patch)
tree8be8e36381d6f25850b887c9ff0df7e9c2279487 /src/jogl/classes/jogamp/opengl/glu/mipmap
parentbe2b608e22d9a2a3a80eb547bee6180c2ca22678 (diff)
Findbugs: Misc minor issues (see below)
- remove duplicate code in branch - Use Type.valueOf(primitive) - Don't use array.toString() directly - remove dead code
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/glu/mipmap')
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java30
2 files changed, 17 insertions, 17 deletions
diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java
index e9b021413..76c34330f 100644
--- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java
+++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java
@@ -58,9 +58,7 @@ public class ExtractSByte implements ExtractPrimitive {
@Override
public double extract( final boolean isSwap, final ByteBuffer sbyte ) {
- final byte b = sbyte.get();
- assert( b <= 127 );
- return( b );
+ return sbyte.get(); // <= 127
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
index fba6a231a..9ff6bd637 100644
--- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
+++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
@@ -661,8 +661,6 @@ public class Mipmap {
public static int gluBuild2DMipmapLevels( final GL gl, final int target, final int internalFormat,
final int width, final int height, final int format, final int type, final int userLevel,
final int baseLevel, final int maxLevel, final Object data ) {
- int dataPos = 0;
-
int level, levels;
final int rc = checkMipmapArgs( internalFormat, format, type );
@@ -686,14 +684,14 @@ public class Mipmap {
}
//PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data );
- ByteBuffer buffer = null;
+ final ByteBuffer buffer;
if( data instanceof ByteBuffer ) {
buffer = (ByteBuffer)data;
- dataPos = buffer.position();
} else if( data instanceof byte[] ) {
- final byte[] array = (byte[])data;
- buffer = ByteBuffer.allocateDirect(array.length);
- buffer.put(array);
+ final byte[] array = (byte[])data;
+ buffer = ByteBuffer.allocateDirect(array.length);
+ buffer.put(array);
+ buffer.flip();
} else if( data instanceof short[] ) {
final short[] array = (short[])data;
buffer = ByteBuffer.allocateDirect( array.length * 2 );
@@ -709,8 +707,11 @@ public class Mipmap {
buffer = ByteBuffer.allocateDirect( array.length * 4 );
final FloatBuffer fb = buffer.asFloatBuffer();
fb.put( array );
+ } else {
+ throw new IllegalArgumentException("Unhandled data type: "+data.getClass().getName());
}
+ final int dataPos = buffer.position();
try {
return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat,
width, height, width, height, format, type, userLevel, baseLevel,
@@ -723,8 +724,6 @@ public class Mipmap {
public static int gluBuild2DMipmaps( final GL gl, final int target, final int internalFormat,
final int width, final int height, final int format, final int type, final Object data ) {
- int dataPos = 0;
-
final int[] widthPowerOf2 = new int[1];
final int[] heightPowerOf2 = new int[1];
int level, levels;
@@ -748,14 +747,14 @@ public class Mipmap {
}
//PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data );
- ByteBuffer buffer = null;
+ final ByteBuffer buffer;
if( data instanceof ByteBuffer ) {
buffer = (ByteBuffer)data;
- dataPos = buffer.position();
} else if( data instanceof byte[] ) {
- final byte[] array = (byte[])data;
- buffer = ByteBuffer.allocateDirect(array.length);
- buffer.put(array);
+ final byte[] array = (byte[])data;
+ buffer = ByteBuffer.allocateDirect(array.length);
+ buffer.put(array);
+ buffer.flip();
} else if( data instanceof short[] ) {
final short[] array = (short[])data;
buffer = ByteBuffer.allocateDirect( array.length * 2 );
@@ -771,8 +770,11 @@ public class Mipmap {
buffer = ByteBuffer.allocateDirect( array.length * 4 );
final FloatBuffer fb = buffer.asFloatBuffer();
fb.put( array );
+ } else {
+ throw new IllegalArgumentException("Unhandled data type: "+data.getClass().getName());
}
+ final int dataPos = buffer.position();
try {
return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat,
width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0,