diff options
author | Sven Gothel <[email protected]> | 2014-07-08 22:10:03 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-08 22:10:03 +0200 |
commit | de53d193c86a02a3cdc46c5c8758192d957d1c67 (patch) | |
tree | 8be8e36381d6f25850b887c9ff0df7e9c2279487 /src/jogl/classes/jogamp/opengl/glu | |
parent | be2b608e22d9a2a3a80eb547bee6180c2ca22678 (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')
3 files changed, 23 insertions, 23 deletions
diff --git a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java index a6952ec5a..c91a045ae 100644 --- a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java @@ -463,21 +463,21 @@ public class GLUquadricImpl implements GLUquadric { x = sin((i * da)); y = cos((i * da)); } - if (nsign == 1.0f) { + // if (nsign == 1.0f) { normal3f(gl, (x * nsign), (y * nsign), (nz * nsign)); TXTR_COORD(gl, s, t); glVertex3f(gl, (x * r), (y * r), z); normal3f(gl, (x * nsign), (y * nsign), (nz * nsign)); TXTR_COORD(gl, s, t + dt); glVertex3f(gl, (x * (r + dr)), (y * (r + dr)), (z + dz)); - } else { + /* } else { normal3f(gl, x * nsign, y * nsign, nz * nsign); TXTR_COORD(gl, s, t); glVertex3f(gl, (x * r), (y * r), z); normal3f(gl, x * nsign, y * nsign, nz * nsign); TXTR_COORD(gl, s, t + dt); glVertex3f(gl, (x * (r + dr)), (y * (r + dr)), (z + dz)); - } + } */ s += ds; } // for slices glEnd(gl); @@ -625,7 +625,7 @@ public class GLUquadricImpl implements GLUquadric { if (innerRadius != 0.0) { float a; glBegin(gl, GL.GL_LINE_LOOP); - for (a = 0.0f; a < 2.0 * PI; a += da) { + for (a = 0.0f; a < PI_2; a += da) { final float x = innerRadius * sin(a); final float y = innerRadius * cos(a); glVertex2f(gl, x, y); @@ -635,7 +635,7 @@ public class GLUquadricImpl implements GLUquadric { { float a; glBegin(gl, GL.GL_LINE_LOOP); - for (a = 0; a < 2.0f * PI; a += da) { + for (a = 0; a < PI_2; a += da) { final float x = outerRadius * sin(a); final float y = outerRadius * cos(a); glVertex2f(gl, x, y); @@ -1120,7 +1120,7 @@ public class GLUquadricImpl implements GLUquadric { // private static final float PI = FloatUtil.PI; - private static final float PI_2 = 2f * FloatUtil.PI; + private static final float PI_2 = 2f * PI; private static final int CACHE_SIZE = 240; private final void glBegin(final GL gl, final int mode) { 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, |