summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
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
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')
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java30
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java14
5 files changed, 30 insertions, 35 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,
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index b1d560f4a..6017c94e4 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -46,12 +46,9 @@ import javax.media.nativewindow.DefaultGraphicsConfiguration;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.MutableSurface;
import javax.media.opengl.GL;
-import javax.media.opengl.GL2;
-import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opengl.util.GLBuffers;
@@ -119,8 +116,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private void createPbuffer() {
final MutableSurface ms = (MutableSurface) getNativeSurface();
final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ms.getGraphicsConfiguration();
- final GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
- final GLProfile glProfile = capabilities.getGLProfile();
final MacOSXCGLDrawableFactory.SharedResource sr = ((MacOSXCGLDrawableFactory)factory).getOrCreateSharedResourceImpl(config.getScreen().getDevice());
if (DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index c65ed084d..7371b0f3b 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -748,24 +748,24 @@ public class FixedFuncPipeline {
if( !gl.getContext().isCPUDataSourcingAvail() ) {
throw new GLException("CPU data sourcing n/a w/ "+gl.getContext());
}
- if( GL.GL_POINTS != mode ) {
+ // if( GL.GL_POINTS != mode ) {
((GLES2)gl).glDrawElements(mode, count, type, indices);
- } else {
+ /* } else {
// FIXME GL_POINTS !
((GLES2)gl).glDrawElements(mode, count, type, indices);
- }
+ } */
}
}
public void glDrawElements(final GL2ES2 gl, final int mode, final int count, final int type, final long indices_buffer_offset) {
validate(gl, true);
if ( GL2GL3.GL_QUADS == mode && !gl.isGL2() ) {
throw new GLException("Cannot handle indexed QUADS on !GL2 w/ VBO due to lack of CPU index access");
- } else if( GL.GL_POINTS != mode ) {
- // FIXME GL_POINTS !
+ } else /* if( GL.GL_POINTS != mode ) */ {
gl.glDrawElements(mode, count, type, indices_buffer_offset);
- } else {
+ } /* else {
+ // FIXME GL_POINTS !
gl.glDrawElements(mode, count, type, indices_buffer_offset);
- }
+ } */
}
private final int textureEnabledCount() {