diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp')
124 files changed, 6631 insertions, 4017 deletions
diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java index 83f5e4ebd..fef9d61dd 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java @@ -36,7 +36,7 @@ import java.io.*; public class Audio { private static Audio instance = null; - private Mixer mixer; + private final Mixer mixer; public synchronized static Audio getInstance() { if (instance == null) { @@ -53,9 +53,9 @@ public class Audio { return mixer; } - public Track newTrack(File file) throws IOException + public Track newTrack(final File file) throws IOException { - Track res = new Track(file); + final Track res = new Track(file); mixer.add(res); return res; } diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java index b36fd2637..a84da723f 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java @@ -48,12 +48,12 @@ public class Mixer { private volatile boolean shutdownDone; // Windows Event object - private long event; + private final long event; private volatile ArrayList<Track> tracks = new ArrayList<Track>(); - private Vec3f leftSpeakerPosition = new Vec3f(-1, 0, 0); - private Vec3f rightSpeakerPosition = new Vec3f( 1, 0, 0); + private final Vec3f leftSpeakerPosition = new Vec3f(-1, 0, 0); + private final Vec3f rightSpeakerPosition = new Vec3f( 1, 0, 0); private float falloffFactor = 1.0f; @@ -64,7 +64,7 @@ public class Mixer { private Mixer() { event = CreateEvent(); new FillerThread().start(); - MixerThread m = new MixerThread(); + final MixerThread m = new MixerThread(); m.setPriority(Thread.MAX_PRIORITY - 1); m.start(); } @@ -73,14 +73,14 @@ public class Mixer { return mixer; } - synchronized void add(Track track) { - ArrayList<Track> newTracks = new ArrayList<Track>(tracks); + synchronized void add(final Track track) { + final ArrayList<Track> newTracks = new ArrayList<Track>(tracks); newTracks.add(track); tracks = newTracks; } - synchronized void remove(Track track) { - ArrayList<Track> newTracks = new ArrayList<Track>(tracks); + synchronized void remove(final Track track) { + final ArrayList<Track> newTracks = new ArrayList<Track>(tracks); newTracks.remove(track); tracks = newTracks; } @@ -88,14 +88,14 @@ public class Mixer { // NOTE: due to a bug on the APX device, we only have mono sounds, // so we currently only pay attention to the position of the left // speaker - public void setLeftSpeakerPosition(float x, float y, float z) { + public void setLeftSpeakerPosition(final float x, final float y, final float z) { leftSpeakerPosition.set(x, y, z); } // NOTE: due to a bug on the APX device, we only have mono sounds, // so we currently only pay attention to the position of the left // speaker - public void setRightSpeakerPosition(float x, float y, float z) { + public void setRightSpeakerPosition(final float x, final float y, final float z) { rightSpeakerPosition.set(x, y, z); } @@ -109,7 +109,7 @@ public class Mixer { falloffFactor + r^2 </PRE> */ - public void setFalloffFactor(float factor) { + public void setFalloffFactor(final float factor) { falloffFactor = factor; } @@ -119,7 +119,7 @@ public class Mixer { SetEvent(event); try { shutdownLock.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { } } } @@ -132,13 +132,13 @@ public class Mixer { @Override public void run() { while (!shutdown) { - List<Track> curTracks = tracks; + final List<Track> curTracks = tracks; - for (Iterator<Track> iter = curTracks.iterator(); iter.hasNext(); ) { - Track track = iter.next(); + for (final Iterator<Track> iter = curTracks.iterator(); iter.hasNext(); ) { + final Track track = iter.next(); try { track.fill(); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); remove(track); } @@ -147,7 +147,7 @@ public class Mixer { try { // Run ten times per second Thread.sleep(100); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -158,7 +158,7 @@ public class Mixer { // Temporary mixing buffer // Interleaved left and right channels float[] mixingBuffer; - private Vec3f temp = new Vec3f(); + private final Vec3f temp = new Vec3f(); MixerThread() { super("Mixer Thread"); @@ -171,7 +171,7 @@ public class Mixer { public void run() { while (!shutdown) { // Get the next buffer - long mixerBuffer = getNextMixerBuffer(); + final long mixerBuffer = getNextMixerBuffer(); if (mixerBuffer != 0) { ByteBuffer buf = getMixerBufferData(mixerBuffer); @@ -203,27 +203,27 @@ public class Mixer { // This assertion should be in place if we have stereo if ((mixingBuffer.length % 2) != 0) { - String msg = "FATAL ERROR: odd number of samples in the mixing buffer"; + final String msg = "FATAL ERROR: odd number of samples in the mixing buffer"; System.out.println(msg); throw new InternalError(msg); } // Run down all of the registered tracks mixing them in - List<Track> curTracks = tracks; + final List<Track> curTracks = tracks; - for (Iterator<Track> iter = curTracks.iterator(); iter.hasNext(); ) { - Track track = iter.next(); + for (final Iterator<Track> iter = curTracks.iterator(); iter.hasNext(); ) { + final Track track = iter.next(); // Consider only playing tracks if (track.isPlaying()) { // First recompute its gain - Vec3f pos = track.getPosition(); - float leftGain = gain(pos, leftSpeakerPosition); - float rightGain = gain(pos, rightSpeakerPosition); + final Vec3f pos = track.getPosition(); + final float leftGain = gain(pos, leftSpeakerPosition); + final float rightGain = gain(pos, rightSpeakerPosition); // Now mix it in int i = 0; while (i < mixingBuffer.length) { if (track.hasNextSample()) { - float sample = track.nextSample(); + final float sample = track.nextSample(); mixingBuffer[i++] = sample * leftGain; mixingBuffer[i++] = sample * rightGain; } else { @@ -240,7 +240,7 @@ public class Mixer { // Now that we have our data, send it down to the card int outPos = 0; for (int i = 0; i < mixingBuffer.length; i++) { - short val = (short) mixingBuffer[i]; + final short val = (short) mixingBuffer[i]; buf.put(outPos++, (byte) val); buf.put(outPos++, (byte) (val >> 8)); } @@ -279,9 +279,9 @@ public class Mixer { // falloffFactor // ------------------- // falloffFactor + r^2 - private float gain(Vec3f pos, Vec3f speakerPos) { + private float gain(final Vec3f pos, final Vec3f speakerPos) { temp.sub(pos, speakerPos); - float dotp = temp.dot(temp); + final float dotp = temp.dot(temp); return (falloffFactor / (falloffFactor + dotp)); } } @@ -321,8 +321,8 @@ public class Mixer { private static Constructor directByteBufferConstructor; private static Map createdBuffers = new HashMap(); // Map Long, ByteBuffer - private static ByteBuffer newDirectByteBuffer(long address, long capacity) { - Long key = new Long(address); + private static ByteBuffer newDirectByteBuffer(final long address, final long capacity) { + final Long key = new Long(address); ByteBuffer buf = (ByteBuffer) createdBuffers.get(key); if (buf == null) { buf = newDirectByteBufferImpl(address, capacity); @@ -332,17 +332,17 @@ public class Mixer { } return buf; } - private static ByteBuffer newDirectByteBufferImpl(long address, long capacity) { + private static ByteBuffer newDirectByteBufferImpl(final long address, final long capacity) { if (directByteBufferClass == null) { try { directByteBufferClass = Class.forName("java.nio.DirectByteBuffer"); - byte[] tmp = new byte[0]; + final byte[] tmp = new byte[0]; directByteBufferConstructor = directByteBufferClass.getDeclaredConstructor(new Class[] { Integer.TYPE, tmp.getClass(), Integer.TYPE }); directByteBufferConstructor.setAccessible(true); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -355,7 +355,7 @@ public class Mixer { null, new Integer((int) address) }); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java index 01346553c..18698f5ea 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java @@ -35,16 +35,16 @@ package com.jogamp.audio.windows.waveout; import java.io.*; class SoundBuffer { - private byte[] data; - private boolean needsByteSwap; + private final byte[] data; + private final boolean needsByteSwap; private int numBytes; - private int bytesPerSample; + private final int bytesPerSample; private int numSamples; private boolean playing; private boolean empty; // Note: needsByteSwap argument makes assumptions about the format - SoundBuffer(int size, int bytesPerSample, boolean needsByteSwap) { + SoundBuffer(final int size, final int bytesPerSample, final boolean needsByteSwap) { this.bytesPerSample = bytesPerSample; this.needsByteSwap = needsByteSwap; data = new byte[size * bytesPerSample]; @@ -55,7 +55,7 @@ class SoundBuffer { return playing; } - void playing(boolean playing) { + void playing(final boolean playing) { this.playing = playing; } @@ -63,11 +63,11 @@ class SoundBuffer { return empty; } - void empty(boolean empty) { + void empty(final boolean empty) { this.empty = empty; } - void fill(InputStream input) throws IOException { + void fill(final InputStream input) throws IOException { synchronized(this) { if (playing) { throw new IllegalStateException("Can not fill a buffer that is playing"); @@ -75,7 +75,7 @@ class SoundBuffer { } empty(true); - int num = input.read(data); + final int num = input.read(data); if (num > 0) { numBytes = num; numSamples = numBytes / bytesPerSample; @@ -96,8 +96,8 @@ class SoundBuffer { // This is called by the mixer and must be extremely fast // FIXME: may want to reconsider use of floating point at this point // FIXME: assumes all sounds are of the same format to avoid normalization - float getSample(int sample) { - int startByte = sample * bytesPerSample; + float getSample(final int sample) { + final int startByte = sample * bytesPerSample; // FIXME: assumes no more than 4 bytes per sample int res = 0; if (needsByteSwap) { @@ -106,7 +106,7 @@ class SoundBuffer { res |= (data[i] & 0xff); } } else { - int endByte = startByte + bytesPerSample - 1; + final int endByte = startByte + bytesPerSample - 1; for (int i = startByte; i <= endByte; i++) { res <<= 8; res |= (data[i] & 0xff); @@ -119,6 +119,6 @@ class SoundBuffer { res = (byte) res; } - return (float) res; + return res; } } diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java index 98a787478..5e55786ac 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java @@ -56,7 +56,7 @@ public class Track { // If we're playing the file, this is its input stream private InputStream input; // Keep around the file name - private File file; + private final File file; // Whether we're playing this sound private boolean playing; // Whether we're looping this sound @@ -64,7 +64,7 @@ public class Track { // The position of this sound; defaults to being at the origin private volatile Vec3f position = new Vec3f(); - Track(File file) throws IOException { + Track(final File file) throws IOException { if (!file.getName().endsWith(".rawsound")) { throw new IOException("Unsupported file format (currently supports only raw sounds)"); } @@ -96,7 +96,7 @@ public class Track { openInput(); // Fill it immediately fill(); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); return; } @@ -109,7 +109,7 @@ public class Track { return playing; } - public synchronized void setLooping(boolean looping) { + public synchronized void setLooping(final boolean looping) { this.looping = looping; } @@ -117,7 +117,7 @@ public class Track { return looping; } - public void setPosition(float x, float y, float z) { + public void setPosition(final float x, final float y, final float z) { position = new Vec3f(x, y, z); } @@ -125,7 +125,7 @@ public class Track { if (input == null) { return; } - SoundBuffer curBuffer = fillingBuffer; + final SoundBuffer curBuffer = fillingBuffer; if (!curBuffer.empty()) { return; } @@ -152,7 +152,7 @@ public class Track { private float leftGain; private float rightGain; - void setLeftGain(float leftGain) { + void setLeftGain(final float leftGain) { this.leftGain = leftGain; } @@ -160,7 +160,7 @@ public class Track { return leftGain; } - void setRightGain(float rightGain) { + void setRightGain(final float rightGain) { this.rightGain = rightGain; } @@ -180,7 +180,7 @@ public class Track { // This is called by the mixer and must be extremely fast float nextSample() { - float res = activeBuffer.getSample(samplePosition++); + final float res = activeBuffer.getSample(samplePosition++); ++samplesRead; if (!hasNextSample()) { swapBuffers(); @@ -193,7 +193,7 @@ public class Track { } synchronized void swapBuffers() { - SoundBuffer tmp = activeBuffer; + final SoundBuffer tmp = activeBuffer; activeBuffer = fillingBuffer; fillingBuffer = tmp; fillingBuffer.empty(true); diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java index 79fb80169..831b25c91 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java @@ -48,11 +48,11 @@ class Vec3f { public Vec3f() {} - public Vec3f(Vec3f arg) { + public Vec3f(final Vec3f arg) { set(arg); } - public Vec3f(float x, float y, float z) { + public Vec3f(final float x, final float y, final float z) { set(x, y, z); } @@ -60,18 +60,18 @@ class Vec3f { return new Vec3f(this); } - public void set(Vec3f arg) { + public void set(final Vec3f arg) { set(arg.x, arg.y, arg.z); } - public void set(float x, float y, float z) { + public void set(final float x, final float y, final float z) { this.x = x; this.y = y; this.z = z; } /** Sets the ith component, 0 <= i < 3 */ - public void set(int i, float val) { + public void set(final int i, final float val) { switch (i) { case 0: x = val; break; case 1: y = val; break; @@ -81,7 +81,7 @@ class Vec3f { } /** Gets the ith component, 0 <= i < 3 */ - public float get(int i) { + public float get(final int i) { switch (i) { case 0: return x; case 1: return y; @@ -94,11 +94,11 @@ class Vec3f { public float y() { return y; } public float z() { return z; } - public void setX(float x) { this.x = x; } - public void setY(float y) { this.y = y; } - public void setZ(float z) { this.z = z; } + public void setX(final float x) { this.x = x; } + public void setY(final float y) { this.y = y; } + public void setZ(final float z) { this.z = z; } - public float dot(Vec3f arg) { + public float dot(final Vec3f arg) { return x * arg.x + y * arg.y + z * arg.z; } @@ -111,87 +111,87 @@ class Vec3f { } public void normalize() { - float len = length(); + final float len = length(); if (len == 0.0f) return; scale(1.0f / len); } /** Returns this * val; creates new vector */ - public Vec3f times(float val) { - Vec3f tmp = new Vec3f(this); + public Vec3f times(final float val) { + final Vec3f tmp = new Vec3f(this); tmp.scale(val); return tmp; } /** this = this * val */ - public void scale(float val) { + public void scale(final float val) { x *= val; y *= val; z *= val; } /** Returns this + arg; creates new vector */ - public Vec3f plus(Vec3f arg) { - Vec3f tmp = new Vec3f(); + public Vec3f plus(final Vec3f arg) { + final Vec3f tmp = new Vec3f(); tmp.add(this, arg); return tmp; } /** this = this + b */ - public void add(Vec3f b) { + public void add(final Vec3f b) { add(this, b); } /** this = a + b */ - public void add(Vec3f a, Vec3f b) { + public void add(final Vec3f a, final Vec3f b) { x = a.x + b.x; y = a.y + b.y; z = a.z + b.z; } /** Returns this + s * arg; creates new vector */ - public Vec3f addScaled(float s, Vec3f arg) { - Vec3f tmp = new Vec3f(); + public Vec3f addScaled(final float s, final Vec3f arg) { + final Vec3f tmp = new Vec3f(); tmp.addScaled(this, s, arg); return tmp; } /** this = a + s * b */ - public void addScaled(Vec3f a, float s, Vec3f b) { + public void addScaled(final Vec3f a, final float s, final Vec3f b) { x = a.x + s * b.x; y = a.y + s * b.y; z = a.z + s * b.z; } /** Returns this - arg; creates new vector */ - public Vec3f minus(Vec3f arg) { - Vec3f tmp = new Vec3f(); + public Vec3f minus(final Vec3f arg) { + final Vec3f tmp = new Vec3f(); tmp.sub(this, arg); return tmp; } /** this = this - b */ - public void sub(Vec3f b) { + public void sub(final Vec3f b) { sub(this, b); } /** this = a - b */ - public void sub(Vec3f a, Vec3f b) { + public void sub(final Vec3f a, final Vec3f b) { x = a.x - b.x; y = a.y - b.y; z = a.z - b.z; } /** Returns this cross arg; creates new vector */ - public Vec3f cross(Vec3f arg) { - Vec3f tmp = new Vec3f(); + public Vec3f cross(final Vec3f arg) { + final Vec3f tmp = new Vec3f(); tmp.cross(this, arg); return tmp; } /** this = a cross b. NOTE: "this" must be a different vector than both a and b. */ - public void cross(Vec3f a, Vec3f b) { + public void cross(final Vec3f a, final Vec3f b) { x = a.y * b.z - a.z * b.y; y = a.z * b.x - a.x * b.z; z = a.x * b.y - a.y * b.x; @@ -200,7 +200,7 @@ class Vec3f { /** Sets each component of this vector to the product of the component with the corresponding component of the argument vector. */ - public void componentMul(Vec3f arg) { + public void componentMul(final Vec3f arg) { x *= arg.x; y *= arg.y; z *= arg.z; diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 023913d7b..f082f358f 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -106,37 +106,37 @@ public class BuildComposablePipeline { // Desktop OpenGL and GLES1 have GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors private boolean hasGL2ES1StackOverflow; - public static Class<?> getClass(String name) { + public static Class<?> getClass(final String name) { Class<?> clazz = null; try { clazz = Class.forName(name); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException( "Could not find class \"" + name + "\"", e); } return clazz; } - public static Method getMethod(Class<?> clazz, Method m) { + public static Method getMethod(final Class<?> clazz, final Method m) { Method res = null; try { res = clazz.getMethod(m.getName(), m.getParameterTypes()); - } catch (Exception e) { + } catch (final Exception e) { } return res; } - public static void main(String[] args) { - String classToComposeAroundName = args[0]; + public static void main(final String[] args) { + final String classToComposeAroundName = args[0]; Class<?> classPrologOpt, classDownstream; - Class<?> classToComposeAround = getClass(classToComposeAroundName); + final Class<?> classToComposeAround = getClass(classToComposeAroundName); - String outputDir = args[1]; + final String outputDir = args[1]; String outputPackage, outputName; int mode; if (args.length > 2) { - String outputClazzName = args[2]; + final String outputClazzName = args[2]; outputPackage = getPackageName(outputClazzName); outputName = getBaseClassName(outputClazzName); classPrologOpt = getClass(args[3]); @@ -159,19 +159,19 @@ public class BuildComposablePipeline { mode = GEN_DEBUG | GEN_TRACE ; } - BuildComposablePipeline composer = + final BuildComposablePipeline composer = new BuildComposablePipeline(mode, outputDir, outputPackage, outputName, classToComposeAround, classPrologOpt, classDownstream); try { composer.emit(); - } catch (IOException e) { + } catch (final IOException e) { throw new RuntimeException( "Error generating composable pipeline source files", e); } } - protected BuildComposablePipeline(int mode, String outputDir, String outputPackage, String outputName, - Class<?> classToComposeAround, Class<?> classPrologOpt, Class<?> classDownstream) { + protected BuildComposablePipeline(final int mode, final String outputDir, final String outputPackage, final String outputName, + final Class<?> classToComposeAround, final Class<?> classPrologOpt, final Class<?> classDownstream) { this.mode = mode; this.outputDir = outputDir; this.outputPackage = outputPackage; @@ -188,13 +188,13 @@ public class BuildComposablePipeline { try { hasImmediateMode = (classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE}) != null); - } catch (Exception e) { + } catch (final Exception e) { } try { hasGL2ES1StackOverflow = hasImmediateMode && (classToComposeAround.getField("GL_STACK_OVERFLOW") != null); - } catch (Exception e) { + } catch (final Exception e) { } } @@ -207,7 +207,7 @@ public class BuildComposablePipeline { final List<Method> publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods()); final Set<PlainMethod> publicMethodsPlain = new HashSet<PlainMethod>(); - for (Iterator<Method> iter = publicMethodsRaw.iterator(); iter.hasNext();) { + for (final Iterator<Method> iter = publicMethodsRaw.iterator(); iter.hasNext();) { final Method method = iter.next(); // Don't hook methods which aren't real GL methods, // such as the synthetic "isGL2ES2" "getGL2ES2" @@ -232,8 +232,8 @@ public class BuildComposablePipeline { } } - public static String getPackageName(String clazzName) { - int lastDot = clazzName.lastIndexOf('.'); + public static String getPackageName(final String clazzName) { + final int lastDot = clazzName.lastIndexOf('.'); if (lastDot == -1) { // no package, class is at root level return null; @@ -241,8 +241,8 @@ public class BuildComposablePipeline { return clazzName.substring(0, lastDot); } - public static String getBaseClassName(String clazzName) { - int lastDot = clazzName.lastIndexOf('.'); + public static String getBaseClassName(final String clazzName) { + final int lastDot = clazzName.lastIndexOf('.'); if (lastDot == -1) { // no package, class is at root level return clazzName; @@ -256,7 +256,7 @@ public class BuildComposablePipeline { Method m; boolean runHooks; - PlainMethod(Method m, boolean runHooks) { + PlainMethod(final Method m, final boolean runHooks) { this.m = m; this.runHooks = runHooks; } @@ -270,10 +270,10 @@ public class BuildComposablePipeline { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj instanceof PlainMethod) { - PlainMethod b = (PlainMethod) obj; - boolean res = + final PlainMethod b = (PlainMethod) obj; + final boolean res = m.getName().equals(b.m.getName()) && m.getModifiers() == b.m.getModifiers() && m.getReturnType().equals(b.m.getReturnType()) @@ -286,7 +286,7 @@ public class BuildComposablePipeline { @Override public int hashCode() { int hash = m.getName().hashCode() ^ m.getModifiers() ^ m.getReturnType().hashCode(); - Class<?>[] args = m.getParameterTypes(); + final Class<?>[] args = m.getParameterTypes(); for (int i = 0; i < args.length; i++) { hash ^= args[i].hashCode(); } @@ -295,8 +295,8 @@ public class BuildComposablePipeline { @Override public String toString() { - Class<?>[] args = m.getParameterTypes(); - StringBuilder argsString = new StringBuilder(); + final Class<?>[] args = m.getParameterTypes(); + final StringBuilder argsString = new StringBuilder(); argsString.append("("); for (int i = 0; i < args.length; i++) { if (i > 0) { @@ -340,7 +340,7 @@ public class BuildComposablePipeline { * @exception IllegalArgumentException if classToComposeAround is not an * interface. */ - PipelineEmitter(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> prologClassOpt, Class<?> downstreamClass) { + PipelineEmitter(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> prologClassOpt, final Class<?> downstreamClass) { this.outputDir = outputDir; this.outputPackage = outputPackage; this.baseInterfaceClass = baseInterfaceClass; @@ -357,31 +357,31 @@ public class BuildComposablePipeline { } } - public void emit(Iterator<PlainMethod> methodsToWrap) throws IOException { - String outputClassName = getOutputName(); + public void emit(final Iterator<PlainMethod> methodsToWrap) throws IOException { + final String outputClassName = getOutputName(); this.file = new File(outputDir + File.separatorChar + outputClassName + ".java"); - String parentDir = file.getParent(); + final String parentDir = file.getParent(); if (parentDir != null) { - File pDirFile = new File(parentDir); + final File pDirFile = new File(parentDir); pDirFile.mkdirs(); } - PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file))); + final PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file))); - List<Class<?>> baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces()); - HashSet<Class<?>> clazzList = new HashSet<Class<?>>(); + final List<Class<?>> baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces()); + final HashSet<Class<?>> clazzList = new HashSet<Class<?>>(); clazzList.add(baseInterfaceClass); clazzList.addAll(baseInterfaces); - int ifNamesNumber = clazzList.size(); + final int ifNamesNumber = clazzList.size(); // keep original order .. clazzList.clear(); - String[] ifNames = new String[ifNamesNumber]; + final String[] ifNames = new String[ifNamesNumber]; { int i = 0; - for (Iterator<Class<?>> iter = baseInterfaces.iterator(); iter.hasNext();) { - Class<?> ifClass = iter.next(); + for (final Iterator<Class<?>> iter = baseInterfaces.iterator(); iter.hasNext();) { + final Class<?> ifClass = iter.next(); if (!clazzList.contains(ifClass)) { ifNames[i++] = ifClass.getName(); clazzList.add(ifClass); @@ -399,12 +399,12 @@ public class BuildComposablePipeline { clazzList.add(prologClassOpt); } - ArrayList<String> imports = new ArrayList<String>(); + final ArrayList<String> imports = new ArrayList<String>(); imports.add("java.io.*"); imports.add("javax.media.opengl.*"); imports.add("com.jogamp.gluegen.runtime.*"); imports.add(Buffer.class.getPackage().getName()+".*"); - for (Class<?> clasS : clazzList) { + for (final Class<?> clasS : clazzList) { imports.add(clasS.getName()); } @@ -418,7 +418,7 @@ public class BuildComposablePipeline { null, new CodeGenUtils.EmissionCallback() { @Override - public void emit(PrintWriter w) { + public void emit(final PrintWriter w) { emitClassDocComment(w); } }); @@ -431,8 +431,8 @@ public class BuildComposablePipeline { emitGLGetMethods(output); while (methodsToWrap.hasNext()) { - PlainMethod pm = methodsToWrap.next(); - Method m = pm.getWrappedMethod(); + final PlainMethod pm = methodsToWrap.next(); + final Method m = pm.getWrappedMethod(); emitMethodDocComment(output, m); emitSignature(output, m); emitBody(output, m, pm.runHooks()); @@ -467,25 +467,25 @@ public class BuildComposablePipeline { return null; } - protected void emitMethodDocComment(PrintWriter output, Method m) { + protected void emitMethodDocComment(final PrintWriter output, final Method m) { } - protected void emitSignature(PrintWriter output, Method m) { + protected void emitSignature(final PrintWriter output, final Method m) { output.format(" @Override%n public %s %s(%s)%n", JavaType.createForClass(m.getReturnType()).getName(), m.getName(), getArgListAsString(m, true, true)); } - protected void emitBody(PrintWriter output, Method m, boolean runHooks) { + protected void emitBody(final PrintWriter output, final Method m, final boolean runHooks) { output.println(" {"); - Class<?> retType = m.getReturnType(); + final Class<?> retType = m.getReturnType(); - boolean callPreDownstreamHook = runHooks && hasPreDownstreamCallHook(m); - boolean callPostDownstreamHook = runHooks && hasPostDownstreamCallHook(m); - boolean callDownstream = (null != getMethod(downstreamClass, m)) + final boolean callPreDownstreamHook = runHooks && hasPreDownstreamCallHook(m); + final boolean callPostDownstreamHook = runHooks && hasPostDownstreamCallHook(m); + final boolean callDownstream = (null != getMethod(downstreamClass, m)) && !(0 != (GEN_PROLOG_XOR_DOWNSTREAM & getMode()) && callPreDownstreamHook); - boolean hasResult = (retType != Void.TYPE); + final boolean hasResult = (retType != Void.TYPE); if (!callDownstream) { if (!emptyDownstreamAllowed()) { @@ -546,14 +546,14 @@ public class BuildComposablePipeline { } - protected String getArgListAsString(Method m, boolean includeArgTypes, boolean includeArgNames) { - StringBuilder buf = new StringBuilder(256); + protected String getArgListAsString(final Method m, final boolean includeArgTypes, final boolean includeArgNames) { + final StringBuilder buf = new StringBuilder(256); if (!includeArgNames && !includeArgTypes) { throw new IllegalArgumentException( "Cannot generate arglist without both arg types and arg names"); } - Class<?>[] argTypes = m.getParameterTypes(); + final Class<?>[] argTypes = m.getParameterTypes(); for (int i = 0; i < argTypes.length; ++i) { if (includeArgTypes) { buf.append(JavaType.createForClass(argTypes[i]).getName()); @@ -588,7 +588,7 @@ public class BuildComposablePipeline { * Called after the class headers have been generated, but before any * method wrappers have been generated. */ - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { output.println(" public static final boolean DEBUG = jogamp.opengl.Debug.debug(\"" + getOutputName() + "\");"); } @@ -601,7 +601,7 @@ public class BuildComposablePipeline { * Called after the method wrappers have been generated, but before the * closing parenthesis of the class is emitted. */ - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { output.println(" @Override"); output.println(" public String toString() {"); output.println(" StringBuilder sb = new StringBuilder();"); @@ -641,7 +641,7 @@ public class BuildComposablePipeline { /** * Emits one of the isGL* methods. */ - protected void emitGLIsMethod(PrintWriter output, String type) { + protected void emitGLIsMethod(final PrintWriter output, final String type) { output.println(" @Override"); output.println(" public final boolean is" + type + "() {"); if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { @@ -660,7 +660,7 @@ public class BuildComposablePipeline { /** * Emits all of the isGL* methods. */ - protected void emitGLIsMethods(PrintWriter output) { + protected void emitGLIsMethods(final PrintWriter output) { output.println(" @Override"); output.println(" public final boolean isGL() {"); output.println(" return true;"); @@ -712,7 +712,7 @@ public class BuildComposablePipeline { /** * Emits one of the getGL* methods. */ - protected void emitGLGetMethod(PrintWriter output, String type) { + protected void emitGLGetMethod(final PrintWriter output, final String type) { output.println(" @Override"); output.println(" public final javax.media.opengl." + type + " get" + type + "() {"); final Class<?> clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); @@ -732,7 +732,7 @@ public class BuildComposablePipeline { /** * Emits all of the getGL* methods. */ - protected void emitGLGetMethods(PrintWriter output) { + protected void emitGLGetMethods(final PrintWriter output) { output.println(" @Override"); output.println(" public final javax.media.opengl.GL getGL() {"); output.println(" return this;"); @@ -768,7 +768,7 @@ public class BuildComposablePipeline { String className; int mode; - CustomPipeline(int mode, String outputDir, String outputPackage, String outputName, Class<?> baseInterfaceClass, Class<?> prologClassOpt, Class<?> downstreamClass) { + CustomPipeline(final int mode, final String outputDir, final String outputPackage, final String outputName, final Class<?> baseInterfaceClass, final Class<?> prologClassOpt, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, prologClassOpt, downstreamClass); className = outputName; this.mode = mode; @@ -795,12 +795,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.print(downstreamName + " " + getDownstreamObjectName()); if (null != prologNameOpt) { @@ -823,7 +823,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); if (null != prologNameOpt) { output.print(" private " + prologNameOpt + " " + getPrologObjectNameOpt() + ";"); @@ -831,7 +831,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * Composable pipeline {@link " + outputPackage + "." + outputName + "}, implementing the interface"); output.println(" * {@link " + baseInterfaceClass.getName() + "}"); @@ -866,12 +866,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return null != getMethod(prologClassOpt, m); } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { if (null != prologNameOpt) { output.print(getPrologObjectNameOpt()); output.print('.'); @@ -883,12 +883,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return false; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { } } // end class CustomPipeline @@ -896,7 +896,7 @@ public class BuildComposablePipeline { String className; - DebugPipeline(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> downstreamClass) { + DebugPipeline(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, null, downstreamClass); className = "Debug" + getBaseInterfaceName(); } @@ -922,12 +922,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ")"); output.println(" {"); @@ -947,7 +947,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); output.println(" private int checkGLError() {"); if (hasImmediateMode) { @@ -1005,7 +1005,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * <p>"); output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); @@ -1023,22 +1023,22 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return true; } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { output.println(" checkContext();"); } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return true; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { if (m.getName().equals("glBegin")) { output.println(" insideBeginEndPair = true;"); output.println(" // NOTE: can't check glGetError(); it's not allowed inside glBegin/glEnd pair"); @@ -1050,12 +1050,12 @@ public class BuildComposablePipeline { output.println(" final int err = checkGLError();"); output.println(" if (err != GL_NO_ERROR) {"); - StringBuilder fmtsb = new StringBuilder(); - StringBuilder argsb = new StringBuilder(); + final StringBuilder fmtsb = new StringBuilder(); + final StringBuilder argsb = new StringBuilder(); fmtsb.append("\"%s("); argsb.append("\"").append(m.getName()).append("\""); - Class<?>[] params = m.getParameterTypes(); + final Class<?>[] params = m.getParameterTypes(); for (int i = 0; i < params.length; i++) { if (i > 0) { fmtsb.append(", "); @@ -1089,7 +1089,7 @@ public class BuildComposablePipeline { String className; - TracePipeline(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> downstreamClass) { + TracePipeline(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, null, downstreamClass); className = "Trace" + getBaseInterfaceName(); } @@ -1115,12 +1115,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ", PrintStream " + getOutputStreamName() + ")"); output.println(" {"); @@ -1136,7 +1136,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); output.println("private PrintStream " + getOutputStreamName() + ";"); output.println("private int indent = 0;"); @@ -1171,7 +1171,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * <p>"); output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); @@ -1189,12 +1189,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return true; } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { if (m.getName().equals("glEnd") || m.getName().equals("glEndList")) { output.println(" indent-=2;"); output.println(" printIndent();"); @@ -1208,13 +1208,13 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return true; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { - Class<?> ret = m.getReturnType(); + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { + final Class<?> ret = m.getReturnType(); if (ret != Void.TYPE) { output.println(" println(\" = \"+_res);"); } else { @@ -1230,8 +1230,8 @@ public class BuildComposablePipeline { } } // end class TracePipeline - public static final void printFunctionCallString(PrintWriter output, Method m) { - Class<?>[] params = m.getParameterTypes(); + public static final void printFunctionCallString(final PrintWriter output, final Method m) { + final Class<?>[] params = m.getParameterTypes(); output.print(" \"" + m.getName() + "(\""); for (int i = 0; i < params.length; i++) { output.print("+\"<" + params[i].getName() + ">"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java index a5a26d18f..f9719c232 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java @@ -138,41 +138,41 @@ public class BuildStaticGLInfo { * classes reside, and the remaining arguments are paths to the C header * files that should be parsed */ - public static void main(String[] args) throws IOException { + public static void main(final String[] args) throws IOException { if (args.length > 0 && args[0].equals("-test")) { - BuildStaticGLInfo builder = new BuildStaticGLInfo(); + final BuildStaticGLInfo builder = new BuildStaticGLInfo(); builder.setDebug(true); - String[] newArgs = new String[args.length - 1]; + final String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); builder.parse(newArgs); builder.dump(); System.exit(0); } - String packageName = args[0]; - String packageDir = args[1]; + final String packageName = args[0]; + final String packageDir = args[1]; - String[] cHeaderFilePaths = new String[args.length - 2]; + final String[] cHeaderFilePaths = new String[args.length - 2]; System.arraycopy(args, 2, cHeaderFilePaths, 0, cHeaderFilePaths.length); - BuildStaticGLInfo builder = new BuildStaticGLInfo(); + final BuildStaticGLInfo builder = new BuildStaticGLInfo(); try { builder.parse(cHeaderFilePaths); - File file = new File(packageDir + File.separatorChar + "StaticGLInfo.java"); - String parentDir = file.getParent(); + final File file = new File(packageDir + File.separatorChar + "StaticGLInfo.java"); + final String parentDir = file.getParent(); if (parentDir != null) { - File pDirFile = new File(parentDir); + final File pDirFile = new File(parentDir); pDirFile.mkdirs(); } - PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file))); + final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file))); builder.emitJavaCode(writer, packageName); writer.flush(); writer.close(); - } catch (Exception e) { - StringBuilder buf = new StringBuilder("{ "); + } catch (final Exception e) { + final StringBuilder buf = new StringBuilder("{ "); for (int i = 0; i < cHeaderFilePaths.length; ++i) { buf.append(cHeaderFilePaths[i]); buf.append(" "); @@ -183,13 +183,13 @@ public class BuildStaticGLInfo { } } - public void setDebug(boolean v) { + public void setDebug(final boolean v) { DEBUG = v; } /** Parses the supplied C header files and adds the function associations contained therein to the internal map. */ - public void parse(String[] cHeaderFilePaths) throws IOException { + public void parse(final String[] cHeaderFilePaths) throws IOException { for (int i = 0; i < cHeaderFilePaths.length; i++) { parse(cHeaderFilePaths[i]); } @@ -197,8 +197,8 @@ public class BuildStaticGLInfo { /** Parses the supplied C header file and adds the function associations contained therein to the internal map. */ - public void parse(String cHeaderFilePath) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); + public void parse(final String cHeaderFilePath) throws IOException { + final BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); String line, activeAssociation = null; Matcher m = null; int block = 0; @@ -264,23 +264,23 @@ public class BuildStaticGLInfo { } public void dump() { - for (String name : extensionToDeclarationMap.keySet()) { - Set<String> decls = extensionToDeclarationMap.get(name); + for (final String name : extensionToDeclarationMap.keySet()) { + final Set<String> decls = extensionToDeclarationMap.get(name); System.out.println("<" + name + "> :"); - List<String> l = new ArrayList<String>(); + final List<String> l = new ArrayList<String>(); l.addAll(decls); Collections.sort(l); - for (String str : l) { + for (final String str : l) { System.out.println(" <" + str + ">"); } } } - public Set<String> getExtension(String identifier) { + public Set<String> getExtension(final String identifier) { return declarationToExtensionMap.get(identifier); } - public Set<String> getDeclarations(String extension) { + public Set<String> getDeclarations(final String extension) { return extensionToDeclarationMap.get(extension); } @@ -288,7 +288,7 @@ public class BuildStaticGLInfo { return extensionToDeclarationMap.keySet(); } - public void emitJavaCode(PrintWriter output, String packageName) { + public void emitJavaCode(final PrintWriter output, final String packageName) { output.println("package " + packageName + ";"); output.println(); output.println("import java.util.*;"); @@ -340,7 +340,7 @@ public class BuildStaticGLInfo { // Compute max capacity int maxCapacity = 0; - for (String name : declarationToExtensionMap.keySet()) { + for (final String name : declarationToExtensionMap.keySet()) { if (!name.startsWith("GL")) { ++maxCapacity; } @@ -348,17 +348,17 @@ public class BuildStaticGLInfo { output.println(" funcToAssocMap = new HashMap(" + maxCapacity + "); // approximate max capacity"); output.println(" String group;"); - ArrayList<String> sets = new ArrayList<String>(extensionToDeclarationMap.keySet()); + final ArrayList<String> sets = new ArrayList<String>(extensionToDeclarationMap.keySet()); Collections.sort(sets); - for (String groupName : sets) { - Set<String> funcs = extensionToDeclarationMap.get(groupName); - List<String> l = new ArrayList<String>(); + for (final String groupName : sets) { + final Set<String> funcs = extensionToDeclarationMap.get(groupName); + final List<String> l = new ArrayList<String>(); l.addAll(funcs); Collections.sort(l); - Iterator<String> funcIter = l.iterator(); + final Iterator<String> funcIter = l.iterator(); boolean printedHeader = false; while (funcIter.hasNext()) { - String funcName = funcIter.next(); + final String funcName = funcIter.next(); if (!funcName.startsWith("GL")) { if (!printedHeader) { output.println(); @@ -380,7 +380,7 @@ public class BuildStaticGLInfo { //---------------------------------------------------------------------- // Internals only below this point // - protected void addAssociation(String identifier, String association) { + protected void addAssociation(final String identifier, final String association) { Set<String> extensions = declarationToExtensionMap.get(identifier); if(null == extensions) { extensions = new HashSet<String>(); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index f1a32fa9c..5da45abfe 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -59,17 +59,17 @@ import java.util.StringTokenizer; public class GLConfiguration extends ProcAddressConfiguration { // The following data members support ignoring an entire extension at a time - private List<String> glHeaders = new ArrayList<String>(); - private Set<String> ignoredExtensions = new HashSet<String>(); - private Set<String> forcedExtensions = new HashSet<String>(); - private Set<String> extensionsRenamedIntoCore = new HashSet<String>(); + private final List<String> glHeaders = new ArrayList<String>(); + private final Set<String> ignoredExtensions = new HashSet<String>(); + private final Set<String> forcedExtensions = new HashSet<String>(); + private final Set<String> extensionsRenamedIntoCore = new HashSet<String>(); private BuildStaticGLInfo glInfo; // Maps function names to the kind of buffer object it deals with - private Map<String, GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String, GLEmitter.BufferObjectKind>(); - private Set<String> bufferObjectOnly = new HashSet<String>(); - private GLEmitter emitter; - private Set<String> dropUniqVendorExtensions = new HashSet<String>(); + private final Map<String, GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String, GLEmitter.BufferObjectKind>(); + private final Set<String> bufferObjectOnly = new HashSet<String>(); + private final GLEmitter emitter; + private final Set<String> dropUniqVendorExtensions = new HashSet<String>(); // This directive is off by default but can help automatically // indicate which extensions have been folded into the core OpenGL @@ -77,52 +77,52 @@ public class GLConfiguration extends ProcAddressConfiguration { private boolean autoUnifyExtensions = false; private boolean allowNonGLExtensions = false; - public GLConfiguration(GLEmitter emitter) { + public GLConfiguration(final GLEmitter emitter) { super(); this.emitter = emitter; try { setProcAddressNameExpr("PFN $UPPERCASE({0}) PROC"); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { throw new RuntimeException("Error configuring ProcAddressNameExpr", e); } } @Override - protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException { + protected void dispatch(final String cmd, final StringTokenizer tok, final File file, final String filename, final int lineNo) throws IOException { if (cmd.equalsIgnoreCase("IgnoreExtension")) { - String sym = readString("IgnoreExtension", tok, filename, lineNo); + final String sym = readString("IgnoreExtension", tok, filename, lineNo); ignoredExtensions.add(sym); } else if (cmd.equalsIgnoreCase("ForceExtension")) { - String sym = readString("ForceExtension", tok, filename, lineNo); + final String sym = readString("ForceExtension", tok, filename, lineNo); forcedExtensions.add(sym); } else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) { - String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); + final String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); extensionsRenamedIntoCore.add(sym); } else if (cmd.equalsIgnoreCase("AllowNonGLExtensions")) { allowNonGLExtensions = readBoolean("AllowNonGLExtensions", tok, filename, lineNo).booleanValue(); } else if (cmd.equalsIgnoreCase("AutoUnifyExtensions")) { autoUnifyExtensions = readBoolean("AutoUnifyExtensions", tok, filename, lineNo).booleanValue(); } else if (cmd.equalsIgnoreCase("GLHeader")) { - String sym = readString("GLHeader", tok, filename, lineNo); + final String sym = readString("GLHeader", tok, filename, lineNo); glHeaders.add(sym); } else if (cmd.equalsIgnoreCase("BufferObjectKind")) { readBufferObjectKind(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("BufferObjectOnly")) { - String sym = readString("BufferObjectOnly", tok, filename, lineNo); + final String sym = readString("BufferObjectOnly", tok, filename, lineNo); bufferObjectOnly.add(sym); } else if (cmd.equalsIgnoreCase("DropUniqVendorExtensions")) { - String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); + final String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); dropUniqVendorExtensions.add(sym); } else { super.dispatch(cmd, tok, file, filename, lineNo); } } - protected void readBufferObjectKind(StringTokenizer tok, String filename, int lineNo) { + protected void readBufferObjectKind(final StringTokenizer tok, final String filename, final int lineNo) { try { - String kindString = tok.nextToken(); + final String kindString = tok.nextToken(); GLEmitter.BufferObjectKind kind = null; - String target = tok.nextToken(); + final String target = tok.nextToken(); if (kindString.equalsIgnoreCase("UnpackPixel")) { kind = GLEmitter.BufferObjectKind.UNPACK_PIXEL; } else if (kindString.equalsIgnoreCase("PackPixel")) { @@ -140,7 +140,7 @@ public class GLConfiguration extends ProcAddressConfiguration { } bufferObjectKinds.put(target, kind); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { throw new RuntimeException("Error parsing \"BufferObjectKind\" command at line " + lineNo + " in file \"" + filename + "\"", e); } @@ -150,10 +150,10 @@ public class GLConfiguration extends ProcAddressConfiguration { automatically generates prologue code for functions associated with buffer objects. */ @Override - public List<String> javaPrologueForMethod(MethodBinding binding, boolean forImplementingMethodCall, boolean eraseBufferAndArrayTypes) { + public List<String> javaPrologueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes) { List<String> res = super.javaPrologueForMethod(binding, forImplementingMethodCall, eraseBufferAndArrayTypes); - GLEmitter.BufferObjectKind kind = getBufferObjectKind(binding.getName()); + final GLEmitter.BufferObjectKind kind = getBufferObjectKind(binding.getName()); if (kind != null) { // Need to generate appropriate prologue based on both buffer // object kind and whether this variant of the MethodBinding @@ -161,7 +161,7 @@ public class GLConfiguration extends ProcAddressConfiguration { // // NOTE we MUST NOT mutate the array returned from the super // call! - ArrayList<String> res2 = new ArrayList<String>(); + final ArrayList<String> res2 = new ArrayList<String>(); if (res != null) { res2.addAll(res); } @@ -196,8 +196,8 @@ public class GLConfiguration extends ProcAddressConfiguration { // Must also filter out bogus rangeCheck directives for VBO/PBO // variants if (emitter.isBufferObjectMethodBinding(binding)) { - for (Iterator<String> iter = res.iterator(); iter.hasNext();) { - String line = iter.next(); + for (final Iterator<String> iter = res.iterator(); iter.hasNext();) { + final String line = iter.next(); if (line.indexOf("Buffers.rangeCheck") >= 0) { iter.remove(); } @@ -211,22 +211,22 @@ public class GLConfiguration extends ProcAddressConfiguration { @Override public void dumpIgnores() { System.err.println("GL Ignored extensions: "); - for (String str : ignoredExtensions) { + for (final String str : ignoredExtensions) { System.err.println("\t" + str); } System.err.println("GL Forced extensions: "); - for (String str : forcedExtensions) { + for (final String str : forcedExtensions) { System.err.println("\t" + str); } super.dumpIgnores(); } - protected boolean shouldIgnoreExtension(String symbol, boolean criteria) { + protected boolean shouldIgnoreExtension(final String symbol, final boolean criteria) { if (criteria && glInfo != null) { final Set<String> extensionNames = glInfo.getExtension(symbol); if( null != extensionNames ) { boolean ignoredExtension = false; - for(Iterator<String> i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { + for(final Iterator<String> i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { final String extensionName = i.next(); if ( extensionName != null && ignoredExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { @@ -245,7 +245,7 @@ public class GLConfiguration extends ProcAddressConfiguration { if( ignoredExtension ) { final Set<String> origSymbols = getRenamedJavaSymbols( symbol ); if(null != origSymbols) { - for(String origSymbol : origSymbols) { + for(final String origSymbol : origSymbols) { if( shouldForceExtension( origSymbol, true, symbol ) ) { ignoredExtension = false; break; @@ -258,11 +258,11 @@ public class GLConfiguration extends ProcAddressConfiguration { return true; } } - boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); - boolean isGLFunc = GLNameResolver.isGLFunction(symbol); + final boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); + final boolean isGLFunc = GLNameResolver.isGLFunction(symbol); if (isGLFunc || isGLEnum) { if (GLNameResolver.isExtensionVEN(symbol, isGLFunc)) { - String extSuffix = GLNameResolver.getExtensionSuffix(symbol, isGLFunc); + final String extSuffix = GLNameResolver.getExtensionSuffix(symbol, isGLFunc); if (getDropUniqVendorExtensions(extSuffix)) { if (DEBUG_IGNORES) { System.err.println("Ignore UniqVendorEXT: " + symbol + ", vendor " + extSuffix); @@ -279,7 +279,7 @@ public class GLConfiguration extends ProcAddressConfiguration { if (criteria && glInfo != null) { final Set<String> extensionNames = glInfo.getExtension(symbol); if( null != extensionNames ) { - for(Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { + for(final Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { final String extensionName = i.next(); if ( extensionName != null && forcedExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { @@ -299,20 +299,20 @@ public class GLConfiguration extends ProcAddressConfiguration { } @Override - public boolean shouldIgnoreInInterface(String symbol) { + public boolean shouldIgnoreInInterface(final String symbol) { return shouldIgnoreInInterface(symbol, true); } - public boolean shouldIgnoreInInterface(String symbol, boolean checkEXT) { + public boolean shouldIgnoreInInterface(final String symbol, final boolean checkEXT) { return shouldIgnoreExtension(symbol, checkEXT) || super.shouldIgnoreInInterface(symbol); } @Override - public boolean shouldIgnoreInImpl(String symbol) { + public boolean shouldIgnoreInImpl(final String symbol) { return shouldIgnoreInImpl(symbol, true); } - public boolean shouldIgnoreInImpl(String symbol, boolean checkEXT) { + public boolean shouldIgnoreInImpl(final String symbol, final boolean checkEXT) { return shouldIgnoreExtension(symbol, checkEXT) || super.shouldIgnoreInImpl(symbol); } @@ -330,32 +330,32 @@ public class GLConfiguration extends ProcAddressConfiguration { } /** shall the non unified (uniq) vendor extensions be dropped ? */ - public boolean getDropUniqVendorExtensions(String extName) { + public boolean getDropUniqVendorExtensions(final String extName) { return dropUniqVendorExtensions.contains(extName); } /** Returns the kind of buffer object this function deals with, or null if none. */ - GLEmitter.BufferObjectKind getBufferObjectKind(String name) { + GLEmitter.BufferObjectKind getBufferObjectKind(final String name) { return bufferObjectKinds.get(name); } - public boolean isBufferObjectFunction(String name) { + public boolean isBufferObjectFunction(final String name) { return (getBufferObjectKind(name) != null); } - public boolean isBufferObjectOnly(String name) { + public boolean isBufferObjectOnly(final String name) { return bufferObjectOnly.contains(name); } /** Parses any GL headers specified in the configuration file for the purpose of being able to ignore an extension at a time. */ - public void parseGLHeaders(GlueEmitterControls controls) throws IOException { + public void parseGLHeaders(final GlueEmitterControls controls) throws IOException { if (!glHeaders.isEmpty()) { glInfo = new BuildStaticGLInfo(); glInfo.setDebug(GlueGen.debug()); - for (String file : glHeaders) { - String fullPath = controls.findHeaderFile(file); + for (final String file : glHeaders) { + final String fullPath = controls.findHeaderFile(file); if (fullPath == null) { throw new IOException("Unable to locate header file \"" + file + "\""); } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index 547382ed1..bc230c83a 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -72,12 +72,12 @@ public class GLEmitter extends ProcAddressEmitter { // Keeps track of which MethodBindings were created for handling // Buffer Object variants. Used as a Set rather than a Map. - private Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>(); + private final Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>(); enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT, INDIRECT} @Override - public void beginEmission(GlueEmitterControls controls) throws IOException { + public void beginEmission(final GlueEmitterControls controls) throws IOException { getGLConfig().parseGLHeaders(controls); renameExtensionsIntoCore(); if (getGLConfig().getAutoUnifyExtensions()) { @@ -93,30 +93,30 @@ public class GLEmitter extends ProcAddressEmitter { // already in the core namespace in desktop OpenGL. It builds upon // renaming mechanisms that are built elsewhere. - GLConfiguration config = getGLConfig(); - Set<String> extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); - BuildStaticGLInfo glInfo = config.getGLInfo(); + final GLConfiguration config = getGLConfig(); + final Set<String> extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); + final BuildStaticGLInfo glInfo = config.getGLInfo(); if (null == glInfo) { if (extensionsRenamedIntoCore.size() > 0) { throw new RuntimeException("ExtensionRenamedIntoCore (num: " + extensionsRenamedIntoCore.size() + "), but no GLHeader"); } return; } - for (String extension : extensionsRenamedIntoCore) { + for (final String extension : extensionsRenamedIntoCore) { if(JavaConfiguration.DEBUG_RENAMES) { System.err.println("<RenameExtensionIntoCore: "+extension+" BEGIN"); } - Set<String> declarations = glInfo.getDeclarations(extension); + final Set<String> declarations = glInfo.getDeclarations(extension); if (declarations != null) { - for (Iterator<String> iterator = declarations.iterator(); iterator.hasNext();) { - String decl = iterator.next(); - boolean isGLFunction = GLNameResolver.isGLFunction(decl); + for (final Iterator<String> iterator = declarations.iterator(); iterator.hasNext();) { + final String decl = iterator.next(); + final boolean isGLFunction = GLNameResolver.isGLFunction(decl); boolean isGLEnumeration = false; if (!isGLFunction) { isGLEnumeration = GLNameResolver.isGLEnumeration(decl); } if (isGLFunction || isGLEnumeration) { - String renamed = GLNameResolver.normalize(decl, isGLFunction); + final String renamed = GLNameResolver.normalize(decl, isGLFunction); if (!renamed.equals(decl)) { config.addJavaSymbolRename(decl, renamed); } @@ -135,8 +135,8 @@ public class GLEmitter extends ProcAddressEmitter { private List<FunctionSymbol> functions; @Override - public void filterSymbols(List<ConstantDefinition> constants, - List<FunctionSymbol> functions) { + public void filterSymbols(final List<ConstantDefinition> constants, + final List<FunctionSymbol> functions) { this.constants = constants; this.functions = functions; doWork(); @@ -153,17 +153,17 @@ public class GLEmitter extends ProcAddressEmitter { } private void doWork() { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (glInfo == null) { return; } // Try to retain a "good" ordering for these symbols - Map<String, ConstantDefinition> constantMap = new LinkedHashMap<String, ConstantDefinition>(); - for (ConstantDefinition def : constants) { + final Map<String, ConstantDefinition> constantMap = new LinkedHashMap<String, ConstantDefinition>(); + for (final ConstantDefinition def : constants) { constantMap.put(def.getName(), def); } - Map<String, FunctionSymbol> functionMap = new LinkedHashMap<String, FunctionSymbol>(); - for (FunctionSymbol sym : functions) { + final Map<String, FunctionSymbol> functionMap = new LinkedHashMap<String, FunctionSymbol>(); + for (final FunctionSymbol sym : functions) { functionMap.put(sym.getName(), sym); } @@ -175,15 +175,15 @@ public class GLEmitter extends ProcAddressEmitter { // that doesn't support the core version of these APIs, the runtime // will take care of looking up the extension version of these entry // points. - Set<String> extensionNames = glInfo.getExtensions(); + final Set<String> extensionNames = glInfo.getExtensions(); - for (String extension : extensionNames) { - Set<String> declarations = glInfo.getDeclarations(extension); + for (final String extension : extensionNames) { + final Set<String> declarations = glInfo.getDeclarations(extension); boolean isExtension = true; boolean shouldUnify = true; String cause = null; - for (String decl : declarations) { - boolean isFunc = !decl.startsWith("GL_"); + for (final String decl : declarations) { + final boolean isFunc = !decl.startsWith("GL_"); if (!GLNameResolver.isExtension(decl, isFunc)) { isExtension = false; break; @@ -202,7 +202,7 @@ public class GLEmitter extends ProcAddressEmitter { } } cause = decl; - String unifiedName = GLNameResolver.normalize(decl, isFunc); + final String unifiedName = GLNameResolver.normalize(decl, isFunc); // NOTE that we look up the unified name in the // BuildStaticGLInfo's notion of the APIs -- since // we might not be emitting glue code for the @@ -225,8 +225,8 @@ public class GLEmitter extends ProcAddressEmitter { } if (isExtension) { if (shouldUnify) { - for (String decl : declarations) { - boolean isFunc = !decl.startsWith("GL_"); + for (final String decl : declarations) { + final boolean isFunc = !decl.startsWith("GL_"); if (isFunc) { functionMap.remove(decl); } else { @@ -244,7 +244,7 @@ public class GLEmitter extends ProcAddressEmitter { } } - private void unifyExtensions(GlueEmitterControls controls) { + private void unifyExtensions(final GlueEmitterControls controls) { controls.runSymbolFilter(new ExtensionUnifier()); } @@ -264,7 +264,7 @@ public class GLEmitter extends ProcAddressEmitter { inform the CMethodBindingEmitter that it is overloaded in this case (though we default to true currently). */ @Override - protected List<MethodBinding> expandMethodBinding(MethodBinding binding) { + protected List<MethodBinding> expandMethodBinding(final MethodBinding binding) { final GLConfiguration glConfig = getGLConfig(); final List<MethodBinding> bindings = super.expandMethodBinding(binding); @@ -322,7 +322,7 @@ public class GLEmitter extends ProcAddressEmitter { } @Override - protected boolean needsModifiedEmitters(FunctionSymbol sym) { + protected boolean needsModifiedEmitters(final FunctionSymbol sym) { if ((!needsProcAddressWrapper(sym) && !needsBufferObjectVariant(sym)) || getConfig().isUnimplemented(sym.getName())) { return false; @@ -331,22 +331,22 @@ public class GLEmitter extends ProcAddressEmitter { return true; } - public boolean isBufferObjectMethodBinding(MethodBinding binding) { + public boolean isBufferObjectMethodBinding(final MethodBinding binding) { return bufferObjectMethodBindings.containsKey(binding); } @Override - public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + public void emitDefine(final ConstantDefinition def, final String optionalComment) throws Exception { + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (null == glInfo) { throw new Exception("No GLInfo for: " + def); } - String symbolRenamed = def.getName(); - StringBuilder newComment = new StringBuilder(); + final String symbolRenamed = def.getName(); + final StringBuilder newComment = new StringBuilder(); newComment.append("Part of "); if (0 == addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, def.getAliasedNames())) { if (def.isEnum()) { - String enumName = def.getEnumName(); + final String enumName = def.getEnumName(); if (null != enumName) { newComment.append(enumName); } else { @@ -362,7 +362,7 @@ public class GLEmitter extends ProcAddressEmitter { // ... // #endif if (JavaConfiguration.DEBUG_IGNORES) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames()); System.err.println("Dropping marker: " + sb.toString()); } @@ -379,12 +379,12 @@ public class GLEmitter extends ProcAddressEmitter { super.emitDefine(def, newComment.toString()); } - private int addExtensionListOfSymbol2Buffer(BuildStaticGLInfo glInfo, StringBuilder buf, String sep1, String name) { + private int addExtensionListOfSymbol2Buffer(final BuildStaticGLInfo glInfo, final StringBuilder buf, final String sep1, final String name) { int num = 0; - Set<String> extensionNames = glInfo.getExtension(name); + final Set<String> extensionNames = glInfo.getExtension(name); if(null!=extensionNames) { - for(Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { - String extensionName = i.next(); + for(final Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { + final String extensionName = i.next(); if (null != extensionName) { buf.append("<code>"); buf.append(extensionName); @@ -398,19 +398,19 @@ public class GLEmitter extends ProcAddressEmitter { } return num; } - private int addExtensionListOfAliasedSymbols2Buffer(BuildStaticGLInfo glInfo, StringBuilder buf, String sep1, String sep2, String name, Collection<String> exclude) { + private int addExtensionListOfAliasedSymbols2Buffer(final BuildStaticGLInfo glInfo, final StringBuilder buf, final String sep1, final String sep2, final String name, final Collection<String> exclude) { int num = 0; if(null != name) { num += addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, name); // extensions of given name boolean needsSep2 = 0<num; - Set<String> origNames = cfg.getRenamedJavaSymbols(name); + final Set<String> origNames = cfg.getRenamedJavaSymbols(name); if(null != origNames) { - for(String origName : origNames) { + for(final String origName : origNames) { if(!exclude.contains(origName)) { if (needsSep2) { buf.append(sep2); // diff-name seperator } - int num2 = addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, origName); // extensions of orig-name + final int num2 = addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, origName); // extensions of orig-name needsSep2 = num<num2; num += num2; } @@ -420,8 +420,8 @@ public class GLEmitter extends ProcAddressEmitter { return num; } - public int addExtensionsOfSymbols2Buffer(StringBuilder buf, String sep1, String sep2, String first, Collection<String> col) { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + public int addExtensionsOfSymbols2Buffer(StringBuilder buf, final String sep1, final String sep2, final String first, final Collection<String> col) { + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (null == glInfo) { throw new RuntimeException("No GLInfo for: " + first); } @@ -432,11 +432,11 @@ public class GLEmitter extends ProcAddressEmitter { num += addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, first, col); boolean needsSep2 = 0<num; - for(Iterator<String> iter = col.iterator(); iter.hasNext(); ) { + for(final Iterator<String> iter = col.iterator(); iter.hasNext(); ) { if(needsSep2) { buf.append(sep2); // diff-name seperator } - int num2 = addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, iter.next(), col); + final int num2 = addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, iter.next(), col); needsSep2 = num<num2; num += num2; } @@ -447,12 +447,12 @@ public class GLEmitter extends ProcAddressEmitter { // Internals only below this point // @Override - protected void generateModifiedEmitters(JavaMethodBindingEmitter baseJavaEmitter, List<FunctionEmitter> emitters) { - List<FunctionEmitter> superEmitters = new ArrayList<FunctionEmitter>(); + protected void generateModifiedEmitters(final JavaMethodBindingEmitter baseJavaEmitter, final List<FunctionEmitter> emitters) { + final List<FunctionEmitter> superEmitters = new ArrayList<FunctionEmitter>(); super.generateModifiedEmitters(baseJavaEmitter, superEmitters); // See whether this is one of the Buffer Object variants - boolean bufferObjectVariant = bufferObjectMethodBindings.containsKey(baseJavaEmitter.getBinding()); + final boolean bufferObjectVariant = bufferObjectMethodBindings.containsKey(baseJavaEmitter.getBinding()); for (FunctionEmitter emitter : superEmitters) { if (emitter instanceof ProcAddressJavaMethodBindingEmitter) { @@ -462,7 +462,7 @@ public class GLEmitter extends ProcAddressEmitter { } } - protected boolean needsBufferObjectVariant(FunctionSymbol sym) { + protected boolean needsBufferObjectVariant(final FunctionSymbol sym) { return getGLConfig().isBufferObjectFunction(sym.getName()); } @@ -475,7 +475,7 @@ public class GLEmitter extends ProcAddressEmitter { */ @Override protected void endProcAddressTable() throws Exception { - PrintWriter w = tableWriter; + final PrintWriter w = tableWriter; w.println(" @Override"); w.println(" protected boolean isFunctionAvailableImpl(String functionNameUsr) throws IllegalArgumentException {"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java index 389d35f99..d491a3712 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -58,8 +58,8 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit protected GLEmitter glEmitter; protected CommentEmitter glCommentEmitter = new GLCommentEmitter(); - public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, boolean callThroughProcAddress, - String getProcAddressTableExpr, boolean changeNameAndArguments, boolean bufferObjectVariant, GLEmitter emitter) { + public GLJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final boolean callThroughProcAddress, + final String getProcAddressTableExpr, final boolean changeNameAndArguments, final boolean bufferObjectVariant, final GLEmitter emitter) { super(methodToWrap, callThroughProcAddress, getProcAddressTableExpr, changeNameAndArguments, emitter); this.bufferObjectVariant = bufferObjectVariant; @@ -67,20 +67,20 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit setCommentEmitter(glCommentEmitter); } - public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, GLEmitter emitter, boolean bufferObjectVariant) { + public GLJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant) { super(methodToWrap); this.bufferObjectVariant = bufferObjectVariant; this.glEmitter = emitter; setCommentEmitter(glCommentEmitter); } - public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { + public GLJavaMethodBindingEmitter(final GLJavaMethodBindingEmitter methodToWrap) { this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant); } @Override - protected String getArgumentName(int i) { - String name = super.getArgumentName(i); + protected String getArgumentName(final int i) { + final String name = super.getArgumentName(i); if (!bufferObjectVariant) { return name; @@ -89,8 +89,8 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit // Emitters for VBO/PBO-related routines change the outgoing // argument name for the buffer if (binding.getJavaArgumentType(i).isLong()) { - Type cType = binding.getCArgumentType(i); - Type targetType = cType.asPointer().getTargetType(); + final Type cType = binding.getCArgumentType(i); + final Type targetType = cType.asPointer().getTargetType(); if (cType.isPointer() && (targetType.isVoid() || targetType.isPrimitive())) { return name + "_buffer_offset"; } @@ -102,10 +102,10 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter { @Override - protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { + protected void emitBindingCSignature(final MethodBinding binding, final PrintWriter writer) { - String symbolRenamed = binding.getName(); - StringBuilder newComment = new StringBuilder(); + final String symbolRenamed = binding.getName(); + final StringBuilder newComment = new StringBuilder(); final FunctionSymbol funcSym = binding.getCSymbol(); writer.print("<code> "); @@ -117,9 +117,9 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { newComment.append("CORE FUNC"); } else { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames()); - RuntimeException ex = new RuntimeException("Couldn't find extension to: " + binding + " ; " + sb.toString()); + final RuntimeException ex = new RuntimeException("Couldn't find extension to: " + binding + " ; " + sb.toString()); glEmitter.getGLConfig().getGLInfo().dump(); // glEmitter.getGLConfig().dumpRenames(); throw ex; diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java index 21946ea89..66819a83e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java @@ -78,7 +78,7 @@ public class StaticGLGenTask extends Task * <p>The {@link org.apache.tools.ant.types.CommandlineJava} that is used * to execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo}.</p> */ - private CommandlineJava glgenCommandline; + private final CommandlineJava glgenCommandline; // ========================================================================= /** @@ -94,7 +94,7 @@ public class StaticGLGenTask extends Task /** * <p>The {@link org.apache.tools.ant.types.FileSet} of GL headers.</p> */ - private FileSet headerSet = new FileSet(); + private final FileSet headerSet = new FileSet(); // ========================================================================= /** @@ -117,7 +117,7 @@ public class StaticGLGenTask extends Task * * @param packageName the name of the package for the generated files */ - public void setPackage(String packageName) + public void setPackage(final String packageName) { log( ("Setting package name to: " + packageName), Project.MSG_VERBOSE); this.packageName = packageName; @@ -128,7 +128,7 @@ public class StaticGLGenTask extends Task * * @param directory the output directory */ - public void setOutputDir(String directory) + public void setOutputDir(final String directory) { log( ("Setting output directory to: " + directory), Project.MSG_VERBOSE); @@ -163,7 +163,7 @@ public class StaticGLGenTask extends Task * * @param headers the string containing the header patterns */ - public void setHeaders(String headers) + public void setHeaders(final String headers) { headerSet.setIncludes(headers); } @@ -236,7 +236,7 @@ public class StaticGLGenTask extends Task * @return <code>true</code> if the string is valid. <code>false</code> * otherwise. */ - private boolean isValid(String string) + private boolean isValid(final String string) { // check for null if(string == null) @@ -265,8 +265,8 @@ public class StaticGLGenTask extends Task // add the header -files- from the FileSet headerSet.setDir(getProject().getBaseDir()); - DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); - String[] directoryFiles = directoryScanner.getIncludedFiles(); + final DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); + final String[] directoryFiles = directoryScanner.getIncludedFiles(); for(int i=0; i<directoryFiles.length; i++) { glgenCommandline.createArgument().setValue(directoryFiles[i]); @@ -279,11 +279,11 @@ public class StaticGLGenTask extends Task * * @throws BuildException */ - private int execute(String[] command) + private int execute(final String[] command) throws BuildException { // create the object that will perform the command execution - Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, + final Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), null); @@ -296,7 +296,7 @@ public class StaticGLGenTask extends Task try { return execute.execute(); - } catch(IOException ioe) + } catch(final IOException ioe) { throw new BuildException(ioe, location); } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java index 4ac9ae3f3..de9e3ed25 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java @@ -61,14 +61,14 @@ import java.util.Set; public class NativeSignatureEmitter extends GLEmitter { @Override - protected List<? extends FunctionEmitter> generateMethodBindingEmitters(Set<MethodBinding> methodBindingSet, FunctionSymbol sym) throws Exception { + protected List<? extends FunctionEmitter> generateMethodBindingEmitters(final Set<MethodBinding> methodBindingSet, final FunctionSymbol sym) throws Exception { // Allow superclass to do most of the work for us - List<? extends FunctionEmitter> res = super.generateMethodBindingEmitters(methodBindingSet, sym); + final List<? extends FunctionEmitter> res = super.generateMethodBindingEmitters(methodBindingSet, sym); // Filter out all non-JavaMethodBindingEmitters - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - FunctionEmitter emitter = iter.next(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final FunctionEmitter emitter = iter.next(); if (!(emitter instanceof JavaMethodBindingEmitter)) { iter.remove(); } @@ -78,13 +78,13 @@ public class NativeSignatureEmitter extends GLEmitter { return res; } - PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); + final PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); - List<FunctionEmitter> processed = new ArrayList<FunctionEmitter>(); + final List<FunctionEmitter> processed = new ArrayList<FunctionEmitter>(); // First, filter out all emitters going to the "other" (public) writer - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - FunctionEmitter emitter = iter.next(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final FunctionEmitter emitter = iter.next(); if (emitter.getDefaultOutput() != writer) { processed.add(emitter); iter.remove(); @@ -93,12 +93,12 @@ public class NativeSignatureEmitter extends GLEmitter { // Now process all of the remaining emitters sorted by MethodBinding while (!res.isEmpty()) { - List<JavaMethodBindingEmitter> emittersForBinding = new ArrayList<JavaMethodBindingEmitter>(); - JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) res.remove(0); + final List<JavaMethodBindingEmitter> emittersForBinding = new ArrayList<JavaMethodBindingEmitter>(); + final JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) res.remove(0); emittersForBinding.add(emitter); - MethodBinding binding = emitter.getBinding(); - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - JavaMethodBindingEmitter emitter2 = (JavaMethodBindingEmitter) iter.next(); + final MethodBinding binding = emitter.getBinding(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final JavaMethodBindingEmitter emitter2 = (JavaMethodBindingEmitter) iter.next(); if (emitter2.getBinding() == binding) { emittersForBinding.add(emitter2); iter.remove(); @@ -111,17 +111,17 @@ public class NativeSignatureEmitter extends GLEmitter { return processed; } - protected void generateNativeSignatureEmitters(MethodBinding binding, List<JavaMethodBindingEmitter> allEmitters) { + protected void generateNativeSignatureEmitters(final MethodBinding binding, final List<JavaMethodBindingEmitter> allEmitters) { if (allEmitters.isEmpty()) { return; } - PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); + final PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); // Give ourselves the chance to interpose on the generation of all code to keep things simple - List<JavaMethodBindingEmitter> newEmitters = new ArrayList<JavaMethodBindingEmitter>(); - for (JavaMethodBindingEmitter javaEmitter : allEmitters) { + final List<JavaMethodBindingEmitter> newEmitters = new ArrayList<JavaMethodBindingEmitter>(); + for (final JavaMethodBindingEmitter javaEmitter : allEmitters) { NativeSignatureJavaMethodBindingEmitter newEmitter = null; if (javaEmitter instanceof GLJavaMethodBindingEmitter) { newEmitter = new NativeSignatureJavaMethodBindingEmitter((GLJavaMethodBindingEmitter) javaEmitter); @@ -138,11 +138,11 @@ public class NativeSignatureEmitter extends GLEmitter { // been called with signatureOnly both true and false. if (signatureContainsStrings(binding) && !haveEmitterWithBody(allEmitters)) { // This basically handles glGetString but also any similar methods - NativeSignatureJavaMethodBindingEmitter javaEmitter = findEmitterWithWriter(allEmitters, writer); + final NativeSignatureJavaMethodBindingEmitter javaEmitter = findEmitterWithWriter(allEmitters, writer); // First, we need to clone this emitter to produce the native // entry point - NativeSignatureJavaMethodBindingEmitter emitter = new NativeSignatureJavaMethodBindingEmitter(javaEmitter); + final NativeSignatureJavaMethodBindingEmitter emitter = new NativeSignatureJavaMethodBindingEmitter(javaEmitter); emitter.removeModifier(JavaMethodBindingEmitter.PUBLIC); emitter.addModifier(JavaMethodBindingEmitter.PRIVATE); emitter.setForImplementingMethodCall(true); @@ -158,22 +158,22 @@ public class NativeSignatureEmitter extends GLEmitter { } } - protected boolean signatureContainsStrings(MethodBinding binding) { + protected boolean signatureContainsStrings(final MethodBinding binding) { for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isString() || type.isStringArray()) { return true; } } - JavaType retType = binding.getJavaReturnType(); + final JavaType retType = binding.getJavaReturnType(); if (retType.isString() || retType.isStringArray()) { return true; } return false; } - protected boolean haveEmitterWithBody(List<JavaMethodBindingEmitter> allEmitters) { - for (JavaMethodBindingEmitter emitter : allEmitters) { + protected boolean haveEmitterWithBody(final List<JavaMethodBindingEmitter> allEmitters) { + for (final JavaMethodBindingEmitter emitter : allEmitters) { if (!emitter.signatureOnly()) { return true; } @@ -181,9 +181,9 @@ public class NativeSignatureEmitter extends GLEmitter { return false; } - protected NativeSignatureJavaMethodBindingEmitter findEmitterWithWriter(List<JavaMethodBindingEmitter> allEmitters, PrintWriter writer) { - for (JavaMethodBindingEmitter jemitter : allEmitters) { - NativeSignatureJavaMethodBindingEmitter emitter = (NativeSignatureJavaMethodBindingEmitter)jemitter; + protected NativeSignatureJavaMethodBindingEmitter findEmitterWithWriter(final List<JavaMethodBindingEmitter> allEmitters, final PrintWriter writer) { + for (final JavaMethodBindingEmitter jemitter : allEmitters) { + final NativeSignatureJavaMethodBindingEmitter emitter = (NativeSignatureJavaMethodBindingEmitter)jemitter; if (emitter.getDefaultOutput() == writer) { return emitter; } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java index 6d9d6f2bb..86080d84f 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java @@ -53,31 +53,31 @@ import java.io.PrintWriter; /** Review: This Package/Class is not used and subject to be deleted. */ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBindingEmitter { - public NativeSignatureJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { + public NativeSignatureJavaMethodBindingEmitter(final GLJavaMethodBindingEmitter methodToWrap) { super(methodToWrap); } - public NativeSignatureJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, GLEmitter emitter, boolean bufferObjectVariant) { + public NativeSignatureJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant) { super(methodToWrap, emitter, bufferObjectVariant); } - public NativeSignatureJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, NativeSignatureEmitter emitter) { + public NativeSignatureJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final NativeSignatureEmitter emitter) { super(methodToWrap, false, null, false, false, emitter); } @Override - protected void emitSignature(PrintWriter writer) { + protected void emitSignature(final PrintWriter writer) { writer.print(getBaseIndentString()); emitNativeSignatureAnnotation(writer); super.emitSignature(writer); } - protected void emitNativeSignatureAnnotation(PrintWriter writer) { + protected void emitNativeSignatureAnnotation(final PrintWriter writer) { if (hasModifier(JavaMethodBindingEmitter.NATIVE)) { // Emit everything as a leaf for now // FIXME: make this configurable writer.print("@NativeSignature(\"l"); - MethodBinding binding = getBinding(); + final MethodBinding binding = getBinding(); if (callThroughProcAddress) { writer.print("p"); } @@ -94,7 +94,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected void emitNativeSignatureElement(PrintWriter writer, JavaType type, Type cType, int index) { + protected void emitNativeSignatureElement(final PrintWriter writer, final JavaType type, final Type cType, final int index) { if (type.isVoid()) { if (index > 0) { throw new InternalError("Error parsing arguments -- void should not be seen aside from argument 0"); @@ -107,7 +107,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } else if (type.isPrimitiveArray()) { writer.print("MO"); } else if (type.isPrimitive()) { - Class<?> clazz = type.getJavaClass(); + final Class<?> clazz = type.getJavaClass(); if (clazz == Byte.TYPE) { writer.print("B"); } else if (clazz == Character.TYPE) { writer.print("C"); } else if (clazz == Double.TYPE) { writer.print("D"); } @@ -132,9 +132,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected String getReturnTypeString(boolean skipArray) { + protected String getReturnTypeString(final boolean skipArray) { if (isForImplementingMethodCall()) { - JavaType returnType = getBinding().getJavaReturnType(); + final JavaType returnType = getBinding().getJavaReturnType(); if (returnType.isString() || returnType.isNIOByteBuffer()) { // Treat these as addresses return "long"; @@ -144,10 +144,10 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitPreCallSetup(MethodBinding binding, PrintWriter writer) { + protected void emitPreCallSetup(final MethodBinding binding, final PrintWriter writer) { super.emitPreCallSetup(binding, writer); for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isNIOBuffer() && !useNIODirectOnly ) { // Emit declarations for variables holding primitive arrays as type Object // We don't know 100% sure we're going to use these at this point in the code, though @@ -160,12 +160,12 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected String getNIOBufferArrayName(int argNumber) { + protected String getNIOBufferArrayName(final int argNumber) { return "__buffer_array_" + argNumber; } @Override - protected int emitArguments(PrintWriter writer) + protected int emitArguments(final PrintWriter writer) { boolean needComma = false; int numEmitted = 0; @@ -191,7 +191,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isVoid()) { // Make sure this is the only param to the method; if it isn't, // there's something wrong with our parsing of the headers. @@ -246,9 +246,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer) { + protected void emitReturnVariableSetupAndCall(final MethodBinding binding, final PrintWriter writer) { writer.print(" "); - JavaType returnType = binding.getJavaReturnType(); + final JavaType returnType = binding.getJavaReturnType(); boolean needsResultAssignment = false; if (!returnType.isVoid()) { @@ -344,7 +344,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected int emitCallArguments(MethodBinding binding, PrintWriter writer, boolean direct) { + protected int emitCallArguments(final MethodBinding binding, final PrintWriter writer, final boolean direct) { // Note that we override this completely because we both need to // move the potential location of the outgoing proc address as // well as change the way we pass out Buffers, arrays, Strings, etc. @@ -368,7 +368,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding ++numArgsEmitted; } for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isJNIEnv() || binding.isArgumentThisPointer(i)) { // Don't need to expose these at the Java level continue; @@ -460,9 +460,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitCallResultReturn(MethodBinding binding, PrintWriter writer) { + protected void emitCallResultReturn(final MethodBinding binding, final PrintWriter writer) { for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isString()) { writer.println(";"); writer.println(" BuffersInternal.freeCString(" + binding.getArgumentName(i) + "_c_str);"); @@ -475,14 +475,14 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding @Override public String getName() { - String res = super.getName(); + final String res = super.getName(); if (forImplementingMethodCall && bufferObjectVariant) { return res + "BufObj"; } return res; } - protected String getImplMethodName(boolean direct) { + protected String getImplMethodName(final boolean direct) { String name = null; if (direct) { name = binding.getName() + "$0"; diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java index 9b57a2f2d..34ab3df9e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java @@ -72,19 +72,19 @@ public class GLNameResolver { }; - public static final boolean isGLFunction(String str) { + public static final boolean isGLFunction(final String str) { return str.startsWith("gl") || /* str.startsWith("glu") || str.startsWith("glX") || */ str.startsWith("egl") || str.startsWith("wgl") || str.startsWith("agl") || str.startsWith("cgl") ; } - public static final boolean isGLEnumeration(String str) { + public static final boolean isGLEnumeration(final String str) { return str.startsWith("GL_") || str.startsWith("GLU_") || str.startsWith("GLX_") || str.startsWith("EGL_") || str.startsWith("WGL_") || str.startsWith("AGL_") || str.startsWith("CGL_") ; } - public static final int getExtensionIdx(String[] extensions, String str, boolean isGLFunc) { + public static final int getExtensionIdx(final String[] extensions, final String str, final boolean isGLFunc) { if(isGLFunc) { for(int i = extensions.length - 1 ; i>=0 ; i--) { if( str.endsWith(extensions[i]) ) { @@ -101,11 +101,11 @@ public class GLNameResolver { return -1; } - public static final boolean isExtension(String[] extensions, String str, boolean isGLFunc) { + public static final boolean isExtension(final String[] extensions, final String str, final boolean isGLFunc) { return getExtensionIdx(extensions, str, isGLFunc)>=0; } - public static final String getExtensionSuffix(String str, boolean isGLFunc) { + public static final String getExtensionSuffix(final String str, final boolean isGLFunc) { int idx = getExtensionIdx(extensionsARB, str, isGLFunc); if(idx>=0) { return extensionsARB[idx]; @@ -117,7 +117,7 @@ public class GLNameResolver { return null; } - public static final String normalize(String[] extensions, String str, boolean isGLFunc) { + public static final String normalize(final String[] extensions, String str, final boolean isGLFunc) { boolean touched = false; for(int i = extensions.length - 1 ; !touched && i>=0 ; i--) { if(isGLFunc) { @@ -136,19 +136,19 @@ public class GLNameResolver { } return str; } - public static final String normalizeARB(String str, boolean isGLFunc) { + public static final String normalizeARB(final String str, final boolean isGLFunc) { return normalize(extensionsARB, str, isGLFunc); } - public static final boolean isExtensionARB(String str, boolean isGLFunc) { + public static final boolean isExtensionARB(final String str, final boolean isGLFunc) { return isExtension(extensionsARB, str, isGLFunc); } - public static final String normalizeVEN(String str, boolean isGLFunc) { + public static final String normalizeVEN(final String str, final boolean isGLFunc) { return normalize(extensionsVEN, str, isGLFunc); } - public static final boolean isExtensionVEN(String str, boolean isGLFunc) { + public static final boolean isExtensionVEN(final String str, final boolean isGLFunc) { return isExtension(extensionsVEN, str, isGLFunc); } - public static final String normalize(String str, boolean isGLFunc) { + public static final String normalize(final String str, final boolean isGLFunc) { if (isExtensionARB(str, isGLFunc)) { return normalizeARB(str, isGLFunc); } @@ -157,12 +157,12 @@ public class GLNameResolver { } return str; } - public static final boolean isExtension(String str, boolean isGLFunc) { + public static final boolean isExtension(final String str, final boolean isGLFunc) { return isExtension(extensionsARB, str, isGLFunc) || isExtension(extensionsVEN, str, isGLFunc); } - public static final int getFuncNamePermutationNumber(String name) { + public static final int getFuncNamePermutationNumber(final String name) { if(isExtensionARB(name, true) || isExtensionVEN(name, true)) { // no name permutation, if it's already a known extension return 1; @@ -170,7 +170,7 @@ public class GLNameResolver { return 1 + extensionsARB.length + extensionsVEN.length; } - public static final String getFuncNamePermutation(String name, int i) { + public static final String getFuncNamePermutation(final String name, int i) { // identity if(i==0) { return name; diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java index 3fb315c99..23d4fc3cf 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java @@ -43,16 +43,16 @@ public class GLProcAddressResolver implements FunctionAddressResolver { public static final boolean DEBUG = false; @Override - public long resolve(String name, DynamicLookupHelper lookup) { + public long resolve(final String name, final DynamicLookupHelper lookup) { long newProcAddress = 0; - int permutations = GLNameResolver.getFuncNamePermutationNumber(name); + final int permutations = GLNameResolver.getFuncNamePermutationNumber(name); for (int i = 0; 0 == newProcAddress && i < permutations; i++) { - String funcName = GLNameResolver.getFuncNamePermutation(name, i); + final String funcName = GLNameResolver.getFuncNamePermutation(name, i); try { newProcAddress = lookup.dynamicLookupFunction(funcName); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); } diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index d4977669e..939035c69 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -106,7 +106,7 @@ public class OutlineShape implements Comparable<OutlineShape> { public final int state; - VerticesState(int state){ + VerticesState(final int state){ this.state = state; } } @@ -149,7 +149,7 @@ public class OutlineShape implements Comparable<OutlineShape> { /** Create a new Outline based Shape */ - public OutlineShape(Vertex.Factory<? extends Vertex> factory) { + public OutlineShape(final Vertex.Factory<? extends Vertex> factory) { this.vertexFactory = factory; this.outlines = new ArrayList<Outline>(3); this.outlines.add(new Outline()); @@ -235,7 +235,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param outline Outline object to be added * @throws NullPointerException if the {@link Outline} element is null */ - public final void addOutline(Outline outline) throws NullPointerException { + public final void addOutline(final Outline outline) throws NullPointerException { addOutline(outlines.size(), outline); } @@ -251,7 +251,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber()) */ - public final void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException { + public final void addOutline(final int position, final Outline outline) throws NullPointerException, IndexOutOfBoundsException { if (null == outline) { throw new NullPointerException("outline is null"); } @@ -285,7 +285,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @throws NullPointerException if the {@link OutlineShape} is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber()) */ - public final void addOutlineShape(OutlineShape outlineShape) throws NullPointerException { + public final void addOutlineShape(final OutlineShape outlineShape) throws NullPointerException { if (null == outlineShape) { throw new NullPointerException("OutlineShape is null"); } @@ -304,7 +304,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ - public final void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException { + public final void setOutline(final int position, final Outline outline) throws NullPointerException, IndexOutOfBoundsException { if (null == outline) { throw new NullPointerException("outline is null"); } @@ -319,7 +319,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param position of the to be removed Outline * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ - public final Outline removeOutline(int position) throws IndexOutOfBoundsException { + public final Outline removeOutline(final int position) throws IndexOutOfBoundsException { dirtyBits |= DIRTY_BOUNDS | DIRTY_TRIANGLES | DIRTY_VERTICES; return outlines.remove(position); } @@ -337,7 +337,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * Returns the {@code Outline} at {@code position} * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ - public final Outline getOutline(int position) throws IndexOutOfBoundsException { + public final Outline getOutline(final int position) throws IndexOutOfBoundsException { return outlines.get(position); } @@ -345,7 +345,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * Adds a vertex to the last open outline to the shape's tail. * @param v the vertex to be added to the OutlineShape */ - public final void addVertex(Vertex v) { + public final void addVertex(final Vertex v) { final Outline lo = getLastOutline(); lo.addVertex(v); if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) { @@ -360,7 +360,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param position indx at which the vertex will be added * @param v the vertex to be added to the OutlineShape */ - public final void addVertex(int position, Vertex v) { + public final void addVertex(final int position, final Vertex v) { final Outline lo = getLastOutline(); lo.addVertex(position, v); if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) { @@ -378,7 +378,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param onCurve flag if this vertex is on the final curve or defines a curved region * of the shape around this vertex. */ - public final void addVertex(float x, float y, boolean onCurve) { + public final void addVertex(final float x, final float y, final boolean onCurve) { addVertex(vertexFactory.create(x, y, 0f, onCurve)); } @@ -391,7 +391,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param onCurve flag if this vertex is on the final curve or defines a curved region * of the shape around this vertex. */ - public final void addVertex(float x, float y, float z, boolean onCurve) { + public final void addVertex(final float x, final float y, final float z, final boolean onCurve) { addVertex(vertexFactory.create(x, y, z, onCurve)); } @@ -407,7 +407,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param onCurve flag if this vertex is on the final curve or defines a curved region * of the shape around this vertex. */ - public final void addVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) { + public final void addVertex(final float[] coordsBuffer, final int offset, final int length, final boolean onCurve) { addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve)); } @@ -421,7 +421,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @param closeTail if true, a clone of the first vertex will be appended, * otherwise a clone of the last vertex will be prepended. */ - public final void closeLastOutline(boolean closeTail) { + public final void closeLastOutline(final boolean closeTail) { if( getLastOutline().setClosed(true) ) { dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES; } @@ -443,7 +443,7 @@ public class OutlineShape implements Comparable<OutlineShape> { // checkPossibleOverlaps = false; } - private void subdivideTriangle(final Outline outline, Vertex a, Vertex b, Vertex c, int index){ + private void subdivideTriangle(final Outline outline, final Vertex a, final Vertex b, final Vertex c, final int index){ VectorUtil.midVec3(tmpV1, a.getCoord(), b.getCoord()); VectorUtil.midVec3(tmpV3, b.getCoord(), c.getCoord()); VectorUtil.midVec3(tmpV2, tmpV1, tmpV3); @@ -516,7 +516,7 @@ public class OutlineShape implements Comparable<OutlineShape> { final int count = getOutlineNumber(); for (int cc = 0; cc < count; cc++) { final Outline outline = getOutline(cc); - int vertexCount = outline.getVertexCount(); + final int vertexCount = outline.getVertexCount(); for(int i=0; i < vertexCount; i++) { final Vertex current = outline.getVertex(i); if(current.isOnCurve() || current == a || current == b || current == c) { @@ -549,7 +549,7 @@ public class OutlineShape implements Comparable<OutlineShape> { final int count = getOutlineNumber(); for (int cc = 0; cc < count; cc++) { final Outline outline = getOutline(cc); - int vertexCount = outline.getVertexCount(); + final int vertexCount = outline.getVertexCount(); for(int i=0; i < vertexCount; i++) { final Vertex current = outline.getVertex(i); if(current.isOnCurve() || current == a || current == b || current == c) { @@ -679,7 +679,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * @return an arraylist of triangles representing the filled region * which is produced by the combination of the outlines */ - public ArrayList<Triangle> getTriangles(VerticesState destinationType) { + public ArrayList<Triangle> getTriangles(final VerticesState destinationType) { final boolean updated; if(destinationType != VerticesState.QUADRATIC_NURBS) { throw new IllegalStateException("destinationType "+destinationType.name()+" not supported (currently "+outlineState.name()+")"); @@ -724,7 +724,7 @@ public class OutlineShape implements Comparable<OutlineShape> { private static Comparator<Outline> reversSizeComparator = new Comparator<Outline>() { @Override - public int compare(Outline o1, Outline o2) { + public int compare(final Outline o1, final Outline o2) { return o2.compareTo(o1); // reverse ! } }; @@ -767,7 +767,7 @@ public class OutlineShape implements Comparable<OutlineShape> { * same outlineState, equal bounds and equal outlines in the same order */ @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if( obj == this) { return true; } diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index e101be33f..350e3ef41 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -115,15 +115,15 @@ public abstract class Region { protected final AABBox box = new AABBox(); protected Frustum frustum = null; - public static boolean isVBAA(int renderModes) { + public static boolean isVBAA(final int renderModes) { return 0 != (renderModes & Region.VBAA_RENDERING_BIT); } - public static boolean isMSAA(int renderModes) { + public static boolean isMSAA(final int renderModes) { return 0 != (renderModes & Region.MSAA_RENDERING_BIT); } - public static boolean isTwoPass(int renderModes) { + public static boolean isTwoPass(final int renderModes) { return 0 != ( renderModes & ( Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT) ); } @@ -132,7 +132,7 @@ public abstract class Region { * i.e. the bit {@link #VARWEIGHT_RENDERING_BIT} is set, * otherwise false. */ - public static boolean hasVariableWeight(int renderModes) { + public static boolean hasVariableWeight(final int renderModes) { return 0 != (renderModes & Region.VARWEIGHT_RENDERING_BIT); } @@ -141,7 +141,7 @@ public abstract class Region { * i.e. the bit {@link #COLORCHANNEL_RENDERING_BIT} is set, * otherwise false. */ - public static boolean hasColorChannel(int renderModes) { + public static boolean hasColorChannel(final int renderModes) { return 0 != (renderModes & Region.COLORCHANNEL_RENDERING_BIT); } @@ -150,11 +150,11 @@ public abstract class Region { * i.e. the bit {@link #COLORTEXTURE_RENDERING_BIT} is set, * otherwise false. */ - public static boolean hasColorTexture(int renderModes) { + public static boolean hasColorTexture(final int renderModes) { return 0 != (renderModes & Region.COLORTEXTURE_RENDERING_BIT); } - public static String getRenderModeString(int renderModes) { + public static String getRenderModeString(final int renderModes) { final String curveS = hasVariableWeight(renderModes) ? "-curve" : ""; final String cChanS = hasColorChannel(renderModes) ? "-cols" : ""; final String cTexS = hasColorTexture(renderModes) ? "-ctex" : ""; @@ -167,7 +167,7 @@ public abstract class Region { } } - protected Region(int regionRenderModes) { + protected Region(final int regionRenderModes) { this.renderModes = regionRenderModes; this.quality = MAX_QUALITY; } @@ -187,7 +187,7 @@ public abstract class Region { public final int getQuality() { return quality; } /** See {@link #MAX_QUALITY} */ - public final void setQuality(int q) { quality=q; } + public final void setQuality(final int q) { quality=q; } protected void clearImpl() { dirty = DIRTY_SHAPE | DIRTY_STATE; @@ -241,13 +241,13 @@ public abstract class Region { /** * Set {@link Frustum} culling for {@link #addOutlineShape(OutlineShape, AffineTransform, float[])}. */ - public final void setFrustum(Frustum frustum) { + public final void setFrustum(final Frustum frustum) { this.frustum = frustum; } final float[] coordsEx = new float[3]; - private void pushNewVertexImpl(final Vertex vertIn, final AffineTransform transform, float[] rgba) { + private void pushNewVertexImpl(final Vertex vertIn, final AffineTransform transform, final float[] rgba) { if( null != transform ) { final float[] coordsIn = vertIn.getCoord(); transform.transform(coordsIn, coordsEx); @@ -261,7 +261,7 @@ public abstract class Region { numVertices++; } - private void pushNewVertexIdxImpl(final Vertex vertIn, final AffineTransform transform, float[] rgba) { + private void pushNewVertexIdxImpl(final Vertex vertIn, final AffineTransform transform, final float[] rgba) { pushIndex(numVertices); pushNewVertexImpl(vertIn, transform, rgba); } @@ -308,7 +308,7 @@ public abstract class Region { final int idxOffset = numVertices; int vertsVNewIdxCount = 0, vertsTMovIdxCount = 0, vertsTNewIdxCount = 0, tris = 0; - int vertsDupCountV = 0, vertsDupCountT = 0, vertsKnownMovedT = 0; + final int vertsDupCountV = 0, vertsDupCountT = 0, vertsKnownMovedT = 0; if( vertsIn.size() >= 3 ) { if(DEBUG_INSTANCE) { System.err.println("Region.addOutlineShape(): Processing Vertices"); @@ -399,7 +399,7 @@ public abstract class Region { /** * See {@link #markShapeDirty()} and {@link #markStateDirty()}. */ - protected final void clearDirtyBits(int v) { + protected final void clearDirtyBits(final int v) { dirty &= ~v; } protected final int getDirtyBits() { return dirty; } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java index 568b8ddac..8f3a10d9d 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -75,7 +75,7 @@ public abstract class GLRegion extends Region { protected final TextureSequence colorTexSeq;
- protected GLRegion(int renderModes, TextureSequence colorTexSeq) {
+ protected GLRegion(final int renderModes, final TextureSequence colorTexSeq) {
super(renderModes);
this.colorTexSeq = colorTexSeq;
}
@@ -103,7 +103,7 @@ public abstract class GLRegion extends Region { /**
* Delete and clear the associated OGL objects.
*/
- public final void destroy(GL2ES2 gl) {
+ public final void destroy(final GL2ES2 gl) {
clear(gl);
destroyImpl(gl);
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index 754eb56e8..9a175c030 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -207,7 +207,7 @@ public class RegionRenderer { initialized = true; } - public final void destroy(GL2ES2 gl) { + public final void destroy(final GL2ES2 gl) { if(!initialized){ if(DEBUG_INSTANCE) { System.err.println("TextRenderer: Not initialized!"); @@ -234,7 +234,7 @@ public class RegionRenderer { * </p> * @see #create(RenderState, GLCallback, GLCallback) */ - public final void enable(GL2ES2 gl, boolean enable) { + public final void enable(final GL2ES2 gl, final boolean enable) { if( enable ) { if( null != enableCallback ) { enableCallback.run(gl, this); @@ -253,12 +253,12 @@ public class RegionRenderer { } /** No PMVMatrix operation is performed here. PMVMatrix is marked dirty. */ - public final void reshapeNotify(int width, int height) { + public final void reshapeNotify(final int width, final int height) { this.vp_width = width; this.vp_height = height; } - public final void reshapePerspective(float angle, int width, int height, float near, float far) { + public final void reshapePerspective(final float angle, final int width, final int height, final float near, final float far) { this.vp_width = width; this.vp_height = height; final float ratio = (float)width/(float)height; @@ -268,7 +268,7 @@ public class RegionRenderer { p.gluPerspective(angle, ratio, near, far); } - public final void reshapeOrtho(int width, int height, float near, float far) { + public final void reshapeOrtho(final int width, final int height, final float near, final float far) { this.vp_width = width; this.vp_height = height; final PMVMatrix p = rs.getMatrix(); @@ -298,7 +298,7 @@ public class RegionRenderer { // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode .. private static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; - private final String getFragmentShaderPrecision(GL2ES2 gl) { + private final String getFragmentShaderPrecision(final GL2ES2 gl) { if( gl.isGLES() ) { return es2_precision_fp; } @@ -489,7 +489,7 @@ public class RegionRenderer { try { posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "uniforms.glsl"); posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "varyings.glsl"); - } catch (IOException ioe) { + } catch (final IOException ioe) { throw new RuntimeException("Failed to read: includes", ioe); } if( 0 > posFp ) { @@ -514,7 +514,7 @@ public class RegionRenderer { } try { posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, shaderSegment); - } catch (IOException ioe) { + } catch (final IOException ioe) { throw new RuntimeException("Failed to read: "+shaderSegment, ioe); } if( 0 > posFp ) { diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index f991855c0..6ff9bf9cd 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -34,6 +34,7 @@ import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import javax.media.opengl.GLUniformData; +import jogamp.common.os.PlatformPropsImpl; import jogamp.graph.curve.opengl.shader.UniformNames; import com.jogamp.common.os.Platform; @@ -64,7 +65,7 @@ public class RenderState { * </p> */ public static final int BITHINT_BLENDING_ENABLED = 1 << 0 ; - + /** * Bitfield hint, {@link #isHintMaskSet(int) if set} * stating globally <i>enabled</i> {@link GL#GL_DEPTH_TEST}, otherwise <i>disabled</i>. @@ -81,15 +82,15 @@ public class RenderState { */ public static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED = 1 << 1 ; - public static RenderState createRenderState(Vertex.Factory<? extends Vertex> pointFactory) { + public static RenderState createRenderState(final Vertex.Factory<? extends Vertex> pointFactory) { return new RenderState(pointFactory, null); } - public static RenderState createRenderState(Vertex.Factory<? extends Vertex> pointFactory, PMVMatrix pmvMatrix) { + public static RenderState createRenderState(final Vertex.Factory<? extends Vertex> pointFactory, final PMVMatrix pmvMatrix) { return new RenderState(pointFactory, pmvMatrix); } - public static final RenderState getRenderState(GL2ES2 gl) { + public static final RenderState getRenderState(final GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(thisKey); } @@ -167,13 +168,13 @@ public class RenderState { return res; } - public StringBuilder toString(StringBuilder sb, boolean alsoUnlocated) { + public StringBuilder toString(StringBuilder sb, final boolean alsoUnlocated) { if(null==sb) { sb = new StringBuilder(); } - sb.append("ProgramLocal[rsID ").append(rsId).append(Platform.NEWLINE); + sb.append("ProgramLocal[rsID ").append(rsId).append(PlatformPropsImpl.NEWLINE); // pmvMatrix.toString(sb, "%.2f"); - sb.append(gcu_PMVMatrix01).append(", ").append(Platform.NEWLINE); + sb.append(gcu_PMVMatrix01).append(", ").append(PlatformPropsImpl.NEWLINE); sb.append(gcu_ColorStatic).append(", "); sb.append(gcu_Weight).append("]"); return sb; @@ -185,7 +186,7 @@ public class RenderState { } } - protected RenderState(Vertex.Factory<? extends Vertex> vertexFactory, PMVMatrix pmvMatrix) { + protected RenderState(final Vertex.Factory<? extends Vertex> vertexFactory, final PMVMatrix pmvMatrix) { this.id = getNextID(); this.sp = null; this.vertexFactory = vertexFactory; @@ -226,11 +227,11 @@ public class RenderState { public final PMVMatrix getMatrix() { return pmvMatrix; } - public static boolean isWeightValid(float v) { + public static boolean isWeightValid(final float v) { return 0.0f <= v && v <= 1.9f ; } public final float getWeight() { return weight[0]; } - public final void setWeight(float v) { + public final void setWeight(final float v) { if( !isWeightValid(v) ) { throw new IllegalArgumentException("Weight out of range"); } @@ -238,11 +239,11 @@ public class RenderState { } - public final float[] getColorStatic(float[] rgbaColor) { + public final float[] getColorStatic(final float[] rgbaColor) { System.arraycopy(colorStatic, 0, rgbaColor, 0, 4); return rgbaColor; } - public final void setColorStatic(float r, float g, float b, float a){ + public final void setColorStatic(final float r, final float g, final float b, final float a){ colorStatic[0] = r; colorStatic[1] = g; colorStatic[2] = b; @@ -301,7 +302,7 @@ public class RenderState { * @param throwOnError TODO * @return true if no error occured, i.e. all locations found, otherwise false. */ - public final boolean updateAttributeLoc(final GL2ES2 gl, final boolean updateLocation, final GLArrayDataServer data, boolean throwOnError) { + public final boolean updateAttributeLoc(final GL2ES2 gl, final boolean updateLocation, final GLArrayDataServer data, final boolean throwOnError) { if( updateLocation || 0 > data.getLocation() ) { final boolean ok = 0 <= data.setLocation(gl, sp.program()); if( throwOnError && !ok ) { @@ -314,29 +315,29 @@ public class RenderState { } - public final boolean isHintMaskSet(int mask) { + public final boolean isHintMaskSet(final int mask) { return mask == ( hintBitfield & mask ); } - public final void setHintMask(int mask) { + public final void setHintMask(final int mask) { hintBitfield |= mask; } - public final void clearHintMask(int mask) { + public final void clearHintMask(final int mask) { hintBitfield &= ~mask; } - public void destroy(GL2ES2 gl) { + public void destroy(final GL2ES2 gl) { if( null != sp ) { sp.destroy(gl); sp = null; } } - public final RenderState attachTo(GL2ES2 gl) { + public final RenderState attachTo(final GL2ES2 gl) { return (RenderState) gl.getContext().attachObject(thisKey, this); } - public final boolean detachFrom(GL2ES2 gl) { - RenderState _rs = (RenderState) gl.getContext().getAttachedObject(thisKey); + public final boolean detachFrom(final GL2ES2 gl) { + final RenderState _rs = (RenderState) gl.getContext().getAttachedObject(thisKey); if(_rs == this) { gl.getContext().detachObject(thisKey); return true; diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index aadbecc91..0fa1f49f1 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -88,7 +88,7 @@ public class TextRegionUtil { */ public static void processString(final ShapeVisitor visitor, final AffineTransform transform, final Font font, final float pixelSize, final CharSequence str, - final AffineTransform temp1, AffineTransform temp2) { + final AffineTransform temp1, final AffineTransform temp2) { final int charCount = str.length(); // region.setFlipped(true); @@ -248,7 +248,7 @@ public class TextRegionUtil { /** * Clear all cached {@link GLRegions}. */ - public void clear(GL2ES2 gl) { + public void clear(final GL2ES2 gl) { // fluchCache(gl) already called final Iterator<GLRegion> iterator = stringCacheMap.values().iterator(); while(iterator.hasNext()){ @@ -269,7 +269,7 @@ public class TextRegionUtil { * * @see #DEFAULT_CACHE_LIMIT */ - public final void setCacheLimit(int newLimit ) { stringCacheLimit = newLimit; } + public final void setCacheLimit(final int newLimit ) { stringCacheLimit = newLimit; } /** * Sets the cache limit, see {@link #setCacheLimit(int)} and validates the cache. @@ -279,7 +279,7 @@ public class TextRegionUtil { * @param gl current GL used to remove cached objects if required * @param newLimit new cache size */ - public final void setCacheLimit(GL2ES2 gl, int newLimit ) { stringCacheLimit = newLimit; validateCache(gl, 0); } + public final void setCacheLimit(final GL2ES2 gl, final int newLimit ) { stringCacheLimit = newLimit; validateCache(gl, 0); } /** * @return the current cache limit @@ -291,7 +291,7 @@ public class TextRegionUtil { */ public final int getCacheSize() { return stringCacheArray.size(); } - protected final void validateCache(GL2ES2 gl, int space) { + protected final void validateCache(final GL2ES2 gl, final int space) { if ( getCacheLimit() > 0 ) { while ( getCacheSize() + space > getCacheLimit() ) { removeCachedRegion(gl, 0); @@ -299,11 +299,11 @@ public class TextRegionUtil { } } - protected final GLRegion getCachedRegion(Font font, CharSequence str, float pixelSize, int special) { + protected final GLRegion getCachedRegion(final Font font, final CharSequence str, final float pixelSize, final int special) { return stringCacheMap.get(getKey(font, str, pixelSize, special)); } - protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, float pixelSize, int special, GLRegion glyphString) { + protected final void addCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final float pixelSize, final int special, final GLRegion glyphString) { if ( 0 != getCacheLimit() ) { final String key = getKey(font, str, pixelSize, special); final GLRegion oldRegion = stringCacheMap.put(key, glyphString); @@ -315,7 +315,7 @@ public class TextRegionUtil { } } - protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int pixelSize, int special) { + protected final void removeCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final int pixelSize, final int special) { final String key = getKey(font, str, pixelSize, special); final GLRegion region = stringCacheMap.remove(key); if(null != region) { @@ -324,7 +324,7 @@ public class TextRegionUtil { stringCacheArray.remove(key); } - protected final void removeCachedRegion(GL2ES2 gl, int idx) { + protected final void removeCachedRegion(final GL2ES2 gl, final int idx) { final String key = stringCacheArray.remove(idx); if( null != key ) { final GLRegion region = stringCacheMap.remove(key); @@ -334,7 +334,7 @@ public class TextRegionUtil { } } - protected final String getKey(Font font, CharSequence str, float pixelSize, int special) { + protected final String getKey(final Font font, final CharSequence str, final float pixelSize, final int special) { final StringBuilder sb = new StringBuilder(); return font.getName(sb, Font.NAME_UNIQUNAME) .append(".").append(str.hashCode()).append(".").append(Float.floatToIntBits(pixelSize)).append(special).toString(); diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index 948600a4a..db775e8dc 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -78,7 +78,7 @@ public class FontFactory { return get(UBUNTU); } - public static final FontSet get(int font) { + public static final FontSet get(final int font) { switch (font) { case JAVA: return JavaFontLoader.get(); @@ -87,7 +87,7 @@ public class FontFactory { } } - public static final Font get(File file) throws IOException { + public static final Font get(final File file) throws IOException { return fontConstr.create(file); } @@ -101,7 +101,7 @@ public class FontFactory { try { final URI uri = TempJarCache.getResource(fname); conn = null != uri ? uri.toURL().openConnection() : null; - } catch (Exception e) { + } catch (final Exception e) { throw new IOException(e); } } else { @@ -113,7 +113,7 @@ public class FontFactory { return null; } - public static boolean isPrintableChar( char c ) { + public static boolean isPrintableChar( final char c ) { if( Character.isWhitespace(c) ) { return true; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 15a45b056..ea2059165 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -87,7 +87,7 @@ public class Outline implements Comparable<Outline> { * @param vertex Vertex to be added * @throws NullPointerException if the {@link Vertex} element is null */ - public final void addVertex(Vertex vertex) throws NullPointerException { + public final void addVertex(final Vertex vertex) throws NullPointerException { addVertex(vertices.size(), vertex); } @@ -98,7 +98,7 @@ public class Outline implements Comparable<Outline> { * @throws NullPointerException if the {@link Vertex} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getVertexNumber()) */ - public final void addVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { + public final void addVertex(final int position, final Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { if (null == vertex) { throw new NullPointerException("vertex is null"); } @@ -116,7 +116,7 @@ public class Outline implements Comparable<Outline> { * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getVertexNumber()) */ - public final void setVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { + public final void setVertex(final int position, final Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { if (null == vertex) { throw new NullPointerException("vertex is null"); } @@ -124,11 +124,11 @@ public class Outline implements Comparable<Outline> { dirtyBBox = true; } - public final Vertex getVertex(int index){ + public final Vertex getVertex(final int index){ return vertices.get(index); } - public int getVertexIndex(Vertex vertex){ + public int getVertexIndex(final Vertex vertex){ return vertices.indexOf(vertex); } @@ -138,7 +138,7 @@ public class Outline implements Comparable<Outline> { * @param position of the to be removed Vertex * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getVertexNumber()) */ - public final Vertex removeVertex(int position) throws IndexOutOfBoundsException { + public final Vertex removeVertex(final int position) throws IndexOutOfBoundsException { dirtyBBox = true; return vertices.remove(position); } @@ -164,7 +164,7 @@ public class Outline implements Comparable<Outline> { * * @param vertices the new outline loop/strip */ - public final void setVertices(ArrayList<Vertex> vertices) { + public final void setVertices(final ArrayList<Vertex> vertices) { this.vertices = vertices; validateBoundingBox(); } @@ -184,7 +184,7 @@ public class Outline implements Comparable<Outline> { * otherwise a clone of the last vertex will be prepended. * @return true if closing performed, otherwise false for NOP */ - public final boolean setClosed(boolean closeTail) { + public final boolean setClosed(final boolean closeTail) { this.closed = true; if( !isEmpty() ) { final Vertex first = vertices.get(0); @@ -253,7 +253,7 @@ public class Outline implements Comparable<Outline> { * @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order */ @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if( obj == this) { return true; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/SVertex.java b/src/jogl/classes/com/jogamp/graph/geom/SVertex.java index 579f92455..8df8fbb31 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/SVertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/SVertex.java @@ -65,7 +65,7 @@ public class SVertex implements Vertex { } @Override - public SVertex create(float[] coordsBuffer, int offset, int length, boolean onCurve) { + public SVertex create(final float[] coordsBuffer, final int offset, final int length, final boolean onCurve) { return new SVertex(coordsBuffer, offset, length, onCurve); } } @@ -100,14 +100,14 @@ public class SVertex implements Vertex { } @Override - public final void setCoord(float x, float y, float z) { + public final void setCoord(final float x, final float y, final float z) { coord[0] = x; coord[1] = y; coord[2] = z; } @Override - public final void setCoord(float[] coordsBuffer, int offset, int length) { + public final void setCoord(final float[] coordsBuffer, final int offset, final int length) { System.arraycopy(coordsBuffer, offset, coord, 0, length); } @@ -122,17 +122,17 @@ public class SVertex implements Vertex { } @Override - public final void setX(float x) { + public final void setX(final float x) { this.coord[0] = x; } @Override - public final void setY(float y) { + public final void setY(final float y) { this.coord[1] = y; } @Override - public final void setZ(float z) { + public final void setZ(final float z) { this.coord[2] = z; } @@ -157,7 +157,7 @@ public class SVertex implements Vertex { } @Override - public final void setOnCurve(boolean onCurve) { + public final void setOnCurve(final boolean onCurve) { this.onCurve = onCurve; } @@ -167,12 +167,12 @@ public class SVertex implements Vertex { } @Override - public final void setId(int id){ + public final void setId(final int id){ this.id = id; } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if( obj == this) { return true; } @@ -192,14 +192,14 @@ public class SVertex implements Vertex { } @Override - public final void setTexCoord(float s, float t, float p) { + public final void setTexCoord(final float s, final float t, final float p) { texCoord[0] = s; texCoord[1] = t; texCoord[2] = p; } @Override - public final void setTexCoord(float[] texCoordsBuffer, int offset, int length) { + public final void setTexCoord(final float[] texCoordsBuffer, final int offset, final int length) { System.arraycopy(texCoordsBuffer, offset, texCoord, 0, length); } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java index 33e53f3ed..fc345f2a7 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java @@ -93,7 +93,7 @@ public class Triangle { return id; } - public void setId(int id) { + public void setId(final int id) { this.id = id; } @@ -118,7 +118,7 @@ public class Triangle { return boundaryVertices; } - public void setVerticesBoundary(boolean[] boundaryVertices) { + public void setVerticesBoundary(final boolean[] boundaryVertices) { this.boundaryVertices = boundaryVertices; } diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index a9b54097f..e765d2d52 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -101,7 +101,7 @@ public class FBObject { * Returns {@link #COLOR}, {@link #DEPTH}, {@link #STENCIL} or {@link #DEPTH_STENCIL} * @throws IllegalArgumentException if <code>format</code> cannot be handled. */ - public static Type determine(int format) throws IllegalArgumentException { + public static Type determine(final int format) throws IllegalArgumentException { switch(format) { case GL.GL_RGBA4: case GL.GL_RGB5_A1: @@ -135,7 +135,7 @@ public class FBObject { private int name; - protected Attachment(Type type, int iFormat, int width, int height, int name) { + protected Attachment(final Type type, final int iFormat, final int width, final int height, final int name) { this.type = type; this.format = iFormat; this.width = width; @@ -148,7 +148,7 @@ public class FBObject { * @param caps the destination for format bits * @param rgba8Avail whether rgba8 is available */ - public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) { + public final void formatToGLCapabilities(final GLCapabilities caps, final boolean rgba8Avail) { final int _format; switch(format) { case GL.GL_RGBA: @@ -224,11 +224,11 @@ public class FBObject { public final int getWidth() { return width; } /** height of attachment */ public final int getHeight() { return height; } - /* pp */ final void setSize(int w, int h) { width = w; height = h; } + /* pp */ final void setSize(final int w, final int h) { width = w; height = h; } /** buffer name [1..max], maybe a texture or renderbuffer name, depending on type. */ public final int getName() { return name; } - /* pp */ final void setName(int n) { name = n; } + /* pp */ final void setName(final int n) { name = n; } /** * Initializes the attachment and set it's parameter, if uninitialized, i.e. name is <code>zero</code>. @@ -263,7 +263,7 @@ public class FBObject { * {@inheritDoc} */ @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if( this == o ) return true; if( ! ( o instanceof Attachment ) ) return false; final Attachment a = (Attachment)o; @@ -299,7 +299,7 @@ public class FBObject { "; name "+toHexString(name)+", obj "+toHexString(objectHashCode())+"]"; } - public static Type getType(int attachmentPoint, int maxColorAttachments) { + public static Type getType(final int attachmentPoint, final int maxColorAttachments) { if( GL.GL_COLOR_ATTACHMENT0 <= attachmentPoint && attachmentPoint < GL.GL_COLOR_ATTACHMENT0+maxColorAttachments ) { return Type.COLOR; } @@ -326,16 +326,16 @@ public class FBObject { * @param height * @param name */ - public RenderAttachment(Type type, int iFormat, int samples, int width, int height, int name) { + public RenderAttachment(final Type type, final int iFormat, final int samples, final int width, final int height, final int name) { super(validateType(type), iFormat, width, height, name); this.samples = samples; } /** number of samples, or zero for no multisampling */ public final int getSamples() { return samples; } - /* pp */ final void setSamples(int s) { samples = s; } + /* pp */ final void setSamples(final int s) { samples = s; } - private static Type validateType(Type type) { + private static Type validateType(final Type type) { switch(type) { case DEPTH_STENCIL: case DEPTH: @@ -354,7 +354,7 @@ public class FBObject { * {@inheritDoc} */ @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if( this == o ) return true; if( ! ( o instanceof RenderAttachment ) ) return false; return super.equals(o) && @@ -376,7 +376,7 @@ public class FBObject { } @Override - public boolean initialize(GL gl) throws GLException { + public boolean initialize(final GL gl) throws GLException { final boolean init = 0 == getName(); if( init ) { checkPreGLError(gl); @@ -405,7 +405,7 @@ public class FBObject { } @Override - public void free(GL gl) { + public void free(final GL gl) { final int[] name = new int[] { getName() }; if( 0 != name[0] ) { if(DEBUG) { @@ -425,7 +425,7 @@ public class FBObject { /** Color render buffer attachment */ public static class ColorAttachment extends RenderAttachment implements Colorbuffer { - public ColorAttachment(int iFormat, int samples, int width, int height, int name) { + public ColorAttachment(final int iFormat, final int samples, final int width, final int height, final int name) { super(Type.COLOR, iFormat, samples, width, height, name); } } @@ -448,8 +448,8 @@ public class FBObject { * @param wrapT * @param name */ - public TextureAttachment(Type type, int iFormat, int width, int height, int dataFormat, int dataType, - int magFilter, int minFilter, int wrapS, int wrapT, int name) { + public TextureAttachment(final Type type, final int iFormat, final int width, final int height, final int dataFormat, final int dataType, + final int magFilter, final int minFilter, final int wrapS, final int wrapT, final int name) { super(validateType(type), iFormat, width, height, name); this.dataFormat = dataFormat; this.dataType = dataType; @@ -459,7 +459,7 @@ public class FBObject { this.wrapT = wrapT; } - private static Type validateType(Type type) { + private static Type validateType(final Type type) { switch(type) { case COLOR_TEXTURE: case DEPTH_TEXTURE: @@ -475,7 +475,7 @@ public class FBObject { * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case. */ @Override - public boolean initialize(GL gl) throws GLException { + public boolean initialize(final GL gl) throws GLException { final boolean init = 0 == getName(); if( init ) { checkPreGLError(gl); @@ -520,7 +520,7 @@ public class FBObject { } @Override - public void free(GL gl) { + public void free(final GL gl) { final int[] name = new int[] { getName() }; if( 0 != name[0] ) { if(DEBUG) { @@ -540,7 +540,7 @@ public class FBObject { "; name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]"; } } - static String toHexString(int v) { + static String toHexString(final int v) { return "0x"+Integer.toHexString(v); } @@ -556,7 +556,7 @@ public class FBObject { * @param height texture height * @return the created and uninitialized color {@link TextureAttachment} */ - public static final TextureAttachment createColorTextureAttachment(GL gl, boolean alpha, int width, int height) { + public static final TextureAttachment createColorTextureAttachment(final GL gl, final boolean alpha, final int width, final int height) { return createColorTextureAttachment(gl, alpha, width, height, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); } @@ -605,8 +605,8 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return the created and uninitialized color {@link TextureAttachment} */ - public static final TextureAttachment createColorTextureAttachment(GL gl, boolean alpha, int width, int height, - int magFilter, int minFilter, int wrapS, int wrapT) { + public static final TextureAttachment createColorTextureAttachment(final GL gl, final boolean alpha, final int width, final int height, + final int magFilter, final int minFilter, final int wrapS, final int wrapT) { final int textureInternalFormat, textureDataFormat, textureDataType; if(gl.isGLES3()) { textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; @@ -640,13 +640,13 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return the created and uninitialized color {@link TextureAttachment} */ - public static final TextureAttachment createColorTextureAttachment(int internalFormat, int width, int height, int dataFormat, int dataType, - int magFilter, int minFilter, int wrapS, int wrapT) { + public static final TextureAttachment createColorTextureAttachment(final int internalFormat, final int width, final int height, final int dataFormat, final int dataType, + final int magFilter, final int minFilter, final int wrapS, final int wrapT) { return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT, 0 /* name */); } - private static boolean hasAlpha(int format) { + private static boolean hasAlpha(final int format) { switch(format) { case GL.GL_RGBA8: case GL.GL_RGBA4: @@ -689,7 +689,7 @@ public class FBObject { // ColorAttachment helper .. // - private final void validateColorAttachmentPointRange(int point) { + private final void validateColorAttachmentPointRange(final int point) { if(!initialized) { throw new GLException("FBO not initialized"); } @@ -701,14 +701,14 @@ public class FBObject { } } - private final void validateAddColorAttachment(int point, Colorbuffer ca) { + private final void validateAddColorAttachment(final int point, final Colorbuffer ca) { validateColorAttachmentPointRange(point); if( null != colorAttachmentPoints[point] ) { throw new IllegalArgumentException("Cannot attach "+ca+", attachment point already in use by "+colorAttachmentPoints[point]+", "+this); } } - private final void addColorAttachment(int point, Colorbuffer ca) { + private final void addColorAttachment(final int point, final Colorbuffer ca) { validateColorAttachmentPointRange(point); final Colorbuffer c = colorAttachmentPoints[point]; if( null != c && c != ca ) { @@ -718,7 +718,7 @@ public class FBObject { colorAttachmentCount++; } - private final void removeColorAttachment(int point, Colorbuffer ca) { + private final void removeColorAttachment(final int point, final Colorbuffer ca) { validateColorAttachmentPointRange(point); final Colorbuffer c = colorAttachmentPoints[point]; if( null != c && c != ca ) { @@ -736,7 +736,7 @@ public class FBObject { * @see #attachTexture2D(GL, int, boolean, int, int, int, int) * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) */ - public final Colorbuffer getColorbuffer(int attachmentPoint) { + public final Colorbuffer getColorbuffer(final int attachmentPoint) { validateColorAttachmentPointRange(attachmentPoint); return colorAttachmentPoints[attachmentPoint]; } @@ -750,7 +750,7 @@ public class FBObject { * @param ca the {@link Colorbuffer} to look for. * @return -1 if the {@link Colorbuffer} could not be found, otherwise [0..{@link #getMaxColorAttachments()}-1] */ - public final int getColorbufferAttachmentPoint(Colorbuffer ca) { + public final int getColorbufferAttachmentPoint(final Colorbuffer ca) { for(int i=0; i<colorAttachmentPoints.length; i++) { if( colorAttachmentPoints[i] == ca ) { return i; @@ -773,7 +773,7 @@ public class FBObject { * @see #attachTexture2D(GL, int, boolean, int, int, int, int) * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) */ - public final Colorbuffer getColorbuffer(Colorbuffer ca) { + public final Colorbuffer getColorbuffer(final Colorbuffer ca) { final int p = getColorbufferAttachmentPoint(ca); return p>=0 ? getColorbuffer(p) : null; } @@ -840,7 +840,7 @@ public class FBObject { this.samplingSinkDirty = true; } - private void init(GL gl, int width, int height, int samples) throws GLException { + private void init(final GL gl, int width, int height, final int samples) throws GLException { if(initialized) { throw new GLException("FBO already initialized"); } @@ -863,7 +863,7 @@ public class FBObject { final boolean NV_fbo_color_attachments = gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments); - int val[] = new int[1]; + final int val[] = new int[1]; checkPreGLError(gl); @@ -874,7 +874,7 @@ public class FBObject { val[0] = 0; gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0); realMaxColorAttachments = 1 <= val[0] ? val[0] : 1; // cap minimum to 1 - } catch (GLException gle) { gle.printStackTrace(); } + } catch (final GLException gle) { gle.printStackTrace(); } } maxColorAttachments = realMaxColorAttachments <= 8 ? realMaxColorAttachments : 8; // cap to limit array size @@ -967,7 +967,7 @@ public class FBObject { * @param newHeight * @throws GLException in case of an error */ - public final void reset(GL gl, int newWidth, int newHeight) { + public final void reset(final GL gl, final int newWidth, final int newHeight) { reset(gl, newWidth, newHeight, 0, false); } @@ -996,7 +996,7 @@ public class FBObject { * * @throws GLException in case of an error, i.e. size too big, etc .. */ - public final void reset(GL gl, int newWidth, int newHeight, int newSamples, boolean resetSamplingSink) { + public final void reset(final GL gl, int newWidth, int newHeight, int newSamples, final boolean resetSamplingSink) { if( !initialized ) { init(gl, newWidth, newHeight, newSamples); return; @@ -1048,7 +1048,7 @@ public class FBObject { * Writes the internal format of the attachments to the given GLCapabilities object. * @param caps the destination for format bits */ - public final void formatToGLCapabilities(GLCapabilities caps) { + public final void formatToGLCapabilities(final GLCapabilities caps) { caps.setSampleBuffers(samples > 0); caps.setNumSamples(samples); caps.setDepthBits(0); @@ -1080,7 +1080,7 @@ public class FBObject { return getStatusString(vStatus); } - public static final String getStatusString(int fbStatus) { + public static final String getStatusString(final int fbStatus) { switch(fbStatus) { case -1: return "NOT A FBO"; @@ -1132,7 +1132,7 @@ public class FBObject { case GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS: case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + case GL2ES3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: if(0 == colorAttachmentCount || null == depth) { // we are in transition @@ -1152,8 +1152,8 @@ public class FBObject { } } - private static int checkPreGLError(GL gl) { - int glerr = gl.glGetError(); + private static int checkPreGLError(final GL gl) { + final int glerr = gl.glGetError(); if(DEBUG && GL.GL_NO_ERROR != glerr) { System.err.println("Pre-existing GL error: "+toHexString(glerr)); Thread.dumpStack(); @@ -1161,7 +1161,7 @@ public class FBObject { return glerr; } - private final boolean checkNoError(GL gl, int err, String exceptionMessage) throws GLException { + private final boolean checkNoError(final GL gl, final int err, final String exceptionMessage) throws GLException { if(GL.GL_NO_ERROR != err) { if(null != gl) { destroy(gl); @@ -1195,7 +1195,7 @@ public class FBObject { * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen * @see #createColorTextureAttachment(GLProfile, boolean, int, int) */ - public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha) throws GLException { + public final TextureAttachment attachTexture2D(final GL gl, final int attachmentPoint, final boolean alpha) throws GLException { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(gl, alpha, width, height)); } @@ -1217,7 +1217,7 @@ public class FBObject { * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen * @see #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int) */ - public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha, int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { + public final TextureAttachment attachTexture2D(final GL gl, final int attachmentPoint, final boolean alpha, final int magFilter, final int minFilter, final int wrapS, final int wrapT) throws GLException { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(gl, alpha, width, height, magFilter, minFilter, wrapS, wrapT)); } @@ -1240,9 +1240,9 @@ public class FBObject { * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen * @see #createColorTextureAttachment(int, int, int, int, int, int, int, int, int) */ - public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, - int internalFormat, int dataFormat, int dataType, - int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { + public final TextureAttachment attachTexture2D(final GL gl, final int attachmentPoint, + final int internalFormat, final int dataFormat, final int dataType, + final int magFilter, final int minFilter, final int wrapS, final int wrapT) throws GLException { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT)); } @@ -1258,7 +1258,7 @@ public class FBObject { * @param alpha set to <code>true</code> if you request alpha channel, otherwise <code>false</code>; * @return uninitialized ColorAttachment instance describing the new attached colorbuffer */ - public final ColorAttachment createColorAttachment(boolean alpha) { + public final ColorAttachment createColorAttachment(final boolean alpha) { final int internalFormat; if( rgba8Avail ) { @@ -1282,7 +1282,7 @@ public class FBObject { * @throws GLException in case the colorbuffer couldn't be allocated * @see #createColorAttachment(boolean) */ - public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, boolean alpha) throws GLException { + public final ColorAttachment attachColorbuffer(final GL gl, final int attachmentPoint, final boolean alpha) throws GLException { return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, createColorAttachment(alpha)); } @@ -1298,7 +1298,7 @@ public class FBObject { * @throws GLException in case the colorbuffer couldn't be allocated * @throws IllegalArgumentException if <code>internalFormat</code> doesn't reflect a colorbuffer */ - public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, int internalFormat) throws GLException, IllegalArgumentException { + public final ColorAttachment attachColorbuffer(final GL gl, final int attachmentPoint, final int internalFormat) throws GLException, IllegalArgumentException { final Attachment.Type atype = Attachment.Type.determine(internalFormat); if( Attachment.Type.COLOR != atype ) { throw new IllegalArgumentException("colorformat invalid: "+toHexString(internalFormat)+", "+this); @@ -1326,12 +1326,12 @@ public class FBObject { * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} */ - public final Colorbuffer attachColorbuffer(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { + public final Colorbuffer attachColorbuffer(final GL gl, final int attachmentPoint, final Colorbuffer colbuf) throws GLException { bind(gl); return attachColorbufferImpl(gl, attachmentPoint, colbuf); } - private final Colorbuffer attachColorbufferImpl(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { + private final Colorbuffer attachColorbufferImpl(final GL gl, final int attachmentPoint, final Colorbuffer colbuf) throws GLException { validateAddColorAttachment(attachmentPoint, colbuf); final boolean initializedColorbuf = colbuf.initialize(gl); @@ -1407,7 +1407,7 @@ public class FBObject { * @see #getDepthAttachment() * @see #getStencilAttachment() */ - public final void attachRenderbuffer(GL gl, Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { + public final void attachRenderbuffer(final GL gl, final Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { if( 0 > reqBits ) { reqBits = 24; } @@ -1493,7 +1493,7 @@ public class FBObject { * @see #getDepthAttachment() * @see #getStencilAttachment() */ - public final void attachRenderbuffer(GL gl, int internalFormat) throws GLException, IllegalArgumentException { + public final void attachRenderbuffer(final GL gl, final int internalFormat) throws GLException, IllegalArgumentException { final Attachment.Type atype = Attachment.Type.determine(internalFormat); if( Attachment.Type.DEPTH != atype && Attachment.Type.STENCIL != atype && Attachment.Type.DEPTH_STENCIL != atype ) { throw new IllegalArgumentException("renderformat invalid: "+toHexString(internalFormat)+", "+this); @@ -1501,7 +1501,7 @@ public class FBObject { attachRenderbufferImpl(gl, atype, internalFormat); } - protected final void attachRenderbufferImpl(GL gl, Attachment.Type atype, int internalFormat) throws GLException { + protected final void attachRenderbufferImpl(final GL gl, final Attachment.Type atype, final int internalFormat) throws GLException { if( null != depth && ( Attachment.Type.DEPTH == atype || Attachment.Type.DEPTH_STENCIL == atype ) ) { throw new GLException("FBO depth buffer already attached (rb "+depth+"), type is "+atype+", "+toHexString(internalFormat)+", "+this); } @@ -1513,7 +1513,7 @@ public class FBObject { attachRenderbufferImpl2(gl, atype, internalFormat); } - private final void attachRenderbufferImpl2(GL gl, Attachment.Type atype, int internalFormat) throws GLException { + private final void attachRenderbufferImpl2(final GL gl, final Attachment.Type atype, final int internalFormat) throws GLException { if( Attachment.Type.DEPTH == atype ) { if(null == depth) { depth = new RenderAttachment(Type.DEPTH, internalFormat, samples, width, height, 0); @@ -1578,7 +1578,7 @@ public class FBObject { * @return the detached Colorbuffer * @throws IllegalArgumentException */ - public final Colorbuffer detachColorbuffer(GL gl, int attachmentPoint, boolean dispose) throws IllegalArgumentException { + public final Colorbuffer detachColorbuffer(final GL gl, final int attachmentPoint, final boolean dispose) throws IllegalArgumentException { bind(gl); final Colorbuffer res = detachColorbufferImpl(gl, attachmentPoint, dispose ? DetachAction.DISPOSE : DetachAction.NONE); @@ -1591,7 +1591,7 @@ public class FBObject { return res; } - private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, DetachAction detachAction) { + private final Colorbuffer detachColorbufferImpl(final GL gl, final int attachmentPoint, final DetachAction detachAction) { Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here if(null == colbuf) { @@ -1661,7 +1661,7 @@ public class FBObject { return colbuf; } - private final void freeAllColorbufferImpl(GL gl) { + private final void freeAllColorbufferImpl(final GL gl) { for(int i=0; i<maxColorAttachments; i++) { final Colorbuffer colbuf = colorAttachmentPoints[i]; // shortcut, don't validate here @@ -1696,7 +1696,7 @@ public class FBObject { * @param dispose true if the Colorbuffer shall be disposed * @param reqAType {@link Type#DEPTH}, {@link Type#DEPTH} or {@link Type#DEPTH_STENCIL} */ - public final void detachRenderbuffer(GL gl, Attachment.Type atype, boolean dispose) throws IllegalArgumentException { + public final void detachRenderbuffer(final GL gl, final Attachment.Type atype, final boolean dispose) throws IllegalArgumentException { bind(gl); detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE); if(DEBUG) { @@ -1718,7 +1718,7 @@ public class FBObject { return res; } - private final void detachRenderbufferImpl(GL gl, Attachment.Type atype, DetachAction detachAction) throws IllegalArgumentException { + private final void detachRenderbufferImpl(final GL gl, Attachment.Type atype, final DetachAction detachAction) throws IllegalArgumentException { switch ( atype ) { case DEPTH: case STENCIL: @@ -1824,7 +1824,7 @@ public class FBObject { } } - private final void freeAllRenderbufferImpl(GL gl) throws IllegalArgumentException { + private final void freeAllRenderbufferImpl(final GL gl) throws IllegalArgumentException { // Note: DEPTH_STENCIL shares buffer w/ depth and stencil final boolean packed = isDepthStencilPackedFormat(); if( null != depth ) { @@ -1853,7 +1853,7 @@ public class FBObject { * </p> * @param gl the current GL context */ - public final void detachAll(GL gl) { + public final void detachAll(final GL gl) { if(null != samplingSink) { samplingSink.detachAll(gl); } @@ -1869,7 +1869,7 @@ public class FBObject { * </p> * @param gl the current GL context */ - public final void detachAllColorbuffer(GL gl) { + public final void detachAllColorbuffer(final GL gl) { if(null != samplingSink) { samplingSink.detachAllColorbuffer(gl); } @@ -1884,7 +1884,7 @@ public class FBObject { * </p> * @param gl the current GL context */ - public final void detachAllTexturebuffer(GL gl) { + public final void detachAllTexturebuffer(final GL gl) { if( !isInitialized() ) { return; } @@ -1902,7 +1902,7 @@ public class FBObject { } } - public final void detachAllRenderbuffer(GL gl) { + public final void detachAllRenderbuffer(final GL gl) { if( !isInitialized() ) { return; } @@ -1913,7 +1913,7 @@ public class FBObject { detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, DetachAction.DISPOSE); } - private final void detachAllImpl(GL gl, boolean detachNonColorbuffer, boolean recreate) { + private final void detachAllImpl(final GL gl, final boolean detachNonColorbuffer, final boolean recreate) { if( !isInitialized() ) { return; } @@ -1957,7 +1957,7 @@ public class FBObject { /** * @param gl the current GL context */ - public final void destroy(GL gl) { + public final void destroy(final GL gl) { if(!initialized) { return; } @@ -1976,7 +1976,7 @@ public class FBObject { final int fb_cache = fbName; fbName = 0; - int name[] = new int[1]; + final int name[] = new int[1]; if(0!=fb_cache) { name[0] = fb_cache; gl.glDeleteFramebuffers(1, name, 0); @@ -2036,7 +2036,7 @@ public class FBObject { * @param gl the current GL context * @throws GLException in case of an error, i.e. size too big, etc .. */ - public final void resetSamplingSink(GL gl) throws GLException { + public final void resetSamplingSink(final GL gl) throws GLException { if(0 == samples) { // MSAA off if(null != samplingSink && samplingSink.initialized) { @@ -2088,7 +2088,7 @@ public class FBObject { } if(null == samplingSinkTexture) { - boolean hasAlpha = hasAttachmentUsingAlpha(); + final boolean hasAlpha = hasAttachmentUsingAlpha(); samplingSinkTexture = samplingSink.attachTexture2D(gl, 0, hasAlpha); } else if( 0 == samplingSinkTexture.getName() ) { samplingSinkTexture.setSize(width, height); @@ -2123,7 +2123,7 @@ public class FBObject { * @return the previous sampling sink or null if none was attached * @throws GLException if this FBO doesn't use MSAA or the given sink uses MSAA itself */ - public FBObject setSamplingSink(FBObject newSamplingSink) throws GLException { + public FBObject setSamplingSink(final FBObject newSamplingSink) throws GLException { final FBObject prev = samplingSink; if( null == newSamplingSink) { samplingSink = null; @@ -2154,7 +2154,7 @@ public class FBObject { * @param gl the current GL context * @throws GLException */ - public final void bind(GL gl) throws GLException { + public final void bind(final GL gl) throws GLException { if(!bound || fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)) { checkInitialized(); if(samples > 0 && fullFBOSupport) { @@ -2180,7 +2180,7 @@ public class FBObject { * @param gl the current GL context * @throws GLException */ - public final void unbind(GL gl) throws GLException { + public final void unbind(final GL gl) throws GLException { if(bound) { if(fullFBOSupport) { // default read/draw buffers, may utilize GLContext/GLDrawable override of @@ -2212,7 +2212,7 @@ public class FBObject { * </p> * @param gl the current GL context */ - public final boolean isBound(GL gl) { + public final boolean isBound(final GL gl) { bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER) ; return bound; } @@ -2244,7 +2244,7 @@ public class FBObject { * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} * @throws IllegalArgumentException */ - public final void syncSamplingSink(GL gl) { + public final void syncSamplingSink(final GL gl) { markUnbound(); if(samples>0 && samplingSinkDirty) { samplingSinkDirty = false; @@ -2279,7 +2279,7 @@ public class FBObject { * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} * @throws IllegalArgumentException */ - public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { + public final void use(final GL gl, final TextureAttachment ta) throws IllegalArgumentException { if(null == ta) { throw new IllegalArgumentException("Null TextureAttachment, this: "+toString()); } syncSamplingSink(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. @@ -2290,7 +2290,7 @@ public class FBObject { * * <p>Leaves the FBO unbound.</p> */ - public final void unuse(GL gl) { + public final void unuse(final GL gl) { unbind(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it } @@ -2309,7 +2309,7 @@ public class FBObject { * @param bits 16, 24 or 32 bits * @throws GLException if {@link #init(GL)} hasn't been called. */ - public final boolean supportsDepth(int bits) throws GLException { + public final boolean supportsDepth(final int bits) throws GLException { checkInitialized(); switch(bits) { case 16: return true; @@ -2324,7 +2324,7 @@ public class FBObject { * @param bits 1, 4, 8 or 16 bits * @throws GLException if {@link #init(GL)} hasn't been called. */ - public final boolean supportsStencil(int bits) throws GLException { + public final boolean supportsStencil(final int bits) throws GLException { checkInitialized(); switch(bits) { case 1: return stencil01Avail; @@ -2400,7 +2400,7 @@ public class FBObject { ", dirty "+samplingSinkDirty+"], state "+getStatusString()+", obj "+toHexString(objectHashCode())+"]"; } - private final void updateStatus(GL gl) { + private final void updateStatus(final GL gl) { if( 0 == fbName ) { vStatus = -1; } else { diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index e9fe80a91..f9a7ab029 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -84,7 +84,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto * and no further lifecycle handling is applied. * @param lock optional custom {@link RecursiveLock}. */ - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock) { + public GLAutoDrawableDelegate(final GLDrawable drawable, final GLContext context, final Object upstreamWidget, final boolean ownDevice, final RecursiveLock lock) { super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); if(null == drawable) { throw new IllegalArgumentException("null drawable"); @@ -118,7 +118,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto * @param newWidth new width in pixel units * @param newWidth new height in pixel units */ - public final void windowResizedOp(int newWidth, int newHeight) { + public final void windowResizedOp(final int newWidth, final int newHeight) { super.defaultWindowResizedOp(newWidth, newHeight); } @@ -154,7 +154,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto * Set the upstream UI toolkit object. * @see #getUpstreamWidget() */ - public final void setUpstreamWidget(Object newUpstreamWidget) { + public final void setUpstreamWidget(final Object newUpstreamWidget) { upstreamWidget = newUpstreamWidget; } diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java index 299e51532..aa56a8442 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -70,9 +70,9 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; public class GLEventListenerState { private static final boolean DEBUG = Debug.debug("GLDrawable") || Debug.debug("GLEventListenerState"); - private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device, - GLCapabilitiesImmutable caps, - GLContext context, int count, GLAnimatorControl anim, boolean animStarted) { + private GLEventListenerState(final AbstractGraphicsDevice upstreamDevice, final boolean proxyOwnsUpstreamDevice, final AbstractGraphicsDevice device, + final GLCapabilitiesImmutable caps, + final GLContext context, final int count, final GLAnimatorControl anim, final boolean animStarted) { this.upstreamDevice = upstreamDevice; this.proxyOwnsUpstreamDevice = proxyOwnsUpstreamDevice; this.device = device; @@ -124,7 +124,7 @@ public class GLEventListenerState { } } - private static AbstractGraphicsDevice cloneDevice(AbstractGraphicsDevice aDevice) { + private static AbstractGraphicsDevice cloneDevice(final AbstractGraphicsDevice aDevice) { return (AbstractGraphicsDevice) aDevice.clone(); } @@ -148,7 +148,7 @@ public class GLEventListenerState { * * @see #moveTo(GLAutoDrawable) */ - public static GLEventListenerState moveFrom(GLAutoDrawable a) { + public static GLEventListenerState moveFrom(final GLAutoDrawable a) { final GLAnimatorControl aAnim = a.getAnimator(); final boolean aAnimStarted; if( null != aAnim ) { @@ -251,7 +251,7 @@ public class GLEventListenerState { * @see #moveFrom(GLAutoDrawable) * @see #isOwner() */ - public final void moveTo(GLAutoDrawable a) { + public final void moveTo(final GLAutoDrawable a) { final GLAnimatorControl aAnim = a.getAnimator(); final boolean hasAnimator = null != aAnim; final boolean aPaused; @@ -407,7 +407,7 @@ public class GLEventListenerState { public static GLRunnable setViewport = new GLRunnable() { @Override - public boolean run(GLAutoDrawable drawable) { + public boolean run(final GLAutoDrawable drawable) { drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return true; } @@ -415,19 +415,19 @@ public class GLEventListenerState { public static GLRunnable glFinish = new GLRunnable() { @Override - public boolean run(GLAutoDrawable drawable) { + public boolean run(final GLAutoDrawable drawable) { drawable.getGL().glFinish(); return true; } }; public static class ReshapeGLEventListener implements GLRunnable { - private GLEventListener listener; - public ReshapeGLEventListener(GLEventListener listener) { + private final GLEventListener listener; + public ReshapeGLEventListener(final GLEventListener listener) { this.listener = listener; } @Override - public boolean run(GLAutoDrawable drawable) { + public boolean run(final GLAutoDrawable drawable) { listener.reshape(drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return true; } diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 9c9f4e3d6..078b48ec2 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -336,7 +336,7 @@ public class GLRendererQuirks { * </p> * @see #areSameStickyDevice(AbstractGraphicsDevice, AbstractGraphicsDevice) */ - public static GLRendererQuirks getStickyDeviceQuirks(AbstractGraphicsDevice device) { + public static GLRendererQuirks getStickyDeviceQuirks(final AbstractGraphicsDevice device) { final String key = device.getUniqueID(); final GLRendererQuirks has = stickyDeviceQuirks.get(key); final GLRendererQuirks res; @@ -353,7 +353,7 @@ public class GLRendererQuirks { * Returns true if both devices have the same {@link AbstractGraphicsDevice#getUniqueID()}, * otherwise false. */ - public static boolean areSameStickyDevice(AbstractGraphicsDevice device1, AbstractGraphicsDevice device2) { + public static boolean areSameStickyDevice(final AbstractGraphicsDevice device1, final AbstractGraphicsDevice device2) { return device1.getUniqueID() == device2.getUniqueID(); } @@ -364,7 +364,7 @@ public class GLRendererQuirks { * </p> * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ - public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, int[] quirks, int offset, int len) throws IllegalArgumentException { + public static void addStickyDeviceQuirks(final AbstractGraphicsDevice device, final int[] quirks, final int offset, final int len) throws IllegalArgumentException { final GLRendererQuirks sq = getStickyDeviceQuirks(device); sq.addQuirks(quirks, offset, len); } @@ -375,7 +375,7 @@ public class GLRendererQuirks { * </p> * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ - public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks quirks) throws IllegalArgumentException { + public static void addStickyDeviceQuirks(final AbstractGraphicsDevice device, final GLRendererQuirks quirks) throws IllegalArgumentException { final GLRendererQuirks sq = getStickyDeviceQuirks(device); sq.addQuirks(quirks); } @@ -386,7 +386,7 @@ public class GLRendererQuirks { * </p> * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ - public static boolean existStickyDeviceQuirk(AbstractGraphicsDevice device, int quirk) { + public static boolean existStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirk) { return getStickyDeviceQuirks(device).exist(quirk); } /** @@ -397,7 +397,7 @@ public class GLRendererQuirks { * </p> * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ - public static void pushStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks dest) { + public static void pushStickyDeviceQuirks(final AbstractGraphicsDevice device, final GLRendererQuirks dest) { dest.addQuirks(getStickyDeviceQuirks(device)); } @@ -413,7 +413,7 @@ public class GLRendererQuirks { * @param len number of quirks to read from offset within quirks array * @throws IllegalArgumentException if one of the quirks is out of range */ - public GLRendererQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException { + public GLRendererQuirks(final int[] quirks, final int offset, final int len) throws IllegalArgumentException { this(); addQuirks(quirks, offset, len); } @@ -424,7 +424,7 @@ public class GLRendererQuirks { * @param len number of quirks to read from offset within quirks array * @throws IllegalArgumentException if one of the quirks is out of range */ - public final void addQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException { + public final void addQuirks(final int[] quirks, final int offset, final int len) throws IllegalArgumentException { int bitmask = 0; if( !( 0 <= offset + len && offset + len <= quirks.length ) ) { throw new IllegalArgumentException("offset and len out of bounds: offset "+offset+", len "+len+", array-len "+quirks.length); @@ -440,7 +440,7 @@ public class GLRendererQuirks { /** * @param quirks valid GLRendererQuirks to be added */ - public final void addQuirks(GLRendererQuirks quirks) { + public final void addQuirks(final GLRendererQuirks quirks) { _bitmask |= quirks._bitmask; } @@ -449,7 +449,7 @@ public class GLRendererQuirks { * @return true if quirk exist, otherwise false * @throws IllegalArgumentException if quirk is out of range */ - public final boolean exist(int quirk) throws IllegalArgumentException { + public final boolean exist(final int quirk) throws IllegalArgumentException { validateQuirk(quirk); return 0 != ( ( 1 << quirk ) & _bitmask ); } @@ -481,7 +481,7 @@ public class GLRendererQuirks { * @param quirk the quirk to be validated, i.e. whether it is out of range * @throws IllegalArgumentException if quirk is out of range */ - public static void validateQuirk(int quirk) throws IllegalArgumentException { + public static void validateQuirk(final int quirk) throws IllegalArgumentException { if( !( 0 <= quirk && quirk < COUNT ) ) { throw new IllegalArgumentException("Quirks must be in range [0.."+COUNT+"[, but quirk: "+quirk); } @@ -492,7 +492,7 @@ public class GLRendererQuirks { * @return the String equivalent of this quirk * @throws IllegalArgumentException if quirk is out of range */ - public static final String toString(int quirk) throws IllegalArgumentException { + public static final String toString(final int quirk) throws IllegalArgumentException { validateQuirk(quirk); return _names[quirk]; } diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index 40f0d180f..8d6765036 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -43,7 +43,7 @@ public class JoglVersion extends JogampVersion { protected static volatile JoglVersion jogampCommonVersionInfo; - protected JoglVersion(String packageName, Manifest mf) { + protected JoglVersion(final String packageName, final Manifest mf) { super(packageName, mf); } @@ -60,17 +60,17 @@ public class JoglVersion extends JogampVersion { return jogampCommonVersionInfo; } - public StringBuilder toString(GL gl, StringBuilder sb) { + public StringBuilder toString(final GL gl, StringBuilder sb) { sb = super.toString(sb).append(Platform.getNewline()); getGLInfo(gl, sb); return sb; } - public String toString(GL gl) { + public String toString(final GL gl) { return toString(gl, null).toString(); } - public static StringBuilder getAvailableCapabilitiesInfo(GLDrawableFactory factory, AbstractGraphicsDevice device, StringBuilder sb) { + public static StringBuilder getAvailableCapabilitiesInfo(final GLDrawableFactory factory, final AbstractGraphicsDevice device, StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); } @@ -84,7 +84,7 @@ public class JoglVersion extends JogampVersion { } done = true; } - } catch (GLException gle) { /* n/a */ } + } catch (final GLException gle) { /* n/a */ } } if(!done) { sb.append("\tnone").append(Platform.getNewline()); @@ -108,7 +108,7 @@ public class JoglVersion extends JogampVersion { return sb; } - public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, boolean withCapabilitiesInfo) { + public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo) { if(null==sb) { sb = new StringBuilder(); } @@ -127,11 +127,11 @@ public class JoglVersion extends JogampVersion { return sb; } - public static StringBuilder getGLInfo(GL gl, StringBuilder sb) { + public static StringBuilder getGLInfo(final GL gl, final StringBuilder sb) { return getGLInfo(gl, sb, false); } - public static StringBuilder getGLInfo(GL gl, StringBuilder sb, boolean withCapabilitiesAndExtensionInfo) { - AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() + public static StringBuilder getGLInfo(final GL gl, StringBuilder sb, final boolean withCapabilitiesAndExtensionInfo) { + final AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() .getGraphicsConfiguration().getScreen().getDevice(); if(null==sb) { sb = new StringBuilder(); @@ -151,11 +151,11 @@ public class JoglVersion extends JogampVersion { return sb; } - public static StringBuilder getGLStrings(GL gl, StringBuilder sb) { + public static StringBuilder getGLStrings(final GL gl, final StringBuilder sb) { return getGLStrings(gl, sb, true); } - public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) { + public static StringBuilder getGLStrings(final GL gl, StringBuilder sb, final boolean withExtensions) { if(null==sb) { sb = new StringBuilder(); } @@ -200,7 +200,7 @@ public class JoglVersion extends JogampVersion { return sb; } - public StringBuilder getBriefOSGLBuildInfo(GL gl, StringBuilder sb) { + public StringBuilder getBriefOSGLBuildInfo(final GL gl, StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); } @@ -217,7 +217,7 @@ public class JoglVersion extends JogampVersion { return sb; } - public static void main(String args[]) { + public static void main(final String args[]) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); // System.err.println(NativeWindowVersion.getInstance()); diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java index 52c2e78eb..e8e9c9584 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java @@ -89,12 +89,12 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf /** Tool has none **/ @Override - public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { + public final long toolGetProcAddress(final long toolGetProcAddressHandle, final String funcName) { return 0; } @Override - public final boolean useToolGetProcAdressFirst(String funcName) { + public final boolean useToolGetProcAdressFirst(final String funcName) { return false; } diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgException.java b/src/jogl/classes/com/jogamp/opengl/cg/CgException.java index 3e42f4d70..0a3535ba6 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgException.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgException.java @@ -50,18 +50,18 @@ public class CgException extends RuntimeException { } /** Constructs a CgException object with the specified detail message. */ - public CgException(String message) { + public CgException(final String message) { super(message); } /** Constructs a CgException object with the specified detail message and root cause. */ - public CgException(String message, Throwable cause) { + public CgException(final String message, final Throwable cause) { super(message, cause); } /** Constructs a CgException object with the specified root cause. */ - public CgException(Throwable cause) { + public CgException(final Throwable cause) { super(cause); } } diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary16.java b/src/jogl/classes/com/jogamp/opengl/math/Binary16.java index 33add46c2..8e4aa9176 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary16.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Binary16.java @@ -151,7 +151,7 @@ public final class Binary16 * the interval of double precision values is far larger than that of the * <code>binary16</code> type. * </p> - * + * * @see #unpackDouble(char) */ @@ -224,7 +224,7 @@ public final class Binary16 * the interval of single precision values is far larger than that of the * <code>binary16</code> type. * </p> - * + * * @see #unpackFloat(char) */ @@ -280,7 +280,7 @@ public final class Binary16 * range <code>[-15, 16]</code> - values outside of this range will be * truncated. * </p> - * + * * @see #unpackGetExponentUnbiased(char) */ @@ -298,7 +298,7 @@ public final class Binary16 * Encode the significand <code>s</code>. Values should be in the range * <code>[0, 1023]</code>. Values outside of this range will be truncated. * </p> - * + * * @see #unpackGetSignificand(char) */ @@ -315,7 +315,7 @@ public final class Binary16 * <code>[0, 1]</code>, with <code>0</code> ironically denoting a positive * value. Values outside of this range will be truncated. * </p> - * + * * @see #unpackGetSign(char) */ @@ -369,7 +369,7 @@ public final class Binary16 * <code>k</code>, and the decoded significand <code>s</code> of * <code>k</code>.</li> * </ul> - * + * * @see #packDouble(double) */ @@ -405,7 +405,7 @@ public final class Binary16 /** * 1. Bias the exponent. - * + * * 2. Shift the result left to the position at which it will appear in the * resulting value. */ @@ -443,7 +443,7 @@ public final class Binary16 * <code>k</code>, and the decoded significand <code>s</code> of * <code>k</code>.</li> * </ul> - * + * * @see #packFloat(float) */ @@ -479,7 +479,7 @@ public final class Binary16 /** * 1. Bias the exponent. - * + * * 2. Shift the result left to the position at which it will appear in the * resulting value. */ @@ -522,7 +522,7 @@ public final class Binary16 * <code>16</code> iff the input is {@link #POSITIVE_INFINITY}, * {@link #NEGATIVE_INFINITY}, or <code>NaN</code>.</li> * </ul> - * + * * @see #packSetExponentUnbiasedUnchecked(int) */ @@ -537,7 +537,7 @@ public final class Binary16 /** * Retrieve the sign bit of the given packed <code>binary16</code> value, as * an integer in the range <code>[0, 1]</code>. - * + * * @see Binary16#packSetSignUnchecked(int) */ @@ -552,7 +552,7 @@ public final class Binary16 * Return the significand of the given packed <code>binary16</code> value as * an integer in the range <code>[0, 1023]</code>. * </p> - * + * * @see Binary16#packSetSignificandUnchecked(int) */ diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary32.java b/src/jogl/classes/com/jogamp/opengl/math/Binary32.java index d98815d9f..599b1ff68 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary32.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Binary32.java @@ -75,7 +75,7 @@ public final class Binary32 * {@link #POSITIVE_INFINITY}, {@link #NEGATIVE_INFINITY}, or * <code>NaN</code>.</li> * </ul> - * + * * @see #packSetExponentUnbiasedUnchecked(int) */ diff --git a/src/jogl/classes/com/jogamp/opengl/math/Binary64.java b/src/jogl/classes/com/jogamp/opengl/math/Binary64.java index 5efad433a..d4ec636a5 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Binary64.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Binary64.java @@ -75,7 +75,7 @@ public final class Binary64 * {@link #POSITIVE_INFINITY}, {@link #NEGATIVE_INFINITY}, or * <code>NaN</code>.</li> * </ul> - * + * * @see #packSetExponentUnbiasedUnchecked(int) */ @@ -93,7 +93,7 @@ public final class Binary64 * Return the significand of the given double value. * </p> */ - + public static long unpackGetSignificand( final double d) { @@ -106,7 +106,7 @@ public final class Binary64 * Return the sign of the given double value. * </p> */ - + public static long unpackGetSign( final double d) { diff --git a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java index b7dbf183f..31408b079 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java @@ -46,15 +46,15 @@ public class FixedPoint { return (int)(value * 65536.0f); } - public static final float toFloat(int value) { - return (float)value/65536.0f; + public static final float toFloat(final int value) { + return value/65536.0f; } - public static final int mult(int x1, int x2) { + public static final int mult(final int x1, final int x2) { return (int) ( ((long)x1*(long)x2)/65536 ); } - public static final int div(int x1, int x2) { + public static final int div(final int x1, final int x2) { return (int) ( (((long)x1)<<16)/x2 ); } } diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java index cf56ff0a4..d2e535eaf 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java @@ -34,6 +34,7 @@ import javax.media.opengl.GLException; import jogamp.opengl.Debug; import com.jogamp.common.os.Platform; +import com.jogamp.opengl.math.geom.AABBox; /** * Basic Float math utility functions. @@ -50,105 +51,292 @@ import com.jogamp.common.os.Platform; | 8 9 10 11 | | 2 6 10 14 | | | | | | 12 13 14 15 | | 3 7 11 15 | + + C R C R + m[0*4+3] = tx; m[0+4*3] = tx; + m[1*4+3] = ty; m[1+4*3] = ty; + m[2*4+3] = tz; m[2+4*3] = tz; * </pre> * </p> * <p> - * See <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix-FAQ</a> + * <ul> + * <li><a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix-FAQ</a></li> + * <li><a href="https://en.wikipedia.org/wiki/Matrix_%28mathematics%29">Wikipedia-Matrix</a></li> + * <li><a href="http://www.euclideanspace.com/maths/algebra/matrix/index.htm">euclideanspace.com-Matrix</a></li> + * </ul> * </p> * <p> - * Derived from ProjectFloat.java - Created 11-jan-2004 + * Implementation utilizes unrolling of small vertices and matrices wherever possible + * while trying to access memory in a linear fashion for performance reasons, see: + * <ul> + * <li><a href="https://code.google.com/p/java-matrix-benchmark/">java-matrix-benchmark</a></li> + * <li><a href="https://github.com/lessthanoptimal/ejml">EJML Efficient Java Matrix Library</a></li> + * </ul> * </p> - * - * @author Erik Duijs, Kenneth Russell, et al. */ -public class FloatUtil { +public final class FloatUtil { public static final boolean DEBUG = Debug.debug("Math"); - private static final float[] IDENTITY_MATRIX = - new float[] { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f }; - - private static final float[] ZERO_MATRIX = - new float[] { - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f }; + // + // Matrix Ops + // /** * Make matrix an identity matrix + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @return given matrix for chaining */ - public static final void makeIdentityf(float[] m, int offset) { - for (int i = 0; i < 16; i++) { - m[i+offset] = IDENTITY_MATRIX[i]; - } + public static float[] makeIdentity(final float[] m, final int m_offset) { + m[m_offset+0+4*0] = 1f; + m[m_offset+1+4*0] = 0f; + m[m_offset+2+4*0] = 0f; + m[m_offset+3+4*0] = 0f; + + m[m_offset+0+4*1] = 0f; + m[m_offset+1+4*1] = 1f; + m[m_offset+2+4*1] = 0f; + m[m_offset+3+4*1] = 0f; + + m[m_offset+0+4*2] = 0f; + m[m_offset+1+4*2] = 0f; + m[m_offset+2+4*2] = 1f; + m[m_offset+3+4*2] = 0f; + + m[m_offset+0+4*3] = 0f; + m[m_offset+1+4*3] = 0f; + m[m_offset+2+4*3] = 0f; + m[m_offset+3+4*3] = 1f; + return m; } /** * Make matrix an identity matrix + * @param m 4x4 matrix in column-major order (also result) + * @return given matrix for chaining */ - public static final void makeIdentityf(FloatBuffer m) { - final int oldPos = m.position(); - m.put(IDENTITY_MATRIX); - m.position(oldPos); + public static float[] makeIdentity(final float[] m) { + m[0+4*0] = 1f; + m[1+4*0] = 0f; + m[2+4*0] = 0f; + m[3+4*0] = 0f; + + m[0+4*1] = 0f; + m[1+4*1] = 1f; + m[2+4*1] = 0f; + m[3+4*1] = 0f; + + m[0+4*2] = 0f; + m[1+4*2] = 0f; + m[2+4*2] = 1f; + m[3+4*2] = 0f; + + m[0+4*3] = 0f; + m[1+4*3] = 0f; + m[2+4*3] = 0f; + m[3+4*3] = 1f; + return m; } /** - * Make matrix an zero matrix + * Make a translation matrix in column-major order from the given axis deltas + * <pre> + Translation matrix (Column Order): + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + x y z 1 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the diagonal and last-row is set. + * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix + * for {@link #makeScale(float[], int, boolean, float, float, float) scaling} + * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation}, + * while leaving the other fields untouched for performance reasons. + * @return given matrix for chaining */ - public static final void makeZero(float[] m, int offset) { - for (int i = 0; i < 16; i++) { - m[i+offset] = 0; - } + public static float[] makeTranslation(final float[] m, final int m_offset, final boolean initM, final float tx, final float ty, final float tz) { + if( initM ) { + makeIdentity(m, m_offset); + } else { + m[m_offset+0+4*0] = 1; + m[m_offset+1+4*1] = 1; + m[m_offset+2+4*2] = 1; + m[m_offset+3+4*3] = 1; + } + m[m_offset+0+4*3] = tx; + m[m_offset+1+4*3] = ty; + m[m_offset+2+4*3] = tz; + return m; } /** - * Make matrix an zero matrix + * Make a translation matrix in column-major order from the given axis deltas + * <pre> + Translation matrix (Column Order): + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + x y z 1 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the diagonal and last-row is set. + * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix + * for {@link #makeScale(float[], int, boolean, float, float, float) scaling} + * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation}, + * while leaving the other fields untouched for performance reasons. + * @return given matrix for chaining */ - public static final void makeZero(FloatBuffer m) { - final int oldPos = m.position(); - m.put(ZERO_MATRIX); - m.position(oldPos); + public static float[] makeTranslation(final float[] m, final boolean initM, final float tx, final float ty, final float tz) { + if( initM ) { + makeIdentity(m); + } else { + m[0+4*0] = 1; + m[1+4*1] = 1; + m[2+4*2] = 1; + m[3+4*3] = 1; + } + m[0+4*3] = tx; + m[1+4*3] = ty; + m[2+4*3] = tz; + return m; } /** - * Make a rotation matrix from the given axis and angle in radians. - * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q38">Matrix-FAQ Q38</a> + * Make a scale matrix in column-major order from the given axis factors + * <pre> + Scale matrix (Any Order): + x 0 0 0 + 0 y 0 0 + 0 0 z 0 + 0 0 0 1 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the diagonal and last-row is set. + * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix + * for {@link #makeScale(float[], int, boolean, float, float, float) scaling} + * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation}, + * while leaving the other fields untouched for performance reasons. + * @return given matrix for chaining */ - public static final void makeRotationAxis(final float angrad, float x, float y, float z, final float[] mat, final int mat_offset, final float[] tmpVec3f) { - final float c = cos(angrad); - final float ic= 1.0f - c; - final float s = sin(angrad); - - tmpVec3f[0]=x; tmpVec3f[1]=y; tmpVec3f[2]=z; - VectorUtil.normalizeVec3(tmpVec3f); - x = tmpVec3f[0]; y = tmpVec3f[1]; z = tmpVec3f[2]; - - // Rotation matrix (Row Order): - // xx(1-c)+c xy(1-c)+zs xz(1-c)-ys 0 - // xy(1-c)-zs yy(1-c)+c yz(1-c)+xs 0 - // xz(1-c)+ys yz(1-c)-xs zz(1-c)+c 0 - // 0 0 0 1 - final float xy = x*y; - final float xz = x*z; - final float xs = x*s; - final float ys = y*s; - final float yz = y*z; - final float zs = z*s; - mat[0+0*4+mat_offset] = x*x*ic+c; - mat[1+0*4+mat_offset] = xy*ic+zs; - mat[2+0*4+mat_offset] = xz*ic-ys; + public static float[] makeScale(final float[] m, final int m_offset, final boolean initM, final float sx, final float sy, final float sz) { + if( initM ) { + makeIdentity(m, m_offset); + } else { + m[m_offset+0+4*3] = 0; + m[m_offset+1+4*3] = 0; + m[m_offset+2+4*3] = 0; + m[m_offset+3+4*3] = 1; + } + m[m_offset+0+4*0] = sx; + m[m_offset+1+4*1] = sy; + m[m_offset+2+4*2] = sz; + return m; + } - mat[0+1*4+mat_offset] = xy*ic-zs; - mat[1+1*4+mat_offset] = y*y*ic+c; - mat[2+1*4+mat_offset] = yz*ic+xs; + /** + * Make a scale matrix in column-major order from the given axis factors + * <pre> + Scale matrix (Any Order): + x 0 0 0 + 0 y 0 0 + 0 0 z 0 + 0 0 0 1 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the diagonal and last-row is set. + * The latter can be utilized to share a once {@link #makeIdentity(float[], int) identity set} matrix + * for {@link #makeScale(float[], int, boolean, float, float, float) scaling} + * and {@link #makeTranslation(float[], int, boolean, float, float, float) translation}, + * while leaving the other fields untouched for performance reasons. + * @return given matrix for chaining + */ + public static float[] makeScale(final float[] m, final boolean initM, final float sx, final float sy, final float sz) { + if( initM ) { + makeIdentity(m); + } else { + m[0+4*3] = 0; + m[1+4*3] = 0; + m[2+4*3] = 0; + m[3+4*3] = 1; + } + m[0+4*0] = sx; + m[1+4*1] = sy; + m[2+4*2] = sz; + return m; + } - mat[0+2*4+mat_offset] = xz*ic+ys; - mat[1+2*4+mat_offset] = yz*ic-xs; - mat[2+2*4+mat_offset] = z*z*ic+c; + /** + * Make a rotation matrix from the given axis and angle in radians. + * <pre> + Rotation matrix (Column Order): + xx(1-c)+c xy(1-c)+zs xz(1-c)-ys 0 + xy(1-c)-zs yy(1-c)+c yz(1-c)+xs 0 + xz(1-c)+ys yz(1-c)-xs zz(1-c)+c 0 + 0 0 0 1 + * </pre> + * <p> + * All matrix fields are set. + * </p> + * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q38">Matrix-FAQ Q38</a> + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @return given matrix for chaining + */ + public static float[] makeRotationAxis(final float[] m, final int m_offset, final float angrad, float x, float y, float z, final float[] tmpVec3f) { + final float c = cos(angrad); + final float ic= 1.0f - c; + final float s = sin(angrad); + + tmpVec3f[0]=x; tmpVec3f[1]=y; tmpVec3f[2]=z; + VectorUtil.normalizeVec3(tmpVec3f); + x = tmpVec3f[0]; y = tmpVec3f[1]; z = tmpVec3f[2]; + + final float xy = x*y; + final float xz = x*z; + final float xs = x*s; + final float ys = y*s; + final float yz = y*z; + final float zs = z*s; + m[0+0*4+m_offset] = x*x*ic+c; + m[1+0*4+m_offset] = xy*ic+zs; + m[2+0*4+m_offset] = xz*ic-ys; + m[3+0*4+m_offset] = 0; + + m[0+1*4+m_offset] = xy*ic-zs; + m[1+1*4+m_offset] = y*y*ic+c; + m[2+1*4+m_offset] = yz*ic+xs; + m[3+1*4+m_offset] = 0; + + m[0+2*4+m_offset] = xz*ic+ys; + m[1+2*4+m_offset] = yz*ic-xs; + m[2+2*4+m_offset] = z*z*ic+c; + m[3+2*4+m_offset] = 0; + + m[0+3*4+m_offset] = 0f; + m[1+3*4+m_offset] = 0f; + m[2+3*4+m_offset] = 0f; + m[3+3*4+m_offset] = 1f; + + return m; } /** @@ -161,9 +349,15 @@ public class FloatUtil { * <li>x - bank</li> * </ul> * </p> + * <p> + * All matrix fields are set. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix * @param bankX the Euler pitch angle in radians. (rotation about the X axis) * @param headingY the Euler yaw angle in radians. (rotation about the Y axis) * @param attitudeZ the Euler roll angle in radians. (rotation about the Z axis) + * @return given matrix for chaining * <p> * Implementation does not use Quaternion and hence is exposed to * <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q34">Gimbal-Lock</a> @@ -171,7 +365,7 @@ public class FloatUtil { * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q36">Matrix-FAQ Q36</a> * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm">euclideanspace.com-eulerToMatrix</a> */ - public static final void makeRotationEuler(final float bankX, final float headingY, final float attitudeZ, final float[] mat, final int mat_offset) { + public static float[] makeRotationEuler(final float[] m, final int m_offset, final float bankX, final float headingY, final float attitudeZ) { // Assuming the angles are in radians. final float ch = cos(headingY); final float sh = sin(headingY); @@ -180,32 +374,45 @@ public class FloatUtil { final float cb = cos(bankX); final float sb = sin(bankX); - mat[0+0*4+mat_offset] = ch*ca; - mat[0+1*4+mat_offset] = sh*sb - ch*sa*cb; - mat[0+2*4+mat_offset] = ch*sa*sb + sh*cb; - mat[1+0*4+mat_offset] = sa; - mat[1+1*4+mat_offset] = ca*cb; - mat[1+2*4+mat_offset] = -ca*sb; - mat[2+0*4+mat_offset] = -sh*ca; - mat[2+1*4+mat_offset] = sh*sa*cb + ch*sb; - mat[2+2*4+mat_offset] = -sh*sa*sb + ch*cb; + m[0+0*4+m_offset] = ch*ca; + m[1+0*4+m_offset] = sa; + m[2+0*4+m_offset] = -sh*ca; + m[3+0*4+m_offset] = 0; + + m[0+1*4+m_offset] = sh*sb - ch*sa*cb; + m[1+1*4+m_offset] = ca*cb; + m[2+1*4+m_offset] = sh*sa*cb + ch*sb; + m[3+1*4+m_offset] = 0; + + m[0+2*4+m_offset] = ch*sa*sb + sh*cb; + m[1+2*4+m_offset] = -ca*sb; + m[2+2*4+m_offset] = -sh*sa*sb + ch*cb; + m[3+2*4+m_offset] = 0; - mat[3+0*4+mat_offset] = 0; - mat[3+1*4+mat_offset] = 0; - mat[3+2*4+mat_offset] = 0; + m[0+3*4+m_offset] = 0; + m[1+3*4+m_offset] = 0; + m[2+3*4+m_offset] = 0; + m[3+3*4+m_offset] = 1; - mat[0+3*4+mat_offset] = 0; - mat[1+3*4+mat_offset] = 0; - mat[2+3*4+mat_offset] = 0; - mat[3+3*4+mat_offset] = 1; + return m; } /** * Make given matrix the orthogonal matrix based on given parameters. - * - * @param a 4x4 matrix in column-major order (also result) - * @param a_off - * @param initA if true, given matrix will be initialized w/ identity matrix. + * <pre> + Ortho matrix (Column Order): + 2/dx 0 0 0 + 0 2/dy 0 0 + 0 0 2/dz 0 + tx ty tz 1 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the orthogonal fields are set. * @param left * @param right * @param bottom @@ -214,18 +421,31 @@ public class FloatUtil { * @param zFar * @return given matrix for chaining */ - public static final float[] makeOrthof(final float[] a, final int a_off, final boolean initA, - final float left, final float right, - final float bottom, final float top, - final float zNear, final float zFar) { - if( initA ) { - FloatUtil.makeIdentityf(a, a_off); - } - // Ortho matrix (Column Order): - // 2/dx 0 0 0 - // 0 2/dy 0 0 - // 0 0 2/dz 0 - // tx ty tz 1 + public static float[] makeOrtho(final float[] m, final int m_offset, final boolean initM, + final float left, final float right, + final float bottom, final float top, + final float zNear, final float zFar) { + if( initM ) { + // m[m_offset+0+4*0] = 1f; + m[m_offset+1+4*0] = 0f; + m[m_offset+2+4*0] = 0f; + m[m_offset+3+4*0] = 0f; + + m[m_offset+0+4*1] = 0f; + // m[m_offset+1+4*1] = 1f; + m[m_offset+2+4*1] = 0f; + m[m_offset+3+4*1] = 0f; + + m[m_offset+0+4*2] = 0f; + m[m_offset+1+4*2] = 0f; + // m[m_offset+2+4*2] = 1f; + m[m_offset+3+4*2] = 0f; + + // m[m_offset+0+4*3] = 0f; + // m[m_offset+1+4*3] = 0f; + // m[m_offset+2+4*3] = 0f; + // m[m_offset+3+4*3] = 1f; + } final float dx=right-left; final float dy=top-bottom; final float dz=zFar-zNear; @@ -233,22 +453,37 @@ public class FloatUtil { final float ty=-1.0f*(top+bottom)/dy; final float tz=-1.0f*(zFar+zNear)/dz; - a[a_off+0+4*0] = 2.0f/dx; - a[a_off+1+4*1] = 2.0f/dy; - a[a_off+2+4*2] = -2.0f/dz; - a[a_off+0+4*3] = tx; - a[a_off+1+4*3] = ty; - a[a_off+2+4*3] = tz; + m[m_offset+0+4*0] = 2.0f/dx; - return a; + m[m_offset+1+4*1] = 2.0f/dy; + + m[m_offset+2+4*2] = -2.0f/dz; + + m[m_offset+0+4*3] = tx; + m[m_offset+1+4*3] = ty; + m[m_offset+2+4*3] = tz; + m[m_offset+3+4*3] = 1f; + + return m; } /** * Make given matrix the frustum matrix based on given parameters. + * <pre> + Frustum matrix (Column Order): + 2*zNear/dx 0 0 0 + 0 2*zNear/dy 0 0 + A B C -1 + 0 0 D 0 + * </pre> + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> * - * @param a 4x4 matrix in column-major order (also result) - * @param a_off - * @param initA if true, given matrix will be initialized w/ identity matrix. + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the frustum fields are set. * @param left * @param right * @param bottom @@ -257,24 +492,37 @@ public class FloatUtil { * @param zFar * @return given matrix for chaining */ - public static final float[] makeFrustumf(final float[] a, final int a_off, final boolean initA, - final float left, final float right, - final float bottom, final float top, - final float zNear, final float zFar) { + public static float[] makeFrustum(final float[] m, final int m_offset, final boolean initM, + final float left, final float right, + final float bottom, final float top, + final float zNear, final float zFar) { if(zNear<=0.0f||zFar<0.0f) { throw new GLException("GL_INVALID_VALUE: zNear and zFar must be positive, and zNear>0"); } if(left==right || top==bottom) { throw new GLException("GL_INVALID_VALUE: top,bottom and left,right must not be equal"); } - if( initA ) { - FloatUtil.makeIdentityf(a, a_off); + if( initM ) { + // m[m_offset+0+4*0] = 1f; + m[m_offset+1+4*0] = 0f; + m[m_offset+2+4*0] = 0f; + m[m_offset+3+4*0] = 0f; + + m[m_offset+0+4*1] = 0f; + // m[m_offset+1+4*1] = 1f; + m[m_offset+2+4*1] = 0f; + m[m_offset+3+4*1] = 0f; + + // m[m_offset+0+4*2] = 0f; + // m[m_offset+1+4*2] = 0f; + // m[m_offset+2+4*2] = 1f; + // m[m_offset+3+4*2] = 0f; + + m[m_offset+0+4*3] = 0f; + m[m_offset+1+4*3] = 0f; + // m[m_offset+2+4*3] = 0f; + // m[m_offset+3+4*3] = 1f; } - // Frustum matrix (Column Order): - // 2*zNear/dx 0 0 0 - // 0 2*zNear/dy 0 0 - // A B C -1 - // 0 0 D 0 final float zNear2 = 2.0f*zNear; final float dx=right-left; final float dy=top-bottom; @@ -284,71 +532,943 @@ public class FloatUtil { final float C=-1.0f*(zFar+zNear)/dz; final float D=-2.0f*(zFar*zNear)/dz; - a[a_off+0+4*0] = zNear2/dx; - a[a_off+1+4*1] = zNear2/dy; - a[a_off+2+4*2] = C; + m[m_offset+0+4*0] = zNear2/dx; - a[a_off+0+4*2] = A; - a[a_off+1+4*2] = B; + m[m_offset+1+4*1] = zNear2/dy; - a[a_off+2+4*3] = D; - a[a_off+3+4*2] = -1.0f; - return a; + m[m_offset+0+4*2] = A; + m[m_offset+1+4*2] = B; + m[m_offset+2+4*2] = C; + m[m_offset+3+4*2] = -1.0f; + + m[m_offset+2+4*3] = D; + m[m_offset+3+4*3] = 0f; + + return m; } /** - * Make given matrix the perspective matrix based on given parameters. + * Make given matrix the perspective {@link #makeFrustum(float[], int, boolean, float, float, float, float, float, float) frustum} + * matrix based on given parameters. + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> * - * @param a 4x4 matrix in column-major order (also result) - * @param a_off - * @param initA if true, given matrix will be initialized w/ identity matrix. - * @param fovy angle in radians + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the frustum fields are set. + * @param fovy_rad angle in radians * @param aspect * @param zNear * @param zFar * @return given matrix for chaining */ - public static final float[] makePerspective(final float[] a, final int a_off, final boolean initA, - final float fovy, final float aspect, final float zNear, final float zFar) { - float top=(float)Math.tan(fovy)*zNear; - float bottom=-1.0f*top; - float left=aspect*bottom; - float right=aspect*top; - return makeFrustumf(a, a_off, initA, left, right, bottom, top, zNear, zFar); + public static float[] makePerspective(final float[] m, final int m_off, final boolean initM, + final float fovy_rad, final float aspect, final float zNear, final float zFar) { + final float top = tan(fovy_rad/2f) * zNear; // use tangent of half-fov ! + final float bottom = -1.0f * top; + final float left = aspect * bottom; + final float right = aspect * top; + return makeFrustum(m, m_off, initM, left, right, bottom, top, zNear, zFar); } /** - * Multiply matrix: [d] = [a] x [b] - * @param a 4x4 matrix in column-major order - * @param b 4x4 matrix in column-major order - * @param d result a*b in column-major order + * Make given matrix the perspective {@link #makeFrustum(float[], int, boolean, float, float, float, float, float, float) frustum} + * matrix based on given parameters. + * <p> + * All matrix fields are only set if <code>initM</code> is <code>true</code>. + * </p> + * + * @param m 4x4 matrix in column-major order (also result) + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param initM if true, given matrix will be initialized w/ identity matrix, + * otherwise only the frustum fields are set. + * @param fovhv {@link FovHVHalves} field of view in both directions, may not be centered, either in radians or tangent + * @param zNear + * @param zFar + * @return given matrix for chaining */ - public static final void multMatrixf(final float[] a, int a_off, final float[] b, int b_off, float[] d, int d_off) { - for (int i = 0; i < 4; i++) { - // one row in column-major order - final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4]; // row-i of a - d[d_off+i+0*4] = ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ; - d[d_off+i+1*4] = ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ; - d[d_off+i+2*4] = ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ; - d[d_off+i+3*4] = ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ; - } + public static float[] makePerspective(final float[] m, final int m_offset, final boolean initM, + final FovHVHalves fovhv, final float zNear, final float zFar) { + final FovHVHalves fovhvTan = fovhv.getInTangents(); // use tangent of half-fov ! + final float top = fovhvTan.top * zNear; + final float bottom = -1.0f * fovhvTan.bottom * zNear; + final float left = -1.0f * fovhvTan.left * zNear; + final float right = fovhvTan.right * zNear; + return makeFrustum(m, m_offset, initM, left, right, bottom, top, zNear, zFar); } /** - * Multiply matrix: [a] = [a] x [b] - * @param a 4x4 matrix in column-major order (also result) - * @param b 4x4 matrix in column-major order + * Make given matrix the <i>look-at</i> matrix based on given parameters. + * <p> + * Consist out of two matrix multiplications: + * <pre> + * <b>R</b> = <b>L</b> x <b>T</b>, + * with <b>L</b> for <i>look-at</i> matrix and + * <b>T</b> for eye translation. + * + * Result <b>R</b> can be utilized for <i>modelview</i> multiplication, i.e. + * <b>M</b> = <b>M</b> x <b>R</b>, + * with <b>M</b> being the <i>modelview</i> matrix. + * </pre> + * </p> + * <p> + * All matrix fields are set. + * </p> + * @param m 4x4 matrix in column-major order, result only + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param eye 3 component eye vector + * @param eye_offset + * @param center 3 component center vector + * @param center_offset + * @param up 3 component up vector + * @param up_offset + * @param mat4Tmp temp float[16] storage + * @return given matrix <code>m</code> for chaining */ - public static final void multMatrixf(final float[] a, int a_off, final float[] b, int b_off) { - for (int i = 0; i < 4; i++) { - // one row in column-major order - final int a_off_i = a_off+i; - final float ai0=a[a_off_i+0*4], ai1=a[a_off_i+1*4], ai2=a[a_off_i+2*4], ai3=a[a_off_i+3*4]; // row-i of a - a[a_off_i+0*4] = ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ; - a[a_off_i+1*4] = ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ; - a[a_off_i+2*4] = ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ; - a[a_off_i+3*4] = ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ; - } + public static float[] makeLookAt(final float[] m, final int m_offset, + final float[] eye, final int eye_offset, + final float[] center, final int center_offset, + final float[] up, final int up_offset, + final float[] mat4Tmp) { + final int forward_off = 0; + final int side_off = 3; + final int up2_off = 6; + + // forward! + mat4Tmp[0] = center[0+center_offset] - eye[0+eye_offset]; + mat4Tmp[1] = center[1+center_offset] - eye[1+eye_offset]; + mat4Tmp[2] = center[2+center_offset] - eye[2+eye_offset]; + + VectorUtil.normalizeVec3(mat4Tmp); // normalize forward + + /* Side = forward x up */ + VectorUtil.crossVec3(mat4Tmp, side_off, mat4Tmp, forward_off, up, up_offset); + VectorUtil.normalizeVec3(mat4Tmp, side_off); // normalize side + + /* Recompute up as: up = side x forward */ + VectorUtil.crossVec3(mat4Tmp, up2_off, mat4Tmp, side_off, mat4Tmp, forward_off); + + m[m_offset + 0 * 4 + 0] = mat4Tmp[0+side_off]; // side + m[m_offset + 0 * 4 + 1] = mat4Tmp[0+up2_off]; // up2 + m[m_offset + 0 * 4 + 2] = -mat4Tmp[0]; // forward + m[m_offset + 0 * 4 + 3] = 0; + + m[m_offset + 1 * 4 + 0] = mat4Tmp[1+side_off]; // side + m[m_offset + 1 * 4 + 1] = mat4Tmp[1+up2_off]; // up2 + m[m_offset + 1 * 4 + 2] = -mat4Tmp[1]; // forward + m[m_offset + 1 * 4 + 3] = 0; + + m[m_offset + 2 * 4 + 0] = mat4Tmp[2+side_off]; // side + m[m_offset + 2 * 4 + 1] = mat4Tmp[2+up2_off]; // up2 + m[m_offset + 2 * 4 + 2] = -mat4Tmp[2]; // forward + m[m_offset + 2 * 4 + 3] = 0; + + m[m_offset + 3 * 4 + 0] = 0; + m[m_offset + 3 * 4 + 1] = 0; + m[m_offset + 3 * 4 + 2] = 0; + m[m_offset + 3 * 4 + 3] = 1; + + makeTranslation(mat4Tmp, true, -eye[0+eye_offset], -eye[1+eye_offset], -eye[2+eye_offset]); + multMatrix(m, m_offset, mat4Tmp, 0); + + return m; + } + + /** + * Make given matrix the <i>pick</i> matrix based on given parameters. + * <p> + * Traditional <code>gluPickMatrix</code> implementation. + * </p> + * <p> + * Consist out of two matrix multiplications: + * <pre> + * <b>R</b> = <b>T</b> x <b>S</b>, + * with <b>T</b> for viewport translation matrix and + * <b>S</b> for viewport scale matrix. + * + * Result <b>R</b> can be utilized for <i>projection</i> multiplication, i.e. + * <b>P</b> = <b>P</b> x <b>R</b>, + * with <b>P</b> being the <i>projection</i> matrix. + * </pre> + * </p> + * <p> + * To effectively use the generated pick matrix for picking, + * call {@link #makePick(float[], int, float, float, float, float, int[], int, float[]) makePick} + * and multiply a {@link #makePerspective(float[], int, boolean, float, float, float, float) custom perspective matrix} + * by this pick matrix. Then you may load the result onto the perspective matrix stack. + * </p> + * <p> + * All matrix fields are set. + * </p> + * @param m 4x4 matrix in column-major order, result only + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @param x the center x-component of a picking region in window coordinates + * @param y the center y-component of a picking region in window coordinates + * @param deltaX the width of the picking region in window coordinates. + * @param deltaY the height of the picking region in window coordinates. + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param mat4Tmp temp float[16] storage + * @return given matrix <code>m</code> for chaining or <code>null</code> if either delta value is <= zero. + */ + public static float[] makePick(final float[] m, final int m_offset, + final float x, final float y, + final float deltaX, final float deltaY, + final int[] viewport, final int viewport_offset, + final float[] mat4Tmp) { + if (deltaX <= 0 || deltaY <= 0) { + return null; + } + + /* Translate and scale the picked region to the entire window */ + makeTranslation(m, m_offset, true, + (viewport[2+viewport_offset] - 2 * (x - viewport[0+viewport_offset])) / deltaX, + (viewport[3+viewport_offset] - 2 * (y - viewport[1+viewport_offset])) / deltaY, + 0); + makeScale(mat4Tmp, true, + viewport[2+viewport_offset] / deltaX, viewport[3+viewport_offset] / deltaY, 1.0f); + multMatrix(m, m_offset, mat4Tmp, 0); + return m; + } + + /** + * Transpose the given matrix. + * + * @param msrc 4x4 matrix in column-major order, the source + * @param msrc_offset offset in given array <i>msrc</i>, i.e. start of the 4x4 matrix + * @param mres 4x4 matrix in column-major order, the result + * @param mres_offset offset in given array <i>mres</i>, i.e. start of the 4x4 matrix + * @return given result matrix <i>mres</i> for chaining + */ + public static float[] transposeMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset) { + mres[mres_offset+0] = msrc[msrc_offset+0*4]; + mres[mres_offset+1] = msrc[msrc_offset+1*4]; + mres[mres_offset+2] = msrc[msrc_offset+2*4]; + mres[mres_offset+3] = msrc[msrc_offset+3*4]; + + final int i4_1 = 1*4; + mres[mres_offset+0+i4_1] = msrc[msrc_offset+1+0*4]; + mres[mres_offset+1+i4_1] = msrc[msrc_offset+1+1*4]; + mres[mres_offset+2+i4_1] = msrc[msrc_offset+1+2*4]; + mres[mres_offset+3+i4_1] = msrc[msrc_offset+1+3*4]; + + final int i4_2 = 2*4; + mres[mres_offset+0+i4_2] = msrc[msrc_offset+2+0*4]; + mres[mres_offset+1+i4_2] = msrc[msrc_offset+2+1*4]; + mres[mres_offset+2+i4_2] = msrc[msrc_offset+2+2*4]; + mres[mres_offset+3+i4_2] = msrc[msrc_offset+2+3*4]; + + final int i4_3 = 3*4; + mres[mres_offset+0+i4_3] = msrc[msrc_offset+3+0*4]; + mres[mres_offset+1+i4_3] = msrc[msrc_offset+3+1*4]; + mres[mres_offset+2+i4_3] = msrc[msrc_offset+3+2*4]; + mres[mres_offset+3+i4_3] = msrc[msrc_offset+3+3*4]; + + return mres; + } + + /** + * Transpose the given matrix. + * + * @param msrc 4x4 matrix in column-major order, the source + * @param mres 4x4 matrix in column-major order, the result + * @return given result matrix <i>mres</i> for chaining + */ + public static float[] transposeMatrix(final float[] msrc, final float[] mres) { + mres[0] = msrc[0*4]; + mres[1] = msrc[1*4]; + mres[2] = msrc[2*4]; + mres[3] = msrc[3*4]; + + final int i4_1 = 1*4; + mres[0+i4_1] = msrc[1+0*4]; + mres[1+i4_1] = msrc[1+1*4]; + mres[2+i4_1] = msrc[1+2*4]; + mres[3+i4_1] = msrc[1+3*4]; + + final int i4_2 = 2*4; + mres[0+i4_2] = msrc[2+0*4]; + mres[1+i4_2] = msrc[2+1*4]; + mres[2+i4_2] = msrc[2+2*4]; + mres[3+i4_2] = msrc[2+3*4]; + + final int i4_3 = 3*4; + mres[0+i4_3] = msrc[3+0*4]; + mres[1+i4_3] = msrc[3+1*4]; + mres[2+i4_3] = msrc[3+2*4]; + mres[3+i4_3] = msrc[3+3*4]; + + return mres; + } + + /** + * Returns the determinant of the given matrix + * @param m 4x4 matrix in column-major order, the source + * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 matrix + * @return the matrix determinant + */ + public static float matrixDeterminant(final float[] m, final int m_offset) { + float a11 = m[ 1+4*1 + m_offset ]; + float a21 = m[ 2+4*1 + m_offset ]; + float a31 = m[ 3+4*1 + m_offset ]; + float a12 = m[ 1+4*2 + m_offset ]; + float a22 = m[ 2+4*2 + m_offset ]; + float a32 = m[ 3+4*2 + m_offset ]; + float a13 = m[ 1+4*3 + m_offset ]; + float a23 = m[ 2+4*3 + m_offset ]; + float a33 = m[ 3+4*3 + m_offset ]; + + float ret = 0; + ret += m[ 0 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a11 = m[ 1+4*0 + m_offset ]; + a21 = m[ 2+4*0 + m_offset ]; + a31 = m[ 3+4*0 + m_offset ]; + ret -= m[ 0+4*1 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a12 = m[ 1+4*1 + m_offset ]; + a22 = m[ 2+4*1 + m_offset ]; + a32 = m[ 3+4*1 + m_offset ]; + ret += m[ 0+4*2 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a13 = m[ 1+4*2 + m_offset ]; + a23 = m[ 2+4*2 + m_offset ]; + a33 = m[ 3+4*2 + m_offset ]; + ret -= m[ 0+4*3 + m_offset ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + return ret; + } + + /** + * Returns the determinant of the given matrix + * @param m 4x4 matrix in column-major order, the source + * @return the matrix determinant + */ + public static float matrixDeterminant(final float[] m) { + float a11 = m[ 1+4*1 ]; + float a21 = m[ 2+4*1 ]; + float a31 = m[ 3+4*1 ]; + float a12 = m[ 1+4*2 ]; + float a22 = m[ 2+4*2 ]; + float a32 = m[ 3+4*2 ]; + float a13 = m[ 1+4*3 ]; + float a23 = m[ 2+4*3 ]; + float a33 = m[ 3+4*3 ]; + + float ret = 0; + ret += m[ 0 ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a11 = m[ 1+4*0 ]; + a21 = m[ 2+4*0 ]; + a31 = m[ 3+4*0 ]; + ret -= m[ 0+4*1 ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a12 = m[ 1+4*1 ]; + a22 = m[ 2+4*1 ]; + a32 = m[ 3+4*1 ]; + ret += m[ 0+4*2 ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + a13 = m[ 1+4*2 ]; + a23 = m[ 2+4*2 ]; + a33 = m[ 3+4*2 ]; + ret -= m[ 0+4*3 ] * ( + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)); + return ret; + } + + /** + * Invert the given matrix. + * <p> + * Returns <code>null</code> if inversion is not possible, + * e.g. matrix is singular due to a bad matrix. + * </p> + * + * @param msrc 4x4 matrix in column-major order, the source + * @param msrc_offset offset in given array <i>msrc</i>, i.e. start of the 4x4 matrix + * @param mres 4x4 matrix in column-major order, the result - may be <code>msrc</code> (in-place) + * @param mres_offset offset in given array <i>mres</i>, i.e. start of the 4x4 matrix - may be <code>msrc_offset</code> (in-place) + * @return given result matrix <i>mres</i> for chaining if successful, otherwise <code>null</code>. See above. + */ + public static float[] invertMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset) { + final float scale; + { + float max = Math.abs(msrc[0]); + + for( int i = 1; i < 16; i++ ) { + final float a = Math.abs(msrc[i]); + if( a > max ) max = a; + } + if( 0 == max ) { + return null; + } + scale = 1.0f/max; + } + + final float a11 = msrc[0+4*0+msrc_offset]*scale; + final float a21 = msrc[1+4*0+msrc_offset]*scale; + final float a31 = msrc[2+4*0+msrc_offset]*scale; + final float a41 = msrc[3+4*0+msrc_offset]*scale; + final float a12 = msrc[0+4*1+msrc_offset]*scale; + final float a22 = msrc[1+4*1+msrc_offset]*scale; + final float a32 = msrc[2+4*1+msrc_offset]*scale; + final float a42 = msrc[3+4*1+msrc_offset]*scale; + final float a13 = msrc[0+4*2+msrc_offset]*scale; + final float a23 = msrc[1+4*2+msrc_offset]*scale; + final float a33 = msrc[2+4*2+msrc_offset]*scale; + final float a43 = msrc[3+4*2+msrc_offset]*scale; + final float a14 = msrc[0+4*3+msrc_offset]*scale; + final float a24 = msrc[1+4*3+msrc_offset]*scale; + final float a34 = msrc[2+4*3+msrc_offset]*scale; + final float a44 = msrc[3+4*3+msrc_offset]*scale; + + final float m11 = + a22*(a33*a44 - a34*a43) - a23*(a32*a44 - a34*a42) + a24*(a32*a43 - a33*a42); + final float m12 = -( + a21*(a33*a44 - a34*a43) - a23*(a31*a44 - a34*a41) + a24*(a31*a43 - a33*a41)); + final float m13 = + a21*(a32*a44 - a34*a42) - a22*(a31*a44 - a34*a41) + a24*(a31*a42 - a32*a41); + final float m14 = -( + a21*(a32*a43 - a33*a42) - a22*(a31*a43 - a33*a41) + a23*(a31*a42 - a32*a41)); + final float m21 = -( + a12*(a33*a44 - a34*a43) - a13*(a32*a44 - a34*a42) + a14*(a32*a43 - a33*a42)); + final float m22 = + a11*(a33*a44 - a34*a43) - a13*(a31*a44 - a34*a41) + a14*(a31*a43 - a33*a41); + final float m23 = -( + a11*(a32*a44 - a34*a42) - a12*(a31*a44 - a34*a41) + a14*(a31*a42 - a32*a41)); + final float m24 = + a11*(a32*a43 - a33*a42) - a12*(a31*a43 - a33*a41) + a13*(a31*a42 - a32*a41); + final float m31 = + a12*(a23*a44 - a24*a43) - a13*(a22*a44 - a24*a42) + a14*(a22*a43 - a23*a42); + final float m32 = -( + a11*(a23*a44 - a24*a43) - a13*(a21*a44 - a24*a41) + a14*(a21*a43 - a23*a41)); + final float m33 = + a11*(a22*a44 - a24*a42) - a12*(a21*a44 - a24*a41) + a14*(a21*a42 - a22*a41); + final float m34 = -( + a11*(a22*a43 - a23*a42) - a12*(a21*a43 - a23*a41) + a13*(a21*a42 - a22*a41)); + final float m41 = -( + a12*(a23*a34 - a24*a33) - a13*(a22*a34 - a24*a32) + a14*(a22*a33 - a23*a32)); + final float m42 = + a11*(a23*a34 - a24*a33) - a13*(a21*a34 - a24*a31) + a14*(a21*a33 - a23*a31); + final float m43 = -( + a11*(a22*a34 - a24*a32) - a12*(a21*a34 - a24*a31) + a14*(a21*a32 - a22*a31)); + final float m44 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31); + + final float det = (a11*m11 + a12*m12 + a13*m13 + a14*m14)/scale; + + if( 0 == det ) { + return null; + } + + mres[0+4*0+mres_offset] = m11 / det; + mres[1+4*0+mres_offset] = m12 / det; + mres[2+4*0+mres_offset] = m13 / det; + mres[3+4*0+mres_offset] = m14 / det; + mres[0+4*1+mres_offset] = m21 / det; + mres[1+4*1+mres_offset] = m22 / det; + mres[2+4*1+mres_offset] = m23 / det; + mres[3+4*1+mres_offset] = m24 / det; + mres[0+4*2+mres_offset] = m31 / det; + mres[1+4*2+mres_offset] = m32 / det; + mres[2+4*2+mres_offset] = m33 / det; + mres[3+4*2+mres_offset] = m34 / det; + mres[0+4*3+mres_offset] = m41 / det; + mres[1+4*3+mres_offset] = m42 / det; + mres[2+4*3+mres_offset] = m43 / det; + mres[3+4*3+mres_offset] = m44 / det; + return mres; + } + + /** + * Invert the given matrix. + * <p> + * Returns <code>null</code> if inversion is not possible, + * e.g. matrix is singular due to a bad matrix. + * </p> + * + * @param msrc 4x4 matrix in column-major order, the source + * @param mres 4x4 matrix in column-major order, the result - may be <code>msrc</code> (in-place) + * @return given result matrix <i>mres</i> for chaining if successful, otherwise <code>null</code>. See above. + */ + public static float[] invertMatrix(final float[] msrc, final float[] mres) { + final float scale; + { + float max = Math.abs(msrc[0]); + + for( int i = 1; i < 16; i++ ) { + final float a = Math.abs(msrc[i]); + if( a > max ) max = a; + } + if( 0 == max ) { + return null; + } + scale = 1.0f/max; + } + + final float a11 = msrc[0+4*0]*scale; + final float a21 = msrc[1+4*0]*scale; + final float a31 = msrc[2+4*0]*scale; + final float a41 = msrc[3+4*0]*scale; + final float a12 = msrc[0+4*1]*scale; + final float a22 = msrc[1+4*1]*scale; + final float a32 = msrc[2+4*1]*scale; + final float a42 = msrc[3+4*1]*scale; + final float a13 = msrc[0+4*2]*scale; + final float a23 = msrc[1+4*2]*scale; + final float a33 = msrc[2+4*2]*scale; + final float a43 = msrc[3+4*2]*scale; + final float a14 = msrc[0+4*3]*scale; + final float a24 = msrc[1+4*3]*scale; + final float a34 = msrc[2+4*3]*scale; + final float a44 = msrc[3+4*3]*scale; + + final float m11 = + a22*(a33*a44 - a34*a43) - a23*(a32*a44 - a34*a42) + a24*(a32*a43 - a33*a42); + final float m12 = -( + a21*(a33*a44 - a34*a43) - a23*(a31*a44 - a34*a41) + a24*(a31*a43 - a33*a41)); + final float m13 = + a21*(a32*a44 - a34*a42) - a22*(a31*a44 - a34*a41) + a24*(a31*a42 - a32*a41); + final float m14 = -( + a21*(a32*a43 - a33*a42) - a22*(a31*a43 - a33*a41) + a23*(a31*a42 - a32*a41)); + final float m21 = -( + a12*(a33*a44 - a34*a43) - a13*(a32*a44 - a34*a42) + a14*(a32*a43 - a33*a42)); + final float m22 = + a11*(a33*a44 - a34*a43) - a13*(a31*a44 - a34*a41) + a14*(a31*a43 - a33*a41); + final float m23 = -( + a11*(a32*a44 - a34*a42) - a12*(a31*a44 - a34*a41) + a14*(a31*a42 - a32*a41)); + final float m24 = + a11*(a32*a43 - a33*a42) - a12*(a31*a43 - a33*a41) + a13*(a31*a42 - a32*a41); + final float m31 = + a12*(a23*a44 - a24*a43) - a13*(a22*a44 - a24*a42) + a14*(a22*a43 - a23*a42); + final float m32 = -( + a11*(a23*a44 - a24*a43) - a13*(a21*a44 - a24*a41) + a14*(a21*a43 - a23*a41)); + final float m33 = + a11*(a22*a44 - a24*a42) - a12*(a21*a44 - a24*a41) + a14*(a21*a42 - a22*a41); + final float m34 = -( + a11*(a22*a43 - a23*a42) - a12*(a21*a43 - a23*a41) + a13*(a21*a42 - a22*a41)); + final float m41 = -( + a12*(a23*a34 - a24*a33) - a13*(a22*a34 - a24*a32) + a14*(a22*a33 - a23*a32)); + final float m42 = + a11*(a23*a34 - a24*a33) - a13*(a21*a34 - a24*a31) + a14*(a21*a33 - a23*a31); + final float m43 = -( + a11*(a22*a34 - a24*a32) - a12*(a21*a34 - a24*a31) + a14*(a21*a32 - a22*a31)); + final float m44 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31); + + final float det = (a11*m11 + a12*m12 + a13*m13 + a14*m14)/scale; + + if( 0 == det ) { + return null; + } + + mres[0+4*0] = m11 / det; + mres[1+4*0] = m12 / det; + mres[2+4*0] = m13 / det; + mres[3+4*0] = m14 / det; + mres[0+4*1] = m21 / det; + mres[1+4*1] = m22 / det; + mres[2+4*1] = m23 / det; + mres[3+4*1] = m24 / det; + mres[0+4*2] = m31 / det; + mres[1+4*2] = m32 / det; + mres[2+4*2] = m33 / det; + mres[3+4*2] = m34 / det; + mres[0+4*3] = m41 / det; + mres[1+4*3] = m42 / det; + mres[2+4*3] = m43 / det; + mres[3+4*3] = m44 / det; + return mres; + } + + /** + * Map object coordinates to window coordinates. + * <p> + * Traditional <code>gluProject</code> implementation. + * </p> + * + * @param objx + * @param objy + * @param objz + * @param modelMatrix 4x4 modelview matrix + * @param modelMatrix_offset + * @param projMatrix 4x4 projection matrix + * @param projMatrix_offset + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param win_pos 3 component window coordinate, the result + * @param win_pos_offset + * @param vec4Tmp1 4 component vector for temp storage + * @param vec4Tmp2 4 component vector for temp storage + * @return true if successful, otherwise false (z is 1) + */ + public static boolean mapObjToWinCoords(final float objx, final float objy, final float objz, + final float[] modelMatrix, final int modelMatrix_offset, + final float[] projMatrix, final int projMatrix_offset, + final int[] viewport, final int viewport_offset, + final float[] win_pos, final int win_pos_offset, + final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) { + vec4Tmp1[0] = objx; + vec4Tmp1[1] = objy; + vec4Tmp1[2] = objz; + vec4Tmp1[3] = 1.0f; + + // vec4Tmp2 = Mv * o + // vec4Tmp1 = P * vec4Tmp2 + // vec4Tmp1 = P * ( Mv * o ) + // vec4Tmp1 = P * Mv * o + multMatrixVec(modelMatrix, modelMatrix_offset, vec4Tmp1, 0, vec4Tmp2, 0); + multMatrixVec(projMatrix, projMatrix_offset, vec4Tmp2, 0, vec4Tmp1, 0); + + if (vec4Tmp1[3] == 0.0f) { + return false; + } + + vec4Tmp1[3] = (1.0f / vec4Tmp1[3]) * 0.5f; + + // Map x, y and z to range 0-1 + vec4Tmp1[0] = vec4Tmp1[0] * vec4Tmp1[3] + 0.5f; + vec4Tmp1[1] = vec4Tmp1[1] * vec4Tmp1[3] + 0.5f; + vec4Tmp1[2] = vec4Tmp1[2] * vec4Tmp1[3] + 0.5f; + + // Map x,y to viewport + win_pos[0+win_pos_offset] = vec4Tmp1[0] * viewport[2+viewport_offset] + viewport[0+viewport_offset]; + win_pos[1+win_pos_offset] = vec4Tmp1[1] * viewport[3+viewport_offset] + viewport[1+viewport_offset]; + win_pos[2+win_pos_offset] = vec4Tmp1[2]; + + return true; + } + + /** + * Map object coordinates to window coordinates. + * <p> + * Traditional <code>gluProject</code> implementation. + * </p> + * + * @param objx + * @param objy + * @param objz + * @param mat4PMv [projection] x [modelview] matrix, i.e. P x Mv + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param win_pos 3 component window coordinate, the result + * @param win_pos_offset + * @param vec4Tmp1 4 component vector for temp storage + * @param vec4Tmp2 4 component vector for temp storage + * @return true if successful, otherwise false (z is 1) + */ + public static boolean mapObjToWinCoords(final float objx, final float objy, final float objz, + final float[/*16*/] mat4PMv, + final int[] viewport, final int viewport_offset, + final float[] win_pos, final int win_pos_offset, + final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) { + vec4Tmp2[0] = objx; + vec4Tmp2[1] = objy; + vec4Tmp2[2] = objz; + vec4Tmp2[3] = 1.0f; + + // vec4Tmp1 = P * Mv * o + multMatrixVec(mat4PMv, vec4Tmp2, vec4Tmp1); + + if (vec4Tmp1[3] == 0.0f) { + return false; + } + + vec4Tmp1[3] = (1.0f / vec4Tmp1[3]) * 0.5f; + + // Map x, y and z to range 0-1 + vec4Tmp1[0] = vec4Tmp1[0] * vec4Tmp1[3] + 0.5f; + vec4Tmp1[1] = vec4Tmp1[1] * vec4Tmp1[3] + 0.5f; + vec4Tmp1[2] = vec4Tmp1[2] * vec4Tmp1[3] + 0.5f; + + // Map x,y to viewport + win_pos[0+win_pos_offset] = vec4Tmp1[0] * viewport[2+viewport_offset] + viewport[0+viewport_offset]; + win_pos[1+win_pos_offset] = vec4Tmp1[1] * viewport[3+viewport_offset] + viewport[1+viewport_offset]; + win_pos[2+win_pos_offset] = vec4Tmp1[2]; + + return true; + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param modelMatrix 4x4 modelview matrix + * @param modelMatrix_offset + * @param projMatrix 4x4 projection matrix + * @param projMatrix_offset + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param obj_pos 3 component object coordinate, the result + * @param obj_pos_offset + * @param mat4Tmp1 16 component matrix for temp storage + * @param mat4Tmp2 16 component matrix for temp storage + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public static boolean mapWinToObjCoords(final float winx, final float winy, final float winz, + final float[] modelMatrix, final int modelMatrix_offset, + final float[] projMatrix, final int projMatrix_offset, + final int[] viewport, final int viewport_offset, + final float[] obj_pos, final int obj_pos_offset, + final float[/*16*/] mat4Tmp1, final float[/*16*/] mat4Tmp2) { + // mat4Tmp1 = P x Mv + multMatrix(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, mat4Tmp1, 0); + + // mat4Tmp1 = Inv(P x Mv) + if ( null == invertMatrix(mat4Tmp1, mat4Tmp1) ) { + return false; + } + mat4Tmp2[0] = winx; + mat4Tmp2[1] = winy; + mat4Tmp2[2] = winz; + mat4Tmp2[3] = 1.0f; + + // Map x and y from window coordinates + mat4Tmp2[0] = (mat4Tmp2[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset]; + mat4Tmp2[1] = (mat4Tmp2[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset]; + + // Map to range -1 to 1 + mat4Tmp2[0] = mat4Tmp2[0] * 2 - 1; + mat4Tmp2[1] = mat4Tmp2[1] * 2 - 1; + mat4Tmp2[2] = mat4Tmp2[2] * 2 - 1; + + final int raw_off = 4; + // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2 + multMatrixVec(mat4Tmp1, 0, mat4Tmp2, 0, mat4Tmp2, raw_off); + + if (mat4Tmp2[3+raw_off] == 0.0) { + return false; + } + + mat4Tmp2[3+raw_off] = 1.0f / mat4Tmp2[3+raw_off]; + + obj_pos[0+obj_pos_offset] = mat4Tmp2[0+raw_off] * mat4Tmp2[3+raw_off]; + obj_pos[1+obj_pos_offset] = mat4Tmp2[1+raw_off] * mat4Tmp2[3+raw_off]; + obj_pos[2+obj_pos_offset] = mat4Tmp2[2+raw_off] * mat4Tmp2[3+raw_off]; + + return true; + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param mat4PMvI inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv) + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param obj_pos 3 component object coordinate, the result + * @param obj_pos_offset + * @param vec4Tmp1 4 component vector for temp storage + * @param vec4Tmp2 4 component vector for temp storage + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public static boolean mapWinToObjCoords(final float winx, final float winy, final float winz, + final float[/*16*/] mat4PMvI, + final int[] viewport, final int viewport_offset, + final float[] obj_pos, final int obj_pos_offset, + final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) { + vec4Tmp1[0] = winx; + vec4Tmp1[1] = winy; + vec4Tmp1[2] = winz; + vec4Tmp1[3] = 1.0f; + + // Map x and y from window coordinates + vec4Tmp1[0] = (vec4Tmp1[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset]; + vec4Tmp1[1] = (vec4Tmp1[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset]; + + // Map to range -1 to 1 + vec4Tmp1[0] = vec4Tmp1[0] * 2 - 1; + vec4Tmp1[1] = vec4Tmp1[1] * 2 - 1; + vec4Tmp1[2] = vec4Tmp1[2] * 2 - 1; + + // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2 + multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2); + + if (vec4Tmp2[3] == 0.0) { + return false; + } + + vec4Tmp2[3] = 1.0f / vec4Tmp2[3]; + + obj_pos[0+obj_pos_offset] = vec4Tmp2[0] * vec4Tmp2[3]; + obj_pos[1+obj_pos_offset] = vec4Tmp2[1] * vec4Tmp2[3]; + obj_pos[2+obj_pos_offset] = vec4Tmp2[2] * vec4Tmp2[3]; + + return true; + } + + /** + * Map two window coordinates to two object coordinates, + * distinguished by their z component. + * + * @param winx + * @param winy + * @param winz1 + * @param winz2 + * @param mat4PMvI inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv) + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param obj1_pos 3 component object coordinate, the result for winz1 + * @param obj1_pos_offset + * @param obj2_pos 3 component object coordinate, the result for winz2 + * @param obj2_pos_offset + * @param vec4Tmp1 4 component vector for temp storage + * @param vec4Tmp2 4 component vector for temp storage + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public static boolean mapWinToObjCoords(final float winx, final float winy, final float winz1, final float winz2, + final float[/*16*/] mat4PMvI, + final int[] viewport, final int viewport_offset, + final float[] obj1_pos, final int obj1_pos_offset, + final float[] obj2_pos, final int obj2_pos_offset, + final float[/*4*/] vec4Tmp1, final float[/*4*/] vec4Tmp2) { + vec4Tmp1[0] = winx; + vec4Tmp1[1] = winy; + vec4Tmp1[3] = 1.0f; + + // Map x and y from window coordinates + vec4Tmp1[0] = (vec4Tmp1[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset]; + vec4Tmp1[1] = (vec4Tmp1[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset]; + + // Map to range -1 to 1 + vec4Tmp1[0] = vec4Tmp1[0] * 2 - 1; + vec4Tmp1[1] = vec4Tmp1[1] * 2 - 1; + + // + // winz1 + // + vec4Tmp1[2] = winz1; + vec4Tmp1[2] = vec4Tmp1[2] * 2 - 1; + + // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2 + multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2); + + if (vec4Tmp2[3] == 0.0) { + return false; + } + + vec4Tmp2[3] = 1.0f / vec4Tmp2[3]; + + obj1_pos[0+obj1_pos_offset] = vec4Tmp2[0] * vec4Tmp2[3]; + obj1_pos[1+obj1_pos_offset] = vec4Tmp2[1] * vec4Tmp2[3]; + obj1_pos[2+obj1_pos_offset] = vec4Tmp2[2] * vec4Tmp2[3]; + + // + // winz2 + // + vec4Tmp1[2] = winz2; + vec4Tmp1[2] = vec4Tmp1[2] * 2 - 1; + + // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2 + multMatrixVec(mat4PMvI, vec4Tmp1, vec4Tmp2); + + if (vec4Tmp2[3] == 0.0) { + return false; + } + + vec4Tmp2[3] = 1.0f / vec4Tmp2[3]; + + obj2_pos[0+obj2_pos_offset] = vec4Tmp2[0] * vec4Tmp2[3]; + obj2_pos[1+obj2_pos_offset] = vec4Tmp2[1] * vec4Tmp2[3]; + obj2_pos[2+obj2_pos_offset] = vec4Tmp2[2] * vec4Tmp2[3]; + + return true; + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject4</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param clipw + * @param modelMatrix 4x4 modelview matrix + * @param modelMatrix_offset + * @param projMatrix 4x4 projection matrix + * @param projMatrix_offset + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param near + * @param far + * @param obj_pos 4 component object coordinate, the result + * @param obj_pos_offset + * @param mat4Tmp1 16 component matrix for temp storage + * @param mat4Tmp2 16 component matrix for temp storage + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public static boolean mapWinToObjCoords(final float winx, final float winy, final float winz, final float clipw, + final float[] modelMatrix, final int modelMatrix_offset, + final float[] projMatrix, final int projMatrix_offset, + final int[] viewport, final int viewport_offset, + final float near, final float far, + final float[] obj_pos, final int obj_pos_offset, + final float[/*16*/] mat4Tmp1, final float[/*16*/] mat4Tmp2) { + // mat4Tmp1 = P x Mv + multMatrix(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, mat4Tmp1, 0); + + // mat4Tmp1 = Inv(P x Mv) + if ( null == invertMatrix(mat4Tmp1, mat4Tmp1) ) { + return false; + } + + mat4Tmp2[0] = winx; + mat4Tmp2[1] = winy; + mat4Tmp2[2] = winz; + mat4Tmp2[3] = 1.0f; + + // Map x and y from window coordinates + mat4Tmp2[0] = (mat4Tmp2[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset]; + mat4Tmp2[1] = (mat4Tmp2[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset]; + mat4Tmp2[2] = (mat4Tmp2[2] - near) / (far - near); + + // Map to range -1 to 1 + mat4Tmp2[0] = mat4Tmp2[0] * 2 - 1; + mat4Tmp2[1] = mat4Tmp2[1] * 2 - 1; + mat4Tmp2[2] = mat4Tmp2[2] * 2 - 1; + + final int raw_off = 4; + // object raw coords = Inv(P x Mv) * winPos -> mat4Tmp2 + multMatrixVec(mat4Tmp1, 0, mat4Tmp2, 0, mat4Tmp2, raw_off); + + if (mat4Tmp2[3+raw_off] == 0.0) { + return false; + } + + mat4Tmp2[3+raw_off] = 1.0f / mat4Tmp2[3+raw_off]; + + obj_pos[0+obj_pos_offset] = mat4Tmp2[0+raw_off]; + obj_pos[1+obj_pos_offset] = mat4Tmp2[1+raw_off]; + obj_pos[2+obj_pos_offset] = mat4Tmp2[2+raw_off]; + obj_pos[3+obj_pos_offset] = mat4Tmp2[3+raw_off]; + + return true; + } + + + /** + * Map two window coordinates w/ shared X/Y and distinctive Z + * to a {@link Ray}. The resulting {@link Ray} maybe used for <i>picking</i> + * using a {@link AABBox#getRayIntersection(Ray, float[]) bounding box}. + * <p> + * Notes for picking <i>winz0</i> and <i>winz1</i>: + * <ul> + * <li>see {@link #getZBufferEpsilon(int, float, float)}</li> + * <li>see {@link #getZBufferValue(int, float, float, float)}</li> + * <li>see {@link #getOrthoWinZ(float, float, float)}</li> + * </ul> + * </p> + * @param winx + * @param winy + * @param winz0 + * @param winz1 + * @param modelMatrix 4x4 modelview matrix + * @param modelMatrix_offset + * @param projMatrix 4x4 projection matrix + * @param projMatrix_offset + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param ray storage for the resulting {@link Ray} + * @param mat4Tmp1 16 component matrix for temp storage + * @param mat4Tmp2 16 component matrix for temp storage + * @param vec4Tmp2 4 component vector for temp storage + * @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity) + */ + public static boolean mapWinToRay(final float winx, final float winy, final float winz0, final float winz1, + final float[] modelMatrix, final int modelMatrix_offset, + final float[] projMatrix, final int projMatrix_offset, + final int[] viewport, final int viewport_offset, + final Ray ray, + final float[/*16*/] mat4Tmp1, final float[/*16*/] mat4Tmp2, final float[/*4*/] vec4Tmp2) { + // mat4Tmp1 = P x Mv + multMatrix(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, mat4Tmp1, 0); + + // mat4Tmp1 = Inv(P x Mv) + if ( null == invertMatrix(mat4Tmp1, mat4Tmp1) ) { + return false; + } + if( mapWinToObjCoords(winx, winy, winz0, winz1, mat4Tmp1, + viewport, viewport_offset, + ray.orig, 0, ray.dir, 0, + mat4Tmp2, vec4Tmp2) ) { + VectorUtil.normalizeVec3( VectorUtil.subVec3(ray.dir, ray.dir, ray.orig) ); + return true; + } else { + return false; + } } /** @@ -356,17 +1476,63 @@ public class FloatUtil { * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order * @param d result a*b in column-major order + * @return given result matrix <i>d</i> for chaining */ - public static final void multMatrixf(final float[] a, int a_off, final float[] b, int b_off, FloatBuffer d) { - final int dP = d.position(); - for (int i = 0; i < 4; i++) { - // one row in column-major order - final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4]; // row-i of a - d.put(dP+i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ); - d.put(dP+i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ); - d.put(dP+i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ); - d.put(dP+i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ); - } + public static float[] multMatrix(final float[] a, final int a_off, final float[] b, final int b_off, final float[] d, final int d_off) { + final float b00 = b[b_off+0+0*4]; + final float b10 = b[b_off+1+0*4]; + final float b20 = b[b_off+2+0*4]; + final float b30 = b[b_off+3+0*4]; + final float b01 = b[b_off+0+1*4]; + final float b11 = b[b_off+1+1*4]; + final float b21 = b[b_off+2+1*4]; + final float b31 = b[b_off+3+1*4]; + final float b02 = b[b_off+0+2*4]; + final float b12 = b[b_off+1+2*4]; + final float b22 = b[b_off+2+2*4]; + final float b32 = b[b_off+3+2*4]; + final float b03 = b[b_off+0+3*4]; + final float b13 = b[b_off+1+3*4]; + final float b23 = b[b_off+2+3*4]; + final float b33 = b[b_off+3+3*4]; + + float ai0=a[a_off+ 0*4]; // row-0 of a + float ai1=a[a_off+ 1*4]; + float ai2=a[a_off+ 2*4]; + float ai3=a[a_off+ 3*4]; + d[d_off+ 0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[d_off+ 1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[d_off+ 2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[d_off+ 3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+1+0*4]; // row-1 of a + ai1=a[a_off+1+1*4]; + ai2=a[a_off+1+2*4]; + ai3=a[a_off+1+3*4]; + d[d_off+1+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[d_off+1+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[d_off+1+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[d_off+1+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+2+0*4]; // row-2 of a + ai1=a[a_off+2+1*4]; + ai2=a[a_off+2+2*4]; + ai3=a[a_off+2+3*4]; + d[d_off+2+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[d_off+2+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[d_off+2+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[d_off+2+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+3+0*4]; // row-3 of a + ai1=a[a_off+3+1*4]; + ai2=a[a_off+3+2*4]; + ai3=a[a_off+3+3*4]; + d[d_off+3+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[d_off+3+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[d_off+3+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[d_off+3+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + return d; } /** @@ -374,75 +1540,189 @@ public class FloatUtil { * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order * @param d result a*b in column-major order + * @return given result matrix <i>d</i> for chaining */ - public static final void multMatrixf(final FloatBuffer a, final float[] b, int b_off, FloatBuffer d) { - final int aP = a.position(); - final int dP = d.position(); - for (int i = 0; i < 4; i++) { - // one row in column-major order - final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a - d.put(dP+i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ); - d.put(dP+i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ); - d.put(dP+i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ); - d.put(dP+i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ); - } + public static float[] multMatrix(final float[] a, final float[] b, final float[] d) { + final float b00 = b[0+0*4]; + final float b10 = b[1+0*4]; + final float b20 = b[2+0*4]; + final float b30 = b[3+0*4]; + final float b01 = b[0+1*4]; + final float b11 = b[1+1*4]; + final float b21 = b[2+1*4]; + final float b31 = b[3+1*4]; + final float b02 = b[0+2*4]; + final float b12 = b[1+2*4]; + final float b22 = b[2+2*4]; + final float b32 = b[3+2*4]; + final float b03 = b[0+3*4]; + final float b13 = b[1+3*4]; + final float b23 = b[2+3*4]; + final float b33 = b[3+3*4]; + + float ai0=a[ 0*4]; // row-0 of a + float ai1=a[ 1*4]; + float ai2=a[ 2*4]; + float ai3=a[ 3*4]; + d[ 0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[ 1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[ 2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[ 3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[1+0*4]; // row-1 of a + ai1=a[1+1*4]; + ai2=a[1+2*4]; + ai3=a[1+3*4]; + d[1+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[1+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[1+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[1+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[2+0*4]; // row-2 of a + ai1=a[2+1*4]; + ai2=a[2+2*4]; + ai3=a[2+3*4]; + d[2+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[2+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[2+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[2+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[3+0*4]; // row-3 of a + ai1=a[3+1*4]; + ai2=a[3+2*4]; + ai3=a[3+3*4]; + d[3+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + d[3+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + d[3+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + d[3+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + return d; } /** * Multiply matrix: [a] = [a] x [b] * @param a 4x4 matrix in column-major order (also result) * @param b 4x4 matrix in column-major order + * @return given result matrix <i>a</i> for chaining */ - public static final void multMatrixf(final FloatBuffer a, final float[] b, int b_off) { - final int aP = a.position(); - for (int i = 0; i < 4; i++) { - // one row in column-major order - final int aP_i = aP+i; - final float ai0=a.get(aP_i+0*4), ai1=a.get(aP_i+1*4), ai2=a.get(aP_i+2*4), ai3=a.get(aP_i+3*4); // row-i of a - a.put(aP_i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ); - a.put(aP_i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ); - a.put(aP_i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ); - a.put(aP_i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ); - } - } + public static float[] multMatrix(final float[] a, final int a_off, final float[] b, final int b_off) { + final float b00 = b[b_off+0+0*4]; + final float b10 = b[b_off+1+0*4]; + final float b20 = b[b_off+2+0*4]; + final float b30 = b[b_off+3+0*4]; + final float b01 = b[b_off+0+1*4]; + final float b11 = b[b_off+1+1*4]; + final float b21 = b[b_off+2+1*4]; + final float b31 = b[b_off+3+1*4]; + final float b02 = b[b_off+0+2*4]; + final float b12 = b[b_off+1+2*4]; + final float b22 = b[b_off+2+2*4]; + final float b32 = b[b_off+3+2*4]; + final float b03 = b[b_off+0+3*4]; + final float b13 = b[b_off+1+3*4]; + final float b23 = b[b_off+2+3*4]; + final float b33 = b[b_off+3+3*4]; + + float ai0=a[a_off+ 0*4]; // row-0 of a + float ai1=a[a_off+ 1*4]; + float ai2=a[a_off+ 2*4]; + float ai3=a[a_off+ 3*4]; + a[a_off+ 0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[a_off+ 1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[a_off+ 2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[a_off+ 3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+1+0*4]; // row-1 of a + ai1=a[a_off+1+1*4]; + ai2=a[a_off+1+2*4]; + ai3=a[a_off+1+3*4]; + a[a_off+1+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[a_off+1+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[a_off+1+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[a_off+1+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+2+0*4]; // row-2 of a + ai1=a[a_off+2+1*4]; + ai2=a[a_off+2+2*4]; + ai3=a[a_off+2+3*4]; + a[a_off+2+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[a_off+2+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[a_off+2+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[a_off+2+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[a_off+3+0*4]; // row-3 of a + ai1=a[a_off+3+1*4]; + ai2=a[a_off+3+2*4]; + ai3=a[a_off+3+3*4]; + a[a_off+3+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[a_off+3+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[a_off+3+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[a_off+3+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; - /** - * Multiply matrix: [d] = [a] x [b] - * @param a 4x4 matrix in column-major order - * @param b 4x4 matrix in column-major order - * @param d result a*b in column-major order - */ - public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, FloatBuffer d) { - final int aP = a.position(); - final int bP = b.position(); - final int dP = d.position(); - for (int i = 0; i < 4; i++) { - // one row in column-major order - final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a - d.put(dP+i+0*4 , ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) ); - d.put(dP+i+1*4 , ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) ); - d.put(dP+i+2*4 , ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) ); - d.put(dP+i+3*4 , ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ); - } + return a; } /** * Multiply matrix: [a] = [a] x [b] * @param a 4x4 matrix in column-major order (also result) * @param b 4x4 matrix in column-major order + * @return given result matrix <i>a</i> for chaining */ - public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b) { - final int aP = a.position(); - final int bP = b.position(); - for (int i = 0; i < 4; i++) { - // one row in column-major order - final int aP_i = aP+i; - final float ai0=a.get(aP_i+0*4), ai1=a.get(aP_i+1*4), ai2=a.get(aP_i+2*4), ai3=a.get(aP_i+3*4); // row-i of a - a.put(aP_i+0*4 , ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) ); - a.put(aP_i+1*4 , ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) ); - a.put(aP_i+2*4 , ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) ); - a.put(aP_i+3*4 , ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ); - } + public static float[] multMatrix(final float[] a, final float[] b) { + final float b00 = b[0+0*4]; + final float b10 = b[1+0*4]; + final float b20 = b[2+0*4]; + final float b30 = b[3+0*4]; + final float b01 = b[0+1*4]; + final float b11 = b[1+1*4]; + final float b21 = b[2+1*4]; + final float b31 = b[3+1*4]; + final float b02 = b[0+2*4]; + final float b12 = b[1+2*4]; + final float b22 = b[2+2*4]; + final float b32 = b[3+2*4]; + final float b03 = b[0+3*4]; + final float b13 = b[1+3*4]; + final float b23 = b[2+3*4]; + final float b33 = b[3+3*4]; + + float ai0=a[ 0*4]; // row-0 of a + float ai1=a[ 1*4]; + float ai2=a[ 2*4]; + float ai3=a[ 3*4]; + a[ 0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[ 1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[ 2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[ 3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[1+0*4]; // row-1 of a + ai1=a[1+1*4]; + ai2=a[1+2*4]; + ai3=a[1+3*4]; + a[1+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[1+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[1+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[1+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[2+0*4]; // row-2 of a + ai1=a[2+1*4]; + ai2=a[2+2*4]; + ai3=a[2+3*4]; + a[2+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[2+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[2+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[2+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + ai0=a[3+0*4]; // row-3 of a + ai1=a[3+1*4]; + ai2=a[3+2*4]; + ai3=a[3+3*4]; + a[3+0*4] = ai0 * b00 + ai1 * b10 + ai2 * b20 + ai3 * b30 ; + a[3+1*4] = ai0 * b01 + ai1 * b11 + ai2 * b21 + ai3 * b31 ; + a[3+2*4] = ai0 * b02 + ai1 * b12 + ai2 * b22 + ai3 * b32 ; + a[3+3*4] = ai0 * b03 + ai1 * b13 + ai2 * b23 + ai3 * b33 ; + + return a; } /** @@ -450,35 +1730,40 @@ public class FloatUtil { * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order * @param d result a*b in column-major order + * @deprecated use on of the float[] variants */ - public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, float[] d, int d_off) { - final int aP = a.position(); - final int bP = b.position(); + public static void multMatrix(final FloatBuffer a, final FloatBuffer b, final float[] d) { + final int a_off = a.position(); + final int b_off = b.position(); for (int i = 0; i < 4; i++) { // one row in column-major order - final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a - d[d_off+i+0*4] = ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) ; - d[d_off+i+1*4] = ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) ; - d[d_off+i+2*4] = ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) ; - d[d_off+i+3*4] = ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ; + final int a_off_i = a_off+i; + final float ai0=a.get(a_off_i+0*4), ai1=a.get(a_off_i+1*4), ai2=a.get(a_off_i+2*4), ai3=a.get(a_off_i+3*4); // row-i of a + d[i+0*4] = ai0 * b.get(b_off+0+0*4) + ai1 * b.get(b_off+1+0*4) + ai2 * b.get(b_off+2+0*4) + ai3 * b.get(b_off+3+0*4) ; + d[i+1*4] = ai0 * b.get(b_off+0+1*4) + ai1 * b.get(b_off+1+1*4) + ai2 * b.get(b_off+2+1*4) + ai3 * b.get(b_off+3+1*4) ; + d[i+2*4] = ai0 * b.get(b_off+0+2*4) + ai1 * b.get(b_off+1+2*4) + ai2 * b.get(b_off+2+2*4) + ai3 * b.get(b_off+3+2*4) ; + d[i+3*4] = ai0 * b.get(b_off+0+3*4) + ai1 * b.get(b_off+1+3*4) + ai2 * b.get(b_off+2+3*4) + ai3 * b.get(b_off+3+3*4) ; } } /** - * @param m_in 4x4 matrix in column-major order - * @param m_in_off - * @param v_in 4-component column-vector - * @param v_out m_in * v_in + * Multiply matrix: [a] = [a] x [b] + * @param a 4x4 matrix in column-major order (also result) + * @param b 4x4 matrix in column-major order + * @deprecated use on of the float[] variants */ - public static final void multMatrixVecf(float[] m_in, int m_in_off, float[] v_in, int v_in_off, float[] v_out, int v_out_off) { - for (int i = 0; i < 4; i++) { - // (one matrix row in column-major order) X (column vector) - v_out[i + v_out_off] = - v_in[0+v_in_off] * m_in[0*4+i+m_in_off] + - v_in[1+v_in_off] * m_in[1*4+i+m_in_off] + - v_in[2+v_in_off] * m_in[2*4+i+m_in_off] + - v_in[3+v_in_off] * m_in[3*4+i+m_in_off]; - } + public static void multMatrix(final FloatBuffer a, final FloatBuffer b) { + final int a_off = a.position(); + final int b_off = b.position(); + for (int i = 0; i < 4; i++) { + // one row in column-major order + final int a_off_i = a_off+i; + final float ai0=a.get(a_off_i+0*4), ai1=a.get(a_off_i+1*4), ai2=a.get(a_off_i+2*4), ai3=a.get(a_off_i+3*4); // row-i of a + a.put(a_off_i+0*4 , ai0 * b.get(b_off+0+0*4) + ai1 * b.get(b_off+1+0*4) + ai2 * b.get(b_off+2+0*4) + ai3 * b.get(b_off+3+0*4) ); + a.put(a_off_i+1*4 , ai0 * b.get(b_off+0+1*4) + ai1 * b.get(b_off+1+1*4) + ai2 * b.get(b_off+2+1*4) + ai3 * b.get(b_off+3+1*4) ); + a.put(a_off_i+2*4 , ai0 * b.get(b_off+0+2*4) + ai1 * b.get(b_off+1+2*4) + ai2 * b.get(b_off+2+2*4) + ai3 * b.get(b_off+3+2*4) ); + a.put(a_off_i+3*4 , ai0 * b.get(b_off+0+3*4) + ai1 * b.get(b_off+1+3*4) + ai2 * b.get(b_off+2+3*4) + ai3 * b.get(b_off+3+3*4) ); + } } /** @@ -486,68 +1771,70 @@ public class FloatUtil { * @param m_in_off * @param v_in 4-component column-vector * @param v_out m_in * v_in + * @return given result vector <i>v_out</i> for chaining */ - public static final void multMatrixVecf(float[] m_in, float[] v_in, float[] v_out) { - for (int i = 0; i < 4; i++) { + public static float[] multMatrixVec(final float[] m_in, final int m_in_off, + final float[] v_in, final int v_in_off, + final float[] v_out, final int v_out_off) { // (one matrix row in column-major order) X (column vector) - v_out[i] = - v_in[0] * m_in[0*4+i] + - v_in[1] * m_in[1*4+i] + - v_in[2] * m_in[2*4+i] + - v_in[3] * m_in[3*4+i]; - } - } + v_out[0 + v_out_off] = v_in[0+v_in_off] * m_in[0*4+m_in_off ] + v_in[1+v_in_off] * m_in[1*4+m_in_off ] + + v_in[2+v_in_off] * m_in[2*4+m_in_off ] + v_in[3+v_in_off] * m_in[3*4+m_in_off ]; - /** - * @param m_in 4x4 matrix in column-major order - * @param v_in 4-component column-vector - * @param v_out m_in * v_in - */ - public static final void multMatrixVecf(FloatBuffer m_in, float[] v_in, int v_in_off, float[] v_out, int v_out_off) { - final int matrixPos = m_in.position(); - for (int i = 0; i < 4; i++) { - // (one matrix row in column-major order) X (column vector) - v_out[i+v_out_off] = - v_in[0+v_in_off] * m_in.get(0*4+i+matrixPos) + - v_in[1+v_in_off] * m_in.get(1*4+i+matrixPos) + - v_in[2+v_in_off] * m_in.get(2*4+i+matrixPos) + - v_in[3+v_in_off] * m_in.get(3*4+i+matrixPos); - } + final int m_in_off_1 = 1+m_in_off; + v_out[1 + v_out_off] = v_in[0+v_in_off] * m_in[0*4+m_in_off_1] + v_in[1+v_in_off] * m_in[1*4+m_in_off_1] + + v_in[2+v_in_off] * m_in[2*4+m_in_off_1] + v_in[3+v_in_off] * m_in[3*4+m_in_off_1]; + + final int m_in_off_2 = 2+m_in_off; + v_out[2 + v_out_off] = v_in[0+v_in_off] * m_in[0*4+m_in_off_2] + v_in[1+v_in_off] * m_in[1*4+m_in_off_2] + + v_in[2+v_in_off] * m_in[2*4+m_in_off_2] + v_in[3+v_in_off] * m_in[3*4+m_in_off_2]; + + final int m_in_off_3 = 3+m_in_off; + v_out[3 + v_out_off] = v_in[0+v_in_off] * m_in[0*4+m_in_off_3] + v_in[1+v_in_off] * m_in[1*4+m_in_off_3] + + v_in[2+v_in_off] * m_in[2*4+m_in_off_3] + v_in[3+v_in_off] * m_in[3*4+m_in_off_3]; + + return v_out; } /** * @param m_in 4x4 matrix in column-major order + * @param m_in_off * @param v_in 4-component column-vector * @param v_out m_in * v_in + * @return given result vector <i>v_out</i> for chaining */ - public static final void multMatrixVecf(FloatBuffer m_in, float[] v_in, float[] v_out) { - final int matrixPos = m_in.position(); - for (int i = 0; i < 4; i++) { + public static float[] multMatrixVec(final float[] m_in, final float[] v_in, final float[] v_out) { // (one matrix row in column-major order) X (column vector) - v_out[i] = - v_in[0] * m_in.get(0*4+i+matrixPos) + - v_in[1] * m_in.get(1*4+i+matrixPos) + - v_in[2] * m_in.get(2*4+i+matrixPos) + - v_in[3] * m_in.get(3*4+i+matrixPos); - } + v_out[0] = v_in[0] * m_in[0*4 ] + v_in[1] * m_in[1*4 ] + + v_in[2] * m_in[2*4 ] + v_in[3] * m_in[3*4 ]; + + v_out[1] = v_in[0] * m_in[0*4+1] + v_in[1] * m_in[1*4+1] + + v_in[2] * m_in[2*4+1] + v_in[3] * m_in[3*4+1]; + + v_out[2] = v_in[0] * m_in[0*4+2] + v_in[1] * m_in[1*4+2] + + v_in[2] * m_in[2*4+2] + v_in[3] * m_in[3*4+2]; + + v_out[3] = v_in[0] * m_in[0*4+3] + v_in[1] * m_in[1*4+3] + + v_in[2] * m_in[2*4+3] + v_in[3] * m_in[3*4+3]; + + return v_out; } /** * @param m_in 4x4 matrix in column-major order * @param v_in 4-component column-vector * @param v_out m_in * v_in + * @deprecated use on of the float[] variants */ - public static final void multMatrixVecf(FloatBuffer m_in, FloatBuffer v_in, FloatBuffer v_out) { - final int inPos = v_in.position(); - final int outPos = v_out.position(); - final int matrixPos = m_in.position(); + public static void multMatrixVec(final FloatBuffer m_in, final float[] v_in, final float[] v_out) { + final int m_in_off = m_in.position(); for (int i = 0; i < 4; i++) { // (one matrix row in column-major order) X (column vector) - v_out.put(i + outPos, - v_in.get(0+inPos) * m_in.get(0*4+i+matrixPos) + - v_in.get(1+inPos) * m_in.get(1*4+i+matrixPos) + - v_in.get(2+inPos) * m_in.get(2*4+i+matrixPos) + - v_in.get(3+inPos) * m_in.get(3*4+i+matrixPos)); + final int i_m_in_off = i+m_in_off; + v_out[i] = + v_in[0] * m_in.get(0*4+i_m_in_off) + + v_in[1] * m_in.get(1*4+i_m_in_off) + + v_in[2] * m_in.get(2*4+i_m_in_off) + + v_in[3] * m_in.get(3*4+i_m_in_off); } } @@ -561,14 +1848,16 @@ public class FloatUtil { * @param column named column to copy * @param v_out the column-vector storage, at least 3 components long * @param v_out_off offset to storage + * @return given result vector <i>v_out</i> for chaining */ - public static final void copyMatrixColumn(final float[] m_in, final int m_in_off, final int column, final float[] v_out, final int v_out_off) { + public static float[] copyMatrixColumn(final float[] m_in, final int m_in_off, final int column, final float[] v_out, final int v_out_off) { v_out[0+v_out_off]=m_in[0+column*4+m_in_off]; v_out[1+v_out_off]=m_in[1+column*4+m_in_off]; v_out[2+v_out_off]=m_in[2+column*4+m_in_off]; if( v_out.length > 3+v_out_off ) { v_out[3+v_out_off]=m_in[3+column*4+m_in_off]; } + return v_out; } /** @@ -581,14 +1870,16 @@ public class FloatUtil { * @param row named row to copy * @param v_out the row-vector storage, at least 3 components long * @param v_out_off offset to storage + * @return given result vector <i>v_out</i> for chaining */ - public static final void copyMatrixRow(final float[] m_in, final int m_in_off, final int row, final float[] v_out, final int v_out_off) { + public static float[] copyMatrixRow(final float[] m_in, final int m_in_off, final int row, final float[] v_out, final int v_out_off) { v_out[0+v_out_off]=m_in[row+0*4+m_in_off]; v_out[1+v_out_off]=m_in[row+1*4+m_in_off]; v_out[2+v_out_off]=m_in[row+2*4+m_in_off]; if( v_out.length > 3+v_out_off ) { v_out[3+v_out_off]=m_in[row+3*4+m_in_off]; } + return v_out; } /** @@ -601,8 +1892,11 @@ public class FloatUtil { * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) * @param row row number to print * @return matrix row string representation + * @deprecated use on of the float[] variants */ - public static StringBuilder matrixRowToString(StringBuilder sb, String f, FloatBuffer a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row) { + public static StringBuilder matrixRowToString(StringBuilder sb, final String f, + final FloatBuffer a, final int aOffset, + final int rows, final int columns, final boolean rowMajorOrder, final int row) { if(null == sb) { sb = new StringBuilder(); } @@ -630,7 +1924,8 @@ public class FloatUtil { * @param row row number to print * @return matrix row string representation */ - public static StringBuilder matrixRowToString(StringBuilder sb, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row) { + public static StringBuilder matrixRowToString(StringBuilder sb, final String f, + final float[] a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder, final int row) { if(null == sb) { sb = new StringBuilder(); } @@ -656,8 +1951,10 @@ public class FloatUtil { * @param columns * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) * @return matrix string representation + * @deprecated use on of the float[] variants */ - public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, FloatBuffer a, int aOffset, int rows, int columns, boolean rowMajorOrder) { + public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f, + final FloatBuffer a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder) { if(null == sb) { sb = new StringBuilder(); } @@ -681,7 +1978,8 @@ public class FloatUtil { * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) * @return matrix string representation */ - public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder) { + public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f, + final float[] a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder) { if(null == sb) { sb = new StringBuilder(); } @@ -706,8 +2004,11 @@ public class FloatUtil { * @param columns * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) * @return side by side representation + * @deprecated use on of the float[] variants */ - public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, FloatBuffer a, int aOffset, FloatBuffer b, int bOffset, int rows, int columns, boolean rowMajorOrder) { + public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f, + final FloatBuffer a, final int aOffset, final FloatBuffer b, final int bOffset, + final int rows, final int columns, final boolean rowMajorOrder) { if(null == sb) { sb = new StringBuilder(); } @@ -735,7 +2036,9 @@ public class FloatUtil { * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) * @return side by side representation */ - public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, float[] b, int bOffset, int rows, int columns, boolean rowMajorOrder) { + public static StringBuilder matrixToString(StringBuilder sb, final String rowPrefix, final String f, + final float[] a, final int aOffset, final float[] b, final int bOffset, + final int rows, final int columns, final boolean rowMajorOrder) { if(null == sb) { sb = new StringBuilder(); } @@ -750,6 +2053,10 @@ public class FloatUtil { return sb; } + // + // Scalar Ops + // + @SuppressWarnings("unused") private static void calculateMachineEpsilonFloat() { final long t0; @@ -840,6 +2147,14 @@ public class FloatUtil { public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d /** + * Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal. + * <p> + * Using {@value}, which is ~100 times {@link FloatUtil#EPSILON}. + * </p> + */ + public static final float INV_DEVIANCE = 1.0E-5f; // FloatUtil.EPSILON == 1.1920929E-7f; double ALLOWED_DEVIANCE: 1.0E-8f + + /** * Return true if both values are equal w/o regarding an epsilon. * <p> * Implementation considers following corner cases: @@ -973,7 +2288,7 @@ public class FloatUtil { public static float getZBufferEpsilon(final int zBits, final float z, final float zNear) { return z * z / ( zNear * ( 1 << zBits ) - z ); } - + /** * Returns Z buffer value of given parameter, * see <a href="http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html">Love Your Z-Buffer</a>. diff --git a/src/jogl/classes/com/jogamp/opengl/math/FovHVHalves.java b/src/jogl/classes/com/jogamp/opengl/math/FovHVHalves.java new file mode 100644 index 000000000..786d146e6 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/math/FovHVHalves.java @@ -0,0 +1,121 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.math; + +/** + * Horizontal and vertical field of view (FOV) halves, + * allowing a non-centered projection. + * <p> + * The values might be either in tangent or radians. + * </p> + */ +public final class FovHVHalves { + /** Half horizontal FOV from center to left. */ + public final float left; + /** Half horizontal FOV from center to right. */ + public final float right; + /** Half vertical FOV from center to top. */ + public final float top; + /** Half vertical FOV from center to bottom. */ + public final float bottom; + /** If true, values are in tangent, otherwise radians.*/ + public final boolean inTangents; + + /** + * Constructor for one {@link FovHVHalves} instance. + * <p> + * It is recommended to pass and store values in tangent + * if used for perspective FOV calculations, since it will avoid conversion to tangent later on. + * </p> + * @param left half horizontal FOV, left side, in tangent or radians + * @param right half horizontal FOV, right side, in tangent or radians + * @param top half vertical FOV, top side, in tangent or radians + * @param bottom half vertical FOV, bottom side, in tangent or radians + * @param inTangents if true, values are in tangent, otherwise radians + */ + public FovHVHalves(final float left, final float right, final float top, final float bottom, final boolean inTangents) { + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + this.inTangents = inTangents; + } + + /** + * Returns a symmetrical centered {@link FovHVHalves} instance in tangents, using: + * <pre> + final float halfHorizFovTan = (float)Math.tan(horizontalFov/2f); + final float halfVertFovTan = (float)Math.tan(verticalFov/2f); + * </pre> + * @param horizontalFov whole horizontal FOV in radians + * @param verticalFov whole vertical FOV in radians + */ + public static FovHVHalves createByRadians(final float horizontalFov, final float verticalFov) { + final float halfHorizFovTan = FloatUtil.tan(horizontalFov/2f); + final float halfVertFovTan = FloatUtil.tan(verticalFov/2f); + return new FovHVHalves(halfHorizFovTan, halfHorizFovTan, halfVertFovTan, halfVertFovTan, true); + } + + /** + * Returns this instance values <i>in tangent</i> values. + * <p> + * If this instance is {@link #inTangents} already, method returns this instance, + * otherwise a newly created instance w/ converted values to tangent. + * </p> + */ + public final FovHVHalves getInTangents() { + if( inTangents ) { + return this; + } else { + return new FovHVHalves(FloatUtil.tan(left), FloatUtil.tan(right), FloatUtil.tan(top), FloatUtil.tan(bottom), true); + } + } + + /** Returns the full horizontal FOV, i.e. {@link #left} + {@link #right}. */ + public final float horzFov() { return left+right; } + + /** Returns the full vertical FOV, i.e. {@link #top} + {@link #bottom}. */ + public final float vertFov() { return top+bottom; } + + public final String toString() { + return "FovHVH["+(inTangents?"tangents":"radians")+": "+left+" l, "+right+" r, "+top+" t, "+bottom+" b]"; + } + public final String toStringInDegrees() { + final float f = 180.0f / FloatUtil.PI; + final String storedAs = inTangents?"tangents":"radians"; + if( inTangents ) { + final float aleft = FloatUtil.atan(left); + final float aright = FloatUtil.atan(right); + final float atop = FloatUtil.atan(top); + final float abottom = FloatUtil.atan(bottom); + return "FovHVH[degrees: "+aleft*f+" l, "+aright*f+" r, "+atop*f+" t, "+abottom*f+" b, stored-as: "+storedAs+"]"; + } else { + return "FovHVH[degrees: "+left*f+" l, "+right*f+" r, "+top*f+" t, "+bottom*f+" b, stored-as: "+storedAs+"]"; + } + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/math/Matrix4.java b/src/jogl/classes/com/jogamp/opengl/math/Matrix4.java new file mode 100644 index 000000000..830f1a882 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/math/Matrix4.java @@ -0,0 +1,152 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.math; + +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.opengl.util.PMVMatrix; + +/** + * Simple float array-backed float 4x4 matrix + * exposing {@link FloatUtil} matrix functionality in an object oriented manner. + * <p> + * Unlike {@link PMVMatrix}, this class only represents one single matrix + * without a complete {@link GLMatrixFunc} implementation, + * allowing this class to be more lightweight. + * </p> + * <p> + * Implementation is not mature - WIP and subject to change. + * </p> + */ +public class Matrix4 { + + public Matrix4() { + matrix = new float[16]; + matrixTxSx = new float[16]; + mat4Tmp1 = new float[16]; + vec4Tmp1 = new float[4]; + FloatUtil.makeIdentity(matrixTxSx); + loadIdentity(); + } + + public final float[] getMatrix() { + return matrix; + } + + public final void loadIdentity() { + FloatUtil.makeIdentity(matrix); + } + + /** + * Multiply matrix: [this] = [this] x [m] + * @param m 4x4 matrix in column-major order + */ + public final void multMatrix(final float[] m, final int m_offset) { + FloatUtil.multMatrix(matrix, 0, m, m_offset); + } + + /** + * Multiply matrix: [this] = [this] x [m] + * @param m 4x4 matrix in column-major order + */ + public final void multMatrix(final float[] m) { + FloatUtil.multMatrix(matrix, m); + } + + /** + * Multiply matrix: [this] = [this] x [m] + * @param m 4x4 matrix in column-major order + */ + public final void multMatrix(final Matrix4 m) { + FloatUtil.multMatrix(matrix, m.getMatrix()); + } + + /** + * @param v_in 4-component column-vector + * @param v_out this * v_in + */ + public final void multVec(final float[] v_in, final float[] v_out) { + FloatUtil.multMatrixVec(matrix, v_in, v_out); + } + + /** + * @param v_in 4-component column-vector + * @param v_out this * v_in + */ + public final void multVec(final float[] v_in, final int v_in_offset, final float[] v_out, final int v_out_offset) { + FloatUtil.multMatrixVec(matrix, 0, v_in, v_in_offset, v_out, v_out_offset); + } + + public final void translate(final float x, final float y, final float z) { + multMatrix(FloatUtil.makeTranslation(matrixTxSx, false, x, y, z)); + } + + public final void scale(final float x, final float y, final float z) { + multMatrix(FloatUtil.makeScale(matrixTxSx, false, x, y, z)); + } + + public final void rotate(final float angrad, final float x, final float y, final float z) { + multMatrix(FloatUtil.makeRotationAxis(mat4Tmp1, 0, angrad, x, y, z, vec4Tmp1)); + } + + /** + * Rotate the current matrix with the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}. + */ + public final void rotate(final Quaternion quat) { + multMatrix(quat.toMatrix(mat4Tmp1, 0)); + } + + public final void transpose() { + System.arraycopy(matrix, 0, mat4Tmp1, 0, 16); + FloatUtil.transposeMatrix(mat4Tmp1, matrix); + } + + public final float determinant() { + return FloatUtil.matrixDeterminant(matrix); + } + + public final boolean invert() { + return null != FloatUtil.invertMatrix(matrix, matrix); + } + + public final void makeOrtho(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { + multMatrix( FloatUtil.makeOrtho(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar) ); + } + + public final void makeFrustum(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { + multMatrix( FloatUtil.makeFrustum(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar) ); + } + + public final void makePerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar) { + multMatrix( FloatUtil.makePerspective(mat4Tmp1, 0, true, fovy_rad, aspect, zNear, zFar) ); + } + + private final float[] matrix, matrixTxSx; + private final float[] mat4Tmp1, vec4Tmp1; +} diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index 319cbad50..5e0784022 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -27,8 +27,6 @@ */ package com.jogamp.opengl.math; -import java.nio.FloatBuffer; - /** * Quaternion implementation supporting * <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q34">Gimbal-Lock</a> free rotations. @@ -50,7 +48,7 @@ public class Quaternion { /** * Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal. * <p> - * Using {@value}, which is ~20 times {@link FloatUtil#EPSILON}. + * Using {@value}, which is ~10 times {@link FloatUtil#EPSILON}. * </p> */ public static final float ALLOWED_DEVIANCE = 1.0E-6f; // FloatUtil.EPSILON == 1.1920929E-7f; double ALLOWED_DEVIANCE: 1.0E-8f @@ -440,7 +438,7 @@ public class Quaternion { * @see #rotateByAngleX(float) * @see #setFromEuler(float, float, float) */ - public final Quaternion rotateByEuler(final float bankX, final float headingY, float attitudeZ) { + public final Quaternion rotateByEuler(final float bankX, final float headingY, final float attitudeZ) { if ( VectorUtil.isZero(bankX, headingY, attitudeZ, FloatUtil.EPSILON) ) { return this; } else { @@ -861,7 +859,7 @@ public class Quaternion { * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm">euclideanspace.com-eulerToQuaternion</a> * @see #toEuler(float[]) */ - public final Quaternion setFromEuler(final float bankX, final float headingY, float attitudeZ) { + public final Quaternion setFromEuler(final float bankX, final float headingY, final float attitudeZ) { if ( VectorUtil.isZero(bankX, headingY, attitudeZ, FloatUtil.EPSILON) ) { return setIdentity(); } else { @@ -943,27 +941,6 @@ public class Quaternion { } /** - * Initializes this quaternion from a 4x4 column rotation matrix - * <p> - * See <a href="ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z">Graphics Gems Code</a>,<br/> - * <a href="http://mathworld.wolfram.com/MatrixTrace.html">MatrixTrace</a>. - * </p> - * <p> - * Buggy <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q55">Matrix-FAQ Q55</a> - * </p> - * - * @param m 4x4 column matrix - * @return this quaternion for chaining. - * @see #toMatrix(FloatBuffer) - */ - public final Quaternion setFromMatrix(final FloatBuffer m) { - final int m_off = m.position(); - return setFromMatrix(m.get(0+0*4+m_off), m.get(0+1*4+m_off), m.get(0+2*4+m_off), - m.get(1+0*4+m_off), m.get(1+1*4+m_off), m.get(1+2*4+m_off), - m.get(2+0*4+m_off), m.get(2+1*4+m_off), m.get(2+2*4+m_off)); - } - - /** * Compute the quaternion from a 3x3 column rotation matrix * <p> * See <a href="ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z">Graphics Gems Code</a>,<br/> @@ -1038,8 +1015,7 @@ public class Quaternion { final float norm = magnitudeSquared(); if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) { // identity matrix -> srecip = 0f - FloatUtil.makeIdentityf(matrix, mat_offset); - return matrix; + return FloatUtil.makeIdentity(matrix, mat_offset); } final float srecip; if ( FloatUtil.isEqual(1f, norm, FloatUtil.EPSILON) ) { @@ -1085,74 +1061,6 @@ public class Quaternion { } /** - * Transform this quaternion to a normalized 4x4 column matrix representing the rotation. - * <p> - * Implementation Details: - * <ul> - * <li> makes identity matrix if {@link #magnitudeSquared()} is {@link FloatUtil#isZero(float, float) is zero} using {@link FloatUtil#EPSILON epsilon}</li> - * </ul> - * </p> - * - * @param matrix FloatBuffer store for the resulting normalized column matrix 4x4 - * @param mat_offset - * @return the given matrix store - * @see <a href="http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54">Matrix-FAQ Q54</a> - * @see #setFromMatrix(FloatBuffer) - */ - public final FloatBuffer toMatrix(final FloatBuffer matrix) { - final int mat_offset = matrix.position(); - - // pre-multipliy scaled-reciprocal-magnitude to reduce multiplications - final float norm = magnitudeSquared(); - if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) { - // identity matrix -> srecip = 0f - FloatUtil.makeIdentityf(matrix); - return matrix; - } - final float srecip; - if ( FloatUtil.isEqual(1f, norm, FloatUtil.EPSILON) ) { - srecip = 2f; - } else { - srecip = 2.0f / norm; - } - - final float xs = srecip * x; - final float ys = srecip * y; - final float zs = srecip * z; - - final float xx = x * xs; - final float xy = x * ys; - final float xz = x * zs; - final float xw = xs * w; - final float yy = y * ys; - final float yz = y * zs; - final float yw = ys * w; - final float zz = z * zs; - final float zw = zs * w; - - matrix.put(0+0*4+mat_offset, 1f - ( yy + zz )); - matrix.put(0+1*4+mat_offset, ( xy - zw )); - matrix.put(0+2*4+mat_offset, ( xz + yw )); - matrix.put(0+3*4+mat_offset, 0f); - - matrix.put(1+0*4+mat_offset, ( xy + zw )); - matrix.put(1+1*4+mat_offset, 1f - ( xx + zz )); - matrix.put(1+2*4+mat_offset, ( yz - xw )); - matrix.put(1+3*4+mat_offset, 0f); - - matrix.put(2+0*4+mat_offset, ( xz - yw )); - matrix.put(2+1*4+mat_offset, ( yz + xw )); - matrix.put(2+2*4+mat_offset, 1f - ( xx + yy )); - matrix.put(2+3*4+mat_offset, 0f); - - matrix.put(3+0*4+mat_offset, 0f); - matrix.put(3+1*4+mat_offset, 0f); - matrix.put(3+2*4+mat_offset, 0f); - matrix.put(3+3*4+mat_offset, 1f); - return matrix; - } - - /** * @param index the 3x3 rotation matrix column to retrieve from this quaternion (normalized). Must be between 0 and 2. * @param result the vector object to store the result in. * @return the result column-vector for chaining. @@ -1246,7 +1154,7 @@ public class Quaternion { * @param m 3x3 column matrix * @return true if representing a rotational matrix, false otherwise */ - public final boolean isRotationMatrix3f(float[] m) { + public final boolean isRotationMatrix3f(final float[] m) { final float epsilon = 0.01f; // margin to allow for rounding errors if (FloatUtil.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon) return false; @@ -1263,7 +1171,7 @@ public class Quaternion { return (FloatUtil.abs(determinant3f(m) - 1) < epsilon); } - private final float determinant3f(float[] m) { + private final float determinant3f(final float[] m) { return m[0] * m[4] * m[8] + m[3] * m[7] * m[2] + m[6] * m[1] * m[5] - m[0] * m[7] * m[5] - m[3] * m[1] * m[8] - m[6] * m[4] * m[2]; } diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java index 7e4f45795..c11c2bd2b 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java @@ -29,17 +29,21 @@ package com.jogamp.opengl.math; import java.util.ArrayList; -public class VectorUtil { +public final class VectorUtil { public static final float[] VEC3_ONE = { 1f, 1f, 1f }; public static final float[] VEC3_ZERO = { 0f, 0f, 0f }; + public static final float[] VEC3_UNIT_Y = { 0f, 1f, 0f }; + public static final float[] VEC3_UNIT_Y_NEG = { 0f, -1f, 0f }; + public static final float[] VEC3_UNIT_Z = { 0f, 0f, 1f }; + public static final float[] VEC3_UNIT_Z_NEG = { 0f, 0f, -1f }; public enum Winding { CW(-1), CCW(1); public final int dir; - Winding(int dir) { + Winding(final int dir) { this.dir = dir; } } @@ -52,7 +56,7 @@ public class VectorUtil { * @param srcOffset offset of src in array * @return copied output vector for chaining */ - public static float[] copyVec2(final float[] dst, int dstOffset, final float[] src, int srcOffset) + public static float[] copyVec2(final float[] dst, final int dstOffset, final float[] src, final int srcOffset) { System.arraycopy(src, srcOffset, dst, dstOffset, 2); return dst; @@ -66,7 +70,7 @@ public class VectorUtil { * @param srcOffset offset of src in array * @return copied output vector for chaining */ - public static float[] copyVec3(final float[] dst, int dstOffset, final float[] src, int srcOffset) + public static float[] copyVec3(final float[] dst, final int dstOffset, final float[] src, final int srcOffset) { System.arraycopy(src, srcOffset, dst, dstOffset, 3); return dst; @@ -80,7 +84,7 @@ public class VectorUtil { * @param srcOffset offset of src in array * @return copied output vector for chaining */ - public static float[] copyVec4(final float[] dst, int dstOffset, final float[] src, int srcOffset) + public static float[] copyVec4(final float[] dst, final int dstOffset, final float[] src, final int srcOffset) { System.arraycopy(src, srcOffset, dst, dstOffset, 4); return dst; @@ -92,7 +96,7 @@ public class VectorUtil { * Implementation uses {@link FloatUtil#isEqual(float, float)}, see API doc for details. * </p> */ - public static boolean isVec2Equal(final float[] vec1, int vec1Offset, final float[] vec2, int vec2Offset) { + public static boolean isVec2Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset) { return FloatUtil.isEqual(vec1[0+vec1Offset], vec2[0+vec2Offset]) && FloatUtil.isEqual(vec1[1+vec1Offset], vec2[1+vec2Offset]) ; } @@ -103,7 +107,7 @@ public class VectorUtil { * Implementation uses {@link FloatUtil#isEqual(float, float)}, see API doc for details. * </p> */ - public static boolean isVec3Equal(final float[] vec1, int vec1Offset, final float[] vec2, int vec2Offset) { + public static boolean isVec3Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset) { return FloatUtil.isEqual(vec1[0+vec1Offset], vec2[0+vec2Offset]) && FloatUtil.isEqual(vec1[1+vec1Offset], vec2[1+vec2Offset]) && FloatUtil.isEqual(vec1[2+vec1Offset], vec2[2+vec2Offset]) ; @@ -115,7 +119,7 @@ public class VectorUtil { * Implementation uses {@link FloatUtil#isEqual(float, float, float)}, see API doc for details. * </p> */ - public static boolean isVec2Equal(final float[] vec1, int vec1Offset, final float[] vec2, int vec2Offset, final float epsilon) { + public static boolean isVec2Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset, final float epsilon) { return FloatUtil.isEqual(vec1[0+vec1Offset], vec2[0+vec2Offset], epsilon) && FloatUtil.isEqual(vec1[1+vec1Offset], vec2[1+vec2Offset], epsilon) ; } @@ -126,7 +130,7 @@ public class VectorUtil { * Implementation uses {@link FloatUtil#isEqual(float, float, float)}, see API doc for details. * </p> */ - public static boolean isVec3Equal(final float[] vec1, int vec1Offset, final float[] vec2, int vec2Offset, final float epsilon) { + public static boolean isVec3Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset, final float epsilon) { return FloatUtil.isEqual(vec1[0+vec1Offset], vec2[0+vec2Offset], epsilon) && FloatUtil.isEqual(vec1[1+vec1Offset], vec2[1+vec2Offset], epsilon) && FloatUtil.isEqual(vec1[2+vec1Offset], vec2[2+vec2Offset], epsilon) ; @@ -248,11 +252,33 @@ public class VectorUtil { /** * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i> */ + public static float normSquareVec2(final float[] vec, final int offset) { + float v = vec[0+offset]; + final float r = v*v; + v = vec[1+offset]; + return r + v*v; + } + + /** + * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i> + */ public static float normSquareVec3(final float[] vec) { return vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]; } /** + * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i> + */ + public static float normSquareVec3(final float[] vec, final int offset) { + float v = vec[0+offset]; + float r = v*v; + v = vec[1+offset]; + r += v*v; + v = vec[2+offset]; + return r + v*v; + } + + /** * Return the length of a vector, a.k.a the <i>norm</i> or <i>magnitude</i> */ public static float normVec2(final float[] vec) { @@ -347,6 +373,26 @@ public class VectorUtil { } /** + * Normalize a vector in place + * @param vector input vector + * @return normalized output vector + */ + public static float[] normalizeVec3(final float[] vector, final int offset) { + final float lengthSq = normSquareVec3(vector, offset); + if ( FloatUtil.isZero(lengthSq, FloatUtil.EPSILON) ) { + vector[0+offset] = 0f; + vector[1+offset] = 0f; + vector[2+offset] = 0f; + } else { + final float invSqr = 1f / FloatUtil.sqrt(lengthSq); + vector[0+offset] *= invSqr; + vector[1+offset] *= invSqr; + vector[2+offset] *= invSqr; + } + return vector; + } + + /** * Scales a vector by param using given result float[] * @param result vector for the result, may be vector (in-place) * @param vector input vector @@ -471,6 +517,20 @@ public class VectorUtil { } /** + * cross product vec1 x vec2 + * @param v1 vector 1 + * @param v2 vector 2 + * @return the resulting vector + */ + public static float[] crossVec3(final float[] r, final int r_offset, final float[] v1, final int v1_offset, final float[] v2, final int v2_offset) + { + r[0+r_offset] = v1[1+v1_offset] * v2[2+v2_offset] - v1[2+v1_offset] * v2[1+v2_offset]; + r[1+r_offset] = v1[2+v1_offset] * v2[0+v2_offset] - v1[0+v1_offset] * v2[2+v2_offset]; + r[2+r_offset] = v1[0+v1_offset] * v2[1+v2_offset] - v1[1+v1_offset] * v2[0+v2_offset]; + return r; + } + + /** * Multiplication of column-major 4x4 matrix with vector * @param colMatrix column matrix (4x4) * @param vec vector(x,y,z) @@ -900,7 +960,7 @@ public class VectorUtil { * @param epsilon * @return resulting intersecting if exists, otherwise null */ - public static float[] line2PlaneIntersection(final float[] result, final Ray ray, float[/*4*/] plane, final float epsilon) { + public static float[] line2PlaneIntersection(final float[] result, final Ray ray, final float[/*4*/] plane, final float epsilon) { final float tmp = dotVec3(ray.dir, plane) ; if ( Math.abs(tmp) < epsilon ) { diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java index e4c1445ff..e454c036a 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java @@ -33,7 +33,6 @@ import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.Quaternion; import com.jogamp.opengl.math.Ray; import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.util.PMVMatrix; /** @@ -69,7 +68,7 @@ public class AABBox { * Create an AABBox copying all values from the given one * @param src the box value to be used for the new instance */ - public AABBox(AABBox src) { + public AABBox(final AABBox src) { copy(src); } @@ -148,7 +147,7 @@ public class AABBox { * @param src source AABBox * @return this AABBox for chaining */ - public final AABBox copy(AABBox src) { + public final AABBox copy(final AABBox src) { System.arraycopy(src.low, 0, low, 0, 3); System.arraycopy(src.high, 0, high, 0, 3); System.arraycopy(src.center, 0, center, 0, 3); @@ -197,8 +196,8 @@ public class AABBox { * @return this AABBox for chaining */ public final AABBox resize(final AABBox newBox) { - float[] newLow = newBox.getLow(); - float[] newHigh = newBox.getHigh(); + final float[] newLow = newBox.getLow(); + final float[] newHigh = newBox.getHigh(); /** test low */ if (newLow[0] < low[0]) @@ -663,7 +662,7 @@ public class AABBox { } @Override - public final boolean equals(Object obj) { + public final boolean equals(final Object obj) { if( obj == this ) { return true; } @@ -680,9 +679,9 @@ public class AABBox { * compute the window bounding box. * <p> * If <code>useCenterZ</code> is <code>true</code>, - * only 4 {@link PMVMatrix#gluProject(float, float, float, int[], int, float[], int) gluProject} + * only 4 {@link FloatUtil#mapObjToWinCoords(float, float, float, float[], int[], int, float[], int, float[], float[]) mapObjToWinCoords} * operations are made on points [1..4] using {@link #getCenter()}'s z-value. - * Otherwise 8 {@link PMVMatrix#gluProject(float, float, float, int[], int, float[], int) gluProject} + * Otherwise 8 {@link FloatUtil#mapObjToWinCoords(float, float, float, float[], int[], int, float[], int, float[], float[]) mapObjToWinCoords} * operation on all 8 points are performed. * </p> * <pre> @@ -691,39 +690,53 @@ public class AABBox { * | | * [1] ------ [3] * </pre> - * @param pmv + * @param mat4PMv P x Mv matrix * @param view * @param useCenterZ - * @param tmpV3 TODO + * @param vec3Tmp0 3 component vector for temp storage + * @param vec4Tmp1 4 component vector for temp storage + * @param vec4Tmp2 4 component vector for temp storage * @return */ - public AABBox mapToWindow(final AABBox result, final PMVMatrix pmv, final int[] view, final boolean useCenterZ, float[] tmpV3) { - // System.err.printf("AABBox.mapToWindow.0: view[%d, %d, %d, %d], this %s%n", view[0], view[1], view[2], view[3], toString()); - float objZ = useCenterZ ? center[2] : getMinZ(); - pmv.gluProject(getMinX(), getMinY(), objZ, view, 0, tmpV3, 0); - // System.err.printf("AABBox.mapToWindow.p1: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMinY(), objZ, tmpV3[0], tmpV3[1], tmpV3[2]); - // System.err.printf("AABBox.mapToWindow.p1: %s%n", pmv.toString()); - result.reset(); - result.resize(tmpV3, 0); - pmv.gluProject(getMinX(), getMaxY(), objZ, view, 0, tmpV3, 0); - // System.err.printf("AABBox.mapToWindow.p2: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMaxY(), objZ, tmpV3[0], tmpV3[1], tmpV3[2]); - result.resize(tmpV3, 0); - pmv.gluProject(getMaxX(), getMinY(), objZ, view, 0, tmpV3, 0); - // System.err.printf("AABBox.mapToWindow.p3: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMinY(), objZ, tmpV3[0], tmpV3[1], tmpV3[2]); - result.resize(tmpV3, 0); - pmv.gluProject(getMaxX(), getMaxY(), objZ, view, 0, tmpV3, 0); - // System.err.printf("AABBox.mapToWindow.p4: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMaxY(), objZ, tmpV3[0], tmpV3[1], tmpV3[2]); - result.resize(tmpV3, 0); + public AABBox mapToWindow(final AABBox result, final float[/*16*/] mat4PMv, final int[] view, final boolean useCenterZ, + final float[] vec3Tmp0, final float[] vec4Tmp1, final float[] vec4Tmp2) { + { + // System.err.printf("AABBox.mapToWindow.0: view[%d, %d, %d, %d], this %s%n", view[0], view[1], view[2], view[3], toString()); + final float objZ = useCenterZ ? center[2] : getMinZ(); + FloatUtil.mapObjToWinCoords(getMinX(), getMinY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + // System.err.printf("AABBox.mapToWindow.p1: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMinY(), objZ, vec3Tmp0[0], vec3Tmp0[1], vec3Tmp0[2]); + // System.err.println("AABBox.mapToWindow.p1:"); + // System.err.println(FloatUtil.matrixToString(null, " mat4PMv", "%10.5f", mat4PMv, 0, 4, 4, false /* rowMajorOrder */)); + + result.reset(); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMinX(), getMaxY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + // System.err.printf("AABBox.mapToWindow.p2: %f, %f, %f -> %f, %f, %f%n", getMinX(), getMaxY(), objZ, vec3Tmp0[0], vec3Tmp0[1], vec3Tmp0[2]); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMaxX(), getMinY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + // System.err.printf("AABBox.mapToWindow.p3: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMinY(), objZ, vec3Tmp0[0], vec3Tmp0[1], vec3Tmp0[2]); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMaxX(), getMaxY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + // System.err.printf("AABBox.mapToWindow.p4: %f, %f, %f -> %f, %f, %f%n", getMaxX(), getMaxY(), objZ, vec3Tmp0[0], vec3Tmp0[1], vec3Tmp0[2]); + result.resize(vec3Tmp0, 0); + } + if( !useCenterZ ) { - objZ = getMaxZ(); - pmv.gluProject(getMinX(), getMinY(), objZ, view, 0, tmpV3, 0); - result.resize(tmpV3, 0); - pmv.gluProject(getMinX(), getMaxY(), objZ, view, 0, tmpV3, 0); - result.resize(tmpV3, 0); - pmv.gluProject(getMaxX(), getMinY(), objZ, view, 0, tmpV3, 0); - result.resize(tmpV3, 0); - pmv.gluProject(getMaxX(), getMaxY(), objZ, view, 0, tmpV3, 0); - result.resize(tmpV3, 0); + final float objZ = getMaxZ(); + FloatUtil.mapObjToWinCoords(getMinX(), getMinY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMinX(), getMaxY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMaxX(), getMinY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + result.resize(vec3Tmp0, 0); + + FloatUtil.mapObjToWinCoords(getMaxX(), getMaxY(), objZ, mat4PMv, view, 0, vec3Tmp0, 0, vec4Tmp1, vec4Tmp2); + result.resize(vec3Tmp0, 0); } if( DEBUG ) { System.err.printf("AABBox.mapToWindow: view[%d, %d], this %s -> %s%n", view[0], view[1], toString(), result.toString()); diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java index 8b4eba222..f6d3c0dfa 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java @@ -27,6 +27,8 @@ */ package com.jogamp.opengl.math.geom; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.os.Platform; /** @@ -68,7 +70,7 @@ import com.jogamp.common.os.Platform; */ public class Frustum { /** Normalized planes[l, r, b, t, n, f] */ - protected Plane[] planes = new Plane[6]; + protected final Plane[] planes = new Plane[6]; /** * Creates an undefined instance w/o calculating the frustum. @@ -113,12 +115,12 @@ public class Frustum { * Negative halfspace is the <i>other side</i> of the plane, i.e. *-1 * </p> **/ - public final float distanceTo(float x, float y, float z) { + public final float distanceTo(final float x, final float y, final float z) { return n[0] * x + n[1] * y + n[2] * z + d; } /** Return distance of plane to given point, see {@link #distanceTo(float, float, float)}. */ - public final float distanceTo(float[] p) { + public final float distanceTo(final float[] p) { return n[0] * p[0] + n[1] * p[1] + n[2] * p[2] + d; } @@ -164,7 +166,7 @@ public class Frustum { * Copy the given <code>src</code> planes into this this instance's planes. * @param src the 6 source planes */ - public final void updateByPlanes(Plane[] src) { + public final void updateByPlanes(final Plane[] src) { for (int i = 0; i < 6; ++i) { final Plane p0 = planes[i]; final float[] p0_n = p0.n; @@ -185,7 +187,7 @@ public class Frustum { * as required by this class. * </p> */ - public void updateByPMV(float[] pmv, int pmv_off) { + public void updateByPMV(final float[] pmv, final int pmv_off) { // Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] column-major // Left: a = m30 + m00, b = m31 + m01, c = m32 + m02, d = m33 + m03 - [0..3] column-major { @@ -265,7 +267,7 @@ public class Frustum { } } - private static final boolean isOutsideImpl(Plane p, AABBox box) { + private static final boolean isOutsideImpl(final Plane p, final AABBox box) { final float[] low = box.getLow(); final float[] high = box.getHigh(); @@ -288,7 +290,7 @@ public class Frustum { * Note: If method returns false, the box may only be partially inside. * </p> */ - public final boolean isAABBoxOutside(AABBox box) { + public final boolean isAABBoxOutside(final AABBox box) { for (int i = 0; i < 6; ++i) { if ( isOutsideImpl(planes[i], box) ) { // fully outside @@ -308,7 +310,7 @@ public class Frustum { * @param p the point * @return {@link Location} of point related to frustum planes */ - public final Location classifyPoint(float[] p) { + public final Location classifyPoint(final float[] p) { Location res = Location.INSIDE; for (int i = 0; i < 6; ++i) { @@ -328,7 +330,7 @@ public class Frustum { * @param p the point * @return true if outside of the frustum, otherwise inside or on a plane */ - public final boolean isPointOutside(float[] p) { + public final boolean isPointOutside(final float[] p) { return Location.OUTSIDE == classifyPoint(p); } @@ -339,7 +341,7 @@ public class Frustum { * @param radius radius of the sphere * @return {@link Location} of point related to frustum planes */ - public final Location classifySphere(float[] p, float radius) { + public final Location classifySphere(final float[] p, final float radius) { Location res = Location.INSIDE; // fully inside for (int i = 0; i < 6; ++i) { @@ -362,7 +364,7 @@ public class Frustum { * @param radius radius of the sphere * @return true if outside of the frustum, otherwise inside or intersecting */ - public final boolean isSphereOutside(float[] p, float radius) { + public final boolean isSphereOutside(final float[] p, final float radius) { return Location.OUTSIDE == classifySphere(p, radius); } @@ -370,13 +372,13 @@ public class Frustum { if( null == sb ) { sb = new StringBuilder(); } - sb.append("Frustum[ Planes[ ").append(Platform.NEWLINE) - .append(" L: ").append(planes[0]).append(", ").append(Platform.NEWLINE) - .append(" R: ").append(planes[1]).append(", ").append(Platform.NEWLINE) - .append(" B: ").append(planes[2]).append(", ").append(Platform.NEWLINE) - .append(" T: ").append(planes[3]).append(", ").append(Platform.NEWLINE) - .append(" N: ").append(planes[4]).append(", ").append(Platform.NEWLINE) - .append(" F: ").append(planes[5]).append("], ").append(Platform.NEWLINE) + sb.append("Frustum[ Planes[ ").append(PlatformPropsImpl.NEWLINE) + .append(" L: ").append(planes[0]).append(", ").append(PlatformPropsImpl.NEWLINE) + .append(" R: ").append(planes[1]).append(", ").append(PlatformPropsImpl.NEWLINE) + .append(" B: ").append(planes[2]).append(", ").append(PlatformPropsImpl.NEWLINE) + .append(" T: ").append(planes[3]).append(", ").append(PlatformPropsImpl.NEWLINE) + .append(" N: ").append(planes[4]).append(", ").append(PlatformPropsImpl.NEWLINE) + .append(" F: ").append(planes[5]).append("], ").append(PlatformPropsImpl.NEWLINE) .append("]"); return sb; } diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index fbe5fedc4..c94d21369 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -125,8 +125,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS private volatile boolean sendReshape; // volatile: maybe written by WindowManager thread w/o locking private static String getThreadName() { return Thread.currentThread().getName(); } - private static String toHexString(int v) { return "0x"+Integer.toHexString(v); } - private static String toHexString(long v) { return "0x"+Long.toHexString(v); } + private static String toHexString(final int v) { return "0x"+Integer.toHexString(v); } + private static String toHexString(final long v) { return "0x"+Long.toHexString(v); } /* * Invokes init(...) on all GLEventListeners. Assumes context is current when run. @@ -215,7 +215,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } else { context.destroy(); } - } catch (GLException gle) { + } catch (final GLException gle) { gle.printStackTrace(); } } @@ -247,7 +247,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS private class DisposeGLEventListenerAction implements Runnable { private GLEventListener listener; private final boolean remove; - private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { + private DisposeGLEventListenerAction(final GLEventListener listener, final boolean remove) { this.listener = listener; this.remove = remove; } @@ -346,7 +346,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the * requested GLCapabilities, and the available capabilities of the graphics device. */ - public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, + public GLCanvas(final Composite parent, final int style, final GLCapabilitiesImmutable capsReqUser, final GLCapabilitiesChooser capsChooser) { this(parent, style, capsReqUser, capsChooser, null); } @@ -418,7 +418,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS final Listener listener = new Listener () { @Override - public void handleEvent (Event event) { + public void handleEvent (final Event event) { switch (event.type) { case SWT.Paint: displayIfNoAnimatorNoCheck(); @@ -438,29 +438,29 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + public final void setSharedContext(final GLContext sharedContext) throws IllegalStateException { helper.setSharedContext(this.context, sharedContext); } @Override - public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + public final void setSharedAutoDrawable(final GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { helper.setSharedAutoDrawable(this, sharedAutoDrawable); } private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override - public final void create(ProxySurface s) { /* nop */ } + public final void create(final ProxySurface s) { /* nop */ } @Override - public final void destroy(ProxySurface s) { /* nop */ } + public final void destroy(final ProxySurface s) { /* nop */ } @Override - public final int getSurfaceWidth(ProxySurface s) { + public final int getSurfaceWidth(final ProxySurface s) { return clientArea.width; } @Override - public final int getSurfaceHeight(ProxySurface s) { + public final int getSurfaceHeight(final ProxySurface s) { return clientArea.height; } @@ -619,7 +619,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); // Create a NativeWindow proxy for the SWT canvas - ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, + final ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, capsRequested, capsChooser, swtCanvasUpStreamHook); // Associate a GL surface with the proxy final GLDrawableImpl _drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); @@ -731,7 +731,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + public GLEventListener getGLEventListener(final int index) throws IndexOutOfBoundsException { return helper.getGLEventListener(index); } @@ -741,17 +741,17 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public boolean getGLEventListenerInitState(GLEventListener listener) { + public boolean getGLEventListenerInitState(final GLEventListener listener) { return helper.getGLEventListenerInitState(listener); } @Override - public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + public void setGLEventListenerInitState(final GLEventListener listener, final boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } @Override - public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { + public GLEventListener disposeGLEventListener(final GLEventListener listener, final boolean remove) { final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); runInGLThread(r); return r.listener; @@ -781,7 +781,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public final Thread setExclusiveContextThread(Thread t) throws GLException { + public final Thread setExclusiveContextThread(final Thread t) throws GLException { return helper.setExclusiveContextThread(t, context); } @@ -837,7 +837,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { + public GLContext setContext(final GLContext newCtx, final boolean destroyPrevCtx) { final RecursiveLock _lock = lock; _lock.lock(); try { @@ -981,7 +981,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS action.run(); } - private void runOnEDTIfAvail(boolean wait, final Runnable action) { + private void runOnEDTIfAvail(final boolean wait, final Runnable action) { final Display d = isDisposed() ? null : getDisplay(); if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) { action.run(); @@ -1025,7 +1025,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS canvas.addGLEventListener(new GLEventListener() { @Override public void init(final GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + final GL gl = drawable.getGL(); System.err.println(JoglVersion.getGLInfo(gl, null)); } @Override diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index d0de3b3a0..496fb88c0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -54,16 +54,16 @@ import javax.media.opengl.GLAutoDrawable; class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { // For efficient rendering of Swing components, in particular when // they overlap one another - private List<JComponent> lightweights = new ArrayList<JComponent>(); - private Map<RepaintManager,RepaintManager> repaintManagers = new IdentityHashMap<RepaintManager,RepaintManager>(); - private Map<JComponent,Rectangle> dirtyRegions = new IdentityHashMap<JComponent,Rectangle>(); + private final List<JComponent> lightweights = new ArrayList<JComponent>(); + private final Map<RepaintManager,RepaintManager> repaintManagers = new IdentityHashMap<RepaintManager,RepaintManager>(); + private final Map<JComponent,Rectangle> dirtyRegions = new IdentityHashMap<JComponent,Rectangle>(); @Override - public void display(ArrayList<GLAutoDrawable> drawables, - boolean ignoreExceptions, - boolean printExceptions) { + public void display(final ArrayList<GLAutoDrawable> drawables, + final boolean ignoreExceptions, + final boolean printExceptions) { for (int i=0; i<drawables.size(); i++) { - GLAutoDrawable drawable = drawables.get(i); + final GLAutoDrawable drawable = drawables.get(i); if (drawable instanceof JComponent) { // Lightweight components need a more efficient drawing // scheme than simply forcing repainting of each one in @@ -73,7 +73,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { } else { try { drawable.display(); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { if (ignoreExceptions) { if (printExceptions) { e.printStackTrace(); @@ -88,7 +88,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { if (lightweights.size() > 0) { try { SwingUtilities.invokeAndWait(drawWithRepaintManagerRunnable); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } lightweights.clear(); @@ -97,10 +97,10 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { // Uses RepaintManager APIs to implement more efficient redrawing of // the Swing widgets we're animating - private Runnable drawWithRepaintManagerRunnable = new Runnable() { + private final Runnable drawWithRepaintManagerRunnable = new Runnable() { @Override public void run() { - for (Iterator<JComponent> iter = lightweights.iterator(); iter.hasNext(); ) { + for (final Iterator<JComponent> iter = lightweights.iterator(); iter.hasNext(); ) { JComponent comp = iter.next(); RepaintManager rm = RepaintManager.currentManager(comp); rm.markCompletelyDirty(comp); @@ -117,13 +117,13 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { // Walk up the hierarchy trying to find a non-optimizable // ancestor - Rectangle visible = comp.getVisibleRect(); + final Rectangle visible = comp.getVisibleRect(); int x = visible.x; int y = visible.y; while (comp != null) { x += comp.getX(); y += comp.getY(); - Component c = comp.getParent(); + final Component c = comp.getParent(); if ((c == null) || (!(c instanceof JComponent))) { comp = null; } else { @@ -132,7 +132,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { rm = RepaintManager.currentManager(comp); repaintManagers.put(rm, rm); // Need to dirty this region - Rectangle dirty = (Rectangle) dirtyRegions.get(comp); + Rectangle dirty = dirtyRegions.get(comp); if (dirty == null) { dirty = new Rectangle(x, y, visible.width, visible.height); dirtyRegions.put(comp, dirty); @@ -150,15 +150,15 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { } // Dirty any needed regions on non-optimizable components - for (Iterator<JComponent> iter = dirtyRegions.keySet().iterator(); iter.hasNext(); ) { - JComponent comp = iter.next(); - Rectangle rect = dirtyRegions.get(comp); - RepaintManager rm = RepaintManager.currentManager(comp); + for (final Iterator<JComponent> iter = dirtyRegions.keySet().iterator(); iter.hasNext(); ) { + final JComponent comp = iter.next(); + final Rectangle rect = dirtyRegions.get(comp); + final RepaintManager rm = RepaintManager.currentManager(comp); rm.addDirtyRegion(comp, rect.x, rect.y, rect.width, rect.height); } // Draw all dirty regions - for (Iterator<RepaintManager> iter = repaintManagers.keySet().iterator(); iter.hasNext(); ) { + for (final Iterator<RepaintManager> iter = repaintManagers.keySet().iterator(); iter.hasNext(); ) { iter.next().paintDirtyRegions(); } dirtyRegions.clear(); @@ -167,7 +167,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { }; @Override - public boolean blockUntilDone(Thread thread) { + public boolean blockUntilDone(final Thread thread) { return Thread.currentThread() != thread && !EventQueue.isDispatchThread(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 799069292..ae09d81a4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -78,7 +78,7 @@ public class Animator extends AnimatorBase { /** * Creates a new Animator w/ an associated ThreadGroup. */ - public Animator(ThreadGroup tg) { + public Animator(final ThreadGroup tg) { super(); setThreadGroup(tg); if(DEBUG) { @@ -89,7 +89,7 @@ public class Animator extends AnimatorBase { /** * Creates a new Animator for a particular drawable. */ - public Animator(GLAutoDrawable drawable) { + public Animator(final GLAutoDrawable drawable) { super(); add(drawable); if(DEBUG) { @@ -100,7 +100,7 @@ public class Animator extends AnimatorBase { /** * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. */ - public Animator(ThreadGroup tg, GLAutoDrawable drawable) { + public Animator(final ThreadGroup tg, final GLAutoDrawable drawable) { super(); setThreadGroup(tg); add(drawable); @@ -110,7 +110,7 @@ public class Animator extends AnimatorBase { } @Override - protected final String getBaseName(String prefix) { + protected final String getBaseName(final String prefix) { return prefix + "Animator" ; } @@ -120,7 +120,7 @@ public class Animator extends AnimatorBase { * animation loop which prevents the CPU from getting swamped. * This method may not have an effect on subclasses. */ - public final synchronized void setRunAsFastAsPossible(boolean runFast) { + public final synchronized void setRunAsFastAsPossible(final boolean runFast) { runAsFastAsPossible = runFast; } @@ -151,7 +151,7 @@ public class Animator extends AnimatorBase { if( drawablesEmpty ) { pauseIssued = true; } - boolean wasPaused = pauseIssued; + final boolean wasPaused = pauseIssued; if (DEBUG) { System.err.println("Animator pause on " + animThread.getName() + ": " + toString()); } @@ -164,7 +164,7 @@ public class Animator extends AnimatorBase { Animator.this.notifyAll(); try { Animator.this.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { } if (wasPaused) { // resume from pause -> reset counter @@ -192,9 +192,9 @@ public class Animator extends AnimatorBase { Thread.yield(); } } - } catch( ThreadDeath td) { + } catch( final ThreadDeath td) { if(DEBUG) { - System.err.println("Animator Catched: "+td.getClass().getName()+": "+td.getMessage()); + System.err.println("Animator caught: "+td.getClass().getName()+": "+td.getMessage()); td.printStackTrace(); } } finally { @@ -232,7 +232,7 @@ public class Animator extends AnimatorBase { * @param tg the {@link ThreadGroup} * @throws GLException if the animator has already been started */ - public final synchronized void setThreadGroup(ThreadGroup tg) throws GLException { + public final synchronized void setThreadGroup(final ThreadGroup tg) throws GLException { if ( isStarted() ) { throw new GLException("Animator already started."); } @@ -248,7 +248,7 @@ public class Animator extends AnimatorBase { runnable = new MainLoop(); } fpsCounter.resetFPSCounter(); - String threadName = getThreadName()+"-"+baseName; + final String threadName = getThreadName()+"-"+baseName; Thread thread; if(null==threadGroup) { thread = new Thread(runnable, threadName); diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 39643744a..68a48381e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -92,7 +92,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { Class<?> clazz; try { clazz = Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl"); - } catch (Exception e) { + } catch (final Exception e) { clazz = null; } awtAnimatorImplClazz = clazz; @@ -112,7 +112,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { drawablesEmpty = true; } - private static final boolean useAWTAnimatorImpl(int modeBits) { + private static final boolean useAWTAnimatorImpl(final int modeBits) { return 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz; } @@ -126,13 +126,13 @@ public abstract class AnimatorBase implements GLAnimatorControl { * * @throws GLException if Animator is {@link #isStarted()} */ - protected final synchronized void initImpl(boolean force) { + protected final synchronized void initImpl(final boolean force) { if( force || null == impl ) { if( useAWTAnimatorImpl( modeBits ) ) { try { impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance(); baseName = getBaseName("AWT"); - } catch (Exception e) { e.printStackTrace(); } + } catch (final Exception e) { e.printStackTrace(); } } if( null == impl ) { impl = new DefaultAnimatorImpl(); @@ -154,7 +154,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD */ - public final synchronized void setModeBits(boolean enable, int bitValues) throws GLException { + public final synchronized void setModeBits(final boolean enable, final int bitValues) throws GLException { final int _oldModeBits = modeBits; if(enable) { modeBits |= bitValues; @@ -225,7 +225,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { } } - boolean paused = pause(); + final boolean paused = pause(); drawables.remove(drawable); drawablesEmpty = drawables.size() == 0; drawable.setAnimator(null); @@ -267,7 +267,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #isExclusiveContextEnabled() */ // @Override - public final synchronized Thread setExclusiveContext(Thread t) { + public final synchronized Thread setExclusiveContext(final Thread t) { final boolean enable = null != t; final Thread old = userExclusiveContextThread; if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae @@ -299,7 +299,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #isExclusiveContextEnabled() */ // @Override - public final boolean setExclusiveContext(boolean enable) { + public final boolean setExclusiveContext(final boolean enable) { final boolean propagateState; final boolean oldExclusiveContext; final Thread _exclusiveContextThread; @@ -324,7 +324,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { while( 0<counter && isAnimating() && !validateDrawablesExclCtxState(dECT) ) { try { Thread.sleep(20); - } catch (InterruptedException e) { } + } catch (final InterruptedException e) { } counter--; } if(resumed) { @@ -379,7 +379,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * to allow propagation of releasing the exclusive thread. * </p> */ - protected final synchronized void setDrawablesExclCtxState(boolean enable) { + protected final synchronized void setDrawablesExclCtxState(final boolean enable) { if(DEBUG) { System.err.println("AnimatorBase.setExclusiveContextImpl exlusive "+exclusiveContext+": Enable "+enable+" for "+this+" - "+Thread.currentThread()); // Thread.dumpStack(); @@ -388,12 +388,12 @@ public abstract class AnimatorBase implements GLAnimatorControl { for (int i=0; i<drawables.size(); i++) { try { drawables.get(i).setExclusiveContextThread( enable ? ect : null ); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { e.printStackTrace(); } } } - protected final boolean validateDrawablesExclCtxState(Thread expected) { + protected final boolean validateDrawablesExclCtxState(final Thread expected) { for (int i=0; i<drawables.size(); i++) { if( expected != drawables.get(i).getExclusiveContextThread() ) { return false; @@ -418,7 +418,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { } @Override - public final void setUpdateFPSFrames(int frames, PrintStream out) { + public final void setUpdateFPSFrames(final int frames, final PrintStream out) { fpsCounter.setUpdateFPSFrames(frames, out); } @@ -470,7 +470,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { /** Sets a flag causing this Animator to ignore exceptions produced while redrawing the drawables. By default this flag is set to false, causing any exception thrown to halt the Animator. */ - public final void setIgnoreExceptions(boolean ignoreExceptions) { + public final void setIgnoreExceptions(final boolean ignoreExceptions) { this.ignoreExceptions = ignoreExceptions; } @@ -478,7 +478,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { this Animator (see {@link #setIgnoreExceptions}), to print the exceptions' stack traces for diagnostic information. Defaults to false. */ - public final void setPrintExceptions(boolean printExceptions) { + public final void setPrintExceptions(final boolean printExceptions) { this.printExceptions = printExceptions; } @@ -495,7 +495,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * if > <code>0</code>, method will wait for the given <code>pollPeriod</code> in milliseconds. * @return <code>true</code> if {@link Condition#eval() waitCondition.eval()} returned <code>false</code>, otherwise <code>false</code>. */ - protected final synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { + protected final synchronized boolean finishLifecycleAction(final Condition waitCondition, long pollPeriod) { /** * It's hard to tell whether the thread which changes the lifecycle has * dependencies on the Animator's internal thread. Currently we @@ -519,7 +519,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { notifyAll(); try { wait(pollPeriod); - } catch (InterruptedException ie) { } + } catch (final InterruptedException ie) { } remaining -= System.currentTimeMillis() - t1 ; nok = waitCondition.eval(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/CustomGLEventListener.java b/src/jogl/classes/com/jogamp/opengl/util/CustomGLEventListener.java new file mode 100644 index 000000000..86443087e --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/CustomGLEventListener.java @@ -0,0 +1,63 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +/** + * Extended {@link GLEventListener} interface + * supporting more fine grained control over the implementation. + */ +public interface CustomGLEventListener extends GLEventListener { + /** + * {@link #display(GLAutoDrawable, int) display flag}: Repeat last produced image. + * <p> + * While a repeated frame shall produce the same artifacts as the last <code>display</code> call, + * e.g. not change animated objects, it shall reflect the {@link #setProjectionModelview(GLAutoDrawable, float[], float[]) current matrix}. + * </p> + */ + public static final int DISPLAY_REPEAT = 1 << 0; + + /** + * {@link #display(GLAutoDrawable, int) display flag}: Do not clear any target buffer, e.g. color-, depth- or stencil-buffers. + */ + public static final int DISPLAY_DONTCLEAR = 1 << 1; + + /** + * Extended {@link #display(GLAutoDrawable) display} method, + * allowing to pass a display flag, e.g. {@link #DISPLAY_REPEAT} or {@link #DISPLAY_DONTCLEAR}. + * <p> + * Method is usually called by a custom rendering loop, + * e.g. for manual stereo rendering or the like. + * </p> + * @param drawable + * @param flags + */ + public void display(final GLAutoDrawable drawable, final int flags); +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index a9c6e6456..7fa4011f8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -42,14 +42,14 @@ import javax.media.opengl.GLAutoDrawable; class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { @Override - public void display(ArrayList<GLAutoDrawable> drawables, - boolean ignoreExceptions, - boolean printExceptions) { + public void display(final ArrayList<GLAutoDrawable> drawables, + final boolean ignoreExceptions, + final boolean printExceptions) { for (int i=0; i<drawables.size(); i++) { - GLAutoDrawable drawable = drawables.get(i); + final GLAutoDrawable drawable = drawables.get(i); try { drawable.display(); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { if (ignoreExceptions) { if (printExceptions) { e.printStackTrace(); @@ -62,7 +62,7 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { } @Override - public boolean blockUntilDone(Thread thread) { + public boolean blockUntilDone(final Thread thread) { return Thread.currentThread() != thread; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 5bd803500..de99ae70d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -65,13 +65,13 @@ public class FPSAnimator extends AnimatorBase { private volatile boolean shouldStop; // MainTask trigger @Override - protected String getBaseName(String prefix) { + protected String getBaseName(final String prefix) { return "FPS" + prefix + "Animator" ; } /** Creates an FPSAnimator with a given target frames-per-second value. Equivalent to <code>FPSAnimator(null, fps)</code>. */ - public FPSAnimator(int fps) { + public FPSAnimator(final int fps) { this(null, fps); } @@ -79,21 +79,21 @@ public class FPSAnimator extends AnimatorBase { value and a flag indicating whether to use fixed-rate scheduling. Equivalent to <code>FPSAnimator(null, fps, scheduleAtFixedRate)</code>. */ - public FPSAnimator(int fps, boolean scheduleAtFixedRate) { + public FPSAnimator(final int fps, final boolean scheduleAtFixedRate) { this(null, fps, scheduleAtFixedRate); } /** Creates an FPSAnimator with a given target frames-per-second value and an initial drawable to animate. Equivalent to <code>FPSAnimator(null, fps, false)</code>. */ - public FPSAnimator(GLAutoDrawable drawable, int fps) { + public FPSAnimator(final GLAutoDrawable drawable, final int fps) { this(drawable, fps, false); } /** Creates an FPSAnimator with a given target frames-per-second value, an initial drawable to animate, and a flag indicating whether to use fixed-rate scheduling. */ - public FPSAnimator(GLAutoDrawable drawable, int fps, boolean scheduleAtFixedRate) { + public FPSAnimator(final GLAutoDrawable drawable, final int fps, final boolean scheduleAtFixedRate) { super(); this.fps = fps; if (drawable != null) { @@ -106,7 +106,7 @@ public class FPSAnimator extends AnimatorBase { * @param fps * @throws GLException if the animator has already been started */ - public final synchronized void setFPS(int fps) throws GLException { + public final synchronized void setFPS(final int fps) throws GLException { if ( isStarted() ) { throw new GLException("Animator already started."); } @@ -122,7 +122,7 @@ public class FPSAnimator extends AnimatorBase { public MainTask() { } - public void start(Timer timer) { + public void start(final Timer timer) { fpsCounter.resetFPSCounter(); shouldRun = true; shouldStop = false; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index a58eb82cd..1a9ec2782 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -69,11 +69,11 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount) + public static GLArrayDataClient createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int initialElementCount) throws GLException { - GLArrayDataClient adc = new GLArrayDataClient(); - GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc); + final GLArrayDataClient adc = new GLArrayDataClient(); + final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc); adc.init(null, index, comps, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, 0, 0, false); return adc; } @@ -99,12 +99,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, - Buffer buffer) + public static GLArrayDataClient createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, + final Buffer buffer) throws GLException { - GLArrayDataClient adc = new GLArrayDataClient(); - GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc); + final GLArrayDataClient adc = new GLArrayDataClient(); + final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc); adc.init(null, index, comps, dataType, normalized, stride, buffer, comps*comps, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, 0, 0, false); return adc; } @@ -118,12 +118,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param normalized Whether the data shall be normalized * @param initialElementCount */ - public static GLArrayDataClient createGLSL(String name, int comps, - int dataType, boolean normalized, int initialElementCount) + public static GLArrayDataClient createGLSL(final String name, final int comps, + final int dataType, final boolean normalized, final int initialElementCount) throws GLException { - GLArrayDataClient adc = new GLArrayDataClient(); - GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc); + final GLArrayDataClient adc = new GLArrayDataClient(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc); adc.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, 0, 0, true); return adc; } @@ -138,18 +138,18 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param stride * @param buffer the user define data */ - public static GLArrayDataClient createGLSL(String name, int comps, - int dataType, boolean normalized, int stride, Buffer buffer) + public static GLArrayDataClient createGLSL(final String name, final int comps, + final int dataType, final boolean normalized, final int stride, final Buffer buffer) throws GLException { - GLArrayDataClient adc = new GLArrayDataClient(); - GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc); + final GLArrayDataClient adc = new GLArrayDataClient(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc); adc.init(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, 0, 0, true); return adc; } @Override - public void associate(Object obj, boolean enable) { + public void associate(final Object obj, final boolean enable) { if(obj instanceof ShaderState) { if(enable) { shaderState = (ShaderState)obj; @@ -177,30 +177,30 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData // @Override - public final void setVBOWritten(boolean written) { + public final void setVBOWritten(final boolean written) { bufferWritten = ( 0 == mappedElementCount ) ? written : true; } @Override - public void destroy(GL gl) { + public void destroy(final GL gl) { reset(gl); super.destroy(gl); } @Override - public void reset(GL gl) { + public void reset(final GL gl) { enableBuffer(gl, false); reset(); } @Override - public void seal(GL gl, boolean seal) { + public void seal(final GL gl, final boolean seal) { seal(seal); enableBuffer(gl, seal); } @Override - public void enableBuffer(GL gl, boolean enable) { + public void enableBuffer(final GL gl, final boolean enable) { if( enableBufferAlways || bufferEnabled != enable ) { if(enable) { checkSeal(true); @@ -213,7 +213,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } @Override - public boolean bindBuffer(GL gl, boolean bind) { + public boolean bindBuffer(final GL gl, final boolean bind) { if(bind) { checkSeal(true); // init/generate VBO name if not done yet @@ -223,7 +223,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } @Override - public void setEnableAlways(boolean always) { + public void setEnableAlways(final boolean always) { enableBufferAlways = always; } @@ -242,7 +242,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } @Override - public void seal(boolean seal) + public void seal(final boolean seal) { if( sealed == seal ) return; sealed = seal; @@ -281,7 +281,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * The arguments remaining elements must be a multiple of this arrays element stride. */ @Override - public void put(Buffer v) { + public void put(final Buffer v) { if ( sealed ) return; /** FIXME: isn't true for interleaved arrays ! if(0!=(v.remaining() % strideL)) { @@ -292,33 +292,33 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } @Override - public void putb(byte v) { + public void putb(final byte v) { if ( sealed ) return; growBufferIfNecessary(1); Buffers.putb(buffer, v); } @Override - public void puts(short v) { + public void puts(final short v) { if ( sealed ) return; growBufferIfNecessary(1); Buffers.puts(buffer, v); } @Override - public void puti(int v) { + public void puti(final int v) { if ( sealed ) return; growBufferIfNecessary(1); Buffers.puti(buffer, v); } @Override - public void putx(int v) { + public void putx(final int v) { puti(v); } @Override - public void putf(float v) { + public void putf(final float v) { if ( sealed ) return; growBufferIfNecessary(1); Buffers.putf(buffer, v); @@ -349,7 +349,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData // non public matters - protected final boolean growBufferIfNecessary(int spareComponents) { + protected final boolean growBufferIfNecessary(final int spareComponents) { if( buffer==null || buffer.remaining()<spareComponents ) { if( 0 != mappedElementCount ) { throw new GLException("Mapped buffer can't grow. Insufficient storage size: Needed "+spareComponents+" components, "+ @@ -411,7 +411,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } } - protected final void checkSeal(boolean test) throws GLException { + protected final void checkSeal(final boolean test) throws GLException { if(!alive) { throw new GLException("Invalid state: "+this); } @@ -424,9 +424,9 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } } - protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data, - int initialElementCount, int mappedElementCount, boolean isVertexAttribute, - GLArrayHandler handler, int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL) + protected void init(final String name, final int index, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer data, + final int initialElementCount, final int mappedElementCount, final boolean isVertexAttribute, + final GLArrayHandler handler, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL) throws GLException { super.init(name, index, comps, dataType, normalized, stride, data, mappedElementCount, @@ -450,7 +450,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData private boolean isValidated = false; - protected void init_vbo(GL gl) { + protected void init_vbo(final GL gl) { if(!isValidated ) { isValidated = true; validate(gl.getGLProfile(), true); @@ -468,7 +468,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * All other values are simply copied. * </p> */ - public GLArrayDataClient(GLArrayDataClient src) { + public GLArrayDataClient(final GLArrayDataClient src) { super(src); this.isValidated = src.isValidated; this.sealed = src.sealed; @@ -481,7 +481,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData try { final Constructor<? extends GLArrayHandler> ctor = clazz.getConstructor(GLArrayDataEditable.class); this.glArrayHandler = ctor.newInstance(this); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException("Could not ctor "+clazz.getName()+"("+this.getClass().getName()+")", e); } } else { diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index 833f1ccda..51c55e326 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -81,12 +81,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataServer createFixed(int index, int compsPerElement, int dataType, boolean normalized, int stride, - Buffer buffer, int vboUsage) + public static GLArrayDataServer createFixed(final int index, final int compsPerElement, final int dataType, final boolean normalized, final int stride, + final Buffer buffer, final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads); ads.init(null, index, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); return ads; @@ -113,12 +113,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataServer createFixed(int index, int compsPerElement, int dataType, boolean normalized, int initialElementCount, - int vboUsage) + public static GLArrayDataServer createFixed(final int index, final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads); ads.init(null, index, compsPerElement, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); return ads; @@ -134,12 +134,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSL(String name, int compsPerElement, - int dataType, boolean normalized, int initialElementCount, int vboUsage) + public static GLArrayDataServer createGLSL(final String name, final int compsPerElement, + final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); ads.init(name, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; @@ -155,12 +155,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param mappedElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLMapped(String name, int compsPerElement, - int dataType, boolean normalized, int mappedElementCount, int vboUsage) + public static GLArrayDataServer createGLSLMapped(final String name, final int compsPerElement, + final int dataType, final boolean normalized, final int mappedElementCount, final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); ads.init(name, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */, mappedElementCount, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); ads.seal(true); @@ -178,13 +178,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param buffer the user define data * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSL(String name, int compsPerElement, - int dataType, boolean normalized, int stride, Buffer buffer, - int vboUsage) + public static GLArrayDataServer createGLSL(final String name, final int compsPerElement, + final int dataType, final boolean normalized, final int stride, final Buffer buffer, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); ads.init(name, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; @@ -203,12 +203,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, .. * {@link GL#glGenBuffers(int, int[], int) */ - public static GLArrayDataServer createData(int compsPerElement, int dataType, int stride, - Buffer buffer, int vboUsage, int vboTarget) + public static GLArrayDataServer createData(final int compsPerElement, final int dataType, final int stride, + final Buffer buffer, final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); ads.init(null, -1, compsPerElement, dataType, false, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, vboTarget, false); return ads; @@ -225,12 +225,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, .. */ - public static GLArrayDataServer createData(int compsPerElement, int dataType, int initialElementCount, - int vboUsage, int vboTarget) + public static GLArrayDataServer createData(final int compsPerElement, final int dataType, final int initialElementCount, + final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); ads.init(null, -1, compsPerElement, dataType, false, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, vboTarget, false); return ads; @@ -249,12 +249,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, .. */ - public static GLArrayDataServer createDataMapped(int compsPerElement, int dataType, int mappedElementCount, - int vboUsage, int vboTarget) + public static GLArrayDataServer createDataMapped(final int compsPerElement, final int dataType, final int mappedElementCount, + final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads); ads.init(null, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, mappedElementCount, false, glArrayHandler, 0, 0, vboUsage, vboTarget, false); return ads; @@ -271,12 +271,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param initialElementCount The initial number of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createFixedInterleaved(int compsPerElement, int dataType, boolean normalized, int initialElementCount, - int vboUsage) + public static GLArrayDataServer createFixedInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); return ads; @@ -293,12 +293,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param mappedElementCount The total number of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createFixedInterleavedMapped(int compsPerElement, int dataType, boolean normalized, int mappedElementCount, - int vboUsage) + public static GLArrayDataServer createFixedInterleavedMapped(final int compsPerElement, final int dataType, final boolean normalized, final int mappedElementCount, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, mappedElementCount, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); ads.seal(true); @@ -317,12 +317,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param buffer The user define data of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createFixedInterleaved(int compsPerElement, int dataType, boolean normalized, int stride, Buffer buffer, - int vboUsage) + public static GLArrayDataServer createFixedInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int stride, final Buffer buffer, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); return ads; @@ -342,7 +342,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param comps This interleaved array segment's component count per element * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} */ - public GLArrayData addFixedSubArray(int index, int comps, int vboTarget) { + public GLArrayData addFixedSubArray(final int index, final int comps, final int vboTarget) { if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) { final int iOffC = interleavedOffset / getComponentSizeInBytes(); throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); @@ -382,12 +382,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param initialElementCount The initial number of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLInterleaved(int compsPerElement, int dataType, boolean normalized, int initialElementCount, - int vboUsage) + public static GLArrayDataServer createGLSLInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; @@ -404,11 +404,11 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param mappedElementCount The total number of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLInterleavedMapped(int compsPerElement, int dataType, boolean normalized, int mappedElementCount, int vboUsage) + public static GLArrayDataServer createGLSLInterleavedMapped(final int compsPerElement, final int dataType, final boolean normalized, final int mappedElementCount, final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */, mappedElementCount, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); ads.seal(true); @@ -427,12 +427,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param buffer The user define data of all interleaved elements * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLInterleaved(int compsPerElement, int dataType, boolean normalized, int stride, Buffer buffer, - int vboUsage) + public static GLArrayDataServer createGLSLInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int stride, final Buffer buffer, + final int vboUsage) throws GLException { - GLArrayDataServer ads = new GLArrayDataServer(); - GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); + final GLArrayDataServer ads = new GLArrayDataServer(); + final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; @@ -451,7 +451,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param comps This interleaved array segment's component count per element * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} */ - public GLArrayData addGLSLSubArray(String name, int comps, int vboTarget) { + public GLArrayData addGLSLSubArray(final String name, final int comps, final int vboTarget) { if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) { final int iOffC = interleavedOffset / getComponentSizeInBytes(); throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); @@ -480,7 +480,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ad; } - public final void setInterleavedOffset(int interleavedOffset) { + public final void setInterleavedOffset(final int interleavedOffset) { this.interleavedOffset = interleavedOffset; } @@ -497,11 +497,11 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // @Override - public void destroy(GL gl) { + public void destroy(final GL gl) { // super.destroy(gl): // - GLArrayDataClient.destroy(gl): disables & clears client-side buffer // - GLArrayDataWrapper.destroy(gl) (clears all values 'vboName' ..) - int _vboName = vboName; + final int _vboName = vboName; super.destroy(gl); if(_vboName!=0) { final int[] tmp = new int[] { _vboName } ; @@ -520,12 +520,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * Only possible if buffer is defined. */ @Override - public void setVBOEnabled(boolean vboUsage) { + public void setVBOEnabled(final boolean vboUsage) { checkSeal(false); super.setVBOEnabled(vboUsage); } - public GLBufferStorage mapStorage(GL gl, int access) { + public GLBufferStorage mapStorage(final GL gl, final int access) { if( null != this.getBuffer() ) { throw new IllegalStateException("user buffer not null"); } @@ -542,7 +542,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE rewind(); return storage; } - public GLBufferStorage mapStorage(GL gl, long offset, long length, int access) { + public GLBufferStorage mapStorage(final GL gl, final long offset, final long length, final int access) { if( null != this.getBuffer() ) { throw new IllegalStateException("user buffer not null"); } @@ -559,7 +559,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE rewind(); return storage; } - private final void setMappedBuffer(GLBufferStorage storage) { + private final void setMappedBuffer(final GLBufferStorage storage) { mappedStorage = storage; final ByteBuffer bb = storage.getMappedBuffer(); if(componentClazz==ByteBuffer.class) { @@ -575,7 +575,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } } - public void unmapStorage(GL gl) { + public void unmapStorage(final GL gl) { if( null == mappedStorage ) { throw new IllegalStateException("not mapped"); } @@ -621,10 +621,10 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // @Override - protected void init(String name, int index, int comps, int dataType, boolean normalized, - int stride, Buffer data, int initialElementCount, int mappedElementCount, - boolean isVertexAttribute, - GLArrayHandler glArrayHandler, int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL) + protected void init(final String name, final int index, final int comps, final int dataType, final boolean normalized, + final int stride, final Buffer data, final int initialElementCount, final int mappedElementCount, + final boolean isVertexAttribute, + final GLArrayHandler glArrayHandler, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL) throws GLException { super.init(name, index, comps, dataType, normalized, stride, data, initialElementCount, mappedElementCount, isVertexAttribute, @@ -634,10 +634,10 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } @Override - protected void init_vbo(GL gl) { + protected void init_vbo(final GL gl) { super.init_vbo(gl); if(vboEnabled && vboName==0) { - int[] tmp = new int[1]; + final int[] tmp = new int[1]; gl.glGenBuffers(1, tmp, 0); vboName = tmp[0]; if(0 < interleavedOffset) { @@ -657,7 +657,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * All other values are simply copied. * </p> */ - public GLArrayDataServer(GLArrayDataServer src) { + public GLArrayDataServer(final GLArrayDataServer src) { super(src); this.interleavedOffset = src.interleavedOffset; this.mappedStorage = src.mappedStorage; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java index f617fed73..867bc00ac 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java @@ -66,11 +66,11 @@ public class GLArrayDataWrapper implements GLArrayData { * * @throws GLException */ - public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, - Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) + public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, + final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataWrapper adc = new GLArrayDataWrapper(); + final GLArrayDataWrapper adc = new GLArrayDataWrapper(); adc.init(null, index, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */, false, vboName, vboOffset, vboUsage, vboTarget); return adc; @@ -93,11 +93,11 @@ public class GLArrayDataWrapper implements GLArrayData { * * @throws GLException */ - public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, - int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget) + public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, + final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataWrapper adc = new GLArrayDataWrapper(); + final GLArrayDataWrapper adc = new GLArrayDataWrapper(); adc.init(null, index, comps, dataType, normalized, stride, null, mappedElementCount, false, vboName, vboOffset, vboUsage, vboTarget); return adc; @@ -119,11 +119,11 @@ public class GLArrayDataWrapper implements GLArrayData { * @return the new create instance * @throws GLException */ - public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, - Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) + public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, + final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataWrapper adc = new GLArrayDataWrapper(); + final GLArrayDataWrapper adc = new GLArrayDataWrapper(); adc.init(name, -1, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */, true, vboName, vboOffset, vboUsage, vboTarget); return adc; @@ -145,11 +145,11 @@ public class GLArrayDataWrapper implements GLArrayData { * @return the new create instance * @throws GLException */ - public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, - int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget) + public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, + final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException { - GLArrayDataWrapper adc = new GLArrayDataWrapper(); + final GLArrayDataWrapper adc = new GLArrayDataWrapper(); adc.init(name, -1, comps, dataType, normalized, stride, null, mappedElementCount, true, vboName, vboOffset, vboUsage, vboTarget); return adc; @@ -163,7 +163,7 @@ public class GLArrayDataWrapper implements GLArrayData { * @param throwException whether to throw an exception if this instance has invalid parameter or not * @return true if this instance has invalid parameter, otherwise false */ - public final boolean validate(GLProfile glp, boolean throwException) { + public final boolean validate(final GLProfile glp, final boolean throwException) { if(!alive) { if(throwException) { throw new GLException("Instance !alive "+this); @@ -180,7 +180,7 @@ public class GLArrayDataWrapper implements GLArrayData { } @Override - public void associate(Object obj, boolean enable) { + public void associate(final Object obj, final boolean enable) { // nop } @@ -198,16 +198,16 @@ public class GLArrayDataWrapper implements GLArrayData { public final int getLocation() { return location; } @Override - public final int setLocation(int v) { location = v; return location; } + public final int setLocation(final int v) { location = v; return location; } @Override - public final int setLocation(GL2ES2 gl, int program) { + public final int setLocation(final GL2ES2 gl, final int program) { location = gl.glGetAttribLocation(program, name); return location; } @Override - public final int setLocation(GL2ES2 gl, int program, int location) { + public final int setLocation(final GL2ES2 gl, final int program, final int location) { this.location = location; gl.glBindAttribLocation(program, location, name); return location; @@ -275,7 +275,7 @@ public class GLArrayDataWrapper implements GLArrayData { public final Class<?> getBufferClass() { return componentClazz; } @Override - public void destroy(GL gl) { + public void destroy(final GL gl) { buffer = null; vboName=0; vboEnabled=false; @@ -305,7 +305,7 @@ public class GLArrayDataWrapper implements GLArrayData { "]"; } - public static final Class<?> getBufferClass(int dataType) { + public static final Class<?> getBufferClass(final int dataType) { switch(dataType) { case GL.GL_BYTE: case GL.GL_UNSIGNED_BYTE: @@ -314,7 +314,7 @@ public class GLArrayDataWrapper implements GLArrayData { case GL.GL_UNSIGNED_SHORT: return ShortBuffer.class; case GL.GL_UNSIGNED_INT: - case GL2ES1.GL_FIXED: + case GL.GL_FIXED: case GL2ES2.GL_INT: return IntBuffer.class; case GL.GL_FLOAT: @@ -325,7 +325,7 @@ public class GLArrayDataWrapper implements GLArrayData { } @Override - public void setName(String newName) { + public void setName(final String newName) { location = -1; name = newName; } @@ -335,7 +335,7 @@ public class GLArrayDataWrapper implements GLArrayData { * Only possible if a VBO buffer name is defined. * @see #setVBOName(int) */ - public void setVBOEnabled(boolean vboEnabled) { + public void setVBOEnabled(final boolean vboEnabled) { this.vboEnabled=vboEnabled; } @@ -345,7 +345,7 @@ public class GLArrayDataWrapper implements GLArrayData { * * @see #setVBOEnabled(boolean) */ - public void setVBOName(int vboName) { + public void setVBOName(final int vboName) { this.vboName=vboName; setVBOEnabled(0!=vboName); } @@ -353,20 +353,20 @@ public class GLArrayDataWrapper implements GLArrayData { /** * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public void setVBOUsage(int vboUsage) { + public void setVBOUsage(final int vboUsage) { this.vboUsage = vboUsage; } /** * @param vboTarget either {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} */ - public void setVBOTarget(int vboTarget) { + public void setVBOTarget(final int vboTarget) { this.vboTarget = vboTarget; } - protected void init(String name, int index, int componentsPerElement, int componentType, - boolean normalized, int stride, Buffer data, int mappedElementCount, - boolean isVertexAttribute, int vboName, long vboOffset, int vboUsage, int vboTarget) + protected void init(final String name, final int index, final int componentsPerElement, final int componentType, + final boolean normalized, final int stride, final Buffer data, final int mappedElementCount, + final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException { if( 0<mappedElementCount && null != data ) { @@ -452,7 +452,7 @@ public class GLArrayDataWrapper implements GLArrayData { * All other values are simply copied. * </p> */ - public GLArrayDataWrapper(GLArrayDataWrapper src) { + public GLArrayDataWrapper(final GLArrayDataWrapper src) { this.alive = src.alive; this.index = src.index; this.location = src.location; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java index b9903ac6d..67dc08450 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java @@ -44,6 +44,7 @@ import java.nio.ByteBuffer; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2ES3; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLES2; import javax.media.opengl.GLException; @@ -65,7 +66,7 @@ public class GLBuffers extends Buffers { * GL_UNSIGNED_INT, <br/> * GL_HILO16_NV <br/> */ - public static final boolean isSignedGLType(int glType) { + public static final boolean isSignedGLType(final int glType) { switch (glType) { // 29 case GL.GL_UNSIGNED_BYTE: case GL.GL_UNSIGNED_SHORT: @@ -85,7 +86,7 @@ public class GLBuffers extends Buffers { * GL_HALF_FLOAT_OES, <br/> * GL_DOUBLE <br/> */ - public static final boolean isGLTypeFixedPoint(int glType) { + public static final boolean isGLTypeFixedPoint(final int glType) { switch(glType) { case GL.GL_FLOAT: case GL.GL_HALF_FLOAT: @@ -123,7 +124,7 @@ public class GLBuffers extends Buffers { * * @return -1 if glType is unhandled, otherwise the actual value > 0 */ - public static final int sizeOfGLType(int glType) { + public static final int sizeOfGLType(final int glType) { switch (glType) { // 29 // case GL2.GL_BITMAP: case GL.GL_BYTE: @@ -136,9 +137,9 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV: - case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4: + case GL.GL_UNSIGNED_SHORT_4_4_4_4: case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1: + case GL.GL_UNSIGNED_SHORT_5_5_5_1: case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV: case GL2.GL_UNSIGNED_SHORT_8_8_APPLE: case GL2.GL_UNSIGNED_SHORT_8_8_REV_APPLE: @@ -151,16 +152,16 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_INT: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: - case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: - case GL2GL3.GL_UNSIGNED_INT_24_8: - case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: + case GL2ES2.GL_UNSIGNED_INT_10_10_10_2: + case GL2ES2.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL.GL_UNSIGNED_INT_24_8: + case GL.GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL2ES3.GL_UNSIGNED_INT_5_9_9_9_REV: case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return SIZEOF_INT; - case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + case GL2ES3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return SIZEOF_LONG; case GL.GL_FLOAT: @@ -197,7 +198,7 @@ public class GLBuffers extends Buffers { * * @return null if glType is unhandled, otherwise the new Buffer object */ - public static final Buffer newDirectGLBuffer(int glType, int numElements) { + public static final Buffer newDirectGLBuffer(final int glType, final int numElements) { switch (glType) { // 29 case GL.GL_BYTE: case GL.GL_UNSIGNED_BYTE: @@ -209,9 +210,9 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV: - case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4: + case GL.GL_UNSIGNED_SHORT_4_4_4_4: case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1: + case GL.GL_UNSIGNED_SHORT_5_5_5_1: case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV: case GL2.GL_UNSIGNED_SHORT_8_8_APPLE: case GL2.GL_UNSIGNED_SHORT_8_8_REV_APPLE: @@ -224,22 +225,22 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_INT: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: - case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: - case GL2GL3.GL_UNSIGNED_INT_24_8: - case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: + case GL2ES2.GL_UNSIGNED_INT_10_10_10_2: + case GL2ES2.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL.GL_UNSIGNED_INT_24_8: + case GL.GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL2ES3.GL_UNSIGNED_INT_5_9_9_9_REV: case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return newDirectIntBuffer(numElements); - case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + case GL2ES3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return newDirectLongBuffer(numElements); case GL.GL_FLOAT: return newDirectFloatBuffer(numElements); - case GL2.GL_DOUBLE: + case GL2GL3.GL_DOUBLE: return newDirectDoubleBuffer(numElements); } return null; @@ -269,7 +270,7 @@ public class GLBuffers extends Buffers { * GL_FLOAT, GL_DOUBLE <br/> * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object */ - public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) { + public static final Buffer sliceGLBuffer(final ByteBuffer parent, final int bytePos, final int byteLen, final int glType) { if (parent == null || byteLen == 0) { return null; } @@ -292,9 +293,9 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV: - case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4: + case GL.GL_UNSIGNED_SHORT_4_4_4_4: case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1: + case GL.GL_UNSIGNED_SHORT_5_5_5_1: case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV: case GL2.GL_UNSIGNED_SHORT_8_8_APPLE: case GL2.GL_UNSIGNED_SHORT_8_8_REV_APPLE: @@ -304,21 +305,21 @@ public class GLBuffers extends Buffers { break; case GL.GL_FIXED: - case GL2GL3.GL_INT: - case GL2ES2.GL_UNSIGNED_INT: + case GL2ES2.GL_INT: + case GL.GL_UNSIGNED_INT: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: - case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: - case GL2GL3.GL_UNSIGNED_INT_24_8: - case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: + case GL2ES2.GL_UNSIGNED_INT_10_10_10_2: + case GL2ES2.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL.GL_UNSIGNED_INT_24_8: + case GL.GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL2ES3.GL_UNSIGNED_INT_5_9_9_9_REV: case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: res = parent.slice().order(parent.order()).asIntBuffer(); // slice and duplicate may change byte order break; - case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + case GL2ES3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: res = parent.slice().order(parent.order()).asLongBuffer(); // slice and duplicate may change byte order break; @@ -326,7 +327,7 @@ public class GLBuffers extends Buffers { res = parent.slice().order(parent.order()).asFloatBuffer(); // slice and duplicate may change byte order break; - case GL2.GL_DOUBLE: + case GL2GL3.GL_DOUBLE: res = parent.slice().order(parent.order()).asDoubleBuffer(); // slice and duplicate may change byte order break; } @@ -334,7 +335,7 @@ public class GLBuffers extends Buffers { return res; } - private static final int glGetInteger(GL gl, int pname, int[] tmp) { + private static final int glGetInteger(final GL gl, final int pname, final int[] tmp) { gl.glGetIntegerv(pname, tmp, 0); return tmp[0]; } @@ -359,9 +360,9 @@ public class GLBuffers extends Buffers { * @return required minimum size of the buffer in bytes * @throws GLException if alignment is invalid. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], - int bytesPerPixel, int width, int height, int depth, - boolean pack) { + public static final int sizeof(final GL gl, final int tmp[], + final int bytesPerPixel, int width, int height, int depth, + final boolean pack) { int rowLength = 0; int skipRows = 0; int skipPixels = 0; @@ -372,9 +373,9 @@ public class GLBuffers extends Buffers { if (pack) { alignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT, tmp); if(gl.isGL2GL3()) { - rowLength = glGetInteger(gl, GL2GL3.GL_PACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp); - skipPixels = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_PIXELS, tmp); + rowLength = glGetInteger(gl, GL2ES3.GL_PACK_ROW_LENGTH, tmp); + skipRows = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_ROWS, tmp); + skipPixels = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_PIXELS, tmp); if (depth > 1) { imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp); skipImages = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_IMAGES, tmp); @@ -383,12 +384,12 @@ public class GLBuffers extends Buffers { } else { alignment = glGetInteger(gl, GL.GL_UNPACK_ALIGNMENT, tmp); if(gl.isGL2GL3 ()) { - rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp); - skipPixels = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_PIXELS, tmp); + rowLength = glGetInteger(gl, GL2ES2.GL_UNPACK_ROW_LENGTH, tmp); + skipRows = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_ROWS, tmp); + skipPixels = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_PIXELS, tmp); if (depth > 1) { - imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp); - skipImages = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_IMAGES, tmp); + imageHeight = glGetInteger(gl, GL2ES3.GL_UNPACK_IMAGE_HEIGHT, tmp); + skipImages = glGetInteger(gl, GL2ES3.GL_UNPACK_SKIP_IMAGES, tmp); } } } @@ -511,9 +512,9 @@ public class GLBuffers extends Buffers { * @return required minimum size of the buffer in bytes * @throws GLException if format, type or alignment is not handled. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], - int format, int type, int width, int height, int depth, - boolean pack) throws GLException { + public static final int sizeof(final GL gl, final int tmp[], + final int format, final int type, final int width, final int height, final int depth, + final boolean pack) throws GLException { if (width < 0) return 0; if (height < 0) return 0; if (depth < 0) return 0; @@ -578,14 +579,14 @@ public class GLBuffers extends Buffers { * @return required size of one pixel in bytes * @throws GLException if format or type alignment is not handled. Please contact the maintainer if this is our bug. */ - public static final int bytesPerPixel(int format, int type) throws GLException { + public static final int bytesPerPixel(final int format, final int type) throws GLException { int compSize = 0; int compCount = componentCount(format); switch (type) /* 30 */ { case GL2.GL_BITMAP: - if (GL2.GL_COLOR_INDEX == format || GL2GL3.GL_STENCIL_INDEX == format) { + if (GL2.GL_COLOR_INDEX == format || GL2ES2.GL_STENCIL_INDEX == format) { compSize = 1; } case GL.GL_BYTE: @@ -615,9 +616,9 @@ public class GLBuffers extends Buffers { break; case GL.GL_UNSIGNED_SHORT_5_6_5: case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV: - case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4: + case GL.GL_UNSIGNED_SHORT_4_4_4_4: case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1: + case GL.GL_UNSIGNED_SHORT_5_5_5_1: case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV: case GL2.GL_UNSIGNED_SHORT_8_8_APPLE: case GL2.GL_UNSIGNED_SHORT_8_8_REV_APPLE: @@ -631,15 +632,15 @@ public class GLBuffers extends Buffers { break; case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: - case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: - case GL2GL3.GL_UNSIGNED_INT_24_8: - case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: + case GL2ES2.GL_UNSIGNED_INT_10_10_10_2: + case GL2ES2.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL.GL_UNSIGNED_INT_24_8: + case GL.GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL2ES3.GL_UNSIGNED_INT_5_9_9_9_REV: compSize = 4; compCount = 1; break; - case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + case GL2ES3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: compSize = 8; compCount = 1; break; @@ -681,33 +682,33 @@ public class GLBuffers extends Buffers { * @return number of components required for the given OpenGL format * @throws GLException if format is not handled. Please contact the maintainer if this is our bug. */ - public static final int componentCount(int format) throws GLException { + public static final int componentCount(final int format) throws GLException { final int compCount; switch (format) /* 26 */ { case GL2.GL_COLOR_INDEX: - case GL2GL3.GL_STENCIL_INDEX: - case GL2GL3.GL_DEPTH_COMPONENT: - case GL2GL3.GL_DEPTH_STENCIL: - case GL2GL3.GL_RED: - case GL2GL3.GL_RED_INTEGER: - case GL2GL3.GL_GREEN: + case GL2ES2.GL_STENCIL_INDEX: + case GL2ES2.GL_DEPTH_COMPONENT: + case GL.GL_DEPTH_STENCIL: + case GL2ES2.GL_RED: + case GL2ES3.GL_RED_INTEGER: + case GL2ES3.GL_GREEN: case GL2GL3.GL_GREEN_INTEGER: - case GL2GL3.GL_BLUE: + case GL2ES3.GL_BLUE: case GL2GL3.GL_BLUE_INTEGER: case GL.GL_ALPHA: case GL.GL_LUMINANCE: compCount = 1; break; case GL.GL_LUMINANCE_ALPHA: - case GL2GL3.GL_RG: - case GL2GL3.GL_RG_INTEGER: + case GL2ES2.GL_RG: + case GL2ES3.GL_RG_INTEGER: case GL2.GL_HILO_NV: case GL2.GL_SIGNED_HILO_NV: compCount = 2; break; case GL.GL_RGB: - case GL2GL3.GL_RGB_INTEGER: + case GL2ES3.GL_RGB_INTEGER: case GL2GL3.GL_BGR: case GL2GL3.GL_BGR_INTEGER: compCount = 3; @@ -716,7 +717,7 @@ public class GLBuffers extends Buffers { compCount = 3; break; case GL.GL_RGBA: - case GL2GL3.GL_RGBA_INTEGER: + case GL2ES3.GL_RGBA_INTEGER: case GL.GL_BGRA: case GL2GL3.GL_BGRA_INTEGER: case GL2.GL_ABGR_EXT: @@ -748,9 +749,9 @@ public class GLBuffers extends Buffers { //---------------------------------------------------------------------- // Conversion routines // - public final static float[] getFloatArray(double[] source) { + public final static float[] getFloatArray(final double[] source) { int i = source.length; - float[] dest = new float[i--]; + final float[] dest = new float[i--]; while (i >= 0) { dest[i] = (float) source[i]; i--; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index cf88e7bf6..c74284299 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -47,19 +47,19 @@ import jogamp.opengl.Debug; public class GLDrawableUtil { protected static final boolean DEBUG = Debug.debug("GLDrawable"); - public static final boolean isAnimatorStartedOnOtherThread(GLAnimatorControl animatorCtrl) { + public static final boolean isAnimatorStartedOnOtherThread(final GLAnimatorControl animatorCtrl) { return ( null != animatorCtrl ) ? animatorCtrl.isStarted() && animatorCtrl.getThread() != Thread.currentThread() : false ; } - public static final boolean isAnimatorStarted(GLAnimatorControl animatorCtrl) { + public static final boolean isAnimatorStarted(final GLAnimatorControl animatorCtrl) { return ( null != animatorCtrl ) ? animatorCtrl.isStarted() : false ; } - public static final boolean isAnimatorAnimatingOnOtherThread(GLAnimatorControl animatorCtrl) { + public static final boolean isAnimatorAnimatingOnOtherThread(final GLAnimatorControl animatorCtrl) { return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() && animatorCtrl.getThread() != Thread.currentThread() : false ; } - public static final boolean isAnimatorAnimating(GLAnimatorControl animatorCtrl) { + public static final boolean isAnimatorAnimating(final GLAnimatorControl animatorCtrl) { return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() : false ; } @@ -79,7 +79,7 @@ public class GLDrawableUtil { * @param listener * @param preserveInitState */ - public static final void moveGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, GLEventListener listener, boolean preserveInitState) { + public static final void moveGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final GLEventListener listener, final boolean preserveInitState) { final boolean initialized = src.getGLEventListenerInitState(listener); src.removeGLEventListener(listener); dest.addGLEventListener(listener); @@ -105,7 +105,7 @@ public class GLDrawableUtil { * @param listener * @param preserveInitState */ - public static final void moveAllGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, boolean preserveInitState) { + public static final void moveAllGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final boolean preserveInitState) { for(int count = src.getGLEventListenerCount(); 0<count; count--) { final GLEventListener listener = src.getGLEventListener(0); moveGLEventListener(src, dest, listener, preserveInitState); @@ -127,7 +127,7 @@ public class GLDrawableUtil { * @param b * @throws GLException if the {@link AbstractGraphicsDevice} are incompatible w/ each other. */ - public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { + public static final void swapGLContextAndAllGLEventListener(final GLAutoDrawable a, final GLAutoDrawable b) { final GLEventListenerState gllsA = GLEventListenerState.moveFrom(a); final GLEventListenerState gllsB = GLEventListenerState.moveFrom(b); @@ -149,7 +149,7 @@ public class GLDrawableUtil { * @param src * @param dest */ - public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { + public static final void swapGLContext(final GLAutoDrawable src, final GLAutoDrawable dest) { final GLAnimatorControl aAnim = src.getAnimator(); final GLAnimatorControl bAnim = dest.getAnimator(); final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index 223c23ebb..ec2991448 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -103,7 +103,7 @@ public class GLPixelBuffer { * @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. * See {@link #getAllowRowStride()} and {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. */ - public DefaultGLPixelBufferProvider(boolean allowRowStride) { + public DefaultGLPixelBufferProvider(final boolean allowRowStride) { this.allowRowStride = allowRowStride; } @@ -111,7 +111,7 @@ public class GLPixelBuffer { public boolean getAllowRowStride() { return allowRowStride; } @Override - public GLPixelAttributes getAttributes(GL gl, int componentCount) { + public GLPixelAttributes getAttributes(final GL gl, final int componentCount) { final GLContext ctx = gl.getContext(); final int dFormat, dType; @@ -121,14 +121,14 @@ public class GLPixelBuffer { dFormat = GL2ES2.GL_RED; } else { // ALPHA is supported on ES2 and GL2, i.e. <= GL3 [core] or compatibility - dFormat = GL2ES2.GL_ALPHA; + dFormat = GL.GL_ALPHA; } dType = GL.GL_UNSIGNED_BYTE; } else if( 3 == componentCount ) { dFormat = GL.GL_RGB; dType = GL.GL_UNSIGNED_BYTE; } else if( 4 == componentCount ) { - int _dFormat = ctx.getDefaultPixelDataFormat(); + final int _dFormat = ctx.getDefaultPixelDataFormat(); final int dComps = GLBuffers.componentCount(_dFormat); if( dComps == componentCount ) { dFormat = _dFormat; @@ -150,11 +150,11 @@ public class GLPixelBuffer { * </p> */ @Override - public GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + public GLPixelBuffer allocate(final GL gl, final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final int minByteSize) { if( minByteSize > 0 ) { return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize), getAllowRowStride()); } else { - int[] tmp = { 0 }; + final int[] tmp = { 0 }; final int byteSize = GLBuffers.sizeof(gl, tmp, pixelAttributes.bytesPerPixel, width, height, depth, pack); return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(byteSize), getAllowRowStride()); } @@ -194,7 +194,7 @@ public class GLPixelBuffer { * @param dataFormat GL data format * @param dataType GL data type */ - public GLPixelAttributes(int dataFormat, int dataType) { + public GLPixelAttributes(final int dataFormat, final int dataType) { this(0 < dataFormat ? GLBuffers.componentCount(dataFormat) : 0, dataFormat, dataType); } /** @@ -203,7 +203,7 @@ public class GLPixelBuffer { * @param dataFormat GL data format * @param dataType GL data type */ - public GLPixelAttributes(int componentCount, int dataFormat, int dataType) { + public GLPixelAttributes(final int componentCount, final int dataFormat, final int dataType) { this(componentCount, dataFormat, dataType, true); } @@ -211,7 +211,7 @@ public class GLPixelBuffer { * Returns the matching {@link GLPixelAttributes} for the given {@link PixelFormat} and {@link GLProfile} if exists, * otherwise returns <code>null</code>. */ - public static final GLPixelAttributes convert(PixelFormat pixFmt, GLProfile glp) { + public static final GLPixelAttributes convert(final PixelFormat pixFmt, final GLProfile glp) { int df = 0; // format int dt = GL.GL_UNSIGNED_BYTE; // data type switch(pixFmt) { @@ -221,7 +221,7 @@ public class GLPixelBuffer { df = GL2ES2.GL_RED; } else { // ALPHA/LUMINANCE is supported on ES2 and GL2, i.e. <= GL3 [core] or compatibility - df = GL2ES2.GL_LUMINANCE; + df = GL.GL_LUMINANCE; } break; case BGR888: @@ -256,7 +256,7 @@ public class GLPixelBuffer { } return null; } - private GLPixelAttributes(int componentCount, int dataFormat, int dataType, boolean checkArgs) { + private GLPixelAttributes(final int componentCount, final int dataFormat, final int dataType, final boolean checkArgs) { this.componentCount = componentCount; this.format = dataFormat; this.type = dataType; @@ -290,7 +290,7 @@ public class GLPixelBuffer { case GL.GL_RGBA: pixFmt = PixelFormat.RGBA8888; break; - case GL2.GL_BGR: + case GL2GL3.GL_BGR: pixFmt = PixelFormat.BGR888; break; case GL.GL_BGRA: @@ -383,7 +383,7 @@ public class GLPixelBuffer { * @param buffer the backing array * @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. */ - public GLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, Buffer buffer, boolean allowRowStride) { + public GLPixelBuffer(final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final Buffer buffer, final boolean allowRowStride) { this.pixelAttributes = pixelAttributes; this.width = width; this.height = height; @@ -414,7 +414,7 @@ public class GLPixelBuffer { } /** Sets the byte position of the {@link #buffer}. */ - public Buffer position(int bytePos) { + public Buffer position(final int bytePos) { return buffer.position( bytePos / bufferElemSize ); } @@ -465,7 +465,7 @@ public class GLPixelBuffer { * @param newByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) */ - public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize) { + public boolean requiresNewBuffer(final GL gl, final int newWidth, final int newHeight, int newByteSize) { if( !isValid() ) { return true; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java index 34b493586..52612d224 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java @@ -171,7 +171,7 @@ public class GLPixelStorageModes { */ public final void resetPack(final GL gl) { // Compared w/ ES2, ES3 and GL3-core spec - gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, 4); // es2, es3, gl3 + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4); // es2, es3, gl3 if( gl.isGL2ES3() ) { gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0); // es3, gl3 gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0); // es3, gl3 @@ -202,7 +202,7 @@ public class GLPixelStorageModes { gl.getGL2().glPushClientAttrib(GL2.GL_CLIENT_PIXEL_STORE_BIT); } else { // ES1 or ES2 deals with pack/unpack alignment only - gl.glGetIntegerv(GL2ES2.GL_PACK_ALIGNMENT, cachePack, 0); + gl.glGetIntegerv(GL.GL_PACK_ALIGNMENT, cachePack, 0); if( gl.isGL2ES3() ) { gl.glGetIntegerv(GL2ES3.GL_PACK_ROW_LENGTH, cachePack, 1); gl.glGetIntegerv(GL2ES3.GL_PACK_SKIP_ROWS, cachePack, 2); @@ -222,7 +222,7 @@ public class GLPixelStorageModes { if( gl.isGL2() ) { gl.getGL2().glPopClientAttrib(); } else { - gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, cachePack[0]); + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, cachePack[0]); if( gl.isGL2ES3() ) { gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, cachePack[1]); gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, cachePack[2]); @@ -242,7 +242,7 @@ public class GLPixelStorageModes { */ public final void resetUnpack(final GL gl) { // Compared w/ ES2, ES3 and GL3-core spec - gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, 4); // es2, es3, gl3 + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 4); // es2, es3, gl3 if( gl.isGL2ES3() ) { gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, 0); // es3, gl3 gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, 0); // es3, gl3 @@ -273,7 +273,7 @@ public class GLPixelStorageModes { gl.getGL2().glPushClientAttrib(GL2.GL_CLIENT_PIXEL_STORE_BIT); } else { // ES1 or ES2 deals with pack/unpack alignment only - gl.glGetIntegerv(GL2ES2.GL_UNPACK_ALIGNMENT, cacheUnpack, 0); + gl.glGetIntegerv(GL.GL_UNPACK_ALIGNMENT, cacheUnpack, 0); if( gl.isGL2ES3() ) { gl.glGetIntegerv(GL2ES2.GL_UNPACK_ROW_LENGTH, cacheUnpack, 1); gl.glGetIntegerv(GL2ES2.GL_UNPACK_SKIP_ROWS, cacheUnpack, 2); @@ -293,7 +293,7 @@ public class GLPixelStorageModes { if( gl.isGL2() ) { gl.getGL2().glPopClientAttrib(); } else { - gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, cacheUnpack[0]); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, cacheUnpack[0]); if( gl.isGL2ES3() ) { gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, cacheUnpack[1]); gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, cacheUnpack[2]); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 680984cdb..abdb7c5f9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -62,11 +62,11 @@ public class GLReadBufferUtil { * @param alpha true for RGBA readPixels, otherwise RGB readPixels. Disclaimer: Alpha maybe forced on ES platforms! * @param write2Texture true if readPixel's TextureData shall be written to a 2d Texture */ - public GLReadBufferUtil(boolean alpha, boolean write2Texture) { + public GLReadBufferUtil(final boolean alpha, final boolean write2Texture) { this(GLPixelBuffer.defaultProviderNoRowStride, alpha, write2Texture); } - public GLReadBufferUtil(GLPixelBufferProvider pixelBufferProvider, boolean alpha, boolean write2Texture) { + public GLReadBufferUtil(final GLPixelBufferProvider pixelBufferProvider, final boolean alpha, final boolean write2Texture) { this.pixelBufferProvider = pixelBufferProvider; this.componentCount = alpha ? 4 : 3 ; this.alignment = alpha ? 4 : 1 ; @@ -110,11 +110,11 @@ public class GLReadBufferUtil { /** * Write the TextureData filled by {@link #readPixels(GLAutoDrawable, boolean)} to file */ - public void write(File dest) { + public void write(final File dest) { try { TextureIO.write(readTextureData, dest); rewindPixelBuffer(); - } catch (IOException ex) { + } catch (final IOException ex) { throw new RuntimeException("can not write to file: " + dest.getAbsolutePath(), ex); } } @@ -131,7 +131,7 @@ public class GLReadBufferUtil { * * @see #GLReadBufferUtil(boolean, boolean) */ - public boolean readPixels(GL gl, boolean mustFlipVertically) { + public boolean readPixels(final GL gl, final boolean mustFlipVertically) { return readPixels(gl, 0, 0, 0, 0, mustFlipVertically); } @@ -150,7 +150,7 @@ public class GLReadBufferUtil { * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). * @see #GLReadBufferUtil(boolean, boolean) */ - public boolean readPixels(GL gl, int inX, int inY, int inWidth, int inHeight, boolean mustFlipVertically) { + public boolean readPixels(final GL gl, final int inX, final int inY, final int inWidth, final int inHeight, final boolean mustFlipVertically) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int width, height; if( 0 >= inWidth || drawable.getSurfaceWidth() < inWidth ) { @@ -207,7 +207,7 @@ public class GLReadBufferUtil { readPixelBuffer.buffer, null /* Flusher */); newData = true; - } catch (Exception e) { + } catch (final Exception e) { readTextureData = null; readPixelBuffer = null; throw new RuntimeException("can not fetch offscreen texture", e); @@ -229,7 +229,7 @@ public class GLReadBufferUtil { readPixelBuffer.clear(); try { gl.glReadPixels(inX, inY, width, height, pixelAttribs.format, pixelAttribs.type, readPixelBuffer.buffer); - } catch(GLException gle) { res = false; gle.printStackTrace(); } + } catch(final GLException gle) { res = false; gle.printStackTrace(); } readPixelBuffer.position( readPixelSize ); readPixelBuffer.flip(); final int glerr1 = gl.glGetError(); @@ -256,7 +256,7 @@ public class GLReadBufferUtil { return res; } - public void dispose(GL gl) { + public void dispose(final GL gl) { if(null != readTexture) { readTexture.destroy(gl); readTextureData = null; diff --git a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java index 966781906..4e44c997a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java @@ -87,7 +87,7 @@ public class Gamma { * @throws IllegalArgumentException if any of the parameters were * out-of-bounds */ - public static boolean setDisplayGamma(GL gl, float gamma, float brightness, float contrast) throws IllegalArgumentException { + public static boolean setDisplayGamma(final GL gl, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException { return GLDrawableFactoryImpl.getFactoryImpl(gl.getContext().getGLDrawable().getGLProfile()).setDisplayGamma(gamma, brightness, contrast); } @@ -101,7 +101,7 @@ public class Gamma { * exiting, calling it is recommended because of the inevitable * unspecified behavior during JVM teardown. */ - public static void resetDisplayGamma(GL gl) { + public static void resetDisplayGamma(final GL gl) { GLDrawableFactoryImpl.getFactoryImpl(gl.getContext().getGLDrawable().getGLProfile()).resetDisplayGamma(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 986f6d8d3..150e92c2e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -18,6 +18,7 @@ import jogamp.opengl.Debug; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.opengl.util.glsl.ShaderState; /** @@ -54,9 +55,9 @@ public class ImmModeSink { static { Debug.initSingleton(); - DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); - DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); - DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); + DEBUG_BEGIN_END = PropertyAccess.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); + DEBUG_DRAW = PropertyAccess.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); + DEBUG_BUFFER = PropertyAccess.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); } public static final int GL_QUADS = 0x0007; // Needs data manipulation on ES1/ES2 @@ -81,12 +82,12 @@ public class ImmModeSink { * @param glBufferUsage VBO <code>usage</code> parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to <code>0</code> for no VBO usage */ - public static ImmModeSink createFixed(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, - int glBufferUsage) { + public static ImmModeSink createFixed(final int initialElementCount, + final int vComps, final int vDataType, + final int cComps, final int cDataType, + final int nComps, final int nDataType, + final int tComps, final int tDataType, + final int glBufferUsage) { return new ImmModeSink(initialElementCount, vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, false, glBufferUsage, null, 0); @@ -114,12 +115,12 @@ public class ImmModeSink { * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, - int glBufferUsage, ShaderState st) { + public static ImmModeSink createGLSL(final int initialElementCount, + final int vComps, final int vDataType, + final int cComps, final int cDataType, + final int nComps, final int nDataType, + final int tComps, final int tDataType, + final int glBufferUsage, final ShaderState st) { return new ImmModeSink(initialElementCount, vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, st, 0); @@ -147,18 +148,18 @@ public class ImmModeSink { * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, - int glBufferUsage, int shaderProgram) { + public static ImmModeSink createGLSL(final int initialElementCount, + final int vComps, final int vDataType, + final int cComps, final int cDataType, + final int nComps, final int nDataType, + final int tComps, final int tDataType, + final int glBufferUsage, final int shaderProgram) { return new ImmModeSink(initialElementCount, vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, null, shaderProgram); } - public void destroy(GL gl) { + public void destroy(final GL gl) { destroyList(gl); vboSet.destroy(gl); @@ -168,16 +169,16 @@ public class ImmModeSink { reset(null); } - public void reset(GL gl) { + public void reset(final GL gl) { destroyList(gl); vboSet.reset(gl); } @Override public String toString() { - StringBuilder sb = new StringBuilder("ImmModeSink["); + final StringBuilder sb = new StringBuilder("ImmModeSink["); sb.append(",\n\tVBO list: "+vboSetList.size()+" ["); - for(Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; ) { + for(final Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; ) { sb.append("\n\t"); sb.append( i.next() ); } @@ -191,7 +192,7 @@ public class ImmModeSink { return sb.toString(); } - public void draw(GL gl, boolean disableBufferAfterDraw) { + public void draw(final GL gl, final boolean disableBufferAfterDraw) { if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this); } @@ -201,7 +202,7 @@ public class ImmModeSink { } } - public void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw) { + public void draw(final GL gl, final Buffer indices, final boolean disableBufferAfterDraw) { if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw(disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this); } @@ -228,19 +229,19 @@ public class ImmModeSink { vboSet.checkSeal(false); } - public final void glEnd(GL gl) { + public final void glEnd(final GL gl) { glEnd(gl, null, true); } - public void glEnd(GL gl, boolean immediateDraw) { + public void glEnd(final GL gl, final boolean immediateDraw) { glEnd(gl, null, immediateDraw); } - public final void glEnd(GL gl, Buffer indices) { + public final void glEnd(final GL gl, final Buffer indices) { glEnd(gl, indices, true); } - private void glEnd(GL gl, Buffer indices, boolean immediateDraw) { + private void glEnd(final GL gl, final Buffer indices, final boolean immediateDraw) { if(DEBUG_BEGIN_END) { System.err.println("ImmModeSink START glEnd(immediate: "+immediateDraw+")"); } @@ -259,117 +260,117 @@ public class ImmModeSink { } } - public void glVertexv(Buffer v) { + public void glVertexv(final Buffer v) { vboSet.glVertexv(v); } - public void glNormalv(Buffer v) { + public void glNormalv(final Buffer v) { vboSet.glNormalv(v); } - public void glColorv(Buffer v) { + public void glColorv(final Buffer v) { vboSet.glColorv(v); } - public void glTexCoordv(Buffer v) { + public void glTexCoordv(final Buffer v) { vboSet.glTexCoordv(v); } - public final void glVertex2f(float x, float y) { + public final void glVertex2f(final float x, final float y) { vboSet.glVertex2f(x,y); } - public final void glVertex3f(float x, float y, float z) { + public final void glVertex3f(final float x, final float y, final float z) { vboSet.glVertex3f(x,y,z); } - public final void glNormal3f(float x, float y, float z) { + public final void glNormal3f(final float x, final float y, final float z) { vboSet.glNormal3f(x,y,z); } - public final void glColor3f(float x, float y, float z) { + public final void glColor3f(final float x, final float y, final float z) { vboSet.glColor3f(x,y,z); } - public final void glColor4f(float x, float y, float z, float a) { + public final void glColor4f(final float x, final float y, final float z, final float a) { vboSet.glColor4f(x,y,z, a); } - public final void glTexCoord2f(float x, float y) { + public final void glTexCoord2f(final float x, final float y) { vboSet.glTexCoord2f(x,y); } - public final void glTexCoord3f(float x, float y, float z) { + public final void glTexCoord3f(final float x, final float y, final float z) { vboSet.glTexCoord3f(x,y,z); } - public final void glVertex2s(short x, short y) { + public final void glVertex2s(final short x, final short y) { vboSet.glVertex2s(x,y); } - public final void glVertex3s(short x, short y, short z) { + public final void glVertex3s(final short x, final short y, final short z) { vboSet.glVertex3s(x,y,z); } - public final void glNormal3s(short x, short y, short z) { + public final void glNormal3s(final short x, final short y, final short z) { vboSet.glNormal3s(x,y,z); } - public final void glColor3s(short x, short y, short z) { + public final void glColor3s(final short x, final short y, final short z) { vboSet.glColor3s(x,y,z); } - public final void glColor4s(short x, short y, short z, short a) { + public final void glColor4s(final short x, final short y, final short z, final short a) { vboSet.glColor4s(x,y,z,a); } - public final void glTexCoord2s(short x, short y) { + public final void glTexCoord2s(final short x, final short y) { vboSet.glTexCoord2s(x,y); } - public final void glTexCoord3s(short x, short y, short z) { + public final void glTexCoord3s(final short x, final short y, final short z) { vboSet.glTexCoord3s(x,y,z); } - public final void glVertex2b(byte x, byte y) { + public final void glVertex2b(final byte x, final byte y) { vboSet.glVertex2b(x,y); } - public final void glVertex3b(byte x, byte y, byte z) { + public final void glVertex3b(final byte x, final byte y, final byte z) { vboSet.glVertex3b(x,y,z); } - public final void glNormal3b(byte x, byte y, byte z) { + public final void glNormal3b(final byte x, final byte y, final byte z) { vboSet.glNormal3b(x,y,z); } - public final void glColor3b(byte x, byte y, byte z) { + public final void glColor3b(final byte x, final byte y, final byte z) { vboSet.glColor3b(x,y,z); } - public final void glColor3ub(byte x, byte y, byte z) { + public final void glColor3ub(final byte x, final byte y, final byte z) { vboSet.glColor3ub(x,y,z); } - public final void glColor4b(byte x, byte y, byte z, byte a) { + public final void glColor4b(final byte x, final byte y, final byte z, final byte a) { vboSet.glColor4b(x,y,z,a); } - public final void glColor4ub(byte x, byte y, byte z, byte a) { + public final void glColor4ub(final byte x, final byte y, final byte z, final byte a) { vboSet.glColor4ub(x,y,z,a); } - public final void glTexCoord2b(byte x, byte y) { + public final void glTexCoord2b(final byte x, final byte y) { vboSet.glTexCoord2b(x,y); } - public final void glTexCoord3b(byte x, byte y, byte z) { + public final void glTexCoord3b(final byte x, final byte y, final byte z) { vboSet.glTexCoord3b(x,y,z); } - protected ImmModeSink(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, - boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { + protected ImmModeSink(final int initialElementCount, + final int vComps, final int vDataType, + final int cComps, final int cDataType, + final int nComps, final int nDataType, + final int tComps, final int tDataType, + final boolean useGLSL, final int glBufferUsage, final ShaderState st, final int shaderProgram) { vboSet = new VBOSet(initialElementCount, vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, st, shaderProgram); @@ -390,9 +391,9 @@ public class ImmModeSink { * @see #createFixed(int, int, int, int, int, int, int, int, int, int) * @see #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) */ - public void setResizeElementCount(int v) { vboSet.setResizeElementCount(v); } + public void setResizeElementCount(final int v) { vboSet.setResizeElementCount(v); } - private void destroyList(GL gl) { + private void destroyList(final GL gl) { for(int i=0; i<vboSetList.size(); i++) { vboSetList.get(i).destroy(gl); } @@ -403,12 +404,12 @@ public class ImmModeSink { private final ArrayList<VBOSet> vboSetList; protected static class VBOSet { - protected VBOSet (int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, - boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { + protected VBOSet (final int initialElementCount, + final int vComps, final int vDataType, + final int cComps, final int cDataType, + final int nComps, final int nDataType, + final int tComps, final int tDataType, + final boolean useGLSL, final int glBufferUsage, final ShaderState st, final int shaderProgram) { // final .. this.glBufferUsage=glBufferUsage; this.initialElementCount=initialElementCount; @@ -465,17 +466,17 @@ public class ImmModeSink { } protected int getResizeElementCount() { return resizeElementCount; } - protected void setResizeElementCount(int v) { resizeElementCount=v; } + protected void setResizeElementCount(final int v) { resizeElementCount=v; } protected boolean getUseVBO() { return useVBO; } - protected final VBOSet regenerate(GL gl) { + protected final VBOSet regenerate(final GL gl) { return new VBOSet(initialElementCount, vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, shaderState, shaderProgram); } - protected void checkSeal(boolean test) throws GLException { + protected void checkSeal(final boolean test) throws GLException { if(0==mode) { throw new GLException("No mode set yet, call glBegin(mode) first:\n\t"+this); } @@ -490,7 +491,7 @@ public class ImmModeSink { private boolean usingShaderProgram = false; - protected void useShaderProgram(GL2ES2 gl, boolean force) { + protected void useShaderProgram(final GL2ES2 gl, final boolean force) { if( force || !usingShaderProgram ) { if(null != shaderState) { shaderState.useProgram(gl, true); @@ -501,7 +502,7 @@ public class ImmModeSink { } } - protected void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw, int i) + protected void draw(final GL gl, final Buffer indices, final boolean disableBufferAfterDraw, final int i) { enableBuffer(gl, true); @@ -544,17 +545,17 @@ public class ImmModeSink { if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; for (int j = 0; j < idxLen; j++) { - gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(idx0+j)), 4); + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, 0x000000ff & b.get(idx0+j), 4); } } else if( GL.GL_UNSIGNED_SHORT == type ){ final ShortBuffer b = (ShortBuffer) indices; for (int j = 0; j < idxLen; j++) { - gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(idx0+j)), 4); + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, 0x0000ffff & b.get(idx0+j), 4); } } else { final IntBuffer b = (IntBuffer) indices; for (int j = 0; j < idxLen; j++) { - gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4); + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, 0xffffffff & b.get(idx0+j), 4); } } } else { @@ -573,24 +574,24 @@ public class ImmModeSink { } } - public void glVertexv(Buffer v) { + public void glVertexv(final Buffer v) { checkSeal(false); Buffers.put(vertexArray, v); } - public void glNormalv(Buffer v) { + public void glNormalv(final Buffer v) { checkSeal(false); Buffers.put(normalArray, v); } - public void glColorv(Buffer v) { + public void glColorv(final Buffer v) { checkSeal(false); Buffers.put(colorArray, v); } - public void glTexCoordv(Buffer v) { + public void glTexCoordv(final Buffer v) { checkSeal(false); Buffers.put(textCoordArray, v); } - public void glVertex2b(byte x, byte y) { + public void glVertex2b(final byte x, final byte y) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -599,7 +600,7 @@ public class ImmModeSink { Buffers.putNb(vertexArray, vDataTypeSigned, y, true); countAndPadding(VERTEX, vComps-2); } - public void glVertex3b(byte x, byte y, byte z) { + public void glVertex3b(final byte x, final byte y, final byte z) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -610,7 +611,7 @@ public class ImmModeSink { Buffers.putNb(vertexArray, vDataTypeSigned, z, true); countAndPadding(VERTEX, vComps-3); } - public void glVertex2s(short x, short y) { + public void glVertex2s(final short x, final short y) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -619,7 +620,7 @@ public class ImmModeSink { Buffers.putNs(vertexArray, vDataTypeSigned, y, true); countAndPadding(VERTEX, vComps-2); } - public void glVertex3s(short x, short y, short z) { + public void glVertex3s(final short x, final short y, final short z) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -630,7 +631,7 @@ public class ImmModeSink { Buffers.putNs(vertexArray, vDataTypeSigned, z, true); countAndPadding(VERTEX, vComps-3); } - public void glVertex2f(float x, float y) { + public void glVertex2f(final float x, final float y) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -639,7 +640,7 @@ public class ImmModeSink { Buffers.putNf(vertexArray, vDataTypeSigned, y); countAndPadding(VERTEX, vComps-2); } - public void glVertex3f(float x, float y, float z) { + public void glVertex3f(final float x, final float y, final float z) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) @@ -651,7 +652,7 @@ public class ImmModeSink { countAndPadding(VERTEX, vComps-3); } - public void glNormal3b(byte x, byte y, byte z) { + public void glNormal3b(final byte x, final byte y, final byte z) { checkSeal(false); growBuffer(NORMAL); if(nComps>0) @@ -662,7 +663,7 @@ public class ImmModeSink { Buffers.putNb(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } - public void glNormal3s(short x, short y, short z) { + public void glNormal3s(final short x, final short y, final short z) { checkSeal(false); growBuffer(NORMAL); if(nComps>0) @@ -673,7 +674,7 @@ public class ImmModeSink { Buffers.putNs(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } - public void glNormal3f(float x, float y, float z) { + public void glNormal3f(final float x, final float y, final float z) { checkSeal(false); growBuffer(NORMAL); if(nComps>0) @@ -685,7 +686,7 @@ public class ImmModeSink { countAndPadding(NORMAL, nComps-3); } - public void glColor3b(byte r, byte g, byte b) { + public void glColor3b(final byte r, final byte g, final byte b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -696,7 +697,7 @@ public class ImmModeSink { Buffers.putNb(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } - public void glColor3ub(byte r, byte g, byte b) { + public void glColor3ub(final byte r, final byte g, final byte b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -707,7 +708,7 @@ public class ImmModeSink { Buffers.putNb(colorArray, cDataTypeSigned, b, false); countAndPadding(COLOR, cComps-3); } - public void glColor4b(byte r, byte g, byte b, byte a) { + public void glColor4b(final byte r, final byte g, final byte b, final byte a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -720,7 +721,7 @@ public class ImmModeSink { Buffers.putNb(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } - public void glColor4ub(byte r, byte g, byte b, byte a) { + public void glColor4ub(final byte r, final byte g, final byte b, final byte a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -733,7 +734,7 @@ public class ImmModeSink { Buffers.putNb(colorArray, cDataTypeSigned, a, false); countAndPadding(COLOR, cComps-4); } - public void glColor3s(short r, short g, short b) { + public void glColor3s(final short r, final short g, final short b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -744,7 +745,7 @@ public class ImmModeSink { Buffers.putNs(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } - public void glColor4s(short r, short g, short b, short a) { + public void glColor4s(final short r, final short g, final short b, final short a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -757,7 +758,7 @@ public class ImmModeSink { Buffers.putNs(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } - public void glColor3f(float r, float g, float b) { + public void glColor3f(final float r, final float g, final float b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -768,7 +769,7 @@ public class ImmModeSink { Buffers.putNf(colorArray, cDataTypeSigned, b); countAndPadding(COLOR, cComps-3); } - public void glColor4f(float r, float g, float b, float a) { + public void glColor4f(final float r, final float g, final float b, final float a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) @@ -782,7 +783,7 @@ public class ImmModeSink { countAndPadding(COLOR, cComps-4); } - public void glTexCoord2b(byte x, byte y) { + public void glTexCoord2b(final byte x, final byte y) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -791,7 +792,7 @@ public class ImmModeSink { Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } - public void glTexCoord3b(byte x, byte y, byte z) { + public void glTexCoord3b(final byte x, final byte y, final byte z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -802,7 +803,7 @@ public class ImmModeSink { Buffers.putNb(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } - public void glTexCoord2s(short x, short y) { + public void glTexCoord2s(final short x, final short y) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -811,7 +812,7 @@ public class ImmModeSink { Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } - public void glTexCoord3s(short x, short y, short z) { + public void glTexCoord3s(final short x, final short y, final short z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -822,7 +823,7 @@ public class ImmModeSink { Buffers.putNs(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } - public void glTexCoord2f(float x, float y) { + public void glTexCoord2f(final float x, final float y) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -831,7 +832,7 @@ public class ImmModeSink { Buffers.putNf(textCoordArray, tDataTypeSigned, y); countAndPadding(TEXTCOORD, tComps-2); } - public void glTexCoord3f(float x, float y, float z) { + public void glTexCoord3f(final float x, final float y, final float z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) @@ -858,7 +859,7 @@ public class ImmModeSink { } } - public void setShaderProgram(int program) { + public void setShaderProgram(final int program) { if(null == shaderState && 0 == program) { throw new IllegalArgumentException("Not allowed to zero shader program if no ShaderState is set"); } @@ -871,7 +872,7 @@ public class ImmModeSink { * @return true if all locations for all used arrays are found (min 1 array), otherwise false. * Also sets 'glslLocationSet' to the return value! */ - private boolean resetGLSLArrayLocation(GL2ES2 gl) { + private boolean resetGLSLArrayLocation(final GL2ES2 gl) { int iA = 0; int iL = 0; @@ -903,7 +904,7 @@ public class ImmModeSink { return glslLocationSet; } - public void destroy(GL gl) { + public void destroy(final GL gl) { reset(gl); vCount=0; cCount=0; nCount=0; tCount=0; @@ -912,7 +913,7 @@ public class ImmModeSink { buffer=null; } - public void reset(GL gl) { + public void reset(final GL gl) { enableBuffer(gl, false); reset(); } @@ -935,16 +936,16 @@ public class ImmModeSink { this.tElems=0; } - public void seal(GL glObj, boolean seal) + public void seal(final GL glObj, final boolean seal) { seal(seal); if(sealedGL==seal) return; sealedGL = seal; - GL gl = glObj.getGL(); + final GL gl = glObj.getGL(); if(seal) { if(useVBO) { if(0 == vboName) { - int[] tmp = new int[1]; + final int[] tmp = new int[1]; gl.glGenBuffers(1, tmp, 0); vboName = tmp[0]; } @@ -967,7 +968,7 @@ public class ImmModeSink { } } - public void seal(boolean seal) + public void seal(final boolean seal) { if(sealed==seal) return; sealed = seal; @@ -977,7 +978,7 @@ public class ImmModeSink { } } - public void enableBuffer(GL gl, boolean enable) { + public void enableBuffer(final GL gl, final boolean enable) { if( bufferEnabled != enable && vElems>0 ) { if(enable) { checkSeal(true); @@ -996,7 +997,7 @@ public class ImmModeSink { } } - private final void writeBuffer(GL gl) { + private final void writeBuffer(final GL gl) { final int vBytes = vElems * vCompsBytes; final int cBytes = cElems * cCompsBytes; final int nBytes = nElems * nCompsBytes; @@ -1021,8 +1022,8 @@ public class ImmModeSink { } } - private void enableBufferFixed(GL gl, boolean enable) { - GL2ES1 glf = gl.getGL2ES1(); + private void enableBufferFixed(final GL gl, final boolean enable) { + final GL2ES1 glf = gl.getGL2ES1(); final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; @@ -1089,8 +1090,8 @@ public class ImmModeSink { } } - private void enableBufferGLSLShaderState(GL gl, boolean enable) { - GL2ES2 glsl = gl.getGL2ES2(); + private void enableBufferGLSLShaderState(final GL gl, final boolean enable) { + final GL2ES2 glsl = gl.getGL2ES2(); final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; @@ -1157,8 +1158,8 @@ public class ImmModeSink { } } - private void enableBufferGLSLSimple(GL gl, boolean enable) { - GL2ES2 glsl = gl.getGL2ES2(); + private void enableBufferGLSLSimple(final GL gl, final boolean enable) { + final GL2ES2 glsl = gl.getGL2ES2(); final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; @@ -1267,7 +1268,7 @@ public class ImmModeSink { return "[v "+vElems+"/"+vCount+", c "+cElems+"/"+cCount+", n "+nElems+"/"+nCount+", t "+tElems+"/"+tCount+"]"; } - protected boolean fitElementInBuffer(int type) { + protected boolean fitElementInBuffer(final int type) { final int addElems = 1; switch (type) { case VERTEX: @@ -1283,7 +1284,7 @@ public class ImmModeSink { } } - protected boolean reallocateBuffer(int addElems) { + protected boolean reallocateBuffer(final int addElems) { final int vAdd = addElems - ( vCount - vElems ); final int cAdd = addElems - ( cCount - cElems ); final int nAdd = addElems - ( nCount - nElems ); @@ -1381,7 +1382,7 @@ public class ImmModeSink { } /** grow buffer by initialElementCount if there is no space for one more element in the designated buffer */ - protected final boolean growBuffer(int type) { + protected final boolean growBuffer(final int type) { if( null !=buffer && !sealed ) { if( !fitElementInBuffer(type) ) { // save olde values .. @@ -1422,7 +1423,7 @@ public class ImmModeSink { * @param type * @param fill */ - private void countAndPadding(int type, int fill) { + private void countAndPadding(final int type, int fill) { if ( sealed ) return; final Buffer dest; diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index c6f1f529d..289183b8e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -34,7 +34,6 @@ package com.jogamp.opengl.util; -import java.nio.Buffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -42,15 +41,13 @@ import javax.media.opengl.GL; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; -import jogamp.opengl.ProjectFloat; +import jogamp.common.os.PlatformPropsImpl; import com.jogamp.common.nio.Buffers; -import com.jogamp.common.os.Platform; import com.jogamp.common.util.FloatStack; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.Quaternion; import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.VectorUtil; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.math.geom.Frustum; @@ -77,30 +74,28 @@ import com.jogamp.opengl.math.geom.Frustum; * </p> * <a name="storageDetails"><h5>Matrix storage details</h5></a> * <p> - * All matrices use a common FloatBuffer storage - * and are a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced} representation of it. - * The common FloatBuffer and hence all matrices may use NIO direct storage or a {@link #usesBackingArray() backing float array}, - * depending how the instance if {@link #PMVMatrix(boolean) being constructed}. + * All matrices are backed up by a common primitive float-array for performance considerations + * and are a {@link Buffers#slice2Float(float[], int, int) sliced} representation of it. * </p> * <p> * <b>Note:</b> * <ul> - * <li>The matrix is a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.</li> + * <li>The matrix is a {@link Buffers#slice2Float(float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.</li> * <li>Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.</li> * <li>If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.</li> * </ul> * </p> */ -public class PMVMatrix implements GLMatrixFunc { +public final class PMVMatrix implements GLMatrixFunc { /** Bit value stating a modified {@link #glGetPMatrixf() projection matrix (P)}, since last {@link #update()} call. */ - public static final int MODIFIED_PROJECTION = 1 << 0; + public static final int MODIFIED_PROJECTION = 1 << 0; /** Bit value stating a modified {@link #glGetMvMatrixf() modelview matrix (Mv)}, since last {@link #update()} call. */ - public static final int MODIFIED_MODELVIEW = 1 << 1; + public static final int MODIFIED_MODELVIEW = 1 << 1; /** Bit value stating a modified {@link #glGetTMatrixf() texture matrix (T)}, since last {@link #update()} call. */ - public static final int MODIFIED_TEXTURE = 1 << 2; + public static final int MODIFIED_TEXTURE = 1 << 2; /** Bit value stating all is modified */ - public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; + public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; /** Bit value stating a dirty {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)}. */ public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0; @@ -180,7 +175,8 @@ public class PMVMatrix implements GLMatrixFunc { * @param a 4x4 matrix in column major order (OpenGL) * @return matrix string representation */ - public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a) { + @SuppressWarnings("deprecation") + public static StringBuilder matrixToString(final StringBuilder sb, final String f, final FloatBuffer a) { return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false); } @@ -191,102 +187,71 @@ public class PMVMatrix implements GLMatrixFunc { * @param b 4x4 matrix in column major order (OpenGL) * @return side by side representation */ - public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a, FloatBuffer b) { + @SuppressWarnings("deprecation") + public static StringBuilder matrixToString(final StringBuilder sb, final String f, final FloatBuffer a, final FloatBuffer b) { return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false); } /** - * Creates an instance of PMVMatrix {@link #PMVMatrix(boolean) PMVMatrix(boolean useBackingArray)}, - * with <code>useBackingArray = true</code>. - */ - public PMVMatrix() { - this(true); - } - - /** * Creates an instance of PMVMatrix. - * - * @param useBackingArray <code>true</code> for non direct NIO Buffers with guaranteed backing array, - * which allows faster access in Java computation. - * <p><code>false</code> for direct NIO buffers w/o a guaranteed backing array. - * In most Java implementations, direct NIO buffers have no backing array - * and hence the Java computation will be throttled down by direct IO get/put - * operations.</p> - * <p>Depending on the application, ie. whether the Java computation or - * JNI invocation and hence native data transfer part is heavier, - * this flag shall be set to <code>true</code> or <code>false</code></p>. + * <p> + * Implementation uses non-direct non-NIO Buffers with guaranteed backing array, + * which allows faster access in Java computation. + * </p> */ - public PMVMatrix(boolean useBackingArray) { - this.usesBackingArray = useBackingArray; - + public PMVMatrix() { // I Identity // T Texture // P Projection // Mv ModelView // Mvi Modelview-Inverse // Mvit Modelview-Inverse-Transpose - if(useBackingArray) { - matrixBufferArray = new float[ 6*16 + ProjectFloat.getRequiredFloatBufferSize() ]; - matrixBuffer = null; - } else { - matrixBufferArray = null; - matrixBuffer = Buffers.newDirectByteBuffer( ( 6*16 + ProjectFloat.getRequiredFloatBufferSize() ) * Buffers.SIZEOF_FLOAT ); - matrixBuffer.mark(); - } - - matrixIdent = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 0*16, 1*16); // I - matrixTex = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 1*16, 1*16); // T - matrixPMvMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 4*16); // P + Mv + Mvi + Mvit - matrixPMvMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 3*16); // P + Mv + Mvi - matrixPMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 2*16); // P + Mv - matrixP = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 1*16); // P - matrixMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 3*16, 1*16); // Mv - matrixMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 4*16, 1*16); // Mvi - matrixMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 5*16, 1*16); // Mvit - - projectFloat = new ProjectFloat(matrixBuffer, matrixBufferArray, 6*16); - - if(null != matrixBuffer) { - matrixBuffer.reset(); - } - FloatUtil.makeIdentityf(matrixIdent); - - tmpVec3f = new float[3]; - tmpMatrix = new float[16]; - matrixRot = new float[16]; - matrixMult = new float[16]; - matrixTrans = new float[16]; - matrixScale = new float[16]; - matrixOrtho = new float[16]; - matrixFrustum = new float[16]; - FloatUtil.makeIdentityf(matrixTrans, 0); - FloatUtil.makeIdentityf(matrixRot, 0); - FloatUtil.makeIdentityf(matrixScale, 0); - FloatUtil.makeIdentityf(matrixOrtho, 0); - FloatUtil.makeZero(matrixFrustum, 0); + matrixArray = new float[5*16]; + + mP_offset = 0*16; + mMv_offset = 1*16; + mTex_offset = 4*16; + + matrixPMvMvit = Buffers.slice2Float(matrixArray, 0*16, 4*16); // P + Mv + Mvi + Mvit + matrixPMvMvi = Buffers.slice2Float(matrixArray, 0*16, 3*16); // P + Mv + Mvi + matrixPMv = Buffers.slice2Float(matrixArray, 0*16, 2*16); // P + Mv + matrixP = Buffers.slice2Float(matrixArray, 0*16, 1*16); // P + matrixMv = Buffers.slice2Float(matrixArray, 1*16, 1*16); // Mv + matrixMvi = Buffers.slice2Float(matrixArray, 2*16, 1*16); // Mvi + matrixMvit = Buffers.slice2Float(matrixArray, 3*16, 1*16); // Mvit + matrixTex = Buffers.slice2Float(matrixArray, 4*16, 1*16); // T + + mat4Tmp1 = new float[16]; + mat4Tmp2 = new float[16]; + mat4Tmp3 = new float[16]; + matrixTxSx = new float[16]; + FloatUtil.makeIdentity(matrixTxSx); // Start w/ zero size to save memory matrixTStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixPStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixMvStack= new FloatStack( 0, 16*16); // growSize: half GL-min size (32) - // default values and mode - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL.GL_TEXTURE); - glLoadIdentity(); - modifiedBits = MODIFIED_ALL; - dirtyBits = DIRTY_ALL; - requestMask = 0; - matrixMode = GL_MODELVIEW; + reset(); frustum = null; } - /** @see #PMVMatrix(boolean) */ - public final boolean usesBackingArray() { return usesBackingArray; } + /** + * Issues {@link #glLoadIdentity()} on all matrices, + * i.e. {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * and resets all internal states. + */ + public final void reset() { + FloatUtil.makeIdentity(matrixArray, mMv_offset); + FloatUtil.makeIdentity(matrixArray, mP_offset); + FloatUtil.makeIdentity(matrixArray, mTex_offset); + + modifiedBits = MODIFIED_ALL; + dirtyBits = DIRTY_ALL; + requestMask = 0; + matrixMode = GL_MODELVIEW; + } /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ public final int glGetMatrixMode() { @@ -402,7 +367,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** Returns the frustum, derived from projection * modelview */ - public Frustum glGetFrustum() { + public final Frustum glGetFrustum() { requestMask |= DIRTY_FRUSTUM; updateImpl(false); return frustum; @@ -420,7 +385,7 @@ public class PMVMatrix implements GLMatrixFunc { * {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX}, * or a matrix-mode-name, i.e. * {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} - * @return the named matrix + * @return the named matrix, not a copy! */ public final FloatBuffer glGetMatrixf(final int matrixName) { switch(matrixName) { @@ -438,6 +403,35 @@ public class PMVMatrix implements GLMatrixFunc { } } + + /** + * Multiplies the {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv} matrix, i.e. + * <pre> + * mat4PMv = P x Mv + * </pre> + * @param mat4PMv 4x4 matrix storage for result + * @param mat4PMv_offset + * @return given matrix for chaining + */ + public final float[] multPMvMatrixf(final float[/*16*/] mat4PMv, final int mat4PMv_offset) { + FloatUtil.multMatrix(matrixArray, mP_offset, matrixArray, mMv_offset, mat4PMv, mat4PMv_offset); + return mat4PMv; + } + + /** + * Multiplies the {@link #glGetMvMatrixf() Mv} and {@link #glGetPMatrixf() P} matrix, i.e. + * <pre> + * mat4MvP = Mv x P + * </pre> + * @param mat4MvP 4x4 matrix storage for result + * @param mat4MvP_offset + * @return given matrix for chaining + */ + public final float[] multMvPMatrixf(final float[/*16*/] mat4MvP, final int mat4MvP_offset) { + FloatUtil.multMatrix(matrixArray, mMv_offset, matrixArray, mP_offset, mat4MvP, mat4MvP_offset); + return mat4MvP; + } + // // GLMatrixFunc implementation // @@ -457,7 +451,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glGetFloatv(final int matrixGetName, final FloatBuffer params) { - int pos = params.position(); + final int pos = params.position(); if(matrixGetName==GL_MATRIX_MODE) { params.put(matrixMode); } else { @@ -469,7 +463,7 @@ public class PMVMatrix implements GLMatrixFunc { } @Override - public final void glGetFloatv(final int matrixGetName, float[] params, final int params_offset) { + public final void glGetFloatv(final int matrixGetName, final float[] params, final int params_offset) { if(matrixGetName==GL_MATRIX_MODE) { params[params_offset]=matrixMode; } else { @@ -481,7 +475,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glGetIntegerv(final int pname, final IntBuffer params) { - int pos = params.position(); + final int pos = params.position(); if(pname==GL_MATRIX_MODE) { params.put(matrixMode); } else { @@ -520,7 +514,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glLoadMatrixf(final java.nio.FloatBuffer m) { - int spos = m.position(); + final int spos = m.position(); if(matrixMode==GL_MODELVIEW) { matrixMv.put(m); matrixMv.reset(); @@ -544,17 +538,17 @@ public class PMVMatrix implements GLMatrixFunc { */ public final void glLoadMatrix(final Quaternion quat) { if(matrixMode==GL_MODELVIEW) { - quat.toMatrix(matrixMv); + quat.toMatrix(matrixArray, mMv_offset); matrixMv.reset(); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - quat.toMatrix(matrixP); + quat.toMatrix(matrixArray, mP_offset); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - quat.toMatrix(matrixTex); + quat.toMatrix(matrixArray, mTex_offset); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; } @@ -593,35 +587,32 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glLoadIdentity() { if(matrixMode==GL_MODELVIEW) { - matrixMv.put(matrixIdent); - matrixMv.reset(); + FloatUtil.makeIdentity(matrixArray, mMv_offset); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - matrixP.put(matrixIdent); - matrixP.reset(); + FloatUtil.makeIdentity(matrixArray, mP_offset); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - matrixTex.put(matrixIdent); - matrixTex.reset(); + FloatUtil.makeIdentity(matrixArray, mTex_offset); modifiedBits |= MODIFIED_TEXTURE; } - matrixIdent.reset(); } + @SuppressWarnings("deprecation") @Override public final void glMultMatrixf(final FloatBuffer m) { if(matrixMode==GL_MODELVIEW) { - FloatUtil.multMatrixf(matrixMv, m); + FloatUtil.multMatrix(matrixMv, m); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - FloatUtil.multMatrixf(matrixP, m); + FloatUtil.multMatrix(matrixP, m); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - FloatUtil.multMatrixf(matrixTex, m); + FloatUtil.multMatrix(matrixTex, m); modifiedBits |= MODIFIED_TEXTURE; } } @@ -629,69 +620,49 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glMultMatrixf(final float[] m, final int m_offset) { if(matrixMode==GL_MODELVIEW) { - FloatUtil.multMatrixf(matrixMv, m, m_offset); + FloatUtil.multMatrix(matrixArray, mMv_offset, m, m_offset); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - FloatUtil.multMatrixf(matrixP, m, m_offset); + FloatUtil.multMatrix(matrixArray, mP_offset, m, m_offset); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - FloatUtil.multMatrixf(matrixTex, m, m_offset); + FloatUtil.multMatrix(matrixArray, mTex_offset, m, m_offset); modifiedBits |= MODIFIED_TEXTURE; } } @Override public final void glTranslatef(final float x, final float y, final float z) { - // Translation matrix (Column Order): - // 1 0 0 0 - // 0 1 0 0 - // 0 0 1 0 - // x y z 1 - matrixTrans[0+4*3] = x; - matrixTrans[1+4*3] = y; - matrixTrans[2+4*3] = z; - glMultMatrixf(matrixTrans, 0); + glMultMatrixf(FloatUtil.makeTranslation(matrixTxSx, false, x, y, z), 0); + } + + @Override + public final void glScalef(final float x, final float y, final float z) { + glMultMatrixf(FloatUtil.makeScale(matrixTxSx, false, x, y, z), 0); } @Override - public final void glRotatef(final float angdeg, final float x, final float y, final float z) { - final float angrad = angdeg * FloatUtil.PI / 180.0f; - FloatUtil.makeRotationAxis(angrad, x, y, z, matrixRot, 0, tmpVec3f); - glMultMatrixf(matrixRot, 0); + public final void glRotatef(final float ang_deg, final float x, final float y, final float z) { + glMultMatrixf(FloatUtil.makeRotationAxis(mat4Tmp1, 0, ang_deg * FloatUtil.PI / 180.0f, x, y, z, mat4Tmp2), 0); } /** * Rotate the current matrix with the given {@link Quaternion}'s rotation {@link Quaternion#toMatrix(float[], int) matrix representation}. */ public final void glRotate(final Quaternion quat) { - quat.toMatrix(tmpMatrix, 0); - glMultMatrixf(tmpMatrix, 0); - } - - @Override - public final void glScalef(final float x, final float y, final float z) { - // Scale matrix (Any Order): - // x 0 0 0 - // 0 y 0 0 - // 0 0 z 0 - // 0 0 0 1 - matrixScale[0+4*0] = x; - matrixScale[1+4*1] = y; - matrixScale[2+4*2] = z; - - glMultMatrixf(matrixScale, 0); + glMultMatrixf(quat.toMatrix(mat4Tmp1, 0), 0); } @Override public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { - glMultMatrixf( FloatUtil.makeOrthof(matrixOrtho, 0, false, left, right, bottom, top, zNear, zFar), 0 ); + glMultMatrixf( FloatUtil.makeOrtho(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar), 0 ); } @Override public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { - glMultMatrixf( FloatUtil.makeFrustumf(matrixFrustum, 0, false, left, right, bottom, top, zNear, zFar), 0 ); + glMultMatrixf( FloatUtil.makeFrustum(mat4Tmp1, 0, true, left, right, bottom, top, zNear, zFar), 0 ); } // @@ -700,9 +671,14 @@ public class PMVMatrix implements GLMatrixFunc { /** * {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} with the perspective/frustum matrix. + * + * @param fovy_deg fov angle in degrees + * @param aspect aspect ratio + * @param zNear + * @param zFar */ - public final void gluPerspective(final float fovy, final float aspect, final float zNear, final float zFar) { - glMultMatrixf( FloatUtil.makePerspective(matrixFrustum, 0, false, fovy*((float)Math.PI)/360.0f, aspect, zNear, zFar), 0 ); + public final void gluPerspective(final float fovy_deg, final float aspect, final float zNear, final float zFar) { + glMultMatrixf( FloatUtil.makePerspective(mat4Tmp1, 0, true, fovy_deg * FloatUtil.PI / 180.0f, aspect, zNear, zFar), 0 ); } /** @@ -712,73 +688,127 @@ public class PMVMatrix implements GLMatrixFunc { public final void gluLookAt(final float eyex, final float eyey, final float eyez, final float centerx, final float centery, final float centerz, final float upx, final float upy, final float upz) { - projectFloat.gluLookAt(this, eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz); + mat4Tmp2[0+0] = eyex; + mat4Tmp2[1+0] = eyey; + mat4Tmp2[2+0] = eyez; + mat4Tmp2[0+4] = centerx; + mat4Tmp2[1+4] = centery; + mat4Tmp2[2+4] = centerz; + mat4Tmp2[0+8] = upx; + mat4Tmp2[1+8] = upy; + mat4Tmp2[2+8] = upz; + glMultMatrixf( + FloatUtil.makeLookAt(mat4Tmp1, 0, mat4Tmp2 /* eye */, 0, mat4Tmp2 /* center */, 4, mat4Tmp2 /* up */, 8, mat4Tmp3), 0); } /** * Map object coordinates to window coordinates. + * <p> + * Traditional <code>gluProject</code> implementation. + * </p> * * @param objx * @param objy * @param objz - * @param viewport + * @param viewport 4 component viewport vector * @param viewport_offset - * @param win_pos + * @param win_pos 3 component window coordinate, the result * @param win_pos_offset - * @return + * @return true if successful, otherwise false (z is 1) */ public final boolean gluProject(final float objx, final float objy, final float objz, final int[] viewport, final int viewport_offset, final float[] win_pos, final int win_pos_offset ) { - if(usesBackingArray) { - return projectFloat.gluProject(objx, objy, objz, - matrixMv.array(), matrixMv.position(), - matrixP.array(), matrixP.position(), - viewport, viewport_offset, - win_pos, win_pos_offset); - } else { - return projectFloat.gluProject(objx, objy, objz, - matrixMv, - matrixP, - viewport, viewport_offset, - win_pos, win_pos_offset); - } + return FloatUtil.mapObjToWinCoords(objx, objy, objz, + matrixArray, mMv_offset, + matrixArray, mP_offset, + viewport, viewport_offset, + win_pos, win_pos_offset, + mat4Tmp1, mat4Tmp2); } /** * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject</code> implementation. + * </p> * * @param winx * @param winy * @param winz - * @param viewport + * @param viewport 4 component viewport vector * @param viewport_offset - * @param obj_pos + * @param obj_pos 3 component object coordinate, the result * @param obj_pos_offset - * @return true if successful, otherwise false (failed to invert matrix, or becomes z is infinity) + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) */ public final boolean gluUnProject(final float winx, final float winy, final float winz, final int[] viewport, final int viewport_offset, final float[] obj_pos, final int obj_pos_offset) { - if(usesBackingArray) { - return projectFloat.gluUnProject(winx, winy, winz, - matrixMv.array(), matrixMv.position(), - matrixP.array(), matrixP.position(), - viewport, viewport_offset, - obj_pos, obj_pos_offset); - } else { - return projectFloat.gluUnProject(winx, winy, winz, - matrixMv, - matrixP, - viewport, viewport_offset, - obj_pos, obj_pos_offset); - } + return FloatUtil.mapWinToObjCoords(winx, winy, winz, + matrixArray, mMv_offset, + matrixArray, mP_offset, + viewport, viewport_offset, + obj_pos, obj_pos_offset, + mat4Tmp1, mat4Tmp2); + } + + /** + * Map window coordinates to object coordinates. + * <p> + * Traditional <code>gluUnProject4</code> implementation. + * </p> + * + * @param winx + * @param winy + * @param winz + * @param clipw + * @param modelMatrix 4x4 modelview matrix + * @param modelMatrix_offset + * @param projMatrix 4x4 projection matrix + * @param projMatrix_offset + * @param viewport 4 component viewport vector + * @param viewport_offset + * @param near + * @param far + * @param obj_pos 4 component object coordinate, the result + * @param obj_pos_offset + * @return true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z) + */ + public boolean gluUnProject4(final float winx, final float winy, final float winz, final float clipw, + final int[] viewport, final int viewport_offset, + final float near, final float far, + final float[] obj_pos, final int obj_pos_offset ) { + return FloatUtil.mapWinToObjCoords(winx, winy, winz, clipw, + matrixArray, mMv_offset, + matrixArray, mP_offset, + viewport, viewport_offset, + near, far, + obj_pos, obj_pos_offset, + mat4Tmp1, mat4Tmp2); } + /** + * Make given matrix the <i>pick</i> matrix based on given parameters. + * <p> + * Traditional <code>gluPickMatrix</code> implementation. + * </p> + * <p> + * See {@link FloatUtil#makePick(float[], int, float, float, float, float, int[], int, float[]) FloatUtil.makePick(..)} for details. + * </p> + * @param x the center x-component of a picking region in window coordinates + * @param y the center y-component of a picking region in window coordinates + * @param deltaX the width of the picking region in window coordinates. + * @param deltaY the height of the picking region in window coordinates. + * @param viewport 4 component viewport vector + * @param viewport_offset + */ public final void gluPickMatrix(final float x, final float y, final float deltaX, final float deltaY, final int[] viewport, final int viewport_offset) { - projectFloat.gluPickMatrix(this, x, y, deltaX, deltaY, viewport, viewport_offset); + if( null != FloatUtil.makePick(mat4Tmp1, 0, x, y, deltaX, deltaY, viewport, viewport_offset, mat4Tmp2) ) { + glMultMatrixf(mat4Tmp1, 0); + } } /** @@ -805,16 +835,15 @@ public class PMVMatrix implements GLMatrixFunc { public final boolean gluUnProjectRay(final float winx, final float winy, final float winz0, final float winz1, final int[] viewport, final int viewport_offset, final Ray ray) { - if( gluUnProject(winx, winy, winz0, viewport, viewport_offset, ray.orig, 0) && - gluUnProject(winx, winy, winz1, viewport, viewport_offset, ray.dir, 0) ) { - VectorUtil.normalizeVec3( VectorUtil.subVec3(ray.dir, ray.dir, ray.orig) ); - return true; - } else { - return false; - } + return FloatUtil.mapWinToRay(winx, winy, winz0, winz1, + matrixArray, mMv_offset, + matrixArray, mP_offset, + viewport, viewport_offset, + ray, + mat4Tmp1, mat4Tmp2, mat4Tmp3); } - public StringBuilder toString(StringBuilder sb, String f) { + public StringBuilder toString(StringBuilder sb, final String f) { if(null == sb) { sb = new StringBuilder(); } @@ -828,21 +857,20 @@ public class PMVMatrix implements GLMatrixFunc { final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); - sb.append("PMVMatrix[backingArray ").append(this.usesBackingArray()); - sb.append(", modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); - sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq); - sb.append("], Projection").append(Platform.NEWLINE); + sb.append("PMVMatrix[modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); + sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq).append("]").append(PlatformPropsImpl.NEWLINE); + sb.append(", Projection").append(PlatformPropsImpl.NEWLINE); matrixToString(sb, f, matrixP); - sb.append(", Modelview").append(Platform.NEWLINE); + sb.append(", Modelview").append(PlatformPropsImpl.NEWLINE); matrixToString(sb, f, matrixMv); - sb.append(", Texture").append(Platform.NEWLINE); + sb.append(", Texture").append(PlatformPropsImpl.NEWLINE); matrixToString(sb, f, matrixTex); if( 0 != ( requestMask & DIRTY_INVERSE_MODELVIEW ) ) { - sb.append(", Inverse Modelview").append(Platform.NEWLINE); + sb.append(", Inverse Modelview").append(PlatformPropsImpl.NEWLINE); matrixToString(sb, f, matrixMvi); } if( 0 != ( requestMask & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) { - sb.append(", Inverse Transposed Modelview").append(Platform.NEWLINE); + sb.append(", Inverse Transposed Modelview").append(PlatformPropsImpl.NEWLINE); matrixToString(sb, f, matrixMvit); } sb.append("]"); @@ -866,7 +894,7 @@ public class PMVMatrix implements GLMatrixFunc { * @see #MODIFIED_MODELVIEW * @see #MODIFIED_TEXTURE */ - public final int getModifiedBits(boolean clear) { + public final int getModifiedBits(final boolean clear) { final int r = modifiedBits; if(clear) { modifiedBits = 0; @@ -983,7 +1011,7 @@ public class PMVMatrix implements GLMatrixFunc { public final boolean update() { return updateImpl(true); } - private final boolean updateImpl(boolean clearModBits) { + private final boolean updateImpl(final boolean clearModBits) { boolean mod = 0 != modifiedBits; if(clearModBits) { modifiedBits = 0; @@ -993,8 +1021,9 @@ public class PMVMatrix implements GLMatrixFunc { if( null == frustum ) { frustum = new Frustum(); } - FloatUtil.multMatrixf(matrixP, matrixMv, tmpMatrix, 0); - frustum.updateByPMV(tmpMatrix, 0); + FloatUtil.multMatrix(matrixArray, mP_offset, matrixArray, mMv_offset, mat4Tmp1, 0); + // FloatUtil.multMatrix(matrixP, matrixMv, mat4Tmp1, 0); + frustum.updateByPMV(mat4Tmp1, 0); dirtyBits &= ~DIRTY_FRUSTUM; mod = true; } @@ -1003,82 +1032,42 @@ public class PMVMatrix implements GLMatrixFunc { return mod; // nothing more requested which may have been dirty } - if(nioBackupArraySupported>=0) { - try { - nioBackupArraySupported = 1; - return setMviMvitNIOBackupArray() || mod; - } catch(UnsupportedOperationException uoe) { - nioBackupArraySupported = -1; - } - } - return setMviMvitNIODirectAccess() || mod; + return setMviMvit() || mod; } // // private // - private int nioBackupArraySupported = 0; // -1 not supported, 0 - TBD, 1 - supported - private final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; + private static final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; - private final boolean setMviMvitNIOBackupArray() { + private final boolean setMviMvit() { final float[] _matrixMvi = matrixMvi.array(); final int _matrixMviOffset = matrixMvi.position(); boolean res = false; if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() - if(!projectFloat.gluInvertMatrixf(matrixMv.array(), matrixMv.position(), _matrixMvi, _matrixMviOffset)) { - throw new GLException(msgCantComputeInverse); - } - dirtyBits &= ~DIRTY_INVERSE_MODELVIEW; - res = true; - } - if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix - final float[] _matrixMvit = matrixMvit.array(); - final int _matrixMvitOffset = matrixMvit.position(); - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - _matrixMvit[_matrixMvitOffset+j+i*4] = _matrixMvi[_matrixMviOffset+i+j*4]; - } - } - dirtyBits &= ~DIRTY_INVERSE_TRANSPOSED_MODELVIEW; - res = true; - } - return res; - } - - private final boolean setMviMvitNIODirectAccess() { - boolean res = false; - if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() - if(!projectFloat.gluInvertMatrixf(matrixMv, matrixMvi)) { + if( null == FloatUtil.invertMatrix(matrixArray, mMv_offset, _matrixMvi, _matrixMviOffset) ) { throw new GLException(msgCantComputeInverse); } dirtyBits &= ~DIRTY_INVERSE_MODELVIEW; res = true; } if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - matrixMvit.put(j+i*4, matrixMvi.get(i+j*4)); - } - } + FloatUtil.transposeMatrix(_matrixMvi, _matrixMviOffset, matrixMvit.array(), matrixMvit.position()); dirtyBits &= ~DIRTY_INVERSE_TRANSPOSED_MODELVIEW; res = true; } return res; } - protected final boolean usesBackingArray; - protected final float[] matrixBufferArray; - protected final Buffer matrixBuffer; - protected final FloatBuffer matrixIdent, matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit; - protected final float[] matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum, tmpVec3f; - protected final float[] tmpMatrix; - protected final FloatStack matrixTStack, matrixPStack, matrixMvStack; - protected final ProjectFloat projectFloat; - protected int matrixMode = GL_MODELVIEW; - protected int modifiedBits = MODIFIED_ALL; - protected int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation - protected int requestMask = 0; // may contain the requested dirty bits: DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW - protected Frustum frustum; + private final float[] matrixArray; + private final int mP_offset, mMv_offset, mTex_offset; + private final FloatBuffer matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit; + private final float[] matrixTxSx; + private final float[] mat4Tmp1, mat4Tmp2, mat4Tmp3; + private final FloatStack matrixTStack, matrixPStack, matrixMvStack; + private int matrixMode = GL_MODELVIEW; + private int modifiedBits = MODIFIED_ALL; + private int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation + private int requestMask = 0; // may contain the requested dirty bits: DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW + private Frustum frustum; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java index fd8f54152..64da547c2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java @@ -192,7 +192,7 @@ public class PNGPixelRect extends PixelRectangle.GenericPixelRect { return new PNGPixelRect(destFmt, new Dimension(width, height), destStrideInBytes, destIsGLOriented, destPixels, dpiX, dpiY); } - private static final int getPixelLUMToAny(PixelFormat dest_fmt, ByteBuffer d, int dOff, byte lum, byte alpha) { + private static final int getPixelLUMToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final byte lum, final byte alpha) { switch(dest_fmt) { case LUMINANCE: d.put(dOff++, lum); diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index 0a3a9d513..3b65b0824 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -51,7 +51,7 @@ public class RandomTileRenderer extends TileRendererBase { } @Override - public final int getParam(int pname) { + public final int getParam(final int pname) { switch (pname) { case TR_IMAGE_WIDTH: return imageSize.getWidth(); @@ -75,7 +75,7 @@ public class RandomTileRenderer extends TileRendererBase { * * @throws IllegalArgumentException is tile x/y are < 0 or tile size is <= 0x0 */ - public void setTileRect(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException, IllegalArgumentException { + public void setTileRect(final int tX, final int tY, final int tWidth, final int tHeight) throws IllegalStateException, IllegalArgumentException { if( 0 > tX || 0 > tY ) { throw new IllegalArgumentException("Tile pos must be >= 0/0"); } @@ -120,7 +120,7 @@ public class RandomTileRenderer extends TileRendererBase { * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override - public final void beginTile(GL gl) throws IllegalStateException, GLException { + public final void beginTile(final GL gl) throws IllegalStateException, GLException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } @@ -143,7 +143,7 @@ public class RandomTileRenderer extends TileRendererBase { } @Override - public void endTile( GL gl ) throws IllegalStateException, GLException { + public void endTile( final GL gl ) throws IllegalStateException, GLException { if( !beginCalled ) { throw new IllegalStateException("beginTile(..) has not been called"); } @@ -229,7 +229,7 @@ public class RandomTileRenderer extends TileRendererBase { * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ - public void display(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException { + public void display(final int tX, final int tY, final int tWidth, final int tHeight) throws IllegalStateException { setTileRect(tX, tY, tWidth, tHeight); display(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java index 47d56bcb1..6e31c78a0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java @@ -70,18 +70,18 @@ public class TGAWriter { * @throws IOException if an I/O error occurred while writing the * file */ - public void open(File file, - int width, - int height, - boolean alpha) throws IOException { - RandomAccessFile out = new RandomAccessFile(file, "rw"); + public void open(final File file, + final int width, + final int height, + final boolean alpha) throws IOException { + final RandomAccessFile out = new RandomAccessFile(file, "rw"); ch = out.getChannel(); - int pixelSize = (alpha ? 32 : 24); - int numChannels = (alpha ? 4 : 3); + final int pixelSize = (alpha ? 32 : 24); + final int numChannels = (alpha ? 4 : 3); - int fileLength = TARGA_HEADER_SIZE + width * height * numChannels; + final int fileLength = TARGA_HEADER_SIZE + width * height * numChannels; out.setLength(fileLength); - MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, fileLength); + final MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, fileLength); // write the TARGA header image.put(0, (byte) 0).put(1, (byte) 0); diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 887312a64..d8410a102 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -145,7 +145,7 @@ public class TileRenderer extends TileRendererBase { private int offsetY; @Override - protected StringBuilder tileDetails(StringBuilder sb) { + protected StringBuilder tileDetails(final StringBuilder sb) { sb.append("# "+currentTile+": ["+currentColumn+"]["+currentRow+"] / "+columns+"x"+rows+", ") .append("rowOrder "+rowOrder+", offset/size "+offsetX+"/"+offsetY+" "+tileSize.getWidth()+"x"+tileSize.getHeight()+" brd "+tileBorder+", "); return super.tileDetails(sb); @@ -165,7 +165,7 @@ public class TileRenderer extends TileRendererBase { * </p> */ @Override - public final void setImageSize(int width, int height) { + public final void setImageSize(final int width, final int height) { super.setImageSize(width, height); reset(); } @@ -184,7 +184,7 @@ public class TileRenderer extends TileRendererBase { * @param height The image-clipping.height * @see #getClippedImageSize() */ - public final void clipImageSize(int width, int height) { + public final void clipImageSize(final int width, final int height) { if( null == imageClippingDim ) { imageClippingDim = new Dimension(width, height); } else { @@ -236,7 +236,7 @@ public class TileRenderer extends TileRendererBase { * to avoid artifacts when rendering lines or points with * thickness > 1. */ - public final void setTileSize(int width, int height, int border) { + public final void setTileSize(final int width, final int height, final int border) { if( 0 > border ) { throw new IllegalArgumentException("Tile border must be >= 0"); } @@ -255,7 +255,7 @@ public class TileRenderer extends TileRendererBase { * @see #TR_TILE_X_OFFSET * @see #TR_TILE_Y_OFFSET **/ - public void setTileOffset(int xoff, int yoff) { + public void setTileOffset(final int xoff, final int yoff) { offsetX = xoff; offsetY = yoff; } @@ -299,7 +299,7 @@ public class TileRenderer extends TileRendererBase { /* pp */ final int getCurrentTile() { return currentTile; } @Override - public final int getParam(int pname) { + public final int getParam(final int pname) { switch (pname) { case TR_IMAGE_WIDTH: return imageSize.getWidth(); @@ -349,7 +349,7 @@ public class TileRenderer extends TileRendererBase { * * @param order The row traversal order, must be either {@link #TR_TOP_TO_BOTTOM} or {@link #TR_BOTTOM_TO_TOP}. */ - public final void setRowOrder(int order) { + public final void setRowOrder(final int order) { if (order == TR_TOP_TO_BOTTOM || order == TR_BOTTOM_TO_TOP) { rowOrder = order; } else { @@ -388,7 +388,7 @@ public class TileRenderer extends TileRendererBase { * {@link #eot() end-of-tiling} has been reached. */ @Override - public final void beginTile( GL gl ) throws IllegalStateException, GLException { + public final void beginTile( final GL gl ) throws IllegalStateException, GLException { if( !isSetup() ) { throw new IllegalStateException("Image size has not been set: "+this); } @@ -408,7 +408,7 @@ public class TileRenderer extends TileRendererBase { assert ( currentRow < rows ); assert ( currentColumn < columns ); - int border = tileBorder; + final int border = tileBorder; final DimensionImmutable clippedImageSize = getClippedImageSize(); int tH, tW; @@ -446,7 +446,7 @@ public class TileRenderer extends TileRendererBase { } @Override - public void endTile( GL gl ) throws IllegalStateException, GLException { + public void endTile( final GL gl ) throws IllegalStateException, GLException { if( !beginCalled ) { throw new IllegalStateException("beginTile(..) has not been called"); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index dabde83dd..a1735766e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -45,7 +45,6 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; -import javax.media.opengl.GLFBODrawable; import jogamp.opengl.Debug; /** @@ -228,14 +227,14 @@ public abstract class TileRendererBase { protected GLEventListener glEventListenerPre = null; protected GLEventListener glEventListenerPost = null; - private final String hashStr(Object o) { + private final String hashStr(final Object o) { final int h = null != o ? o.hashCode() : 0; return "0x"+Integer.toHexString(h); } - protected StringBuilder tileDetails(StringBuilder sb) { + protected StringBuilder tileDetails(final StringBuilder sb) { return sb.append("cur "+currentTileXPos+"/"+currentTileYPos+" "+currentTileWidth+"x"+currentTileHeight+", buffer "+hashStr(tileBuffer)); } - public StringBuilder toString(StringBuilder sb) { + public StringBuilder toString(final StringBuilder sb) { final int gladListenerCount = null != listeners ? listeners.length : 0; sb.append("tile["); tileDetails(sb); @@ -246,7 +245,7 @@ public abstract class TileRendererBase { } @Override public String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); return getClass().getSimpleName()+ "["+toString(sb).toString()+"]"; } @@ -270,7 +269,7 @@ public abstract class TileRendererBase { * * @param buffer The buffer itself. Must be large enough to contain a random tile */ - public final void setTileBuffer(GLPixelBuffer buffer) { + public final void setTileBuffer(final GLPixelBuffer buffer) { tileBuffer = buffer; if( DEBUG ) { System.err.println("TileRenderer: tile-buffer "+tileBuffer); @@ -286,7 +285,7 @@ public abstract class TileRendererBase { * @param width The width of the final image * @param height The height of the final image */ - public void setImageSize(int width, int height) { + public void setImageSize(final int width, final int height) { imageSize.set(width, height); } @@ -298,7 +297,7 @@ public abstract class TileRendererBase { * * @param buffer the buffer itself, must be large enough to hold the final image */ - public final void setImageBuffer(GLPixelBuffer buffer) { + public final void setImageBuffer(final GLPixelBuffer buffer) { imageBuffer = buffer; if( DEBUG ) { System.err.println("TileRenderer: image-buffer "+imageBuffer); @@ -308,7 +307,7 @@ public abstract class TileRendererBase { /** @see #setImageBuffer(GLPixelBuffer) */ public final GLPixelBuffer getImageBuffer() { return imageBuffer; } - /* pp */ final void validateGL(GL gl) throws GLException { + /* pp */ final void validateGL(final GL gl) throws GLException { if( imageBuffer != null && !gl.isGL2ES3()) { throw new GLException("Using image-buffer w/ inssufficient GL context: "+gl.getContext().getGLVersion()+", "+gl.getGLProfile()); } @@ -415,7 +414,7 @@ public abstract class TileRendererBase { * See {@link GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable)}. * </p> */ - public final boolean reqPreSwapBuffers(GLCapabilitiesImmutable chosenCaps) { + public final boolean reqPreSwapBuffers(final GLCapabilitiesImmutable chosenCaps) { return GLDrawableUtil.swapBuffersBeforeRead(chosenCaps); } @@ -466,7 +465,7 @@ public abstract class TileRendererBase { * @see #getAttachedDrawable() * @see #detachAutoDrawable() */ - public final void attachAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { + public final void attachAutoDrawable(final GLAutoDrawable glad) throws IllegalStateException { if( null != this.glad ) { throw new IllegalStateException("GLAutoDrawable already attached"); } @@ -551,7 +550,7 @@ public abstract class TileRendererBase { * @param preTile the pre operations * @param postTile the post operations */ - public final void setGLEventListener(GLEventListener preTile, GLEventListener postTile) { + public final void setGLEventListener(final GLEventListener preTile, final GLEventListener postTile) { glEventListenerPre = preTile; glEventListenerPost = postTile; } @@ -573,7 +572,7 @@ public abstract class TileRendererBase { final TileRenderer tileRenderer = TileRendererBase.this instanceof TileRenderer ? (TileRenderer) TileRendererBase.this : null; @Override - public void init(GLAutoDrawable drawable) { + public void init(final GLAutoDrawable drawable) { if( null != glEventListenerPre ) { glEventListenerPre.init(drawable); } @@ -590,7 +589,7 @@ public abstract class TileRendererBase { } } @Override - public void dispose(GLAutoDrawable drawable) { + public void dispose(final GLAutoDrawable drawable) { if( null != glEventListenerPre ) { glEventListenerPre.dispose(drawable); } @@ -603,7 +602,7 @@ public abstract class TileRendererBase { } } @Override - public void display(GLAutoDrawable drawable) { + public void display(final GLAutoDrawable drawable) { if( null != glEventListenerPre ) { glEventListenerPre.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); glEventListenerPre.display(drawable); @@ -660,6 +659,6 @@ public abstract class TileRendererBase { } } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } }; }
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java index b29846d91..99def6f5c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java @@ -60,7 +60,7 @@ public class TimeFrameI { pts = INVALID_PTS; duration = 0; } - public TimeFrameI(int pts, int duration) { + public TimeFrameI(final int pts, final int duration) { this.pts = pts; this.duration = duration; } @@ -68,11 +68,11 @@ public class TimeFrameI { /** Get this frame's presentation timestamp (PTS) in milliseconds. */ public final int getPTS() { return pts; } /** Set this frame's presentation timestamp (PTS) in milliseconds. */ - public final void setPTS(int pts) { this.pts = pts; } + public final void setPTS(final int pts) { this.pts = pts; } /** Get this frame's duration in milliseconds. */ public final int getDuration() { return duration; } /** Set this frame's duration in milliseconds. */ - public final void setDuration(int duration) { this.duration = duration; } + public final void setDuration(final int duration) { this.duration = duration; } @Override public String toString() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index 1d835dd33..6d875fcf5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -61,7 +61,7 @@ public interface AudioSink { * @param planar true for planar data package (each channel in own data buffer), false for packed data channels interleaved in one buffer. * @param littleEndian true for little-endian, false for big endian */ - public AudioFormat(int sampleRate, int sampleSize, int channelCount, boolean signed, boolean fixedP, boolean planar, boolean littleEndian) { + public AudioFormat(final int sampleRate, final int sampleSize, final int channelCount, final boolean signed, final boolean fixedP, final boolean planar, final boolean littleEndian) { this.sampleRate = sampleRate; this.sampleSize = sampleSize; this.channelCount = channelCount; @@ -104,7 +104,7 @@ public interface AudioSink { * Time -> Byte Count * </p> */ - public final int getDurationsByteSize(int millisecs) { + public final int getDurationsByteSize(final int millisecs) { final int bytesPerSample = sampleSize >>> 3; // /8 return millisecs * ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } @@ -116,7 +116,7 @@ public interface AudioSink { * Byte Count -> Time * </p> */ - public final int getBytesDuration(int byteCount) { + public final int getBytesDuration(final int byteCount) { final int bytesPerSample = sampleSize >>> 3; // /8 return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } @@ -132,7 +132,7 @@ public interface AudioSink { * </p> * @param sampleCount sample count per frame and channel */ - public final float getSamplesDuration(int sampleCount) { + public final float getSamplesDuration(final int sampleCount) { return ( 1000f * sampleCount ) / sampleRate; } @@ -151,7 +151,7 @@ public interface AudioSink { * @param millisecs time in milliseconds * @param frameDuration duration per frame in milliseconds. */ - public final int getFrameCount(int millisecs, float frameDuration) { + public final int getFrameCount(final int millisecs, final float frameDuration) { return Math.max(1, (int) ( millisecs / frameDuration + 0.5f )); } @@ -170,7 +170,7 @@ public interface AudioSink { * </p> * @param sampleCount sample count */ - public final int getSamplesByteCount(int sampleCount) { + public final int getSamplesByteCount(final int sampleCount) { return sampleCount * ( sampleSize >>> 3 ); } @@ -189,7 +189,7 @@ public interface AudioSink { * </p> * @param byteCount number of bytes */ - public final int getBytesSampleCount(int byteCount) { + public final int getBytesSampleCount(final int byteCount) { return ( byteCount << 3 ) / sampleSize; } @@ -208,7 +208,7 @@ public interface AudioSink { public AudioFrame() { this.byteSize = 0; } - public AudioFrame(int pts, int duration, int byteCount) { + public AudioFrame(final int pts, final int duration, final int byteCount) { super(pts, duration); this.byteSize=byteCount; } @@ -216,7 +216,7 @@ public interface AudioSink { /** Get this frame's size in bytes. */ public final int getByteSize() { return byteSize; } /** Set this frame's size in bytes. */ - public final void setByteSize(int size) { this.byteSize=size; } + public final void setByteSize(final int size) { this.byteSize=size; } @Override public String toString() { @@ -226,7 +226,7 @@ public interface AudioSink { public static class AudioDataFrame extends AudioFrame { protected final ByteBuffer data; - public AudioDataFrame(int pts, int duration, ByteBuffer bytes, int byteCount) { + public AudioDataFrame(final int pts, final int duration, final ByteBuffer bytes, final int byteCount) { super(pts, duration, byteCount); if( byteCount > bytes.remaining() ) { throw new IllegalArgumentException("Give size "+byteCount+" exceeds remaining bytes in ls "+bytes+". "+this); diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java index 2cfd40df7..a2b29b4eb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java @@ -50,7 +50,7 @@ public class AudioSinkFactory { return new NullAudioSink(); } - public static AudioSink create(final ClassLoader cl, String implName) { + public static AudioSink create(final ClassLoader cl, final String implName) { final AudioSink audioSink; if(ReflectionUtil.isClassAvailable(implName, cl)){ try { @@ -58,8 +58,8 @@ public class AudioSinkFactory { if( audioSink.isInitialized() ) { return audioSink; } - } catch (Throwable t) { - if(AudioSink.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } + } catch (final Throwable t) { + if(AudioSink.DEBUG) { System.err.println("Caught "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } } return null; diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 215275951..4fffd9fab 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -246,10 +246,10 @@ public interface GLMediaPlayer extends TextureSequence { */ @SuppressWarnings("serial") public static class StreamException extends Exception { - public StreamException(Throwable cause) { + public StreamException(final Throwable cause) { super(cause); } - public StreamException(String message, Throwable cause) { + public StreamException(final String message, final Throwable cause) { super(message, cause); } } @@ -318,7 +318,7 @@ public interface GLMediaPlayer extends TextureSequence { public final int id; - State(int id){ + State(final int id){ this.id = id; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java index 248e265f5..9378cec91 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java @@ -55,12 +55,12 @@ public class GLMediaPlayerFactory { return new NullGLMediaPlayer(); } - public static GLMediaPlayer create(final ClassLoader cl, String implName) { + public static GLMediaPlayer create(final ClassLoader cl, final String implName) { try { if(((Boolean)ReflectionUtil.callStaticMethod(implName, isAvailableMethodName, null, null, cl)).booleanValue()) { return (GLMediaPlayer) ReflectionUtil.createInstance(implName, cl); } - } catch (Throwable t) { if(GLMediaPlayer.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } + } catch (final Throwable t) { if(GLMediaPlayer.DEBUG) { System.err.println("Caught "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } return null; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index a33356067..04bc0a15d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -31,6 +31,7 @@ import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.DataBufferInt; +import java.awt.image.Raster; import java.awt.image.SinglePixelPackedSampleModel; import java.awt.image.WritableRaster; import java.nio.Buffer; @@ -78,8 +79,8 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. * If <code>true</code>, user shall decide whether to use a {@link #getAlignedImage(int, int) width-aligned image}. */ - public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, - Buffer buffer, boolean allowRowStride) { + public AWTGLPixelBuffer(final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final BufferedImage image, + final Buffer buffer, final boolean allowRowStride) { super(pixelAttributes, width, height, depth, pack, buffer, allowRowStride); this.image = image; } @@ -97,7 +98,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * @return * @throws IllegalArgumentException if requested size exceeds image size */ - public BufferedImage getAlignedImage(int width, int height) throws IllegalArgumentException { + public BufferedImage getAlignedImage(final int width, final int height) throws IllegalArgumentException { if( width * height > image.getWidth() * image.getHeight() ) { throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight()); } @@ -110,12 +111,12 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster0.getSampleModel(); final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), width, height, width /* scanLineStride */, sppsm0.getBitMasks()); - final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null); + final WritableRaster raster1 = Raster.createWritableRaster(sppsm1, dataBuffer, null); return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); } } - public final boolean isDataBufferSource(BufferedImage imageU) { + public final boolean isDataBufferSource(final BufferedImage imageU) { final DataBuffer dataBuffer0 = image.getRaster().getDataBuffer(); final DataBuffer dataBufferU = imageU.getRaster().getDataBuffer(); return dataBufferU == dataBuffer0; @@ -143,14 +144,14 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * See {@link #getAllowRowStride()} and {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. * If <code>true</code>, user shall decide whether to use a {@link AWTGLPixelBuffer#getAlignedImage(int, int) width-aligned image}. */ - public AWTGLPixelBufferProvider(boolean allowRowStride) { + public AWTGLPixelBufferProvider(final boolean allowRowStride) { this.allowRowStride = allowRowStride; } @Override public boolean getAllowRowStride() { return allowRowStride; } @Override - public GLPixelAttributes getAttributes(GL gl, int componentCount) { + public GLPixelAttributes getAttributes(final GL gl, final int componentCount) { return 4 == componentCount ? awtPixelAttributesIntRGBA4 : awtPixelAttributesIntRGB3; } @@ -161,7 +162,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * </p> */ @Override - public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + public AWTGLPixelBuffer allocate(final GL gl, final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final int minByteSize) { final BufferedImage image = new BufferedImage(width, height, 4 == pixelAttributes.componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); final Buffer ibuffer = IntBuffer.wrap( readBackIntBuffer ); @@ -186,7 +187,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { /** * @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. */ - public SingleAWTGLPixelBufferProvider(boolean allowRowStride) { + public SingleAWTGLPixelBufferProvider(final boolean allowRowStride) { super(allowRowStride); } @@ -197,7 +198,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * </p> */ @Override - public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + public AWTGLPixelBuffer allocate(final GL gl, final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final int minByteSize) { if( 4 == pixelAttributes.componentCount ) { if( null == singleRGBA4 || singleRGBA4.requiresNewBuffer(gl, width, height, minByteSize) ) { singleRGBA4 = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); @@ -211,7 +212,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { } } - private AWTGLPixelBuffer allocateImpl(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + private AWTGLPixelBuffer allocateImpl(final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final int minByteSize) { final BufferedImage image = new BufferedImage(width, height, 4 == pixelAttributes.componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); final Buffer ibuffer = IntBuffer.wrap( readBackIntBuffer ); @@ -220,7 +221,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link AWTGLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ @Override - public AWTGLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes) { + public AWTGLPixelBuffer getSingleBuffer(final GLPixelAttributes pixelAttributes) { return 4 == pixelAttributes.componentCount ? singleRGBA4 : singleRGB3; } @@ -229,7 +230,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * @return the newly initialized single {@link AWTGLPixelBuffer}, or null if already allocated. */ @Override - public AWTGLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack) { + public AWTGLPixelBuffer initSingleton(final int componentCount, final int width, final int height, final int depth, final boolean pack) { if( 4 == componentCount ) { if( null != singleRGBA4 ) { return null; diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index 3c5d6be2d..06e3ccda5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -46,7 +46,7 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { * * @param alpha */ - public AWTGLReadBufferUtil(GLProfile glp, boolean alpha) { + public AWTGLReadBufferUtil(final GLProfile glp, final boolean alpha) { super(new AWTGLPixelBuffer.AWTGLPixelBufferProvider( glp.isGL2ES3() /* allowRowStride */ ), alpha, false); } @@ -64,7 +64,7 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). * @see #AWTGLReadBufferUtil(GLProfile, boolean) */ - public BufferedImage readPixelsToBufferedImage(GL gl, boolean awtOrientation) { + public BufferedImage readPixelsToBufferedImage(final GL gl, final boolean awtOrientation) { return readPixelsToBufferedImage(gl, 0, 0, 0, 0, awtOrientation); } @@ -84,7 +84,7 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). * @see #AWTGLReadBufferUtil(GLProfile, boolean) */ - public BufferedImage readPixelsToBufferedImage(GL gl, int inX, int inY, int inWidth, int inHeight, boolean awtOrientation) { + public BufferedImage readPixelsToBufferedImage(final GL gl, final int inX, final int inY, final int inWidth, final int inHeight, final boolean awtOrientation) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int width, height; if( 0 >= inWidth || drawable.getSurfaceWidth() < inWidth ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java index df3cc4a39..4023a06f0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java @@ -50,8 +50,8 @@ public class ImageUtil { /** Flips the supplied BufferedImage vertically. This is often a necessary conversion step to display a Java2D image correctly with OpenGL and vice versa. */ - public static void flipImageVertically(BufferedImage image) { - WritableRaster raster = image.getRaster(); + public static void flipImageVertically(final BufferedImage image) { + final WritableRaster raster = image.getRaster(); Object scanline1 = null; Object scanline2 = null; @@ -73,8 +73,8 @@ public class ImageUtil { * * @return A instance of <code>BufferedImage</code> with a type compatible with the graphics card. */ - public static BufferedImage createCompatibleImage(int width, int height) { - GraphicsConfiguration configuration = + public static BufferedImage createCompatibleImage(final int width, final int height) { + final GraphicsConfiguration configuration = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); return configuration.createCompatibleImage(width, height); @@ -92,7 +92,7 @@ public class ImageUtil { * * @return A thumbnail with the requested width or the original picture if thumbWidth = image.getWidth() */ - public static BufferedImage createThumbnail(BufferedImage image, int thumbWidth) { + public static BufferedImage createThumbnail(final BufferedImage image, final int thumbWidth) { // Thanks to Romain Guy for this utility if (thumbWidth > image.getWidth()) { throw new IllegalArgumentException("Thumbnail width must be greater than image width"); @@ -102,7 +102,7 @@ public class ImageUtil { return image; } - float ratio = (float) image.getWidth() / (float) image.getHeight(); + final float ratio = (float) image.getWidth() / (float) image.getHeight(); int width = image.getWidth(); BufferedImage thumb = image; @@ -112,8 +112,8 @@ public class ImageUtil { width = thumbWidth; } - BufferedImage temp = createCompatibleImage(width, (int) (width / ratio)); - Graphics2D g2 = temp.createGraphics(); + final BufferedImage temp = createCompatibleImage(width, (int) (width / ratio)); + final Graphics2D g2 = temp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null); diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java index 1ad7b9987..a78bc9bb3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java @@ -49,13 +49,13 @@ import javax.media.opengl.*; efficiency. */ public class Overlay { - private GLDrawable drawable; + private final GLDrawable drawable; private TextureRenderer renderer; private boolean contentsLost; /** Creates a new Java 2D overlay on top of the specified GLDrawable. */ - public Overlay(GLDrawable drawable) { + public Overlay(final GLDrawable drawable) { this.drawable = drawable; } @@ -103,7 +103,7 @@ public class Overlay { @param height the height of the region to update @throws GLException If an OpenGL context is not current when this method is called */ - public void markDirty(int x, int y, int width, int height) { + public void markDirty(final int x, final int y, final int width, final int height) { renderer.markDirty(x, y, width, height); } @@ -159,7 +159,7 @@ public class Overlay { @throws GLException If an OpenGL context is not current when this method is called */ - public void draw(int x, int y, int width, int height) throws GLException { + public void draw(final int x, final int y, final int width, final int height) throws GLException { draw(x, y, x, y, width, height); } @@ -184,9 +184,9 @@ public class Overlay { @throws GLException If an OpenGL context is not current when this method is called */ - public void draw(int screenx, int screeny, - int overlayx, int overlayy, - int width, int height) throws GLException { + public void draw(final int screenx, final int screeny, + final int overlayx, final int overlayy, + final int width, final int height) throws GLException { renderer.drawOrthoRect(screenx, screeny, overlayx, overlayy, width, height); diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java index f686b672a..ac208044b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java @@ -88,9 +88,9 @@ public class Screenshot { * @throws IOException if an I/O error occurred while writing the * file */ - public static void writeToTargaFile(File file, - int width, - int height) throws GLException, IOException { + public static void writeToTargaFile(final File file, + final int width, + final int height) throws GLException, IOException { writeToTargaFile(file, width, height, false); } @@ -115,10 +115,10 @@ public class Screenshot { * @throws IOException if an I/O error occurred while writing the * file */ - public static void writeToTargaFile(File file, - int width, - int height, - boolean alpha) throws GLException, IOException { + public static void writeToTargaFile(final File file, + final int width, + final int height, + final boolean alpha) throws GLException, IOException { writeToTargaFile(file, 0, 0, width, height, alpha); } @@ -145,27 +145,27 @@ public class Screenshot { * @throws IOException if an I/O error occurred while writing the * file */ - public static void writeToTargaFile(File file, - int x, - int y, - int width, - int height, - boolean alpha) throws GLException, IOException { + public static void writeToTargaFile(final File file, + final int x, + final int y, + final int width, + final int height, + final boolean alpha) throws GLException, IOException { if (alpha) { checkExtABGR(); } - TGAWriter writer = new TGAWriter(); + final TGAWriter writer = new TGAWriter(); writer.open(file, width, height, alpha); - ByteBuffer bgr = writer.getImageData(); + final ByteBuffer bgr = writer.getImageData(); - GL gl = GLContext.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); // Set up pixel storage modes - GLPixelStorageModes psm = new GLPixelStorageModes(); + final GLPixelStorageModes psm = new GLPixelStorageModes(); psm.setPackAlignment(gl, 1); - int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); + final int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); // read the BGR values into the image buffer gl.glReadPixels(x, y, width, height, readbackType, @@ -198,8 +198,8 @@ public class Screenshot { * @throws GLException if an OpenGL context was not current or * another OpenGL-related error occurred */ - public static BufferedImage readToBufferedImage(int width, - int height) throws GLException { + public static BufferedImage readToBufferedImage(final int width, + final int height) throws GLException { return readToBufferedImage(width, height, false); } @@ -223,9 +223,9 @@ public class Screenshot { * @throws GLException if an OpenGL context was not current or * another OpenGL-related error occurred */ - public static BufferedImage readToBufferedImage(int width, - int height, - boolean alpha) throws GLException { + public static BufferedImage readToBufferedImage(final int width, + final int height, + final boolean alpha) throws GLException { return readToBufferedImage(0, 0, width, height, alpha); } @@ -251,26 +251,26 @@ public class Screenshot { * @throws GLException if an OpenGL context was not current or * another OpenGL-related error occurred */ - public static BufferedImage readToBufferedImage(int x, - int y, - int width, - int height, - boolean alpha) throws GLException { - int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); - int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); + public static BufferedImage readToBufferedImage(final int x, + final int y, + final int width, + final int height, + final boolean alpha) throws GLException { + final int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); + final int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); if (alpha) { checkExtABGR(); } // Allocate necessary storage - BufferedImage image = new BufferedImage(width, height, bufImgType); + final BufferedImage image = new BufferedImage(width, height, bufImgType); - GLContext glc = GLContext.getCurrent(); - GL gl = glc.getGL(); + final GLContext glc = GLContext.getCurrent(); + final GL gl = glc.getGL(); // Set up pixel storage modes - GLPixelStorageModes psm = new GLPixelStorageModes(); + final GLPixelStorageModes psm = new GLPixelStorageModes(); psm.setPackAlignment(gl, 1); // read the BGR values into the image @@ -313,9 +313,9 @@ public class Screenshot { * not be written to disk due to the requested file format being * unsupported by ImageIO */ - public static void writeToFile(File file, - int width, - int height) throws IOException, GLException { + public static void writeToFile(final File file, + final int width, + final int height) throws IOException, GLException { writeToFile(file, width, height, false); } @@ -348,10 +348,10 @@ public class Screenshot { * not be written to disk due to the requested file format being * unsupported by ImageIO */ - public static void writeToFile(File file, - int width, - int height, - boolean alpha) throws IOException, GLException { + public static void writeToFile(final File file, + final int width, + final int height, + final boolean alpha) throws IOException, GLException { writeToFile(file, 0, 0, width, height, alpha); } @@ -386,26 +386,26 @@ public class Screenshot { * not be written to disk due to the requested file format being * unsupported by ImageIO */ - public static void writeToFile(File file, - int x, - int y, - int width, - int height, + public static void writeToFile(final File file, + final int x, + final int y, + final int width, + final int height, boolean alpha) throws IOException, GLException { - String fileSuffix = IOUtil.getFileSuffix(file); + final String fileSuffix = IOUtil.getFileSuffix(file); if (alpha && (fileSuffix.equals("jpg") || fileSuffix.equals("jpeg"))) { // JPEGs can't deal properly with alpha channels alpha = false; } - BufferedImage image = readToBufferedImage(x, y, width, height, alpha); + final BufferedImage image = readToBufferedImage(x, y, width, height, alpha); if (!ImageIO.write(image, fileSuffix, file)) { throw new IOException("Unsupported file format " + fileSuffix); } } private static void checkExtABGR() { - GL gl = GLContext.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (!gl.isExtensionAvailable(GLExtensions.EXT_abgr)) { throw new IllegalArgumentException("Saving alpha channel requires GL_EXT_abgr"); diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 46dc73003..660d3bc6a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -40,7 +40,7 @@ package com.jogamp.opengl.util.awt; import com.jogamp.common.nio.Buffers; - +import com.jogamp.common.util.PropertyAccess; import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.packrect.*; @@ -60,14 +60,12 @@ import java.awt.RenderingHints; import java.awt.event.*; import java.awt.font.*; import java.awt.geom.*; - import java.nio.*; - import java.text.*; - import java.util.*; import javax.media.opengl.*; +import javax.media.opengl.fixedfunc.GLPointerFunc; import javax.media.opengl.glu.*; import javax.media.opengl.awt.*; @@ -132,7 +130,7 @@ public class TextRenderer { static { Debug.initSingleton(); - DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true); + DEBUG = PropertyAccess.isPropertyDefined("jogl.debug.TextRenderer", true); } // These are occasionally useful for more in-depth debugging @@ -218,7 +216,7 @@ public class TextRenderer { @param font the font to render with */ - public TextRenderer(Font font) { + public TextRenderer(final Font font) { this(font, false, false, null, false); } @@ -232,7 +230,7 @@ public class TextRenderer { @param font the font to render with @param mipmap whether to attempt use of automatic mipmap generation */ - public TextRenderer(Font font, boolean mipmap) { + public TextRenderer(final Font font, final boolean mipmap) { this(font, false, false, null, mipmap); } @@ -249,8 +247,8 @@ public class TextRenderer { @param useFractionalMetrics whether to use fractional font metrics at the Java 2D level */ - public TextRenderer(Font font, boolean antialiased, - boolean useFractionalMetrics) { + public TextRenderer(final Font font, final boolean antialiased, + final boolean useFractionalMetrics) { this(font, antialiased, useFractionalMetrics, null, false); } @@ -268,8 +266,8 @@ public class TextRenderer { @param renderDelegate the render delegate to use to draw the text's bitmap, or null to use the default one */ - public TextRenderer(Font font, boolean antialiased, - boolean useFractionalMetrics, RenderDelegate renderDelegate) { + public TextRenderer(final Font font, final boolean antialiased, + final boolean useFractionalMetrics, final RenderDelegate renderDelegate) { this(font, antialiased, useFractionalMetrics, renderDelegate, false); } @@ -290,9 +288,9 @@ public class TextRenderer { text's bitmap, or null to use the default one @param mipmap whether to attempt use of automatic mipmap generation */ - public TextRenderer(Font font, boolean antialiased, - boolean useFractionalMetrics, RenderDelegate renderDelegate, - boolean mipmap) { + public TextRenderer(final Font font, final boolean antialiased, + final boolean useFractionalMetrics, RenderDelegate renderDelegate, + final boolean mipmap) { this.font = font; this.antialiased = antialiased; this.useFractionalMetrics = useFractionalMetrics; @@ -314,7 +312,7 @@ public class TextRenderer { /** Returns the bounding rectangle of the given String, assuming it was rendered at the origin. See {@link #getBounds(CharSequence) getBounds(CharSequence)}. */ - public Rectangle2D getBounds(String str) { + public Rectangle2D getBounds(final String str) { return getBounds((CharSequence) str); } @@ -333,12 +331,12 @@ public class TextRenderer { {@link java.awt.font.GlyphVector#getPixelBounds getPixelBounds}, etc.) the returned bounds correspond to, although every effort is made to ensure an accurate bound. */ - public Rectangle2D getBounds(CharSequence str) { + public Rectangle2D getBounds(final CharSequence str) { // FIXME: this should be more optimized and use the glyph cache - Rect r = stringLocations.get(str); + final Rect r = stringLocations.get(str); if (r != null) { - TextData data = (TextData) r.getUserData(); + final TextData data = (TextData) r.getUserData(); // Reconstitute the Java 2D results based on the cached values return new Rectangle2D.Double(-data.origin().x, -data.origin().y, @@ -385,7 +383,7 @@ public class TextRenderer { @param height the height of the current on-screen OpenGL drawable @throws javax.media.opengl.GLException If an OpenGL context is not current when this method is called */ - public void beginRendering(int width, int height) throws GLException { + public void beginRendering(final int width, final int height) throws GLException { beginRendering(width, height, true); } @@ -405,7 +403,7 @@ public class TextRenderer { @param disableDepthTest whether to disable the depth test @throws GLException If an OpenGL context is not current when this method is called */ - public void beginRendering(int width, int height, boolean disableDepthTest) + public void beginRendering(final int width, final int height, final boolean disableDepthTest) throws GLException { beginRendering(true, width, height, disableDepthTest); } @@ -432,8 +430,8 @@ public class TextRenderer { @param color the new color to use for rendering text @throws GLException If an OpenGL context is not current when this method is called */ - public void setColor(Color color) throws GLException { - boolean noNeedForFlush = (haveCachedColor && (cachedColor != null) && + public void setColor(final Color color) throws GLException { + final boolean noNeedForFlush = (haveCachedColor && (cachedColor != null) && color.equals(cachedColor)); if (!noNeedForFlush) { @@ -460,9 +458,9 @@ public class TextRenderer { transparent, 1.0f = completely opaque @throws GLException If an OpenGL context is not current when this method is called */ - public void setColor(float r, float g, float b, float a) + public void setColor(final float r, final float g, final float b, final float a) throws GLException { - boolean noNeedForFlush = (haveCachedColor && (cachedColor == null) && + final boolean noNeedForFlush = (haveCachedColor && (cachedColor == null) && (r == cachedR) && (g == cachedG) && (b == cachedB) && (a == cachedA)); @@ -490,14 +488,14 @@ public class TextRenderer { @param y the y coordinate at which to draw @throws GLException If an OpenGL context is not current when this method is called */ - public void draw(CharSequence str, int x, int y) throws GLException { + public void draw(final CharSequence str, final int x, final int y) throws GLException { draw3D(str, x, y, 0, 1); } /** Draws the supplied String at the desired location using the renderer's current color. See {@link #draw(CharSequence, int, int) draw(CharSequence, int, int)}. */ - public void draw(String str, int x, int y) throws GLException { + public void draw(final String str, final int x, final int y) throws GLException { draw3D(str, x, y, 0, 1); } @@ -513,8 +511,8 @@ public class TextRenderer { @param scaleFactor a uniform scale factor applied to the width and height of the drawn rectangle @throws GLException If an OpenGL context is not current when this method is called */ - public void draw3D(CharSequence str, float x, float y, float z, - float scaleFactor) { + public void draw3D(final CharSequence str, final float x, final float y, final float z, + final float scaleFactor) { internal_draw3D(str, x, y, z, scaleFactor); } @@ -522,12 +520,12 @@ public class TextRenderer { renderer's current color. See {@link #draw3D(CharSequence, float, float, float, float) draw3D(CharSequence, float, float, float, float)}. */ - public void draw3D(String str, float x, float y, float z, float scaleFactor) { + public void draw3D(final String str, final float x, final float y, final float z, final float scaleFactor) { internal_draw3D(str, x, y, z, scaleFactor); } /** Returns the pixel width of the given character. */ - public float getCharWidth(char inChar) { + public float getCharWidth(final char inChar) { return mGlyphProducer.getGlyphPixelWidth(inChar); } @@ -582,20 +580,20 @@ public class TextRenderer { // Internals only below this point // - private static Rectangle2D preNormalize(Rectangle2D src) { + private static Rectangle2D preNormalize(final Rectangle2D src) { // Need to round to integer coordinates // Also give ourselves a little slop around the reported // bounds of glyphs because it looks like neither the visual // nor the pixel bounds works perfectly well - int minX = (int) Math.floor(src.getMinX()) - 1; - int minY = (int) Math.floor(src.getMinY()) - 1; - int maxX = (int) Math.ceil(src.getMaxX()) + 1; - int maxY = (int) Math.ceil(src.getMaxY()) + 1; + final int minX = (int) Math.floor(src.getMinX()) - 1; + final int minY = (int) Math.floor(src.getMinY()) - 1; + final int maxX = (int) Math.ceil(src.getMaxX()) + 1; + final int maxY = (int) Math.ceil(src.getMaxY()) + 1; return new Rectangle2D.Double(minX, minY, maxX - minX, maxY - minY); } - private Rectangle2D normalize(Rectangle2D src) { + private Rectangle2D normalize(final Rectangle2D src) { // Give ourselves a boundary around each entity on the backing // store in order to prevent bleeding of nearby Strings due to // the fact that we use linear filtering @@ -603,7 +601,7 @@ public class TextRenderer { // NOTE that this boundary is quite heuristic and is related // to how far away in 3D we may view the text -- // heuristically, 1.5% of the font's height - int boundary = (int) Math.max(1, 0.015 * font.getSize()); + final int boundary = (int) Math.max(1, 0.015 * font.getSize()); return new Rectangle2D.Double((int) Math.floor(src.getMinX() - boundary), (int) Math.floor(src.getMinY() - boundary), @@ -612,7 +610,7 @@ public class TextRenderer { } private TextureRenderer getBackingStore() { - TextureRenderer renderer = (TextureRenderer) packer.getBackingStore(); + final TextureRenderer renderer = (TextureRenderer) packer.getBackingStore(); if (renderer != cachedBackingStore) { // Backing store changed since last time; discard any cached Graphics2D @@ -629,7 +627,7 @@ public class TextRenderer { } private Graphics2D getGraphics2D() { - TextureRenderer renderer = getBackingStore(); + final TextureRenderer renderer = getBackingStore(); if (cachedGraphics == null) { cachedGraphics = renderer.createGraphics(); @@ -650,9 +648,9 @@ public class TextRenderer { return cachedGraphics; } - private void beginRendering(boolean ortho, int width, int height, - boolean disableDepthTestForOrtho) { - GL2 gl = GLContext.getCurrentGL().getGL2(); + private void beginRendering(final boolean ortho, final int width, final int height, + final boolean disableDepthTestForOrtho) { + final GL2 gl = GLContext.getCurrentGL().getGL2(); if (DEBUG && !debugged) { debug(gl); @@ -677,8 +675,8 @@ public class TextRenderer { if (!haveMaxSize) { // Query OpenGL for the maximum texture size and set it in the // RectanglePacker to keep it from expanding too large - int[] sz = new int[1]; - gl.glGetIntegerv(GL2.GL_MAX_TEXTURE_SIZE, sz, 0); + final int[] sz = new int[1]; + gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, sz, 0); packer.setMaxSize(sz[0], sz[0]); haveMaxSize = true; } @@ -711,12 +709,12 @@ public class TextRenderer { * @param ortho * @throws GLException */ - private void endRendering(boolean ortho) throws GLException { + private void endRendering(final boolean ortho) throws GLException { flushGlyphPipeline(); inBeginEndPair = false; - GL2 gl = GLContext.getCurrentGL().getGL2(); + final GL2 gl = GLContext.getCurrentGL().getGL2(); // Pop client attrib bits used by the pipelined quad renderer gl.glPopClientAttrib(); @@ -726,8 +724,8 @@ public class TextRenderer { // binding if (getUseVertexArrays() && is15Available(gl)) { try { - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); - } catch (Exception e) { + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + } catch (final Exception e) { isExtensionAvailable_GL_VERSION_1_5 = false; } } @@ -756,8 +754,8 @@ public class TextRenderer { // text strings that haven't been used recently packer.visit(new RectVisitor() { @Override - public void visit(Rect rect) { - TextData data = (TextData) rect.getUserData(); + public void visit(final Rect rect) { + final TextData data = (TextData) rect.getUserData(); if (data.used()) { data.clearUsed(); @@ -767,11 +765,11 @@ public class TextRenderer { } }); - for (Rect r : deadRects) { + for (final Rect r : deadRects) { packer.remove(r); stringLocations.remove(((TextData) r.getUserData()).string()); - int unicodeToClearFromCache = ((TextData) r.getUserData()).unicodeID; + final int unicodeToClearFromCache = ((TextData) r.getUserData()).unicodeID; if (unicodeToClearFromCache > 0) { mGlyphProducer.clearCacheEntry(unicodeToClearFromCache); @@ -786,7 +784,7 @@ public class TextRenderer { } // If we removed dead rectangles this cycle, try to do a compaction - float frag = packer.verticalFragmentationRatio(); + final float frag = packer.verticalFragmentationRatio(); if (!deadRects.isEmpty() && (frag > MAX_VERTICAL_FRAGMENTATION)) { if (DEBUG) { @@ -804,10 +802,10 @@ public class TextRenderer { } } - private void internal_draw3D(CharSequence str, float x, float y, float z, - float scaleFactor) { - for (Glyph glyph : mGlyphProducer.getGlyphs(str)) { - float advance = glyph.draw3D(x, y, z, scaleFactor); + private void internal_draw3D(final CharSequence str, float x, final float y, final float z, + final float scaleFactor) { + for (final Glyph glyph : mGlyphProducer.getGlyphs(str)) { + final float advance = glyph.draw3D(x, y, z, scaleFactor); x += advance * scaleFactor; } } @@ -818,8 +816,8 @@ public class TextRenderer { } } - private void draw3D_ROBUST(CharSequence str, float x, float y, float z, - float scaleFactor) { + private void draw3D_ROBUST(final CharSequence str, final float x, final float y, final float z, + final float scaleFactor) { String curStr; if (str instanceof String) { curStr = (String) str; @@ -833,9 +831,9 @@ public class TextRenderer { if (rect == null) { // Rasterize this string and place it on the backing store Graphics2D g = getGraphics2D(); - Rectangle2D origBBox = preNormalize(renderDelegate.getBounds(curStr, font, getFontRenderContext())); - Rectangle2D bbox = normalize(origBBox); - Point origin = new Point((int) -bbox.getMinX(), + final Rectangle2D origBBox = preNormalize(renderDelegate.getBounds(curStr, font, getFontRenderContext())); + final Rectangle2D bbox = normalize(origBBox); + final Point origin = new Point((int) -bbox.getMinX(), (int) -bbox.getMinY()); rect = new Rect(0, 0, (int) bbox.getWidth(), (int) bbox.getHeight(), @@ -850,8 +848,8 @@ public class TextRenderer { // OK, should now have an (x, y) for this rectangle; rasterize // the String - int strx = rect.x() + origin.x; - int stry = rect.y() + origin.y; + final int strx = rect.x() + origin.x; + final int stry = rect.y() + origin.y; // Clear out the area we're going to draw into g.setComposite(AlphaComposite.Clear); @@ -862,7 +860,7 @@ public class TextRenderer { renderDelegate.draw(g, curStr, strx, stry); if (DRAW_BBOXES) { - TextData data = (TextData) rect.getUserData(); + final TextData data = (TextData) rect.getUserData(); // Draw a bounding box on the backing store g.drawRect(strx - data.origOriginX(), stry - data.origOriginY(), @@ -880,15 +878,15 @@ public class TextRenderer { } // OK, now draw the portion of the backing store to the screen - TextureRenderer renderer = getBackingStore(); + final TextureRenderer renderer = getBackingStore(); // NOTE that the rectangles managed by the packer have their // origin at the upper-left but the TextureRenderer's origin is // at its lower left!!! - TextData data = (TextData) rect.getUserData(); + final TextData data = (TextData) rect.getUserData(); data.markUsed(); - Rectangle2D origRect = data.origRect(); + final Rectangle2D origRect = data.origRect(); // Align the leftmost point of the baseline to the (x, y, z) coordinate requested renderer.draw3DRect(x - (scaleFactor * data.origOriginX()), @@ -902,10 +900,10 @@ public class TextRenderer { //---------------------------------------------------------------------- // Debugging functionality // - private void debug(GL gl) { + private void debug(final GL gl) { dbgFrame = new Frame("TextRenderer Debug Output"); - GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile())); + final GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile())); dbgCanvas.setSharedContext(GLContext.getCurrent()); dbgCanvas.addGLEventListener(new DebugListener(gl, dbgFrame)); dbgFrame.add(dbgCanvas); @@ -913,7 +911,7 @@ public class TextRenderer { final FPSAnimator anim = new FPSAnimator(dbgCanvas, 10); dbgFrame.addWindowListener(new WindowAdapter() { @Override - public void windowClosing(WindowEvent e) { + public void windowClosing(final WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting @@ -999,11 +997,11 @@ public class TextRenderer { CharSequenceIterator() { } - CharSequenceIterator(CharSequence sequence) { + CharSequenceIterator(final CharSequence sequence) { initFromCharSequence(sequence); } - public void initFromCharSequence(CharSequence sequence) { + public void initFromCharSequence(final CharSequence sequence) { mSequence = sequence; mLength = mSequence.length(); mCurrentIndex = 0; @@ -1040,7 +1038,7 @@ public class TextRenderer { } @Override - public char setIndex(int position) { + public char setIndex(final int position) { mCurrentIndex = position; return current(); @@ -1063,7 +1061,7 @@ public class TextRenderer { @Override public Object clone() { - CharSequenceIterator iter = new CharSequenceIterator(mSequence); + final CharSequenceIterator iter = new CharSequenceIterator(mSequence); iter.mCurrentIndex = mCurrentIndex; return iter; @@ -1108,7 +1106,7 @@ public class TextRenderer { private boolean used; // Whether this text was used recently - TextData(String str, Point origin, Rectangle2D origRect, int unicodeID) { + TextData(final String str, final Point origin, final Rectangle2D origRect, final int unicodeID) { this.str = str; this.origin = origin; this.origRect = origRect; @@ -1154,7 +1152,7 @@ public class TextRenderer { private Graphics2D g; @Override - public Object allocateBackingStore(int w, int h) { + public Object allocateBackingStore(final int w, final int h) { // FIXME: should consider checking Font's attributes to see // whether we're likely to need to support a full RGBA backing // store (i.e., non-default Paint, foreground color, etc.), but @@ -1177,12 +1175,12 @@ public class TextRenderer { } @Override - public void deleteBackingStore(Object backingStore) { + public void deleteBackingStore(final Object backingStore) { ((TextureRenderer) backingStore).dispose(); } @Override - public boolean preExpand(Rect cause, int attemptNumber) { + public boolean preExpand(final Rect cause, final int attemptNumber) { // Only try this one time; clear out potentially obsolete entries // NOTE: this heuristic and the fact that it clears the used bit // of all entries seems to cause cycling of entries in some @@ -1218,7 +1216,7 @@ public class TextRenderer { } @Override - public boolean additionFailed(Rect cause, int attemptNumber) { + public boolean additionFailed(final Rect cause, final int attemptNumber) { // Heavy hammer -- might consider doing something different packer.clear(); stringLocations.clear(); @@ -1242,13 +1240,13 @@ public class TextRenderer { } @Override - public void beginMovement(Object oldBackingStore, Object newBackingStore) { + public void beginMovement(final Object oldBackingStore, final Object newBackingStore) { // Exit the begin / end pair if necessary if (inBeginEndPair) { // Draw any outstanding glyphs flush(); - GL2 gl = GLContext.getCurrentGL().getGL2(); + final GL2 gl = GLContext.getCurrentGL().getGL2(); // Pop client attrib bits used by the pipelined quad renderer gl.glPopClientAttrib(); @@ -1258,8 +1256,8 @@ public class TextRenderer { // binding if (getUseVertexArrays() && is15Available(gl)) { try { - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); - } catch (Exception e) { + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + } catch (final Exception e) { isExtensionAvailable_GL_VERSION_1_5 = false; } } @@ -1271,15 +1269,15 @@ public class TextRenderer { } } - TextureRenderer newRenderer = (TextureRenderer) newBackingStore; + final TextureRenderer newRenderer = (TextureRenderer) newBackingStore; g = newRenderer.createGraphics(); } @Override - public void move(Object oldBackingStore, Rect oldLocation, - Object newBackingStore, Rect newLocation) { - TextureRenderer oldRenderer = (TextureRenderer) oldBackingStore; - TextureRenderer newRenderer = (TextureRenderer) newBackingStore; + public void move(final Object oldBackingStore, final Rect oldLocation, + final Object newBackingStore, final Rect newLocation) { + final TextureRenderer oldRenderer = (TextureRenderer) oldBackingStore; + final TextureRenderer newRenderer = (TextureRenderer) newBackingStore; if (oldRenderer == newRenderer) { // Movement on the same backing store -- easy case @@ -1288,7 +1286,7 @@ public class TextRenderer { newLocation.y() - oldLocation.y()); } else { // Need to draw from the old renderer's image into the new one - Image img = oldRenderer.getImage(); + final Image img = oldRenderer.getImage(); g.drawImage(img, newLocation.x(), newLocation.y(), newLocation.x() + newLocation.w(), newLocation.y() + newLocation.h(), oldLocation.x(), @@ -1298,11 +1296,11 @@ public class TextRenderer { } @Override - public void endMovement(Object oldBackingStore, Object newBackingStore) { + public void endMovement(final Object oldBackingStore, final Object newBackingStore) { g.dispose(); // Sync the whole surface - TextureRenderer newRenderer = (TextureRenderer) newBackingStore; + final TextureRenderer newRenderer = (TextureRenderer) newBackingStore; newRenderer.markDirty(0, 0, newRenderer.getWidth(), newRenderer.getHeight()); @@ -1316,7 +1314,7 @@ public class TextRenderer { } // Push client attrib bits used by the pipelined quad renderer - GL2 gl = GLContext.getCurrentGL().getGL2(); + final GL2 gl = GLContext.getCurrentGL().getGL2(); gl.glPushClientAttrib((int) GL2.GL_ALL_CLIENT_ATTRIB_BITS); if (haveCachedColor) { @@ -1340,32 +1338,32 @@ public class TextRenderer { } @Override - public Rectangle2D getBounds(CharSequence str, Font font, - FontRenderContext frc) { + public Rectangle2D getBounds(final CharSequence str, final Font font, + final FontRenderContext frc) { return getBounds(font.createGlyphVector(frc, new CharSequenceIterator(str)), frc); } @Override - public Rectangle2D getBounds(String str, Font font, - FontRenderContext frc) { + public Rectangle2D getBounds(final String str, final Font font, + final FontRenderContext frc) { return getBounds(font.createGlyphVector(frc, str), frc); } @Override - public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) { + public Rectangle2D getBounds(final GlyphVector gv, final FontRenderContext frc) { return gv.getVisualBounds(); } @Override - public void drawGlyphVector(Graphics2D graphics, GlyphVector str, - int x, int y) { + public void drawGlyphVector(final Graphics2D graphics, final GlyphVector str, + final int x, final int y) { graphics.drawGlyphVector(str, x, y); } @Override - public void draw(Graphics2D graphics, String str, int x, int y) { + public void draw(final Graphics2D graphics, final String str, final int x, final int y) { graphics.drawString(str, x, y); } } @@ -1415,11 +1413,11 @@ public class TextRenderer { private boolean needAdvance; // Creates a Glyph representing an individual Unicode character - public Glyph(int unicodeID, - int glyphCode, - float advance, - GlyphVector singleUnicodeGlyphVector, - GlyphProducer producer) { + public Glyph(final int unicodeID, + final int glyphCode, + final float advance, + final GlyphVector singleUnicodeGlyphVector, + final GlyphProducer producer) { this.unicodeID = unicodeID; this.glyphCode = glyphCode; this.advance = advance; @@ -1430,7 +1428,7 @@ public class TextRenderer { // Creates a Glyph representing a sequence of characters, with // an indication of whether additional single glyphs are being // rendered after it - public Glyph(String str, boolean needAdvance) { + public Glyph(final String str, final boolean needAdvance) { this.str = str; this.needAdvance = needAdvance; } @@ -1451,14 +1449,14 @@ public class TextRenderer { } /** Draws this glyph and returns the (x) advance for this glyph */ - public float draw3D(float inX, float inY, float z, float scaleFactor) { + public float draw3D(final float inX, final float inY, final float z, final float scaleFactor) { if (str != null) { draw3D_ROBUST(str, inX, inY, z, scaleFactor); if (!needAdvance) { return 0; } // Compute and return the advance for this string - GlyphVector gv = font.createGlyphVector(getFontRenderContext(), str); + final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), str); float totalAdvance = 0; for (int i = 0; i < gv.getNumGlyphs(); i++) { totalAdvance += gv.getGlyphMetrics(i).getAdvance(); @@ -1476,32 +1474,32 @@ public class TextRenderer { mPipelinedQuadRenderer = new Pipelined_QuadRenderer(); } - TextureRenderer renderer = getBackingStore(); + final TextureRenderer renderer = getBackingStore(); // Handles case where NPOT texture is used for backing store - TextureCoords wholeImageTexCoords = renderer.getTexture().getImageTexCoords(); - float xScale = wholeImageTexCoords.right(); - float yScale = wholeImageTexCoords.bottom(); + final TextureCoords wholeImageTexCoords = renderer.getTexture().getImageTexCoords(); + final float xScale = wholeImageTexCoords.right(); + final float yScale = wholeImageTexCoords.bottom(); - Rect rect = glyphRectForTextureMapping; - TextData data = (TextData) rect.getUserData(); + final Rect rect = glyphRectForTextureMapping; + final TextData data = (TextData) rect.getUserData(); data.markUsed(); - Rectangle2D origRect = data.origRect(); + final Rectangle2D origRect = data.origRect(); - float x = inX - (scaleFactor * data.origOriginX()); - float y = inY - (scaleFactor * ((float) origRect.getHeight() - data.origOriginY())); + final float x = inX - (scaleFactor * data.origOriginX()); + final float y = inY - (scaleFactor * ((float) origRect.getHeight() - data.origOriginY())); - int texturex = rect.x() + (data.origin().x - data.origOriginX()); - int texturey = renderer.getHeight() - rect.y() - (int) origRect.getHeight() - + final int texturex = rect.x() + (data.origin().x - data.origOriginX()); + final int texturey = renderer.getHeight() - rect.y() - (int) origRect.getHeight() - (data.origin().y - data.origOriginY()); - int width = (int) origRect.getWidth(); - int height = (int) origRect.getHeight(); + final int width = (int) origRect.getWidth(); + final int height = (int) origRect.getHeight(); - float tx1 = xScale * texturex / renderer.getWidth(); - float ty1 = yScale * (1.0f - + final float tx1 = xScale * texturex / renderer.getWidth(); + final float ty1 = yScale * (1.0f - ((float) texturey / (float) renderer.getHeight())); - float tx2 = xScale * (texturex + width) / renderer.getWidth(); - float ty2 = yScale * (1.0f - + final float tx2 = xScale * (texturex + width) / renderer.getWidth(); + final float ty2 = yScale * (1.0f - ((float) (texturey + height) / (float) renderer.getHeight())); mPipelinedQuadRenderer.glTexCoord2f(tx1, ty1); @@ -1515,7 +1513,7 @@ public class TextRenderer { mPipelinedQuadRenderer.glTexCoord2f(tx1, ty2); mPipelinedQuadRenderer.glVertex3f(x, y + (height * scaleFactor), z); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } return advance; @@ -1527,21 +1525,21 @@ public class TextRenderer { } private void upload() { - GlyphVector gv = getGlyphVector(); - Rectangle2D origBBox = preNormalize(renderDelegate.getBounds(gv, getFontRenderContext())); - Rectangle2D bbox = normalize(origBBox); - Point origin = new Point((int) -bbox.getMinX(), + final GlyphVector gv = getGlyphVector(); + final Rectangle2D origBBox = preNormalize(renderDelegate.getBounds(gv, getFontRenderContext())); + final Rectangle2D bbox = normalize(origBBox); + final Point origin = new Point((int) -bbox.getMinX(), (int) -bbox.getMinY()); - Rect rect = new Rect(0, 0, (int) bbox.getWidth(), + final Rect rect = new Rect(0, 0, (int) bbox.getWidth(), (int) bbox.getHeight(), new TextData(null, origin, origBBox, unicodeID)); packer.add(rect); glyphRectForTextureMapping = rect; - Graphics2D g = getGraphics2D(); + final Graphics2D g = getGraphics2D(); // OK, should now have an (x, y) for this rectangle; rasterize // the glyph - int strx = rect.x() + origin.x; - int stry = rect.y() + origin.y; + final int strx = rect.x() + origin.x; + final int stry = rect.y() + origin.y; // Clear out the area we're going to draw into g.setComposite(AlphaComposite.Clear); @@ -1552,7 +1550,7 @@ public class TextRenderer { renderDelegate.drawGlyphVector(g, gv, strx, stry); if (DRAW_BBOXES) { - TextData data = (TextData) rect.getUserData(); + final TextData data = (TextData) rect.getUserData(); // Draw a bounding box on the backing store g.drawRect(strx - data.origOriginX(), stry - data.origOriginY(), @@ -1572,7 +1570,7 @@ public class TextRenderer { } private GlyphVector getGlyphVector() { - GlyphVector gv = singleUnicodeGlyphVector; + final GlyphVector gv = singleUnicodeGlyphVector; if (gv != null) { singleUnicodeGlyphVector = null; // Don't need this anymore return gv; @@ -1595,13 +1593,13 @@ public class TextRenderer { // We re-use this for each incoming string CharSequenceIterator iter = new CharSequenceIterator(); - GlyphProducer(int fontLengthInGlyphs) { + GlyphProducer(final int fontLengthInGlyphs) { unicodes2Glyphs = new int[512]; glyphCache = new Glyph[fontLengthInGlyphs]; clearAllCacheEntries(); } - public List<Glyph> getGlyphs(CharSequence inString) { + public List<Glyph> getGlyphs(final CharSequence inString) { glyphsOutput.clear(); GlyphVector fullRunGlyphVector; fullRunGlyphVector = fullGlyphVectorCache.get(inString.toString()); @@ -1610,30 +1608,30 @@ public class TextRenderer { fullRunGlyphVector = font.createGlyphVector(getFontRenderContext(), iter); fullGlyphVectorCache.put(inString.toString(), fullRunGlyphVector); } - boolean complex = (fullRunGlyphVector.getLayoutFlags() != 0); + final boolean complex = (fullRunGlyphVector.getLayoutFlags() != 0); if (complex || DISABLE_GLYPH_CACHE) { // Punt to the robust version of the renderer glyphsOutput.add(new Glyph(inString.toString(), false)); return glyphsOutput; } - int lengthInGlyphs = fullRunGlyphVector.getNumGlyphs(); + final int lengthInGlyphs = fullRunGlyphVector.getNumGlyphs(); int i = 0; while (i < lengthInGlyphs) { - Character letter = CharacterCache.valueOf(inString.charAt(i)); + final Character letter = CharacterCache.valueOf(inString.charAt(i)); GlyphMetrics metrics = glyphMetricsCache.get(letter); if (metrics == null) { metrics = fullRunGlyphVector.getGlyphMetrics(i); glyphMetricsCache.put(letter, metrics); } - Glyph glyph = getGlyph(inString, metrics, i); + final Glyph glyph = getGlyph(inString, metrics, i); if (glyph != null) { glyphsOutput.add(glyph); i++; } else { // Assemble a run of characters that don't fit in // the cache - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); while (i < lengthInGlyphs && getGlyph(inString, fullRunGlyphVector.getGlyphMetrics(i), i) == null) { buf.append(inString.charAt(i++)); @@ -1646,10 +1644,10 @@ public class TextRenderer { return glyphsOutput; } - public void clearCacheEntry(int unicodeID) { - int glyphID = unicodes2Glyphs[unicodeID]; + public void clearCacheEntry(final int unicodeID) { + final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { - Glyph glyph = glyphCache[glyphID]; + final Glyph glyph = glyphCache[glyphID]; if (glyph != null) { glyph.clear(); } @@ -1664,20 +1662,20 @@ public class TextRenderer { } } - public void register(Glyph glyph) { + public void register(final Glyph glyph) { unicodes2Glyphs[glyph.getUnicodeID()] = glyph.getGlyphCode(); glyphCache[glyph.getGlyphCode()] = glyph; } - public float getGlyphPixelWidth(char unicodeID) { - Glyph glyph = getGlyph(unicodeID); + public float getGlyphPixelWidth(final char unicodeID) { + final Glyph glyph = getGlyph(unicodeID); if (glyph != null) { return glyph.getAdvance(); } // Have to do this the hard / uncached way singleUnicode[0] = unicodeID; - GlyphVector gv = font.createGlyphVector(fontRenderContext, + final GlyphVector gv = font.createGlyphVector(fontRenderContext, singleUnicode); return gv.getGlyphMetrics(0).getAdvance(); } @@ -1685,52 +1683,52 @@ public class TextRenderer { // Returns a glyph object for this single glyph. Returns null // if the unicode or glyph ID would be out of bounds of the // glyph cache. - private Glyph getGlyph(CharSequence inString, - GlyphMetrics glyphMetrics, - int index) { - char unicodeID = inString.charAt(index); + private Glyph getGlyph(final CharSequence inString, + final GlyphMetrics glyphMetrics, + final int index) { + final char unicodeID = inString.charAt(index); if (unicodeID >= unicodes2Glyphs.length) { return null; } - int glyphID = unicodes2Glyphs[unicodeID]; + final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { return glyphCache[glyphID]; } // Must fabricate the glyph singleUnicode[0] = unicodeID; - GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); + final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); return getGlyph(unicodeID, gv, glyphMetrics); } // It's unclear whether this variant might produce less // optimal results than if we can see the entire GlyphVector // for the incoming string - private Glyph getGlyph(int unicodeID) { + private Glyph getGlyph(final int unicodeID) { if (unicodeID >= unicodes2Glyphs.length) { return null; } - int glyphID = unicodes2Glyphs[unicodeID]; + final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { return glyphCache[glyphID]; } singleUnicode[0] = (char) unicodeID; - GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); + final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); return getGlyph(unicodeID, gv, gv.getGlyphMetrics(0)); } - private Glyph getGlyph(int unicodeID, - GlyphVector singleUnicodeGlyphVector, - GlyphMetrics metrics) { - int glyphCode = singleUnicodeGlyphVector.getGlyphCode(0); + private Glyph getGlyph(final int unicodeID, + final GlyphVector singleUnicodeGlyphVector, + final GlyphMetrics metrics) { + final int glyphCode = singleUnicodeGlyphVector.getGlyphCode(0); // Have seen huge glyph codes (65536) coming out of some fonts in some Unicode situations if (glyphCode >= glyphCache.length) { return null; } - Glyph glyph = new Glyph(unicodeID, + final Glyph glyph = new Glyph(unicodeID, glyphCode, metrics.getAdvance(), singleUnicodeGlyphVector, @@ -1752,7 +1750,7 @@ public class TextRenderer { } } - public static Character valueOf(char c) { + public static Character valueOf(final char c) { if (c <= 127) { // must cache return CharacterCache.cache[c]; } @@ -1769,7 +1767,7 @@ public class TextRenderer { int mVBO_For_ResuableTileTexCoords; Pipelined_QuadRenderer() { - GL2 gl = GLContext.getCurrentGL().getGL2(); + final GL2 gl = GLContext.getCurrentGL().getGL2(); mVertCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsVerts); mTexCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsTex); @@ -1777,34 +1775,34 @@ public class TextRenderer { if (usingVBOs) { try { - int[] vbos = new int[2]; + final int[] vbos = new int[2]; gl.glGenBuffers(2, IntBuffer.wrap(vbos)); mVBO_For_ResuableTileVertices = vbos[0]; mVBO_For_ResuableTileTexCoords = vbos[1]; - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, mVBO_For_ResuableTileVertices); - gl.glBufferData(GL2.GL_ARRAY_BUFFER, kTotalBufferSizeBytesVerts, - null, GL2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline + gl.glBufferData(GL.GL_ARRAY_BUFFER, kTotalBufferSizeBytesVerts, + null, GL2ES2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, mVBO_For_ResuableTileTexCoords); - gl.glBufferData(GL2.GL_ARRAY_BUFFER, kTotalBufferSizeBytesTex, - null, GL2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline - } catch (Exception e) { + gl.glBufferData(GL.GL_ARRAY_BUFFER, kTotalBufferSizeBytesTex, + null, GL2ES2.GL_STREAM_DRAW); // stream draw because this is a single quad use pipeline + } catch (final Exception e) { isExtensionAvailable_GL_VERSION_1_5 = false; usingVBOs = false; } } } - public void glTexCoord2f(float v, float v1) { + public void glTexCoord2f(final float v, final float v1) { mTexCoords.put(v); mTexCoords.put(v1); } - public void glVertex3f(float inX, float inY, float inZ) { + public void glVertex3f(final float inX, final float inY, final float inZ) { mVertCoords.put(inX); mVertCoords.put(inY); mVertCoords.put(inZ); @@ -1826,41 +1824,41 @@ public class TextRenderer { private void drawVertexArrays() { if (mOutstandingGlyphsVerticesPipeline > 0) { - GL2 gl = GLContext.getCurrentGL().getGL2(); + final GL2 gl = GLContext.getCurrentGL().getGL2(); - TextureRenderer renderer = getBackingStore(); + final TextureRenderer renderer = getBackingStore(); renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? mVertCoords.rewind(); mTexCoords.rewind(); - gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); + gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); if (usingVBOs) { - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, mVBO_For_ResuableTileVertices); - gl.glBufferSubData(GL2.GL_ARRAY_BUFFER, 0, + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, 0, mOutstandingGlyphsVerticesPipeline * kSizeInBytes_OneVertices_VertexData, mVertCoords); // upload only the new stuff - gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0); + gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0); } else { - gl.glVertexPointer(3, GL2.GL_FLOAT, 0, mVertCoords); + gl.glVertexPointer(3, GL.GL_FLOAT, 0, mVertCoords); } - gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY); + gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY); if (usingVBOs) { - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, mVBO_For_ResuableTileTexCoords); - gl.glBufferSubData(GL2.GL_ARRAY_BUFFER, 0, + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, 0, mOutstandingGlyphsVerticesPipeline * kSizeInBytes_OneVertices_TexData, mTexCoords); // upload only the new stuff - gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, 0); + gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0); } else { - gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, mTexCoords); + gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, mTexCoords); } - gl.glDrawArrays(GL2.GL_QUADS, 0, + gl.glDrawArrays(GL2GL3.GL_QUADS, 0, mOutstandingGlyphsVerticesPipeline); mVertCoords.rewind(); @@ -1871,14 +1869,14 @@ public class TextRenderer { private void drawIMMEDIATE() { if (mOutstandingGlyphsVerticesPipeline > 0) { - TextureRenderer renderer = getBackingStore(); + final TextureRenderer renderer = getBackingStore(); renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? - GL2 gl = GLContext.getCurrentGL().getGL2(); - gl.glBegin(GL2.GL_QUADS); + final GL2 gl = GLContext.getCurrentGL().getGL2(); + gl.glBegin(GL2GL3.GL_QUADS); try { - int numberOfQuads = mOutstandingGlyphsVerticesPipeline / 4; + final int numberOfQuads = mOutstandingGlyphsVerticesPipeline / 4; mVertCoords.rewind(); mTexCoords.rewind(); @@ -1899,7 +1897,7 @@ public class TextRenderer { gl.glVertex3f(mVertCoords.get(), mVertCoords.get(), mVertCoords.get()); } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } finally { gl.glEnd(); @@ -1915,21 +1913,21 @@ public class TextRenderer { private GLU glu; private Frame frame; - DebugListener(GL gl, Frame frame) { + DebugListener(final GL gl, final Frame frame) { this.glu = GLU.createGLU(gl); this.frame = frame; } @Override - public void display(GLAutoDrawable drawable) { - GL2 gl = GLContext.getCurrentGL().getGL2(); - gl.glClear(GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_COLOR_BUFFER_BIT); + public void display(final GLAutoDrawable drawable) { + final GL2 gl = GLContext.getCurrentGL().getGL2(); + gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT); if (packer == null) { return; } - TextureRenderer rend = getBackingStore(); + final TextureRenderer rend = getBackingStore(); final int w = rend.getWidth(); final int h = rend.getHeight(); rend.beginOrthoRendering(w, h); @@ -1947,24 +1945,23 @@ public class TextRenderer { } @Override - public void dispose(GLAutoDrawable drawable) { - glu.destroy(); + public void dispose(final GLAutoDrawable drawable) { glu=null; frame=null; } // Unused methods @Override - public void init(GLAutoDrawable drawable) { + public void init(final GLAutoDrawable drawable) { } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, - int height) { + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, + final int height) { } - public void displayChanged(GLAutoDrawable drawable, - boolean modeChanged, boolean deviceChanged) { + public void displayChanged(final GLAutoDrawable drawable, + final boolean modeChanged, final boolean deviceChanged) { } } @@ -1975,7 +1972,7 @@ public class TextRenderer { * certain graphics cards which have poor vertex array * performance. Defaults to true. */ - public void setUseVertexArrays(boolean useVertexArrays) { + public void setUseVertexArrays(final boolean useVertexArrays) { this.useVertexArrays = useVertexArrays; } @@ -1994,7 +1991,7 @@ public class TextRenderer { * graphics cards do not behave well when this is enabled, * resulting in fuzzy text. Defaults to true. */ - public void setSmoothing(boolean smoothing) { + public void setSmoothing(final boolean smoothing) { this.smoothing = smoothing; getBackingStore().setSmoothing(smoothing); } @@ -2009,7 +2006,7 @@ public class TextRenderer { return smoothing; } - private final boolean is15Available(GL gl) { + private final boolean is15Available(final GL gl) { if (!checkFor_isExtensionAvailable_GL_VERSION_1_5) { isExtensionAvailable_GL_VERSION_1_5 = gl.isExtensionAvailable(GLExtensions.VERSION_1_5); checkFor_isExtensionAvailable_GL_VERSION_1_5 = true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java index 26e1eb041..ef59f9fa0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java @@ -48,7 +48,10 @@ import java.awt.Rectangle; import java.awt.image.*; import javax.media.opengl.*; +import javax.media.opengl.fixedfunc.GLLightingFunc; +import javax.media.opengl.fixedfunc.GLMatrixFunc; import javax.media.opengl.glu.gl2.*; + import com.jogamp.opengl.util.texture.*; import com.jogamp.opengl.util.texture.awt.*; @@ -70,10 +73,10 @@ public class TextureRenderer { // appropriate threads, which would be somewhat unfortunate. // Whether we have an alpha channel in the (RGB/A) backing store - private boolean alpha; + private final boolean alpha; // Whether we're using only a GL_INTENSITY backing store - private boolean intensity; + private final boolean intensity; // Whether we're attempting to use automatic mipmap generation support private boolean mipmap; @@ -91,7 +94,7 @@ public class TextureRenderer { private boolean mustReallocateTexture; private Rectangle dirtyRegion; - private GLUgl2 glu = new GLUgl2(); + private final GLUgl2 glu = new GLUgl2(); // Current color private float r = 1.0f; @@ -108,7 +111,7 @@ public class TextureRenderer { @param height the height of the texture to render into @param alpha whether to allocate an alpha channel for the texture */ - public TextureRenderer(int width, int height, boolean alpha) { + public TextureRenderer(final int width, final int height, final boolean alpha) { this(width, height, alpha, false); } @@ -123,13 +126,13 @@ public class TextureRenderer { @param alpha whether to allocate an alpha channel for the texture @param mipmap whether to attempt use of automatic mipmap generation */ - public TextureRenderer(int width, int height, boolean alpha, boolean mipmap) { + public TextureRenderer(final int width, final int height, final boolean alpha, final boolean mipmap) { this(width, height, alpha, false, mipmap); } // Internal constructor to avoid confusion since alpha only makes // sense when intensity is not set - private TextureRenderer(int width, int height, boolean alpha, boolean intensity, boolean mipmap) { + private TextureRenderer(final int width, final int height, final boolean alpha, final boolean intensity, final boolean mipmap) { this.alpha = alpha; this.intensity = intensity; this.mipmap = mipmap; @@ -140,7 +143,7 @@ public class TextureRenderer { which acts only as an alpha channel. No mipmap support is requested. Internally, this associates a GL_INTENSITY OpenGL texture with the backing store. */ - public static TextureRenderer createAlphaOnlyRenderer(int width, int height) { + public static TextureRenderer createAlphaOnlyRenderer(final int width, final int height) { return createAlphaOnlyRenderer(width, height, false); } @@ -150,7 +153,7 @@ public class TextureRenderer { better smoothing when rendering the TextureRenderer's contents at a distance. Internally, this associates a GL_INTENSITY OpenGL texture with the backing store. */ - public static TextureRenderer createAlphaOnlyRenderer(int width, int height, boolean mipmap) { + public static TextureRenderer createAlphaOnlyRenderer(final int width, final int height, final boolean mipmap) { return new TextureRenderer(width, height, false, true, mipmap); } @@ -205,7 +208,7 @@ public class TextureRenderer { @param height the new height of the backing store of this renderer @throws GLException If an OpenGL context is not current when this method is called */ - public void setSize(int width, int height) throws GLException { + public void setSize(final int width, final int height) throws GLException { init(width, height); } @@ -216,7 +219,7 @@ public class TextureRenderer { @param d the new size of the backing store of this renderer @throws GLException If an OpenGL context is not current when this method is called */ - public void setSize(Dimension d) throws GLException { + public void setSize(final Dimension d) throws GLException { setSize(d.width, d.height); } @@ -228,7 +231,7 @@ public class TextureRenderer { @param smoothing whether smoothing is enabled for the OpenGL texture */ - public void setSmoothing(boolean smoothing) { + public void setSmoothing(final boolean smoothing) { this.smoothing = smoothing; smoothingChanged = true; } @@ -275,8 +278,8 @@ public class TextureRenderer { @param width the width of the region to update @param height the height of the region to update */ - public void markDirty(int x, int y, int width, int height) { - Rectangle curRegion = new Rectangle(x, y, width, height); + public void markDirty(final int x, final int y, final int width, final int height) { + final Rectangle curRegion = new Rectangle(x, y, width, height); if (dirtyRegion == null) { dirtyRegion = curRegion; } else { @@ -333,7 +336,7 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - public void beginOrthoRendering(int width, int height) throws GLException { + public void beginOrthoRendering(final int width, final int height) throws GLException { beginOrthoRendering(width, height, true); } @@ -355,7 +358,7 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - public void beginOrthoRendering(int width, int height, boolean disableDepthTest) throws GLException { + public void beginOrthoRendering(final int width, final int height, final boolean disableDepthTest) throws GLException { beginRendering(true, width, height, disableDepthTest); } @@ -399,8 +402,8 @@ public class TextureRenderer { transparent, 1.0f = completely opaque @throws GLException If an OpenGL context is not current when this method is called */ - public void setColor(float r, float g, float b, float a) throws GLException { - GL2 gl = GLContext.getCurrentGL().getGL2(); + public void setColor(final float r, final float g, final float b, final float a) throws GLException { + final GL2 gl = GLContext.getCurrentGL().getGL2(); this.r = r * a; this.g = g * a; this.b = b * a; @@ -417,7 +420,7 @@ public class TextureRenderer { @param color the new color to use for rendering @throws GLException If an OpenGL context is not current when this method is called */ - public void setColor(Color color) throws GLException { + public void setColor(final Color color) throws GLException { // Get color's RGBA components as floats in the range [0,1]. if (compArray == null) { compArray = new float[4]; @@ -440,7 +443,7 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - public void drawOrthoRect(int screenx, int screeny) throws GLException { + public void drawOrthoRect(final int screenx, final int screeny) throws GLException { drawOrthoRect(screenx, screeny, 0, 0, getWidth(), getHeight()); } @@ -462,9 +465,9 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - public void drawOrthoRect(int screenx, int screeny, - int texturex, int texturey, - int width, int height) throws GLException { + public void drawOrthoRect(final int screenx, final int screeny, + final int texturex, final int texturey, + final int width, final int height) throws GLException { draw3DRect(screenx, screeny, 0, texturex, texturey, width, height, 1); } @@ -493,16 +496,16 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - public void draw3DRect(float x, float y, float z, - int texturex, int texturey, - int width, int height, - float scaleFactor) throws GLException { - GL2 gl = GLContext.getCurrentGL().getGL2(); - Texture texture = getTexture(); - TextureCoords coords = texture.getSubImageTexCoords(texturex, texturey, + public void draw3DRect(final float x, final float y, final float z, + final int texturex, final int texturey, + final int width, final int height, + final float scaleFactor) throws GLException { + final GL2 gl = GLContext.getCurrentGL().getGL2(); + final Texture texture = getTexture(); + final TextureCoords coords = texture.getSubImageTexCoords(texturex, texturey, texturex + width, texturey + height); - gl.glBegin(GL2.GL_QUADS); + gl.glBegin(GL2GL3.GL_QUADS); gl.glTexCoord2f(coords.left(), coords.bottom()); gl.glVertex3f(x, y, z); gl.glTexCoord2f(coords.right(), coords.bottom()); @@ -550,70 +553,70 @@ public class TextureRenderer { // Internals only below this point // - private void beginRendering(boolean ortho, int width, int height, boolean disableDepthTestForOrtho) { - GL2 gl = GLContext.getCurrentGL().getGL2(); - int attribBits = - GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_COLOR_BUFFER_BIT | - (ortho ? (GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT) : 0); + private void beginRendering(final boolean ortho, final int width, final int height, final boolean disableDepthTestForOrtho) { + final GL2 gl = GLContext.getCurrentGL().getGL2(); + final int attribBits = + GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL.GL_COLOR_BUFFER_BIT | + (ortho ? (GL.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT) : 0); gl.glPushAttrib(attribBits); - gl.glDisable(GL2.GL_LIGHTING); + gl.glDisable(GLLightingFunc.GL_LIGHTING); if (ortho) { if (disableDepthTestForOrtho) { - gl.glDisable(GL2.GL_DEPTH_TEST); + gl.glDisable(GL.GL_DEPTH_TEST); } - gl.glDisable(GL2.GL_CULL_FACE); - gl.glMatrixMode(GL2.GL_PROJECTION); + gl.glDisable(GL.GL_CULL_FACE); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluOrtho2D(0, width, 0, height); - gl.glMatrixMode(GL2.GL_MODELVIEW); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); - gl.glMatrixMode(GL2.GL_TEXTURE); + gl.glMatrixMode(GL.GL_TEXTURE); gl.glPushMatrix(); gl.glLoadIdentity(); } - gl.glEnable(GL2.GL_BLEND); - gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA); - Texture texture = getTexture(); + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA); + final Texture texture = getTexture(); texture.enable(gl); texture.bind(gl); - gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); + gl.glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, GL2ES1.GL_MODULATE); // Change polygon color to last saved gl.glColor4f(r, g, b, a); if (smoothingChanged) { smoothingChanged = false; if (smoothing) { - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); if (mipmap) { - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); } else { - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); } } else { - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); } } } - private void endRendering(boolean ortho) { - GL2 gl = GLContext.getCurrentGL().getGL2(); - Texture texture = getTexture(); + private void endRendering(final boolean ortho) { + final GL2 gl = GLContext.getCurrentGL().getGL2(); + final Texture texture = getTexture(); texture.disable(gl); if (ortho) { - gl.glMatrixMode(GL2.GL_PROJECTION); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); - gl.glMatrixMode(GL2.GL_MODELVIEW); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPopMatrix(); - gl.glMatrixMode(GL2.GL_TEXTURE); + gl.glMatrixMode(GL.GL_TEXTURE); gl.glPopMatrix(); } gl.glPopAttrib(); } - private void init(int width, int height) { - GL2 gl = GLContext.getCurrentGL().getGL2(); + private void init(final int width, final int height) { + final GL2 gl = GLContext.getCurrentGL().getGL2(); // Discard previous BufferedImage if any if (image != null) { image.flush(); @@ -621,8 +624,8 @@ public class TextureRenderer { } // Infer the internal format if not an intensity texture - int internalFormat = (intensity ? GL2.GL_INTENSITY : 0); - int imageType = + final int internalFormat = (intensity ? GL2.GL_INTENSITY : 0); + final int imageType = (intensity ? BufferedImage.TYPE_BYTE_GRAY : (alpha ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_RGB)); image = new BufferedImage(width, height, imageType); @@ -650,9 +653,9 @@ public class TextureRenderer { @throws GLException If an OpenGL context is not current when this method is called */ - private void sync(int x, int y, int width, int height) throws GLException { + private void sync(final int x, final int y, final int width, final int height) throws GLException { // Force allocation if necessary - boolean canSkipUpdate = ensureTexture(); + final boolean canSkipUpdate = ensureTexture(); if (!canSkipUpdate) { // Update specified region. @@ -667,7 +670,7 @@ public class TextureRenderer { // Returns true if the texture was newly allocated, false if not private boolean ensureTexture() { - GL gl = GLContext.getCurrentGL(); + final GL gl = GLContext.getCurrentGL(); if (mustReallocateTexture) { if (texture != null) { texture.destroy(gl); @@ -688,8 +691,8 @@ public class TextureRenderer { if (!smoothing) { // The TextureIO classes default to GL_LINEAR filtering - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); - texture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + texture.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); } return true; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java index e8df6aaec..1f055211d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java @@ -53,12 +53,12 @@ class BitmapCharRec { public float advance; public byte[] bitmap; - public BitmapCharRec(int width, - int height, - float xorig, - float yorig, - float advance, - byte[] bitmap) { + public BitmapCharRec(final int width, + final int height, + final float xorig, + final float yorig, + final float advance, + final byte[] bitmap) { this.width = width; this.height = height; this.xorig = xorig; diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java index d4ee12b32..7b8418704 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java @@ -51,10 +51,10 @@ class BitmapFontRec { public int first; public BitmapCharRec[] ch; - public BitmapFontRec(String name, - int num_chars, - int first, - BitmapCharRec[] ch) { + public BitmapFontRec(final String name, + final int num_chars, + final int first, + final BitmapCharRec[] ch) { this.name = name; this.num_chars = num_chars; this.first = first; diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java index 5e26e0d14..d79f16638 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java @@ -49,7 +49,7 @@ class CoordRec { public float x; public float y; - public CoordRec(float x, float y) { + public CoordRec(final float x, final float y) { this.x = x; this.y = y; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java index 42529f3f1..92cbd66da 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java @@ -40,6 +40,7 @@ package com.jogamp.opengl.util.gl2; import javax.media.opengl.*; +import javax.media.opengl.fixedfunc.GLLightingFunc; import javax.media.opengl.glu.*; import javax.media.opengl.glu.gl2.*; @@ -103,13 +104,13 @@ public class GLUT { public static final int BITMAP_HELVETICA_12 = 7; public static final int BITMAP_HELVETICA_18 = 8; - private GLUgl2 glu = new GLUgl2(); + private final GLUgl2 glu = new GLUgl2(); //---------------------------------------------------------------------- // Shapes // - public void glutWireSphere(double radius, int slices, int stacks) { + public void glutWireSphere(final double radius, final int slices, final int stacks) { quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_LINE); glu.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); @@ -119,7 +120,7 @@ public class GLUT { glu.gluSphere(quadObj, radius, slices, stacks); } - public void glutSolidSphere(double radius, int slices, int stacks) { + public void glutSolidSphere(final double radius, final int slices, final int stacks) { quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_FILL); glu.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); @@ -129,8 +130,8 @@ public class GLUT { glu.gluSphere(quadObj, radius, slices, stacks); } - public void glutWireCone(double base, double height, - int slices, int stacks) { + public void glutWireCone(final double base, final double height, + final int slices, final int stacks) { quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_LINE); glu.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); @@ -140,8 +141,8 @@ public class GLUT { glu.gluCylinder(quadObj, base, 0.0, height, slices, stacks); } - public void glutSolidCone(double base, double height, - int slices, int stacks) { + public void glutSolidCone(final double base, final double height, + final int slices, final int stacks) { quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_FILL); glu.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); @@ -151,7 +152,7 @@ public class GLUT { glu.gluCylinder(quadObj, base, 0.0, height, slices, stacks); } - public void glutWireCylinder(double radius, double height, int slices, int stacks) { + public void glutWireCylinder(final double radius, final double height, final int slices, final int stacks) { quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_LINE); glu.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); @@ -161,13 +162,13 @@ public class GLUT { glu.gluCylinder(quadObj, radius, radius, height, slices, stacks); } - public void glutSolidCylinder(double radius, double height, int slices, int stacks) { - GL2 gl = GLUgl2.getCurrentGL2(); + public void glutSolidCylinder(final double radius, final double height, final int slices, final int stacks) { + final GL2 gl = GLUgl2.getCurrentGL2(); // Prepare table of points for drawing end caps - double [] x = new double[slices]; - double [] y = new double[slices]; - double angleDelta = Math.PI * 2 / slices; + final double [] x = new double[slices]; + final double [] y = new double[slices]; + final double angleDelta = Math.PI * 2 / slices; double angle = 0; for (int i = 0 ; i < slices ; i ++) { angle = i * angleDelta; @@ -176,7 +177,7 @@ public class GLUT { } // Draw bottom cap - gl.glBegin(GL2.GL_TRIANGLE_FAN); + gl.glBegin(GL.GL_TRIANGLE_FAN); gl.glNormal3d(0,0,-1); gl.glVertex3d(0,0,0); for (int i = 0 ; i < slices ; i ++) { @@ -186,7 +187,7 @@ public class GLUT { gl.glEnd(); // Draw top cap - gl.glBegin(GL2.GL_TRIANGLE_FAN); + gl.glBegin(GL.GL_TRIANGLE_FAN); gl.glNormal3d(0,0,1); gl.glVertex3d(0,0,height); for (int i = 0 ; i < slices ; i ++) { @@ -205,58 +206,58 @@ public class GLUT { glu.gluCylinder(quadObj, radius, radius, height, slices, stacks); } - public void glutWireCube(float size) { - drawBox(GLUgl2.getCurrentGL2(), size, GL2.GL_LINE_LOOP); + public void glutWireCube(final float size) { + drawBox(GLUgl2.getCurrentGL2(), size, GL.GL_LINE_LOOP); } - public void glutSolidCube(float size) { - drawBox(GLUgl2.getCurrentGL2(), size, GL2.GL_QUADS); + public void glutSolidCube(final float size) { + drawBox(GLUgl2.getCurrentGL2(), size, GL2GL3.GL_QUADS); } - public void glutWireTorus(double innerRadius, double outerRadius, - int nsides, int rings) { - GL2 gl = GLUgl2.getCurrentGL2(); + public void glutWireTorus(final double innerRadius, final double outerRadius, + final int nsides, final int rings) { + final GL2 gl = GLUgl2.getCurrentGL2(); gl.glPushAttrib(GL2.GL_POLYGON_BIT); - gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE); doughnut(gl, innerRadius, outerRadius, nsides, rings); gl.glPopAttrib(); } - public void glutSolidTorus(double innerRadius, double outerRadius, - int nsides, int rings) { + public void glutSolidTorus(final double innerRadius, final double outerRadius, + final int nsides, final int rings) { doughnut(GLUgl2.getCurrentGL2(), innerRadius, outerRadius, nsides, rings); } public void glutWireDodecahedron() { - dodecahedron(GLUgl2.getCurrentGL2(), GL2.GL_LINE_LOOP); + dodecahedron(GLUgl2.getCurrentGL2(), GL.GL_LINE_LOOP); } public void glutSolidDodecahedron() { - dodecahedron(GLUgl2.getCurrentGL2(), GL2.GL_TRIANGLE_FAN); + dodecahedron(GLUgl2.getCurrentGL2(), GL.GL_TRIANGLE_FAN); } public void glutWireOctahedron() { - octahedron(GLUgl2.getCurrentGL2(), GL2.GL_LINE_LOOP); + octahedron(GLUgl2.getCurrentGL2(), GL.GL_LINE_LOOP); } public void glutSolidOctahedron() { - octahedron(GLUgl2.getCurrentGL2(), GL2.GL_TRIANGLES); + octahedron(GLUgl2.getCurrentGL2(), GL.GL_TRIANGLES); } public void glutWireIcosahedron() { - icosahedron(GLUgl2.getCurrentGL2(), GL2.GL_LINE_LOOP); + icosahedron(GLUgl2.getCurrentGL2(), GL.GL_LINE_LOOP); } public void glutSolidIcosahedron() { - icosahedron(GLUgl2.getCurrentGL2(), GL2.GL_TRIANGLES); + icosahedron(GLUgl2.getCurrentGL2(), GL.GL_TRIANGLES); } public void glutWireTetrahedron() { - tetrahedron(GLUgl2.getCurrentGL2(), GL2.GL_LINE_LOOP); + tetrahedron(GLUgl2.getCurrentGL2(), GL.GL_LINE_LOOP); } public void glutSolidTetrahedron() { - tetrahedron(GLUgl2.getCurrentGL2(), GL2.GL_TRIANGLES); + tetrahedron(GLUgl2.getCurrentGL2(), GL.GL_TRIANGLES); } /** @@ -266,7 +267,7 @@ public class GLUT { * @param scale * the factor by which to scale the teapot */ - public void glutSolidTeapot(double scale) { + public void glutSolidTeapot(final double scale) { glutSolidTeapot(scale, true); } @@ -285,8 +286,8 @@ public class GLUT { * whether to create the teapot in exactly the same way as in the C * implementation of GLUT */ - public void glutSolidTeapot(double scale, boolean cStyle) { - teapot(GLUgl2.getCurrentGL2(), 14, scale, GL2.GL_FILL, cStyle); + public void glutSolidTeapot(final double scale, final boolean cStyle) { + teapot(GLUgl2.getCurrentGL2(), 14, scale, GL2GL3.GL_FILL, cStyle); } /** @@ -296,7 +297,7 @@ public class GLUT { * @param scale * the factor by which to scale the teapot */ - public void glutWireTeapot(double scale) { + public void glutWireTeapot(final double scale) { glutWireTeapot(scale, true); } @@ -315,22 +316,22 @@ public class GLUT { * whether to create the teapot in exactly the same way as in the C * implementation of GLUT */ - public void glutWireTeapot(double scale, boolean cStyle) { - teapot(GLUgl2.getCurrentGL2(), 10, scale, GL2.GL_LINE, cStyle); + public void glutWireTeapot(final double scale, final boolean cStyle) { + teapot(GLUgl2.getCurrentGL2(), 10, scale, GL2GL3.GL_LINE, cStyle); } //---------------------------------------------------------------------- // Fonts // - public void glutBitmapCharacter(int font, char character) { - GL2 gl = GLUgl2.getCurrentGL2(); - int[] swapbytes = new int[1]; - int[] lsbfirst = new int[1]; - int[] rowlength = new int[1]; - int[] skiprows = new int[1]; - int[] skippixels = new int[1]; - int[] alignment = new int[1]; + public void glutBitmapCharacter(final int font, final char character) { + final GL2 gl = GLUgl2.getCurrentGL2(); + final int[] swapbytes = new int[1]; + final int[] lsbfirst = new int[1]; + final int[] rowlength = new int[1]; + final int[] skiprows = new int[1]; + final int[] skippixels = new int[1]; + final int[] alignment = new int[1]; beginBitmap(gl, swapbytes, lsbfirst, @@ -348,14 +349,14 @@ public class GLUT { alignment); } - public void glutBitmapString (int font, String string) { - GL2 gl = GLUgl2.getCurrentGL2(); - int[] swapbytes = new int[1]; - int[] lsbfirst = new int[1]; - int[] rowlength = new int[1]; - int[] skiprows = new int[1]; - int[] skippixels = new int[1]; - int[] alignment = new int[1]; + public void glutBitmapString (final int font, final String string) { + final GL2 gl = GLUgl2.getCurrentGL2(); + final int[] swapbytes = new int[1]; + final int[] lsbfirst = new int[1]; + final int[] rowlength = new int[1]; + final int[] skiprows = new int[1]; + final int[] skippixels = new int[1]; + final int[] alignment = new int[1]; beginBitmap(gl, swapbytes, lsbfirst, @@ -363,7 +364,7 @@ public class GLUT { skiprows, skippixels, alignment); - int len = string.length(); + final int len = string.length(); for (int i = 0; i < len; i++) { bitmapCharacterImpl(gl, font, string.charAt(i)); } @@ -376,31 +377,31 @@ public class GLUT { alignment); } - public int glutBitmapWidth (int font, char character) { - BitmapFontRec fontinfo = getBitmapFont(font); - int c = character & 0xFFFF; + public int glutBitmapWidth (final int font, final char character) { + final BitmapFontRec fontinfo = getBitmapFont(font); + final int c = character & 0xFFFF; if (c < fontinfo.first || c >= fontinfo.first + fontinfo.num_chars) return 0; - BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; + final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; if (ch != null) return (int) ch.advance; else return 0; } - public void glutStrokeCharacter(int font, char character) { - GL2 gl = GLUgl2.getCurrentGL2(); - StrokeFontRec fontinfo = getStrokeFont(font); - int c = character & 0xFFFF; + public void glutStrokeCharacter(final int font, final char character) { + final GL2 gl = GLUgl2.getCurrentGL2(); + final StrokeFontRec fontinfo = getStrokeFont(font); + final int c = character & 0xFFFF; if (c < 0 || c >= fontinfo.num_chars) return; - StrokeCharRec ch = fontinfo.ch[c]; + final StrokeCharRec ch = fontinfo.ch[c]; if (ch != null) { for (int i = 0; i < ch.num_strokes; i++) { - StrokeRec stroke = ch.stroke[i]; - gl.glBegin(GL2.GL_LINE_STRIP); + final StrokeRec stroke = ch.stroke[i]; + gl.glBegin(GL.GL_LINE_STRIP); for (int j = 0; j < stroke.num_coords; j++) { - CoordRec coord = stroke.coord[j]; + final CoordRec coord = stroke.coord[j]; gl.glVertex2f(coord.x, coord.y); } gl.glEnd(); @@ -409,21 +410,21 @@ public class GLUT { } } - public void glutStrokeString(int font, String string) { - GL2 gl = GLUgl2.getCurrentGL2(); - StrokeFontRec fontinfo = getStrokeFont(font); - int len = string.length(); + public void glutStrokeString(final int font, final String string) { + final GL2 gl = GLUgl2.getCurrentGL2(); + final StrokeFontRec fontinfo = getStrokeFont(font); + final int len = string.length(); for (int pos = 0; pos < len; pos++) { - int c = string.charAt(pos) & 0xFFFF; + final int c = string.charAt(pos) & 0xFFFF; if (c < 0 || c >= fontinfo.num_chars) continue; - StrokeCharRec ch = fontinfo.ch[c]; + final StrokeCharRec ch = fontinfo.ch[c]; if (ch != null) { for (int i = 0; i < ch.num_strokes; i++) { - StrokeRec stroke = ch.stroke[i]; - gl.glBegin(GL2.GL_LINE_STRIP); + final StrokeRec stroke = ch.stroke[i]; + gl.glBegin(GL.GL_LINE_STRIP); for (int j = 0; j < stroke.num_coords; j++) { - CoordRec coord = stroke.coord[j]; + final CoordRec coord = stroke.coord[j]; gl.glVertex2f(coord.x, coord.y); } gl.glEnd(); @@ -433,30 +434,30 @@ public class GLUT { } } - public int glutStrokeWidth (int font, char character) { + public int glutStrokeWidth (final int font, final char character) { return (int) glutStrokeWidthf(font, character); } - public float glutStrokeWidthf (int font, char character) { - StrokeFontRec fontinfo = getStrokeFont(font); - int c = character & 0xFFFF; + public float glutStrokeWidthf (final int font, final char character) { + final StrokeFontRec fontinfo = getStrokeFont(font); + final int c = character & 0xFFFF; if (c < 0 || c >= fontinfo.num_chars) return 0; - StrokeCharRec ch = fontinfo.ch[c]; + final StrokeCharRec ch = fontinfo.ch[c]; if (ch != null) return ch.right; else return 0; } - public int glutBitmapLength (int font, String string) { - BitmapFontRec fontinfo = getBitmapFont(font); + public int glutBitmapLength (final int font, final String string) { + final BitmapFontRec fontinfo = getBitmapFont(font); int length = 0; - int len = string.length(); + final int len = string.length(); for (int pos = 0; pos < len; pos++) { - int c = string.charAt(pos) & 0xFFFF; + final int c = string.charAt(pos) & 0xFFFF; if (c >= fontinfo.first && c < fontinfo.first + fontinfo.num_chars) { - BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; + final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; if (ch != null) length += ch.advance; } @@ -464,18 +465,18 @@ public class GLUT { return length; } - public int glutStrokeLength (int font, String string) { + public int glutStrokeLength (final int font, final String string) { return (int) glutStrokeLengthf(font, string); } - public float glutStrokeLengthf (int font, String string) { - StrokeFontRec fontinfo = getStrokeFont(font); + public float glutStrokeLengthf (final int font, final String string) { + final StrokeFontRec fontinfo = getStrokeFont(font); float length = 0; - int len = string.length(); + final int len = string.length(); for (int i = 0; i < len; i++) { - char c = string.charAt(i); + final char c = string.charAt(i); if (c >= 0 && c < fontinfo.num_chars) { - StrokeCharRec ch = fontinfo.ch[c]; + final StrokeCharRec ch = fontinfo.ch[c]; if (ch != null) length += ch.right; } @@ -491,9 +492,9 @@ public class GLUT { The polyhedron is centered at the origin. */ public void glutWireRhombicDodecahedron() { - GL2 gl = GLUgl2.getCurrentGL2(); + final GL2 gl = GLUgl2.getCurrentGL2(); for( int i = 0; i < 12; i++ ) { - gl.glBegin( GL2.GL_LINE_LOOP ); + gl.glBegin( GL.GL_LINE_LOOP ); gl.glNormal3dv( rdod_n[ i ],0 ); gl.glVertex3dv( rdod_r[ rdod_v[ i ][ 0 ] ],0 ); gl.glVertex3dv( rdod_r[ rdod_v[ i ][ 1 ] ],0 ); @@ -511,8 +512,8 @@ public class GLUT { The polyhedron is centered at the origin. */ public void glutSolidRhombicDodecahedron() { - GL2 gl = GLUgl2.getCurrentGL2(); - gl.glBegin( GL2.GL_QUADS ); + final GL2 gl = GLUgl2.getCurrentGL2(); + gl.glBegin( GL2GL3.GL_QUADS ); for( int i = 0; i < 12; i++ ) { gl.glNormal3dv( rdod_n[ i ],0 ); gl.glVertex3dv( rdod_r[ rdod_v[ i ][ 0 ] ],0 ); @@ -532,7 +533,7 @@ public class GLUT { // private GLUquadric quadObj; - private void quadObjInit(GLUgl2 glu) { + private void quadObjInit(final GLUgl2 glu) { if (quadObj == null) { quadObj = glu.gluNewQuadric(); } @@ -541,7 +542,7 @@ public class GLUT { } } - private static void doughnut(GL2 gl, double r, double R, int nsides, int rings) { + private static void doughnut(final GL2 gl, final double r, final double R, final int nsides, final int rings) { int i, j; float theta, phi, theta1; float cosTheta, sinTheta; @@ -597,9 +598,9 @@ public class GLUT { {5, 6, 2, 1}, {7, 4, 0, 3} }; - private void drawBox(GL2 gl, float size, int type) { + private void drawBox(final GL2 gl, final float size, final int type) { if (boxVertices == null) { - float[][] v = new float[8][]; + final float[][] v = new float[8][]; for (int i = 0; i < 8; i++) { v[i] = new float[3]; } @@ -611,9 +612,9 @@ public class GLUT { v[1][2] = v[2][2] = v[5][2] = v[6][2] = 0.5f; boxVertices = v; } - float[][] v = boxVertices; - float[][] n = boxNormals; - int[][] faces = boxFaces; + final float[][] v = boxVertices; + final float[][] n = boxNormals; + final int[][] faces = boxFaces; for (int i = 5; i >= 0; i--) { gl.glBegin(type); gl.glNormal3fv(n[i], 0); @@ -664,14 +665,14 @@ public class GLUT { dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha; } - private static void diff3(float[] a, float[] b, float[] c) { + private static void diff3(final float[] a, final float[] b, final float[] c) { c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; c[2] = a[2] - b[2]; } - private static void crossprod(float[] v1, float[] v2, float[] prod) { - float[] p = new float[3]; /* in case prod == v1 or v2 */ + private static void crossprod(final float[] v1, final float[] v2, final float[] prod) { + final float[] p = new float[3]; /* in case prod == v1 or v2 */ p[0] = v1[1] * v2[2] - v2[1] * v1[2]; p[1] = v1[2] * v2[0] - v2[2] * v1[0]; @@ -681,7 +682,7 @@ public class GLUT { prod[2] = p[2]; } - private static void normalize(float[] v) { + private static void normalize(final float[] v) { float d; d = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); @@ -694,10 +695,10 @@ public class GLUT { v[2] *= d; } - private void pentagon(GL2 gl, int a, int b, int c, int d, int e, int shadeType) { - float[] n0 = new float[3]; - float[] d1 = new float[3]; - float[] d2 = new float[3]; + private void pentagon(final GL2 gl, final int a, final int b, final int c, final int d, final int e, final int shadeType) { + final float[] n0 = new float[3]; + final float[] d1 = new float[3]; + final float[] d2 = new float[3]; diff3(dodec[a], dodec[b], d1); diff3(dodec[b], dodec[c], d2); @@ -714,7 +715,7 @@ public class GLUT { gl.glEnd(); } - private void dodecahedron(GL2 gl, int type) { + private void dodecahedron(final GL2 gl, final int type) { if (dodec == null) { initDodecahedron(); } @@ -732,9 +733,9 @@ public class GLUT { pentagon(gl, 4, 12, 5, 16, 17, type); } - private static void recorditem(GL2 gl, float[] n1, float[] n2, float[] n3, int shadeType) { - float[] q0 = new float[3]; - float[] q1 = new float[3]; + private static void recorditem(final GL2 gl, final float[] n1, final float[] n2, final float[] n3, final int shadeType) { + final float[] q0 = new float[3]; + final float[] q1 = new float[3]; diff3(n1, n2, q0); diff3(n2, n3, q1); @@ -749,11 +750,11 @@ public class GLUT { gl.glEnd(); } - private static void subdivide(GL2 gl, float[] v0, float[] v1, float[] v2, int shadeType) { + private static void subdivide(final GL2 gl, final float[] v0, final float[] v1, final float[] v2, final int shadeType) { int depth; - float[] w0 = new float[3]; - float[] w1 = new float[3]; - float[] w2 = new float[3]; + final float[] w0 = new float[3]; + final float[] w1 = new float[3]; + final float[] w2 = new float[3]; float l; int i, j, k, n; @@ -785,10 +786,10 @@ public class GLUT { } } - private static void drawtriangle(GL2 gl, int i, float[][] data, int[][] ndx, int shadeType) { - float[] x0 = data[ndx[i][0]]; - float[] x1 = data[ndx[i][1]]; - float[] x2 = data[ndx[i][2]]; + private static void drawtriangle(final GL2 gl, final int i, final float[][] data, final int[][] ndx, final int shadeType) { + final float[] x0 = data[ndx[i][0]]; + final float[] x1 = data[ndx[i][1]]; + final float[] x2 = data[ndx[i][2]]; subdivide(gl, x0, x1, x2, shadeType); } @@ -816,7 +817,7 @@ public class GLUT { {1, 3, 5} }; - private static void octahedron(GL2 gl, int shadeType) { + private static void octahedron(final GL2 gl, final int shadeType) { int i; for (i = 7; i >= 0; i--) { @@ -870,7 +871,7 @@ public class GLUT { {7, 2, 11}, }; - private static void icosahedron(GL2 gl, int shadeType) { + private static void icosahedron(final GL2 gl, final int shadeType) { int i; for (i = 19; i >= 0; i--) { @@ -950,7 +951,7 @@ public class GLUT { {1, 2, 3} }; - private static final void tetrahedron(GL2 gl, int shadeType) { + private static final void tetrahedron(final GL2 gl, final int shadeType) { for (int i = 3; i >= 0; i--) drawtriangle(gl, i, tdata, tndex, shadeType); } @@ -1112,28 +1113,28 @@ public class GLUT { 0, 0, 1, 0, 0, 1, 1, 1 }; - private static void teapot(GL2 gl, - int grid, - double scale, - int type, - boolean backCompatible) + private static void teapot(final GL2 gl, + final int grid, + final double scale, + final int type, + final boolean backCompatible) { // As mentioned above, GL2.glMap2f expects a packed array of floats - float[] p = new float[4*4*3]; - float[] q = new float[4*4*3]; - float[] r = new float[4*4*3]; - float[] s = new float[4*4*3]; + final float[] p = new float[4*4*3]; + final float[] q = new float[4*4*3]; + final float[] r = new float[4*4*3]; + final float[] s = new float[4*4*3]; int i, j, k, l; gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_EVAL_BIT | GL2.GL_POLYGON_BIT); gl.glEnable(GL2.GL_AUTO_NORMAL); - gl.glEnable(GL2.GL_NORMALIZE); + gl.glEnable(GLLightingFunc.GL_NORMALIZE); gl.glEnable(GL2.GL_MAP2_VERTEX_3); gl.glEnable(GL2.GL_MAP2_TEXTURE_COORD_2); gl.glPushMatrix(); if (!backCompatible) { // The time has come to have the teapot no longer be inside out - gl.glFrontFace(GL2.GL_CW); + gl.glFrontFace(GL.GL_CW); gl.glScaled(0.5*scale, 0.5*scale, 0.5*scale); } else { // We want the teapot in it's backward compatible position and @@ -1184,29 +1185,29 @@ public class GLUT { gl.glPopAttrib(); } - private static void evaluateTeapotMesh(GL2 gl, - int grid, - int type, - int partNum, - boolean repairSingularities) + private static void evaluateTeapotMesh(final GL2 gl, + final int grid, + final int type, + final int partNum, + final boolean repairSingularities) { if (repairSingularities && (partNum == 5 || partNum == 3)) { // Instead of using evaluators that give bad results at singularities, // evaluate by hand - gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, type); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, type); for (int nv = 0; nv < grid; nv++) { if (nv == 0) { // Draw a small triangle-fan to fill the hole gl.glDisable(GL2.GL_AUTO_NORMAL); gl.glNormal3f(0, 0, partNum == 3 ? 1 : -1); - gl.glBegin(GL2.GL_TRIANGLE_FAN); + gl.glBegin(GL.GL_TRIANGLE_FAN); { gl.glEvalCoord2f(0, 0); // Note that we draw in clock-wise order to match the evaluator // method for (int nu = 0; nu <= grid; nu++) { - gl.glEvalCoord2f(nu / (float)grid, (1f / grid) / (float)grid); + gl.glEvalCoord2f(nu / (float)grid, (1f / grid) / grid); } } gl.glEnd(); @@ -1219,7 +1220,7 @@ public class GLUT { for (int nu = grid; nu >= 0; nu--) { gl.glEvalCoord2f(nu / (float)grid, (nv + 1) / (float)grid); gl.glEvalCoord2f(nu / (float)grid, Math.max(nv, 1f / grid) - / (float)grid); + / grid); } } gl.glEnd(); @@ -1233,13 +1234,13 @@ public class GLUT { // Font implementation // - private static void bitmapCharacterImpl(GL2 gl, int font, char cin) { - BitmapFontRec fontinfo = getBitmapFont(font); - int c = cin & 0xFFFF; + private static void bitmapCharacterImpl(final GL2 gl, final int font, final char cin) { + final BitmapFontRec fontinfo = getBitmapFont(font); + final int c = cin & 0xFFFF; if (c < fontinfo.first || c >= fontinfo.first + fontinfo.num_chars) return; - BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; + final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first]; if (ch != null) { gl.glBitmap(ch.width, ch.height, ch.xorig, ch.yorig, ch.advance, 0, ch.bitmap, 0); @@ -1249,7 +1250,7 @@ public class GLUT { private static final BitmapFontRec[] bitmapFonts = new BitmapFontRec[9]; private static final StrokeFontRec[] strokeFonts = new StrokeFontRec[9]; - private static BitmapFontRec getBitmapFont(int font) { + private static BitmapFontRec getBitmapFont(final int font) { BitmapFontRec rec = bitmapFonts[font]; if (rec == null) { switch (font) { @@ -1282,7 +1283,7 @@ public class GLUT { return rec; } - private static StrokeFontRec getStrokeFont(int font) { + private static StrokeFontRec getStrokeFont(final int font) { StrokeFontRec rec = strokeFonts[font]; if (rec == null) { switch (font) { @@ -1299,44 +1300,44 @@ public class GLUT { return rec; } - private static void beginBitmap(GL2 gl, - int[] swapbytes, - int[] lsbfirst, - int[] rowlength, - int[] skiprows, - int[] skippixels, - int[] alignment) { - gl.glGetIntegerv(GL2.GL_UNPACK_SWAP_BYTES, swapbytes, 0); - gl.glGetIntegerv(GL2.GL_UNPACK_LSB_FIRST, lsbfirst, 0); - gl.glGetIntegerv(GL2.GL_UNPACK_ROW_LENGTH, rowlength, 0); - gl.glGetIntegerv(GL2.GL_UNPACK_SKIP_ROWS, skiprows, 0); - gl.glGetIntegerv(GL2.GL_UNPACK_SKIP_PIXELS, skippixels, 0); - gl.glGetIntegerv(GL2.GL_UNPACK_ALIGNMENT, alignment, 0); + private static void beginBitmap(final GL2 gl, + final int[] swapbytes, + final int[] lsbfirst, + final int[] rowlength, + final int[] skiprows, + final int[] skippixels, + final int[] alignment) { + gl.glGetIntegerv(GL2GL3.GL_UNPACK_SWAP_BYTES, swapbytes, 0); + gl.glGetIntegerv(GL2GL3.GL_UNPACK_LSB_FIRST, lsbfirst, 0); + gl.glGetIntegerv(GL2ES2.GL_UNPACK_ROW_LENGTH, rowlength, 0); + gl.glGetIntegerv(GL2ES2.GL_UNPACK_SKIP_ROWS, skiprows, 0); + gl.glGetIntegerv(GL2ES2.GL_UNPACK_SKIP_PIXELS, skippixels, 0); + gl.glGetIntegerv(GL.GL_UNPACK_ALIGNMENT, alignment, 0); /* Little endian machines (DEC Alpha for example) could benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE instead of GL_FALSE, but this would require changing the generated bitmaps too. */ - gl.glPixelStorei(GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE); - gl.glPixelStorei(GL2.GL_UNPACK_LSB_FIRST, GL2.GL_FALSE); - gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, 0); - gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, 0); - gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, 0); - gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1); + gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE); + gl.glPixelStorei(GL2GL3.GL_UNPACK_LSB_FIRST, GL.GL_FALSE); + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, 0); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, 0); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, 0); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); } - private static void endBitmap(GL2 gl, - int[] swapbytes, - int[] lsbfirst, - int[] rowlength, - int[] skiprows, - int[] skippixels, - int[] alignment) { + private static void endBitmap(final GL2 gl, + final int[] swapbytes, + final int[] lsbfirst, + final int[] rowlength, + final int[] skiprows, + final int[] skippixels, + final int[] alignment) { /* Restore saved modes. */ - gl.glPixelStorei(GL2.GL_UNPACK_SWAP_BYTES, swapbytes[0]); - gl.glPixelStorei(GL2.GL_UNPACK_LSB_FIRST, lsbfirst[0]); - gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, rowlength[0]); - gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, skiprows[0]); - gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, skippixels[0]); - gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, alignment[0]); + gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES, swapbytes[0]); + gl.glPixelStorei(GL2GL3.GL_UNPACK_LSB_FIRST, lsbfirst[0]); + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, rowlength[0]); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, skiprows[0]); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, skippixels[0]); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, alignment[0]); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java index 3587ca992..a191efdb4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java @@ -46,14 +46,14 @@ class GLUTStrokeMonoRoman { /* char: 33 '!' */ static final CoordRec char33_stroke0[] = { - new CoordRec((float) 52.381, (float) 100 ), + new CoordRec((float) 52.381, 100 ), new CoordRec((float) 52.381, (float) 33.3333 ), }; static final CoordRec char33_stroke1[] = { new CoordRec((float) 52.381, (float) 9.5238 ), new CoordRec((float) 47.6191, (float) 4.7619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), new CoordRec((float) 57.1429, (float) 4.7619 ), new CoordRec((float) 52.381, (float) 9.5238 ), }; @@ -66,12 +66,12 @@ static final StrokeRec char33[] = { /* char: 34 '"' */ static final CoordRec char34_stroke0[] = { - new CoordRec((float) 33.3334, (float) 100 ), + new CoordRec((float) 33.3334, 100 ), new CoordRec((float) 33.3334, (float) 66.6667 ), }; static final CoordRec char34_stroke1[] = { - new CoordRec((float) 71.4286, (float) 100 ), + new CoordRec((float) 71.4286, 100 ), new CoordRec((float) 71.4286, (float) 66.6667 ), }; @@ -89,7 +89,7 @@ static final CoordRec char35_stroke0[] = { static final CoordRec char35_stroke1[] = { new CoordRec((float) 83.3334, (float) 119.048 ), - new CoordRec((float) 50, (float) -33.3333 ), + new CoordRec(50, (float) -33.3333 ), }; static final CoordRec char35_stroke2[] = { @@ -124,8 +124,8 @@ static final CoordRec char36_stroke1[] = { static final CoordRec char36_stroke2[] = { new CoordRec((float) 85.7143, (float) 85.7143 ), new CoordRec((float) 76.1905, (float) 95.2381 ), - new CoordRec((float) 61.9047, (float) 100 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 61.9047, 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 28.5714, (float) 95.2381 ), new CoordRec((float) 19.0476, (float) 85.7143 ), new CoordRec((float) 19.0476, (float) 76.1905 ), @@ -138,8 +138,8 @@ static final CoordRec char36_stroke2[] = { new CoordRec((float) 85.7143, (float) 28.5714 ), new CoordRec((float) 85.7143, (float) 14.2857 ), new CoordRec((float) 76.1905, (float) 4.7619 ), - new CoordRec((float) 61.9047, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 61.9047, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 28.5714, (float) 4.7619 ), new CoordRec((float) 19.0476, (float) 14.2857 ), }; @@ -153,12 +153,12 @@ static final StrokeRec char36[] = { /* char: 37 '%' */ static final CoordRec char37_stroke0[] = { - new CoordRec((float) 95.2381, (float) 100 ), - new CoordRec((float) 9.5238, (float) 0 ), + new CoordRec((float) 95.2381, 100 ), + new CoordRec((float) 9.5238, 0 ), }; static final CoordRec char37_stroke1[] = { - new CoordRec((float) 33.3333, (float) 100 ), + new CoordRec((float) 33.3333, 100 ), new CoordRec((float) 42.8571, (float) 90.4762 ), new CoordRec((float) 42.8571, (float) 80.9524 ), new CoordRec((float) 38.0952, (float) 71.4286 ), @@ -167,13 +167,13 @@ static final CoordRec char37_stroke1[] = { new CoordRec((float) 9.5238, (float) 76.1905 ), new CoordRec((float) 9.5238, (float) 85.7143 ), new CoordRec((float) 14.2857, (float) 95.2381 ), - new CoordRec((float) 23.8095, (float) 100 ), - new CoordRec((float) 33.3333, (float) 100 ), + new CoordRec((float) 23.8095, 100 ), + new CoordRec((float) 33.3333, 100 ), new CoordRec((float) 42.8571, (float) 95.2381 ), new CoordRec((float) 57.1428, (float) 90.4762 ), new CoordRec((float) 71.4286, (float) 90.4762 ), new CoordRec((float) 85.7143, (float) 95.2381 ), - new CoordRec((float) 95.2381, (float) 100 ), + new CoordRec((float) 95.2381, 100 ), }; static final CoordRec char37_stroke2[] = { @@ -181,8 +181,8 @@ static final CoordRec char37_stroke2[] = { new CoordRec((float) 66.6667, (float) 28.5714 ), new CoordRec((float) 61.9048, (float) 19.0476 ), new CoordRec((float) 61.9048, (float) 9.5238 ), - new CoordRec((float) 71.4286, (float) 0 ), - new CoordRec((float) 80.9524, (float) 0 ), + new CoordRec((float) 71.4286, 0 ), + new CoordRec((float) 80.9524, 0 ), new CoordRec((float) 90.4762, (float) 4.7619 ), new CoordRec((float) 95.2381, (float) 14.2857 ), new CoordRec((float) 95.2381, (float) 23.8095 ), @@ -199,8 +199,8 @@ static final StrokeRec char37[] = { /* char: 38 '&' */ static final CoordRec char38_stroke0[] = { - new CoordRec((float) 100, (float) 57.1429 ), - new CoordRec((float) 100, (float) 61.9048 ), + new CoordRec(100, (float) 57.1429 ), + new CoordRec(100, (float) 61.9048 ), new CoordRec((float) 95.2381, (float) 66.6667 ), new CoordRec((float) 90.4762, (float) 66.6667 ), new CoordRec((float) 85.7143, (float) 61.9048 ), @@ -208,8 +208,8 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 71.4286, (float) 28.5714 ), new CoordRec((float) 61.9048, (float) 14.2857 ), new CoordRec((float) 52.3809, (float) 4.7619 ), - new CoordRec((float) 42.8571, (float) 0 ), - new CoordRec((float) 23.8095, (float) 0 ), + new CoordRec((float) 42.8571, 0 ), + new CoordRec((float) 23.8095, 0 ), new CoordRec((float) 14.2857, (float) 4.7619 ), new CoordRec((float) 9.5238, (float) 9.5238 ), new CoordRec((float) 4.7619, (float) 19.0476 ), @@ -221,7 +221,7 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 57.1429, (float) 76.1905 ), new CoordRec((float) 57.1429, (float) 85.7143 ), new CoordRec((float) 52.3809, (float) 95.2381 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 33.3333, (float) 95.2381 ), new CoordRec((float) 28.5714, (float) 85.7143 ), new CoordRec((float) 28.5714, (float) 76.1905 ), @@ -229,10 +229,10 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 42.8571, (float) 47.619 ), new CoordRec((float) 66.6667, (float) 14.2857 ), new CoordRec((float) 76.1905, (float) 4.7619 ), - new CoordRec((float) 85.7143, (float) 0 ), - new CoordRec((float) 95.2381, (float) 0 ), - new CoordRec((float) 100, (float) 4.7619 ), - new CoordRec((float) 100, (float) 9.5238 ), + new CoordRec((float) 85.7143, 0 ), + new CoordRec((float) 95.2381, 0 ), + new CoordRec(100, (float) 4.7619 ), + new CoordRec(100, (float) 9.5238 ), }; static final StrokeRec char38[] = { @@ -242,7 +242,7 @@ static final StrokeRec char38[] = { /* char: 39 ''' */ static final CoordRec char39_stroke0[] = { - new CoordRec((float) 52.381, (float) 100 ), + new CoordRec((float) 52.381, 100 ), new CoordRec((float) 52.381, (float) 66.6667 ), }; @@ -255,12 +255,12 @@ static final StrokeRec char39[] = { static final CoordRec char40_stroke0[] = { new CoordRec((float) 69.0476, (float) 119.048 ), new CoordRec((float) 59.5238, (float) 109.524 ), - new CoordRec((float) 50, (float) 95.2381 ), + new CoordRec(50, (float) 95.2381 ), new CoordRec((float) 40.4762, (float) 76.1905 ), new CoordRec((float) 35.7143, (float) 52.381 ), new CoordRec((float) 35.7143, (float) 33.3333 ), new CoordRec((float) 40.4762, (float) 9.5238 ), - new CoordRec((float) 50, (float) -9.5238 ), + new CoordRec(50, (float) -9.5238 ), new CoordRec((float) 59.5238, (float) -23.8095 ), new CoordRec((float) 69.0476, (float) -33.3333 ), }; @@ -315,7 +315,7 @@ static final StrokeRec char42[] = { static final CoordRec char43_stroke0[] = { new CoordRec((float) 52.3809, (float) 85.7143 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char43_stroke1[] = { @@ -332,7 +332,7 @@ static final StrokeRec char43[] = { static final CoordRec char44_stroke0[] = { new CoordRec((float) 57.1429, (float) 4.7619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), new CoordRec((float) 47.6191, (float) 4.7619 ), new CoordRec((float) 52.381, (float) 9.5238 ), new CoordRec((float) 57.1429, (float) 4.7619 ), @@ -361,7 +361,7 @@ static final StrokeRec char45[] = { static final CoordRec char46_stroke0[] = { new CoordRec((float) 52.381, (float) 9.5238 ), new CoordRec((float) 47.6191, (float) 4.7619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), new CoordRec((float) 57.1429, (float) 4.7619 ), new CoordRec((float) 52.381, (float) 9.5238 ), }; @@ -374,7 +374,7 @@ static final StrokeRec char46[] = { static final CoordRec char47_stroke0[] = { new CoordRec((float) 19.0476, (float) -14.2857 ), - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 85.7143, 100 ), }; static final StrokeRec char47[] = { @@ -384,23 +384,23 @@ static final StrokeRec char47[] = { /* char: 48 '0' */ static final CoordRec char48_stroke0[] = { - new CoordRec((float) 47.619, (float) 100 ), + new CoordRec((float) 47.619, 100 ), new CoordRec((float) 33.3333, (float) 95.2381 ), new CoordRec((float) 23.8095, (float) 80.9524 ), new CoordRec((float) 19.0476, (float) 57.1429 ), new CoordRec((float) 19.0476, (float) 42.8571 ), new CoordRec((float) 23.8095, (float) 19.0476 ), new CoordRec((float) 33.3333, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 57.1428, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 57.1428, 0 ), new CoordRec((float) 71.4286, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 19.0476 ), new CoordRec((float) 85.7143, (float) 42.8571 ), new CoordRec((float) 85.7143, (float) 57.1429 ), new CoordRec((float) 80.9524, (float) 80.9524 ), new CoordRec((float) 71.4286, (float) 95.2381 ), - new CoordRec((float) 57.1428, (float) 100 ), - new CoordRec((float) 47.619, (float) 100 ), + new CoordRec((float) 57.1428, 100 ), + new CoordRec((float) 47.619, 100 ), }; static final StrokeRec char48[] = { @@ -411,9 +411,9 @@ static final StrokeRec char48[] = { static final CoordRec char49_stroke0[] = { new CoordRec((float) 40.4762, (float) 80.9524 ), - new CoordRec((float) 50, (float) 85.7143 ), - new CoordRec((float) 64.2857, (float) 100 ), - new CoordRec((float) 64.2857, (float) 0 ), + new CoordRec(50, (float) 85.7143 ), + new CoordRec((float) 64.2857, 100 ), + new CoordRec((float) 64.2857, 0 ), }; static final StrokeRec char49[] = { @@ -427,16 +427,16 @@ static final CoordRec char50_stroke0[] = { new CoordRec((float) 23.8095, (float) 80.9524 ), new CoordRec((float) 28.5714, (float) 90.4762 ), new CoordRec((float) 33.3333, (float) 95.2381 ), - new CoordRec((float) 42.8571, (float) 100 ), - new CoordRec((float) 61.9047, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), + new CoordRec((float) 61.9047, 100 ), new CoordRec((float) 71.4286, (float) 95.2381 ), new CoordRec((float) 76.1905, (float) 90.4762 ), new CoordRec((float) 80.9524, (float) 80.9524 ), new CoordRec((float) 80.9524, (float) 71.4286 ), new CoordRec((float) 76.1905, (float) 61.9048 ), new CoordRec((float) 66.6666, (float) 47.619 ), - new CoordRec((float) 19.0476, (float) 0 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 19.0476, 0 ), + new CoordRec((float) 85.7143, 0 ), }; static final StrokeRec char50[] = { @@ -446,8 +446,8 @@ static final StrokeRec char50[] = { /* char: 51 '3' */ static final CoordRec char51_stroke0[] = { - new CoordRec((float) 28.5714, (float) 100 ), - new CoordRec((float) 80.9524, (float) 100 ), + new CoordRec((float) 28.5714, 100 ), + new CoordRec((float) 80.9524, 100 ), new CoordRec((float) 52.3809, (float) 61.9048 ), new CoordRec((float) 66.6666, (float) 61.9048 ), new CoordRec((float) 76.1905, (float) 57.1429 ), @@ -456,8 +456,8 @@ static final CoordRec char51_stroke0[] = { new CoordRec((float) 85.7143, (float) 28.5714 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 71.4286, (float) 4.7619 ), - new CoordRec((float) 57.1428, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 57.1428, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 28.5714, (float) 4.7619 ), new CoordRec((float) 23.8095, (float) 9.5238 ), new CoordRec((float) 19.0476, (float) 19.0476 ), @@ -470,14 +470,14 @@ static final StrokeRec char51[] = { /* char: 52 '4' */ static final CoordRec char52_stroke0[] = { - new CoordRec((float) 64.2857, (float) 100 ), + new CoordRec((float) 64.2857, 100 ), new CoordRec((float) 16.6667, (float) 33.3333 ), new CoordRec((float) 88.0952, (float) 33.3333 ), }; static final CoordRec char52_stroke1[] = { - new CoordRec((float) 64.2857, (float) 100 ), - new CoordRec((float) 64.2857, (float) 0 ), + new CoordRec((float) 64.2857, 100 ), + new CoordRec((float) 64.2857, 0 ), }; static final StrokeRec char52[] = { @@ -488,8 +488,8 @@ static final StrokeRec char52[] = { /* char: 53 '5' */ static final CoordRec char53_stroke0[] = { - new CoordRec((float) 76.1905, (float) 100 ), - new CoordRec((float) 28.5714, (float) 100 ), + new CoordRec((float) 76.1905, 100 ), + new CoordRec((float) 28.5714, 100 ), new CoordRec((float) 23.8095, (float) 57.1429 ), new CoordRec((float) 28.5714, (float) 61.9048 ), new CoordRec((float) 42.8571, (float) 66.6667 ), @@ -500,8 +500,8 @@ static final CoordRec char53_stroke0[] = { new CoordRec((float) 85.7143, (float) 28.5714 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 71.4286, (float) 4.7619 ), - new CoordRec((float) 57.1428, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 57.1428, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 28.5714, (float) 4.7619 ), new CoordRec((float) 23.8095, (float) 9.5238 ), new CoordRec((float) 19.0476, (float) 19.0476 ), @@ -516,16 +516,16 @@ static final StrokeRec char53[] = { static final CoordRec char54_stroke0[] = { new CoordRec((float) 78.5714, (float) 85.7143 ), new CoordRec((float) 73.8096, (float) 95.2381 ), - new CoordRec((float) 59.5238, (float) 100 ), - new CoordRec((float) 50, (float) 100 ), + new CoordRec((float) 59.5238, 100 ), + new CoordRec(50, 100 ), new CoordRec((float) 35.7143, (float) 95.2381 ), new CoordRec((float) 26.1905, (float) 80.9524 ), new CoordRec((float) 21.4286, (float) 57.1429 ), new CoordRec((float) 21.4286, (float) 33.3333 ), new CoordRec((float) 26.1905, (float) 14.2857 ), new CoordRec((float) 35.7143, (float) 4.7619 ), - new CoordRec((float) 50, (float) 0 ), - new CoordRec((float) 54.7619, (float) 0 ), + new CoordRec(50, 0 ), + new CoordRec((float) 54.7619, 0 ), new CoordRec((float) 69.0476, (float) 4.7619 ), new CoordRec((float) 78.5714, (float) 14.2857 ), new CoordRec((float) 83.3334, (float) 28.5714 ), @@ -533,7 +533,7 @@ static final CoordRec char54_stroke0[] = { new CoordRec((float) 78.5714, (float) 47.619 ), new CoordRec((float) 69.0476, (float) 57.1429 ), new CoordRec((float) 54.7619, (float) 61.9048 ), - new CoordRec((float) 50, (float) 61.9048 ), + new CoordRec(50, (float) 61.9048 ), new CoordRec((float) 35.7143, (float) 57.1429 ), new CoordRec((float) 26.1905, (float) 47.619 ), new CoordRec((float) 21.4286, (float) 33.3333 ), @@ -546,13 +546,13 @@ static final StrokeRec char54[] = { /* char: 55 '7' */ static final CoordRec char55_stroke0[] = { - new CoordRec((float) 85.7143, (float) 100 ), - new CoordRec((float) 38.0952, (float) 0 ), + new CoordRec((float) 85.7143, 100 ), + new CoordRec((float) 38.0952, 0 ), }; static final CoordRec char55_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 85.7143, 100 ), }; static final StrokeRec char55[] = { @@ -563,7 +563,7 @@ static final StrokeRec char55[] = { /* char: 56 '8' */ static final CoordRec char56_stroke0[] = { - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 28.5714, (float) 95.2381 ), new CoordRec((float) 23.8095, (float) 85.7143 ), new CoordRec((float) 23.8095, (float) 76.1905 ), @@ -576,8 +576,8 @@ static final CoordRec char56_stroke0[] = { new CoordRec((float) 85.7143, (float) 19.0476 ), new CoordRec((float) 80.9524, (float) 9.5238 ), new CoordRec((float) 76.1905, (float) 4.7619 ), - new CoordRec((float) 61.9047, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 61.9047, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 28.5714, (float) 4.7619 ), new CoordRec((float) 23.8095, (float) 9.5238 ), new CoordRec((float) 19.0476, (float) 19.0476 ), @@ -590,8 +590,8 @@ static final CoordRec char56_stroke0[] = { new CoordRec((float) 80.9524, (float) 76.1905 ), new CoordRec((float) 80.9524, (float) 85.7143 ), new CoordRec((float) 76.1905, (float) 95.2381 ), - new CoordRec((float) 61.9047, (float) 100 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 61.9047, 100 ), + new CoordRec((float) 42.8571, 100 ), }; static final StrokeRec char56[] = { @@ -605,23 +605,23 @@ static final CoordRec char57_stroke0[] = { new CoordRec((float) 78.5714, (float) 52.381 ), new CoordRec((float) 69.0476, (float) 42.8571 ), new CoordRec((float) 54.7619, (float) 38.0952 ), - new CoordRec((float) 50, (float) 38.0952 ), + new CoordRec(50, (float) 38.0952 ), new CoordRec((float) 35.7143, (float) 42.8571 ), new CoordRec((float) 26.1905, (float) 52.381 ), new CoordRec((float) 21.4286, (float) 66.6667 ), new CoordRec((float) 21.4286, (float) 71.4286 ), new CoordRec((float) 26.1905, (float) 85.7143 ), new CoordRec((float) 35.7143, (float) 95.2381 ), - new CoordRec((float) 50, (float) 100 ), - new CoordRec((float) 54.7619, (float) 100 ), + new CoordRec(50, 100 ), + new CoordRec((float) 54.7619, 100 ), new CoordRec((float) 69.0476, (float) 95.2381 ), new CoordRec((float) 78.5714, (float) 85.7143 ), new CoordRec((float) 83.3334, (float) 66.6667 ), new CoordRec((float) 83.3334, (float) 42.8571 ), new CoordRec((float) 78.5714, (float) 19.0476 ), new CoordRec((float) 69.0476, (float) 4.7619 ), - new CoordRec((float) 54.7619, (float) 0 ), - new CoordRec((float) 45.2381, (float) 0 ), + new CoordRec((float) 54.7619, 0 ), + new CoordRec((float) 45.2381, 0 ), new CoordRec((float) 30.9524, (float) 4.7619 ), new CoordRec((float) 26.1905, (float) 14.2857 ), }; @@ -643,7 +643,7 @@ static final CoordRec char58_stroke0[] = { static final CoordRec char58_stroke1[] = { new CoordRec((float) 52.381, (float) 9.5238 ), new CoordRec((float) 47.6191, (float) 4.7619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), new CoordRec((float) 57.1429, (float) 4.7619 ), new CoordRec((float) 52.381, (float) 9.5238 ), }; @@ -665,7 +665,7 @@ static final CoordRec char59_stroke0[] = { static final CoordRec char59_stroke1[] = { new CoordRec((float) 57.1429, (float) 4.7619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), new CoordRec((float) 47.6191, (float) 4.7619 ), new CoordRec((float) 52.381, (float) 9.5238 ), new CoordRec((float) 57.1429, (float) 4.7619 ), @@ -684,7 +684,7 @@ static final StrokeRec char59[] = { static final CoordRec char60_stroke0[] = { new CoordRec((float) 90.4762, (float) 85.7143 ), new CoordRec((float) 14.2857, (float) 42.8571 ), - new CoordRec((float) 90.4762, (float) 0 ), + new CoordRec((float) 90.4762, 0 ), }; static final StrokeRec char60[] = { @@ -713,7 +713,7 @@ static final StrokeRec char61[] = { static final CoordRec char62_stroke0[] = { new CoordRec((float) 14.2857, (float) 85.7143 ), new CoordRec((float) 90.4762, (float) 42.8571 ), - new CoordRec((float) 14.2857, (float) 0 ), + new CoordRec((float) 14.2857, 0 ), }; static final StrokeRec char62[] = { @@ -727,8 +727,8 @@ static final CoordRec char63_stroke0[] = { new CoordRec((float) 23.8095, (float) 80.9524 ), new CoordRec((float) 28.5714, (float) 90.4762 ), new CoordRec((float) 33.3333, (float) 95.2381 ), - new CoordRec((float) 42.8571, (float) 100 ), - new CoordRec((float) 61.9047, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), + new CoordRec((float) 61.9047, 100 ), new CoordRec((float) 71.4285, (float) 95.2381 ), new CoordRec((float) 76.1905, (float) 90.4762 ), new CoordRec((float) 80.9524, (float) 80.9524 ), @@ -742,7 +742,7 @@ static final CoordRec char63_stroke0[] = { static final CoordRec char63_stroke1[] = { new CoordRec((float) 52.3809, (float) 9.5238 ), new CoordRec((float) 47.619, (float) 4.7619 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), new CoordRec((float) 57.1428, (float) 4.7619 ), new CoordRec((float) 52.3809, (float) 9.5238 ), }; @@ -775,14 +775,14 @@ static final CoordRec char64_stroke1[] = { new CoordRec((float) 78.5714, (float) 61.9048 ), new CoordRec((float) 69.0476, (float) 71.4286 ), new CoordRec((float) 54.7619, (float) 76.1905 ), - new CoordRec((float) 50, (float) 76.1905 ), + new CoordRec(50, (float) 76.1905 ), new CoordRec((float) 35.7143, (float) 71.4286 ), new CoordRec((float) 26.1905, (float) 61.9048 ), new CoordRec((float) 21.4286, (float) 47.619 ), new CoordRec((float) 21.4286, (float) 42.8571 ), new CoordRec((float) 26.1905, (float) 28.5714 ), new CoordRec((float) 35.7143, (float) 19.0476 ), - new CoordRec((float) 50, (float) 14.2857 ), + new CoordRec(50, (float) 14.2857 ), new CoordRec((float) 54.7619, (float) 14.2857 ), new CoordRec((float) 69.0476, (float) 19.0476 ), }; @@ -795,13 +795,13 @@ static final StrokeRec char64[] = { /* char: 65 'A' */ static final CoordRec char65_stroke0[] = { - new CoordRec((float) 52.3809, (float) 100 ), - new CoordRec((float) 14.2857, (float) 0 ), + new CoordRec((float) 52.3809, 100 ), + new CoordRec((float) 14.2857, 0 ), }; static final CoordRec char65_stroke1[] = { - new CoordRec((float) 52.3809, (float) 100 ), - new CoordRec((float) 90.4762, (float) 0 ), + new CoordRec((float) 52.3809, 100 ), + new CoordRec((float) 90.4762, 0 ), }; static final CoordRec char65_stroke2[] = { @@ -818,13 +818,13 @@ static final StrokeRec char65[] = { /* char: 66 'B' */ static final CoordRec char66_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char66_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 61.9047, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 61.9047, 100 ), new CoordRec((float) 76.1905, (float) 95.2381 ), new CoordRec((float) 80.9524, (float) 90.4762 ), new CoordRec((float) 85.7143, (float) 80.9524 ), @@ -843,8 +843,8 @@ static final CoordRec char66_stroke2[] = { new CoordRec((float) 85.7143, (float) 19.0476 ), new CoordRec((float) 80.9524, (float) 9.5238 ), new CoordRec((float) 76.1905, (float) 4.7619 ), - new CoordRec((float) 61.9047, (float) 0 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 61.9047, 0 ), + new CoordRec((float) 19.0476, 0 ), }; static final StrokeRec char66[] = { @@ -859,8 +859,8 @@ static final CoordRec char67_stroke0[] = { new CoordRec((float) 88.0952, (float) 76.1905 ), new CoordRec((float) 83.3334, (float) 85.7143 ), new CoordRec((float) 73.8096, (float) 95.2381 ), - new CoordRec((float) 64.2857, (float) 100 ), - new CoordRec((float) 45.2381, (float) 100 ), + new CoordRec((float) 64.2857, 100 ), + new CoordRec((float) 45.2381, 100 ), new CoordRec((float) 35.7143, (float) 95.2381 ), new CoordRec((float) 26.1905, (float) 85.7143 ), new CoordRec((float) 21.4286, (float) 76.1905 ), @@ -869,8 +869,8 @@ static final CoordRec char67_stroke0[] = { new CoordRec((float) 21.4286, (float) 23.8095 ), new CoordRec((float) 26.1905, (float) 14.2857 ), new CoordRec((float) 35.7143, (float) 4.7619 ), - new CoordRec((float) 45.2381, (float) 0 ), - new CoordRec((float) 64.2857, (float) 0 ), + new CoordRec((float) 45.2381, 0 ), + new CoordRec((float) 64.2857, 0 ), new CoordRec((float) 73.8096, (float) 4.7619 ), new CoordRec((float) 83.3334, (float) 14.2857 ), new CoordRec((float) 88.0952, (float) 23.8095 ), @@ -883,13 +883,13 @@ static final StrokeRec char67[] = { /* char: 68 'D' */ static final CoordRec char68_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char68_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 52.3809, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 52.3809, 100 ), new CoordRec((float) 66.6666, (float) 95.2381 ), new CoordRec((float) 76.1905, (float) 85.7143 ), new CoordRec((float) 80.9524, (float) 76.1905 ), @@ -898,8 +898,8 @@ static final CoordRec char68_stroke1[] = { new CoordRec((float) 80.9524, (float) 23.8095 ), new CoordRec((float) 76.1905, (float) 14.2857 ), new CoordRec((float) 66.6666, (float) 4.7619 ), - new CoordRec((float) 52.3809, (float) 0 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), + new CoordRec((float) 19.0476, 0 ), }; static final StrokeRec char68[] = { @@ -910,13 +910,13 @@ static final StrokeRec char68[] = { /* char: 69 'E' */ static final CoordRec char69_stroke0[] = { - new CoordRec((float) 21.4286, (float) 100 ), - new CoordRec((float) 21.4286, (float) 0 ), + new CoordRec((float) 21.4286, 100 ), + new CoordRec((float) 21.4286, 0 ), }; static final CoordRec char69_stroke1[] = { - new CoordRec((float) 21.4286, (float) 100 ), - new CoordRec((float) 83.3334, (float) 100 ), + new CoordRec((float) 21.4286, 100 ), + new CoordRec((float) 83.3334, 100 ), }; static final CoordRec char69_stroke2[] = { @@ -925,8 +925,8 @@ static final CoordRec char69_stroke2[] = { }; static final CoordRec char69_stroke3[] = { - new CoordRec((float) 21.4286, (float) 0 ), - new CoordRec((float) 83.3334, (float) 0 ), + new CoordRec((float) 21.4286, 0 ), + new CoordRec((float) 83.3334, 0 ), }; static final StrokeRec char69[] = { @@ -939,13 +939,13 @@ static final StrokeRec char69[] = { /* char: 70 'F' */ static final CoordRec char70_stroke0[] = { - new CoordRec((float) 21.4286, (float) 100 ), - new CoordRec((float) 21.4286, (float) 0 ), + new CoordRec((float) 21.4286, 100 ), + new CoordRec((float) 21.4286, 0 ), }; static final CoordRec char70_stroke1[] = { - new CoordRec((float) 21.4286, (float) 100 ), - new CoordRec((float) 83.3334, (float) 100 ), + new CoordRec((float) 21.4286, 100 ), + new CoordRec((float) 83.3334, 100 ), }; static final CoordRec char70_stroke2[] = { @@ -965,8 +965,8 @@ static final CoordRec char71_stroke0[] = { new CoordRec((float) 88.0952, (float) 76.1905 ), new CoordRec((float) 83.3334, (float) 85.7143 ), new CoordRec((float) 73.8096, (float) 95.2381 ), - new CoordRec((float) 64.2857, (float) 100 ), - new CoordRec((float) 45.2381, (float) 100 ), + new CoordRec((float) 64.2857, 100 ), + new CoordRec((float) 45.2381, 100 ), new CoordRec((float) 35.7143, (float) 95.2381 ), new CoordRec((float) 26.1905, (float) 85.7143 ), new CoordRec((float) 21.4286, (float) 76.1905 ), @@ -975,8 +975,8 @@ static final CoordRec char71_stroke0[] = { new CoordRec((float) 21.4286, (float) 23.8095 ), new CoordRec((float) 26.1905, (float) 14.2857 ), new CoordRec((float) 35.7143, (float) 4.7619 ), - new CoordRec((float) 45.2381, (float) 0 ), - new CoordRec((float) 64.2857, (float) 0 ), + new CoordRec((float) 45.2381, 0 ), + new CoordRec((float) 64.2857, 0 ), new CoordRec((float) 73.8096, (float) 4.7619 ), new CoordRec((float) 83.3334, (float) 14.2857 ), new CoordRec((float) 88.0952, (float) 23.8095 ), @@ -996,13 +996,13 @@ static final StrokeRec char71[] = { /* char: 72 'H' */ static final CoordRec char72_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char72_stroke1[] = { - new CoordRec((float) 85.7143, (float) 100 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 85.7143, 100 ), + new CoordRec((float) 85.7143, 0 ), }; static final CoordRec char72_stroke2[] = { @@ -1019,8 +1019,8 @@ static final StrokeRec char72[] = { /* char: 73 'I' */ static final CoordRec char73_stroke0[] = { - new CoordRec((float) 52.381, (float) 100 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 100 ), + new CoordRec((float) 52.381, 0 ), }; static final StrokeRec char73[] = { @@ -1030,12 +1030,12 @@ static final StrokeRec char73[] = { /* char: 74 'J' */ static final CoordRec char74_stroke0[] = { - new CoordRec((float) 76.1905, (float) 100 ), + new CoordRec((float) 76.1905, 100 ), new CoordRec((float) 76.1905, (float) 23.8095 ), new CoordRec((float) 71.4286, (float) 9.5238 ), new CoordRec((float) 66.6667, (float) 4.7619 ), - new CoordRec((float) 57.1429, (float) 0 ), - new CoordRec((float) 47.6191, (float) 0 ), + new CoordRec((float) 57.1429, 0 ), + new CoordRec((float) 47.6191, 0 ), new CoordRec((float) 38.0953, (float) 4.7619 ), new CoordRec((float) 33.3334, (float) 9.5238 ), new CoordRec((float) 28.5715, (float) 23.8095 ), @@ -1049,18 +1049,18 @@ static final StrokeRec char74[] = { /* char: 75 'K' */ static final CoordRec char75_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char75_stroke1[] = { - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 85.7143, 100 ), new CoordRec((float) 19.0476, (float) 33.3333 ), }; static final CoordRec char75_stroke2[] = { new CoordRec((float) 42.8571, (float) 57.1429 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 85.7143, 0 ), }; static final StrokeRec char75[] = { @@ -1072,13 +1072,13 @@ static final StrokeRec char75[] = { /* char: 76 'L' */ static final CoordRec char76_stroke0[] = { - new CoordRec((float) 23.8095, (float) 100 ), - new CoordRec((float) 23.8095, (float) 0 ), + new CoordRec((float) 23.8095, 100 ), + new CoordRec((float) 23.8095, 0 ), }; static final CoordRec char76_stroke1[] = { - new CoordRec((float) 23.8095, (float) 0 ), - new CoordRec((float) 80.9524, (float) 0 ), + new CoordRec((float) 23.8095, 0 ), + new CoordRec((float) 80.9524, 0 ), }; static final StrokeRec char76[] = { @@ -1089,23 +1089,23 @@ static final StrokeRec char76[] = { /* char: 77 'M' */ static final CoordRec char77_stroke0[] = { - new CoordRec((float) 14.2857, (float) 100 ), - new CoordRec((float) 14.2857, (float) 0 ), + new CoordRec((float) 14.2857, 100 ), + new CoordRec((float) 14.2857, 0 ), }; static final CoordRec char77_stroke1[] = { - new CoordRec((float) 14.2857, (float) 100 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 14.2857, 100 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char77_stroke2[] = { - new CoordRec((float) 90.4762, (float) 100 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 90.4762, 100 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char77_stroke3[] = { - new CoordRec((float) 90.4762, (float) 100 ), - new CoordRec((float) 90.4762, (float) 0 ), + new CoordRec((float) 90.4762, 100 ), + new CoordRec((float) 90.4762, 0 ), }; static final StrokeRec char77[] = { @@ -1118,18 +1118,18 @@ static final StrokeRec char77[] = { /* char: 78 'N' */ static final CoordRec char78_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char78_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 85.7143, 0 ), }; static final CoordRec char78_stroke2[] = { - new CoordRec((float) 85.7143, (float) 100 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 85.7143, 100 ), + new CoordRec((float) 85.7143, 0 ), }; static final StrokeRec char78[] = { @@ -1141,7 +1141,7 @@ static final StrokeRec char78[] = { /* char: 79 'O' */ static final CoordRec char79_stroke0[] = { - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 33.3333, (float) 95.2381 ), new CoordRec((float) 23.8095, (float) 85.7143 ), new CoordRec((float) 19.0476, (float) 76.1905 ), @@ -1150,8 +1150,8 @@ static final CoordRec char79_stroke0[] = { new CoordRec((float) 19.0476, (float) 23.8095 ), new CoordRec((float) 23.8095, (float) 14.2857 ), new CoordRec((float) 33.3333, (float) 4.7619 ), - new CoordRec((float) 42.8571, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 42.8571, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4286, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 85.7143, (float) 23.8095 ), @@ -1160,8 +1160,8 @@ static final CoordRec char79_stroke0[] = { new CoordRec((float) 85.7143, (float) 76.1905 ), new CoordRec((float) 80.9524, (float) 85.7143 ), new CoordRec((float) 71.4286, (float) 95.2381 ), - new CoordRec((float) 61.9047, (float) 100 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 61.9047, 100 ), + new CoordRec((float) 42.8571, 100 ), }; static final StrokeRec char79[] = { @@ -1171,13 +1171,13 @@ static final StrokeRec char79[] = { /* char: 80 'P' */ static final CoordRec char80_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char80_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 61.9047, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 61.9047, 100 ), new CoordRec((float) 76.1905, (float) 95.2381 ), new CoordRec((float) 80.9524, (float) 90.4762 ), new CoordRec((float) 85.7143, (float) 80.9524 ), @@ -1196,7 +1196,7 @@ static final StrokeRec char80[] = { /* char: 81 'Q' */ static final CoordRec char81_stroke0[] = { - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 33.3333, (float) 95.2381 ), new CoordRec((float) 23.8095, (float) 85.7143 ), new CoordRec((float) 19.0476, (float) 76.1905 ), @@ -1205,8 +1205,8 @@ static final CoordRec char81_stroke0[] = { new CoordRec((float) 19.0476, (float) 23.8095 ), new CoordRec((float) 23.8095, (float) 14.2857 ), new CoordRec((float) 33.3333, (float) 4.7619 ), - new CoordRec((float) 42.8571, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 42.8571, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4286, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 85.7143, (float) 23.8095 ), @@ -1215,8 +1215,8 @@ static final CoordRec char81_stroke0[] = { new CoordRec((float) 85.7143, (float) 76.1905 ), new CoordRec((float) 80.9524, (float) 85.7143 ), new CoordRec((float) 71.4286, (float) 95.2381 ), - new CoordRec((float) 61.9047, (float) 100 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 61.9047, 100 ), + new CoordRec((float) 42.8571, 100 ), }; static final CoordRec char81_stroke1[] = { @@ -1232,13 +1232,13 @@ static final StrokeRec char81[] = { /* char: 82 'R' */ static final CoordRec char82_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char82_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 61.9047, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 61.9047, 100 ), new CoordRec((float) 76.1905, (float) 95.2381 ), new CoordRec((float) 80.9524, (float) 90.4762 ), new CoordRec((float) 85.7143, (float) 80.9524 ), @@ -1251,7 +1251,7 @@ static final CoordRec char82_stroke1[] = { static final CoordRec char82_stroke2[] = { new CoordRec((float) 52.3809, (float) 52.381 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 85.7143, 0 ), }; static final StrokeRec char82[] = { @@ -1265,8 +1265,8 @@ static final StrokeRec char82[] = { static final CoordRec char83_stroke0[] = { new CoordRec((float) 85.7143, (float) 85.7143 ), new CoordRec((float) 76.1905, (float) 95.2381 ), - new CoordRec((float) 61.9047, (float) 100 ), - new CoordRec((float) 42.8571, (float) 100 ), + new CoordRec((float) 61.9047, 100 ), + new CoordRec((float) 42.8571, 100 ), new CoordRec((float) 28.5714, (float) 95.2381 ), new CoordRec((float) 19.0476, (float) 85.7143 ), new CoordRec((float) 19.0476, (float) 76.1905 ), @@ -1279,8 +1279,8 @@ static final CoordRec char83_stroke0[] = { new CoordRec((float) 85.7143, (float) 28.5714 ), new CoordRec((float) 85.7143, (float) 14.2857 ), new CoordRec((float) 76.1905, (float) 4.7619 ), - new CoordRec((float) 61.9047, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 61.9047, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 28.5714, (float) 4.7619 ), new CoordRec((float) 19.0476, (float) 14.2857 ), }; @@ -1292,13 +1292,13 @@ static final StrokeRec char83[] = { /* char: 84 'T' */ static final CoordRec char84_stroke0[] = { - new CoordRec((float) 52.3809, (float) 100 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 100 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char84_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 85.7143, 100 ), }; static final StrokeRec char84[] = { @@ -1309,16 +1309,16 @@ static final StrokeRec char84[] = { /* char: 85 'U' */ static final CoordRec char85_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), new CoordRec((float) 19.0476, (float) 28.5714 ), new CoordRec((float) 23.8095, (float) 14.2857 ), new CoordRec((float) 33.3333, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 57.1428, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 57.1428, 0 ), new CoordRec((float) 71.4286, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 85.7143, (float) 28.5714 ), - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 85.7143, 100 ), }; static final StrokeRec char85[] = { @@ -1328,13 +1328,13 @@ static final StrokeRec char85[] = { /* char: 86 'V' */ static final CoordRec char86_stroke0[] = { - new CoordRec((float) 14.2857, (float) 100 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 14.2857, 100 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char86_stroke1[] = { - new CoordRec((float) 90.4762, (float) 100 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 90.4762, 100 ), + new CoordRec((float) 52.3809, 0 ), }; static final StrokeRec char86[] = { @@ -1345,23 +1345,23 @@ static final StrokeRec char86[] = { /* char: 87 'W' */ static final CoordRec char87_stroke0[] = { - new CoordRec((float) 4.7619, (float) 100 ), - new CoordRec((float) 28.5714, (float) 0 ), + new CoordRec((float) 4.7619, 100 ), + new CoordRec((float) 28.5714, 0 ), }; static final CoordRec char87_stroke1[] = { - new CoordRec((float) 52.3809, (float) 100 ), - new CoordRec((float) 28.5714, (float) 0 ), + new CoordRec((float) 52.3809, 100 ), + new CoordRec((float) 28.5714, 0 ), }; static final CoordRec char87_stroke2[] = { - new CoordRec((float) 52.3809, (float) 100 ), - new CoordRec((float) 76.1905, (float) 0 ), + new CoordRec((float) 52.3809, 100 ), + new CoordRec((float) 76.1905, 0 ), }; static final CoordRec char87_stroke3[] = { - new CoordRec((float) 100, (float) 100 ), - new CoordRec((float) 76.1905, (float) 0 ), + new CoordRec(100, 100 ), + new CoordRec((float) 76.1905, 0 ), }; static final StrokeRec char87[] = { @@ -1374,13 +1374,13 @@ static final StrokeRec char87[] = { /* char: 88 'X' */ static final CoordRec char88_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 85.7143, 0 ), }; static final CoordRec char88_stroke1[] = { - new CoordRec((float) 85.7143, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 85.7143, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final StrokeRec char88[] = { @@ -1391,13 +1391,13 @@ static final StrokeRec char88[] = { /* char: 89 'Y' */ static final CoordRec char89_stroke0[] = { - new CoordRec((float) 14.2857, (float) 100 ), + new CoordRec((float) 14.2857, 100 ), new CoordRec((float) 52.3809, (float) 52.381 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char89_stroke1[] = { - new CoordRec((float) 90.4762, (float) 100 ), + new CoordRec((float) 90.4762, 100 ), new CoordRec((float) 52.3809, (float) 52.381 ), }; @@ -1409,18 +1409,18 @@ static final StrokeRec char89[] = { /* char: 90 'Z' */ static final CoordRec char90_stroke0[] = { - new CoordRec((float) 85.7143, (float) 100 ), - new CoordRec((float) 19.0476, (float) 0 ), + new CoordRec((float) 85.7143, 100 ), + new CoordRec((float) 19.0476, 0 ), }; static final CoordRec char90_stroke1[] = { - new CoordRec((float) 19.0476, (float) 100 ), - new CoordRec((float) 85.7143, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), + new CoordRec((float) 85.7143, 100 ), }; static final CoordRec char90_stroke2[] = { - new CoordRec((float) 19.0476, (float) 0 ), - new CoordRec((float) 85.7143, (float) 0 ), + new CoordRec((float) 19.0476, 0 ), + new CoordRec((float) 85.7143, 0 ), }; static final StrokeRec char90[] = { @@ -1461,7 +1461,7 @@ static final StrokeRec char91[] = { /* char: 92 '\' */ static final CoordRec char92_stroke0[] = { - new CoordRec((float) 19.0476, (float) 100 ), + new CoordRec((float) 19.0476, 100 ), new CoordRec((float) 85.7143, (float) -14.2857 ), }; @@ -1518,11 +1518,11 @@ static final StrokeRec char94[] = { /* char: 95 '_' */ static final CoordRec char95_stroke0[] = { - new CoordRec((float) 0, (float) -33.3333 ), + new CoordRec(0, (float) -33.3333 ), new CoordRec((float) 104.762, (float) -33.3333 ), new CoordRec((float) 104.762, (float) -28.5714 ), - new CoordRec((float) 0, (float) -28.5714 ), - new CoordRec((float) 0, (float) -33.3333 ), + new CoordRec(0, (float) -28.5714 ), + new CoordRec(0, (float) -33.3333 ), }; static final StrokeRec char95[] = { @@ -1532,12 +1532,12 @@ static final StrokeRec char95[] = { /* char: 96 '`' */ static final CoordRec char96_stroke0[] = { - new CoordRec((float) 42.8572, (float) 100 ), + new CoordRec((float) 42.8572, 100 ), new CoordRec((float) 66.6667, (float) 71.4286 ), }; static final CoordRec char96_stroke1[] = { - new CoordRec((float) 42.8572, (float) 100 ), + new CoordRec((float) 42.8572, 100 ), new CoordRec((float) 38.0953, (float) 95.2381 ), new CoordRec((float) 66.6667, (float) 71.4286 ), }; @@ -1551,7 +1551,7 @@ static final StrokeRec char96[] = { static final CoordRec char97_stroke0[] = { new CoordRec((float) 80.9524, (float) 66.6667 ), - new CoordRec((float) 80.9524, (float) 0 ), + new CoordRec((float) 80.9524, 0 ), }; static final CoordRec char97_stroke1[] = { @@ -1565,8 +1565,8 @@ static final CoordRec char97_stroke1[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1579,8 +1579,8 @@ static final StrokeRec char97[] = { /* char: 98 'b' */ static final CoordRec char98_stroke0[] = { - new CoordRec((float) 23.8095, (float) 100 ), - new CoordRec((float) 23.8095, (float) 0 ), + new CoordRec((float) 23.8095, 100 ), + new CoordRec((float) 23.8095, 0 ), }; static final CoordRec char98_stroke1[] = { @@ -1594,8 +1594,8 @@ static final CoordRec char98_stroke1[] = { new CoordRec((float) 80.9524, (float) 28.5714 ), new CoordRec((float) 76.1905, (float) 14.2857 ), new CoordRec((float) 66.6666, (float) 4.7619 ), - new CoordRec((float) 57.1428, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 57.1428, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 33.3333, (float) 4.7619 ), new CoordRec((float) 23.8095, (float) 14.2857 ), }; @@ -1618,8 +1618,8 @@ static final CoordRec char99_stroke0[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1631,8 +1631,8 @@ static final StrokeRec char99[] = { /* char: 100 'd' */ static final CoordRec char100_stroke0[] = { - new CoordRec((float) 80.9524, (float) 100 ), - new CoordRec((float) 80.9524, (float) 0 ), + new CoordRec((float) 80.9524, 100 ), + new CoordRec((float) 80.9524, 0 ), }; static final CoordRec char100_stroke1[] = { @@ -1646,8 +1646,8 @@ static final CoordRec char100_stroke1[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1673,8 +1673,8 @@ static final CoordRec char101_stroke0[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1686,11 +1686,11 @@ static final StrokeRec char101[] = { /* char: 102 'f' */ static final CoordRec char102_stroke0[] = { - new CoordRec((float) 71.4286, (float) 100 ), - new CoordRec((float) 61.9048, (float) 100 ), + new CoordRec((float) 71.4286, 100 ), + new CoordRec((float) 61.9048, 100 ), new CoordRec((float) 52.381, (float) 95.2381 ), new CoordRec((float) 47.6191, (float) 80.9524 ), - new CoordRec((float) 47.6191, (float) 0 ), + new CoordRec((float) 47.6191, 0 ), }; static final CoordRec char102_stroke1[] = { @@ -1726,8 +1726,8 @@ static final CoordRec char103_stroke1[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1740,18 +1740,18 @@ static final StrokeRec char103[] = { /* char: 104 'h' */ static final CoordRec char104_stroke0[] = { - new CoordRec((float) 26.1905, (float) 100 ), - new CoordRec((float) 26.1905, (float) 0 ), + new CoordRec((float) 26.1905, 100 ), + new CoordRec((float) 26.1905, 0 ), }; static final CoordRec char104_stroke1[] = { new CoordRec((float) 26.1905, (float) 47.619 ), new CoordRec((float) 40.4762, (float) 61.9048 ), - new CoordRec((float) 50, (float) 66.6667 ), + new CoordRec(50, (float) 66.6667 ), new CoordRec((float) 64.2857, (float) 66.6667 ), new CoordRec((float) 73.8095, (float) 61.9048 ), new CoordRec((float) 78.5715, (float) 47.619 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final StrokeRec char104[] = { @@ -1762,16 +1762,16 @@ static final StrokeRec char104[] = { /* char: 105 'i' */ static final CoordRec char105_stroke0[] = { - new CoordRec((float) 47.6191, (float) 100 ), + new CoordRec((float) 47.6191, 100 ), new CoordRec((float) 52.381, (float) 95.2381 ), - new CoordRec((float) 57.1429, (float) 100 ), + new CoordRec((float) 57.1429, 100 ), new CoordRec((float) 52.381, (float) 104.762 ), - new CoordRec((float) 47.6191, (float) 100 ), + new CoordRec((float) 47.6191, 100 ), }; static final CoordRec char105_stroke1[] = { new CoordRec((float) 52.381, (float) 66.6667 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), }; static final StrokeRec char105[] = { @@ -1782,11 +1782,11 @@ static final StrokeRec char105[] = { /* char: 106 'j' */ static final CoordRec char106_stroke0[] = { - new CoordRec((float) 57.1429, (float) 100 ), + new CoordRec((float) 57.1429, 100 ), new CoordRec((float) 61.9048, (float) 95.2381 ), - new CoordRec((float) 66.6667, (float) 100 ), + new CoordRec((float) 66.6667, 100 ), new CoordRec((float) 61.9048, (float) 104.762 ), - new CoordRec((float) 57.1429, (float) 100 ), + new CoordRec((float) 57.1429, 100 ), }; static final CoordRec char106_stroke1[] = { @@ -1805,8 +1805,8 @@ static final StrokeRec char106[] = { /* char: 107 'k' */ static final CoordRec char107_stroke0[] = { - new CoordRec((float) 26.1905, (float) 100 ), - new CoordRec((float) 26.1905, (float) 0 ), + new CoordRec((float) 26.1905, 100 ), + new CoordRec((float) 26.1905, 0 ), }; static final CoordRec char107_stroke1[] = { @@ -1816,7 +1816,7 @@ static final CoordRec char107_stroke1[] = { static final CoordRec char107_stroke2[] = { new CoordRec((float) 45.2381, (float) 38.0952 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final StrokeRec char107[] = { @@ -1828,8 +1828,8 @@ static final StrokeRec char107[] = { /* char: 108 'l' */ static final CoordRec char108_stroke0[] = { - new CoordRec((float) 52.381, (float) 100 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 100 ), + new CoordRec((float) 52.381, 0 ), }; static final StrokeRec char108[] = { @@ -1839,18 +1839,18 @@ static final StrokeRec char108[] = { /* char: 109 'm' */ static final CoordRec char109_stroke0[] = { - new CoordRec((float) 0, (float) 66.6667 ), - new CoordRec((float) 0, (float) 0 ), + new CoordRec(0, (float) 66.6667 ), + new CoordRec(0, 0 ), }; static final CoordRec char109_stroke1[] = { - new CoordRec((float) 0, (float) 47.619 ), + new CoordRec(0, (float) 47.619 ), new CoordRec((float) 14.2857, (float) 61.9048 ), new CoordRec((float) 23.8095, (float) 66.6667 ), new CoordRec((float) 38.0952, (float) 66.6667 ), new CoordRec((float) 47.619, (float) 61.9048 ), new CoordRec((float) 52.381, (float) 47.619 ), - new CoordRec((float) 52.381, (float) 0 ), + new CoordRec((float) 52.381, 0 ), }; static final CoordRec char109_stroke2[] = { @@ -1858,9 +1858,9 @@ static final CoordRec char109_stroke2[] = { new CoordRec((float) 66.6667, (float) 61.9048 ), new CoordRec((float) 76.1905, (float) 66.6667 ), new CoordRec((float) 90.4762, (float) 66.6667 ), - new CoordRec((float) 100, (float) 61.9048 ), + new CoordRec(100, (float) 61.9048 ), new CoordRec((float) 104.762, (float) 47.619 ), - new CoordRec((float) 104.762, (float) 0 ), + new CoordRec((float) 104.762, 0 ), }; static final StrokeRec char109[] = { @@ -1873,17 +1873,17 @@ static final StrokeRec char109[] = { static final CoordRec char110_stroke0[] = { new CoordRec((float) 26.1905, (float) 66.6667 ), - new CoordRec((float) 26.1905, (float) 0 ), + new CoordRec((float) 26.1905, 0 ), }; static final CoordRec char110_stroke1[] = { new CoordRec((float) 26.1905, (float) 47.619 ), new CoordRec((float) 40.4762, (float) 61.9048 ), - new CoordRec((float) 50, (float) 66.6667 ), + new CoordRec(50, (float) 66.6667 ), new CoordRec((float) 64.2857, (float) 66.6667 ), new CoordRec((float) 73.8095, (float) 61.9048 ), new CoordRec((float) 78.5715, (float) 47.619 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final StrokeRec char110[] = { @@ -1901,8 +1901,8 @@ static final CoordRec char111_stroke0[] = { new CoordRec((float) 21.4286, (float) 28.5714 ), new CoordRec((float) 26.1905, (float) 14.2857 ), new CoordRec((float) 35.7143, (float) 4.7619 ), - new CoordRec((float) 45.2381, (float) 0 ), - new CoordRec((float) 59.5238, (float) 0 ), + new CoordRec((float) 45.2381, 0 ), + new CoordRec((float) 59.5238, 0 ), new CoordRec((float) 69.0476, (float) 4.7619 ), new CoordRec((float) 78.5714, (float) 14.2857 ), new CoordRec((float) 83.3334, (float) 28.5714 ), @@ -1935,8 +1935,8 @@ static final CoordRec char112_stroke1[] = { new CoordRec((float) 80.9524, (float) 28.5714 ), new CoordRec((float) 76.1905, (float) 14.2857 ), new CoordRec((float) 66.6666, (float) 4.7619 ), - new CoordRec((float) 57.1428, (float) 0 ), - new CoordRec((float) 42.8571, (float) 0 ), + new CoordRec((float) 57.1428, 0 ), + new CoordRec((float) 42.8571, 0 ), new CoordRec((float) 33.3333, (float) 4.7619 ), new CoordRec((float) 23.8095, (float) 14.2857 ), }; @@ -1964,8 +1964,8 @@ static final CoordRec char113_stroke1[] = { new CoordRec((float) 23.8095, (float) 28.5714 ), new CoordRec((float) 28.5714, (float) 14.2857 ), new CoordRec((float) 38.0952, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 61.9047, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 61.9047, 0 ), new CoordRec((float) 71.4285, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), }; @@ -1979,7 +1979,7 @@ static final StrokeRec char113[] = { static final CoordRec char114_stroke0[] = { new CoordRec((float) 33.3334, (float) 66.6667 ), - new CoordRec((float) 33.3334, (float) 0 ), + new CoordRec((float) 33.3334, 0 ), }; static final CoordRec char114_stroke1[] = { @@ -2011,8 +2011,8 @@ static final CoordRec char115_stroke0[] = { new CoordRec((float) 78.5715, (float) 19.0476 ), new CoordRec((float) 78.5715, (float) 14.2857 ), new CoordRec((float) 73.8095, (float) 4.7619 ), - new CoordRec((float) 59.5238, (float) 0 ), - new CoordRec((float) 45.2381, (float) 0 ), + new CoordRec((float) 59.5238, 0 ), + new CoordRec((float) 45.2381, 0 ), new CoordRec((float) 30.9524, (float) 4.7619 ), new CoordRec((float) 26.1905, (float) 14.2857 ), }; @@ -2024,11 +2024,11 @@ static final StrokeRec char115[] = { /* char: 116 't' */ static final CoordRec char116_stroke0[] = { - new CoordRec((float) 47.6191, (float) 100 ), + new CoordRec((float) 47.6191, 100 ), new CoordRec((float) 47.6191, (float) 19.0476 ), new CoordRec((float) 52.381, (float) 4.7619 ), - new CoordRec((float) 61.9048, (float) 0 ), - new CoordRec((float) 71.4286, (float) 0 ), + new CoordRec((float) 61.9048, 0 ), + new CoordRec((float) 71.4286, 0 ), }; static final CoordRec char116_stroke1[] = { @@ -2047,15 +2047,15 @@ static final CoordRec char117_stroke0[] = { new CoordRec((float) 26.1905, (float) 66.6667 ), new CoordRec((float) 26.1905, (float) 19.0476 ), new CoordRec((float) 30.9524, (float) 4.7619 ), - new CoordRec((float) 40.4762, (float) 0 ), - new CoordRec((float) 54.7619, (float) 0 ), + new CoordRec((float) 40.4762, 0 ), + new CoordRec((float) 54.7619, 0 ), new CoordRec((float) 64.2857, (float) 4.7619 ), new CoordRec((float) 78.5715, (float) 19.0476 ), }; static final CoordRec char117_stroke1[] = { new CoordRec((float) 78.5715, (float) 66.6667 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final StrokeRec char117[] = { @@ -2067,12 +2067,12 @@ static final StrokeRec char117[] = { static final CoordRec char118_stroke0[] = { new CoordRec((float) 23.8095, (float) 66.6667 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), }; static final CoordRec char118_stroke1[] = { new CoordRec((float) 80.9524, (float) 66.6667 ), - new CoordRec((float) 52.3809, (float) 0 ), + new CoordRec((float) 52.3809, 0 ), }; static final StrokeRec char118[] = { @@ -2084,22 +2084,22 @@ static final StrokeRec char118[] = { static final CoordRec char119_stroke0[] = { new CoordRec((float) 14.2857, (float) 66.6667 ), - new CoordRec((float) 33.3333, (float) 0 ), + new CoordRec((float) 33.3333, 0 ), }; static final CoordRec char119_stroke1[] = { new CoordRec((float) 52.3809, (float) 66.6667 ), - new CoordRec((float) 33.3333, (float) 0 ), + new CoordRec((float) 33.3333, 0 ), }; static final CoordRec char119_stroke2[] = { new CoordRec((float) 52.3809, (float) 66.6667 ), - new CoordRec((float) 71.4286, (float) 0 ), + new CoordRec((float) 71.4286, 0 ), }; static final CoordRec char119_stroke3[] = { new CoordRec((float) 90.4762, (float) 66.6667 ), - new CoordRec((float) 71.4286, (float) 0 ), + new CoordRec((float) 71.4286, 0 ), }; static final StrokeRec char119[] = { @@ -2113,12 +2113,12 @@ static final StrokeRec char119[] = { static final CoordRec char120_stroke0[] = { new CoordRec((float) 26.1905, (float) 66.6667 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final CoordRec char120_stroke1[] = { new CoordRec((float) 78.5715, (float) 66.6667 ), - new CoordRec((float) 26.1905, (float) 0 ), + new CoordRec((float) 26.1905, 0 ), }; static final StrokeRec char120[] = { @@ -2130,12 +2130,12 @@ static final StrokeRec char120[] = { static final CoordRec char121_stroke0[] = { new CoordRec((float) 26.1905, (float) 66.6667 ), - new CoordRec((float) 54.7619, (float) 0 ), + new CoordRec((float) 54.7619, 0 ), }; static final CoordRec char121_stroke1[] = { new CoordRec((float) 83.3334, (float) 66.6667 ), - new CoordRec((float) 54.7619, (float) 0 ), + new CoordRec((float) 54.7619, 0 ), new CoordRec((float) 45.2381, (float) -19.0476 ), new CoordRec((float) 35.7143, (float) -28.5714 ), new CoordRec((float) 26.1905, (float) -33.3333 ), @@ -2151,7 +2151,7 @@ static final StrokeRec char121[] = { static final CoordRec char122_stroke0[] = { new CoordRec((float) 78.5715, (float) 66.6667 ), - new CoordRec((float) 26.1905, (float) 0 ), + new CoordRec((float) 26.1905, 0 ), }; static final CoordRec char122_stroke1[] = { @@ -2160,8 +2160,8 @@ static final CoordRec char122_stroke1[] = { }; static final CoordRec char122_stroke2[] = { - new CoordRec((float) 26.1905, (float) 0 ), - new CoordRec((float) 78.5715, (float) 0 ), + new CoordRec((float) 26.1905, 0 ), + new CoordRec((float) 78.5715, 0 ), }; static final StrokeRec char122[] = { @@ -2175,20 +2175,20 @@ static final StrokeRec char122[] = { static final CoordRec char123_stroke0[] = { new CoordRec((float) 64.2857, (float) 119.048 ), new CoordRec((float) 54.7619, (float) 114.286 ), - new CoordRec((float) 50, (float) 109.524 ), - new CoordRec((float) 45.2381, (float) 100 ), + new CoordRec(50, (float) 109.524 ), + new CoordRec((float) 45.2381, 100 ), new CoordRec((float) 45.2381, (float) 90.4762 ), - new CoordRec((float) 50, (float) 80.9524 ), + new CoordRec(50, (float) 80.9524 ), new CoordRec((float) 54.7619, (float) 76.1905 ), new CoordRec((float) 59.5238, (float) 66.6667 ), new CoordRec((float) 59.5238, (float) 57.1429 ), - new CoordRec((float) 50, (float) 47.619 ), + new CoordRec(50, (float) 47.619 ), }; static final CoordRec char123_stroke1[] = { new CoordRec((float) 54.7619, (float) 114.286 ), - new CoordRec((float) 50, (float) 104.762 ), - new CoordRec((float) 50, (float) 95.2381 ), + new CoordRec(50, (float) 104.762 ), + new CoordRec(50, (float) 95.2381 ), new CoordRec((float) 54.7619, (float) 85.7143 ), new CoordRec((float) 59.5238, (float) 80.9524 ), new CoordRec((float) 64.2857, (float) 71.4286 ), @@ -2199,21 +2199,21 @@ static final CoordRec char123_stroke1[] = { new CoordRec((float) 64.2857, (float) 23.8095 ), new CoordRec((float) 64.2857, (float) 14.2857 ), new CoordRec((float) 59.5238, (float) 4.7619 ), - new CoordRec((float) 54.7619, (float) 0 ), - new CoordRec((float) 50, (float) -9.5238 ), - new CoordRec((float) 50, (float) -19.0476 ), + new CoordRec((float) 54.7619, 0 ), + new CoordRec(50, (float) -9.5238 ), + new CoordRec(50, (float) -19.0476 ), new CoordRec((float) 54.7619, (float) -28.5714 ), }; static final CoordRec char123_stroke2[] = { - new CoordRec((float) 50, (float) 38.0952 ), + new CoordRec(50, (float) 38.0952 ), new CoordRec((float) 59.5238, (float) 28.5714 ), new CoordRec((float) 59.5238, (float) 19.0476 ), new CoordRec((float) 54.7619, (float) 9.5238 ), - new CoordRec((float) 50, (float) 4.7619 ), + new CoordRec(50, (float) 4.7619 ), new CoordRec((float) 45.2381, (float) -4.7619 ), new CoordRec((float) 45.2381, (float) -14.2857 ), - new CoordRec((float) 50, (float) -23.8095 ), + new CoordRec(50, (float) -23.8095 ), new CoordRec((float) 54.7619, (float) -28.5714 ), new CoordRec((float) 64.2857, (float) -33.3333 ), }; @@ -2239,22 +2239,22 @@ static final StrokeRec char124[] = { static final CoordRec char125_stroke0[] = { new CoordRec((float) 40.4762, (float) 119.048 ), - new CoordRec((float) 50, (float) 114.286 ), + new CoordRec(50, (float) 114.286 ), new CoordRec((float) 54.7619, (float) 109.524 ), - new CoordRec((float) 59.5238, (float) 100 ), + new CoordRec((float) 59.5238, 100 ), new CoordRec((float) 59.5238, (float) 90.4762 ), new CoordRec((float) 54.7619, (float) 80.9524 ), - new CoordRec((float) 50, (float) 76.1905 ), + new CoordRec(50, (float) 76.1905 ), new CoordRec((float) 45.2381, (float) 66.6667 ), new CoordRec((float) 45.2381, (float) 57.1429 ), new CoordRec((float) 54.7619, (float) 47.619 ), }; static final CoordRec char125_stroke1[] = { - new CoordRec((float) 50, (float) 114.286 ), + new CoordRec(50, (float) 114.286 ), new CoordRec((float) 54.7619, (float) 104.762 ), new CoordRec((float) 54.7619, (float) 95.2381 ), - new CoordRec((float) 50, (float) 85.7143 ), + new CoordRec(50, (float) 85.7143 ), new CoordRec((float) 45.2381, (float) 80.9524 ), new CoordRec((float) 40.4762, (float) 71.4286 ), new CoordRec((float) 40.4762, (float) 61.9048 ), @@ -2264,22 +2264,22 @@ static final CoordRec char125_stroke1[] = { new CoordRec((float) 40.4762, (float) 23.8095 ), new CoordRec((float) 40.4762, (float) 14.2857 ), new CoordRec((float) 45.2381, (float) 4.7619 ), - new CoordRec((float) 50, (float) 0 ), + new CoordRec(50, 0 ), new CoordRec((float) 54.7619, (float) -9.5238 ), new CoordRec((float) 54.7619, (float) -19.0476 ), - new CoordRec((float) 50, (float) -28.5714 ), + new CoordRec(50, (float) -28.5714 ), }; static final CoordRec char125_stroke2[] = { new CoordRec((float) 54.7619, (float) 38.0952 ), new CoordRec((float) 45.2381, (float) 28.5714 ), new CoordRec((float) 45.2381, (float) 19.0476 ), - new CoordRec((float) 50, (float) 9.5238 ), + new CoordRec(50, (float) 9.5238 ), new CoordRec((float) 54.7619, (float) 4.7619 ), new CoordRec((float) 59.5238, (float) -4.7619 ), new CoordRec((float) 59.5238, (float) -14.2857 ), new CoordRec((float) 54.7619, (float) -23.8095 ), - new CoordRec((float) 50, (float) -28.5714 ), + new CoordRec(50, (float) -28.5714 ), new CoordRec((float) 40.4762, (float) -33.3333 ), }; @@ -2327,7 +2327,7 @@ static final StrokeRec char126[] = { /* char: 127 */ static final CoordRec char127_stroke0[] = { - new CoordRec((float) 71.4286, (float) 100 ), + new CoordRec((float) 71.4286, 100 ), new CoordRec((float) 33.3333, (float) -33.3333 ), }; @@ -2339,8 +2339,8 @@ static final CoordRec char127_stroke1[] = { new CoordRec((float) 19.0476, (float) 23.8095 ), new CoordRec((float) 23.8095, (float) 14.2857 ), new CoordRec((float) 33.3333, (float) 4.7619 ), - new CoordRec((float) 47.619, (float) 0 ), - new CoordRec((float) 57.1428, (float) 0 ), + new CoordRec((float) 47.619, 0 ), + new CoordRec((float) 57.1428, 0 ), new CoordRec((float) 71.4286, (float) 4.7619 ), new CoordRec((float) 80.9524, (float) 14.2857 ), new CoordRec((float) 85.7143, (float) 28.5714 ), @@ -2357,38 +2357,38 @@ static final StrokeRec char127[] = { }; static final StrokeCharRec chars[] = { - new StrokeCharRec(0, /* char0 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char1 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char2 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char3 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char4 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char5 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char6 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char7 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char8 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char9 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char10 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char11 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char12 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char13 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char14 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char15 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char16 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char17 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char18 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char19 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char20 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char21 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char22 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char23 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char24 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char25 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char26 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char27 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char28 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char29 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char30 */ null, (float) 0, (float) 0 ), - new StrokeCharRec(0, /* char31 */ null, (float) 0, (float) 0 ), + new StrokeCharRec(0, /* char0 */ null, 0, 0 ), + new StrokeCharRec(0, /* char1 */ null, 0, 0 ), + new StrokeCharRec(0, /* char2 */ null, 0, 0 ), + new StrokeCharRec(0, /* char3 */ null, 0, 0 ), + new StrokeCharRec(0, /* char4 */ null, 0, 0 ), + new StrokeCharRec(0, /* char5 */ null, 0, 0 ), + new StrokeCharRec(0, /* char6 */ null, 0, 0 ), + new StrokeCharRec(0, /* char7 */ null, 0, 0 ), + new StrokeCharRec(0, /* char8 */ null, 0, 0 ), + new StrokeCharRec(0, /* char9 */ null, 0, 0 ), + new StrokeCharRec(0, /* char10 */ null, 0, 0 ), + new StrokeCharRec(0, /* char11 */ null, 0, 0 ), + new StrokeCharRec(0, /* char12 */ null, 0, 0 ), + new StrokeCharRec(0, /* char13 */ null, 0, 0 ), + new StrokeCharRec(0, /* char14 */ null, 0, 0 ), + new StrokeCharRec(0, /* char15 */ null, 0, 0 ), + new StrokeCharRec(0, /* char16 */ null, 0, 0 ), + new StrokeCharRec(0, /* char17 */ null, 0, 0 ), + new StrokeCharRec(0, /* char18 */ null, 0, 0 ), + new StrokeCharRec(0, /* char19 */ null, 0, 0 ), + new StrokeCharRec(0, /* char20 */ null, 0, 0 ), + new StrokeCharRec(0, /* char21 */ null, 0, 0 ), + new StrokeCharRec(0, /* char22 */ null, 0, 0 ), + new StrokeCharRec(0, /* char23 */ null, 0, 0 ), + new StrokeCharRec(0, /* char24 */ null, 0, 0 ), + new StrokeCharRec(0, /* char25 */ null, 0, 0 ), + new StrokeCharRec(0, /* char26 */ null, 0, 0 ), + new StrokeCharRec(0, /* char27 */ null, 0, 0 ), + new StrokeCharRec(0, /* char28 */ null, 0, 0 ), + new StrokeCharRec(0, /* char29 */ null, 0, 0 ), + new StrokeCharRec(0, /* char30 */ null, 0, 0 ), + new StrokeCharRec(0, /* char31 */ null, 0, 0 ), new StrokeCharRec(0, /* char32 */ null, (float) 52.381, (float) 104.762 ), new StrokeCharRec(2, char33, (float) 52.381, (float) 104.762 ), new StrokeCharRec(2, char34, (float) 52.381, (float) 104.762 ), diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java index cf51ddd3c..5b614c64e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java @@ -46,14 +46,14 @@ class GLUTStrokeRoman { /* char: 33 '!' */ static final CoordRec char33_stroke0[] = { - new CoordRec((float) 13.3819, (float) 100), + new CoordRec((float) 13.3819, 100), new CoordRec((float) 13.3819, (float) 33.3333), }; static final CoordRec char33_stroke1[] = { new CoordRec((float) 13.3819, (float) 9.5238), new CoordRec((float) 8.62, (float) 4.7619), - new CoordRec((float) 13.3819, (float) 0), + new CoordRec((float) 13.3819, 0), new CoordRec((float) 18.1438, (float) 4.7619), new CoordRec((float) 13.3819, (float) 9.5238), }; @@ -66,12 +66,12 @@ static final StrokeRec char33[] = { /* char: 34 '"' */ static final CoordRec char34_stroke0[] = { - new CoordRec((float) 4.02, (float) 100), + new CoordRec((float) 4.02, 100), new CoordRec((float) 4.02, (float) 66.6667), }; static final CoordRec char34_stroke1[] = { - new CoordRec((float) 42.1152, (float) 100), + new CoordRec((float) 42.1152, 100), new CoordRec((float) 42.1152, (float) 66.6667), }; @@ -124,8 +124,8 @@ static final CoordRec char36_stroke1[] = { static final CoordRec char36_stroke2[] = { new CoordRec((float) 71.4867, (float) 85.7143), new CoordRec((float) 61.9629, (float) 95.2381), - new CoordRec((float) 47.6771, (float) 100), - new CoordRec((float) 28.6295, (float) 100), + new CoordRec((float) 47.6771, 100), + new CoordRec((float) 28.6295, 100), new CoordRec((float) 14.3438, (float) 95.2381), new CoordRec((float) 4.82, (float) 85.7143), new CoordRec((float) 4.82, (float) 76.1905), @@ -138,8 +138,8 @@ static final CoordRec char36_stroke2[] = { new CoordRec((float) 71.4867, (float) 28.5714), new CoordRec((float) 71.4867, (float) 14.2857), new CoordRec((float) 61.9629, (float) 4.7619), - new CoordRec((float) 47.6771, (float) 0), - new CoordRec((float) 28.6295, (float) 0), + new CoordRec((float) 47.6771, 0), + new CoordRec((float) 28.6295, 0), new CoordRec((float) 14.3438, (float) 4.7619), new CoordRec((float) 4.82, (float) 14.2857), }; @@ -153,12 +153,12 @@ static final StrokeRec char36[] = { /* char: 37 '%' */ static final CoordRec char37_stroke0[] = { - new CoordRec((float) 92.0743, (float) 100), - new CoordRec((float) 6.36, (float) 0), + new CoordRec((float) 92.0743, 100), + new CoordRec((float) 6.36, 0), }; static final CoordRec char37_stroke1[] = { - new CoordRec((float) 30.1695, (float) 100), + new CoordRec((float) 30.1695, 100), new CoordRec((float) 39.6933, (float) 90.4762), new CoordRec((float) 39.6933, (float) 80.9524), new CoordRec((float) 34.9314, (float) 71.4286), @@ -167,13 +167,13 @@ static final CoordRec char37_stroke1[] = { new CoordRec((float) 6.36, (float) 76.1905), new CoordRec((float) 6.36, (float) 85.7143), new CoordRec((float) 11.1219, (float) 95.2381), - new CoordRec((float) 20.6457, (float) 100), - new CoordRec((float) 30.1695, (float) 100), + new CoordRec((float) 20.6457, 100), + new CoordRec((float) 30.1695, 100), new CoordRec((float) 39.6933, (float) 95.2381), new CoordRec((float) 53.979, (float) 90.4762), new CoordRec((float) 68.2648, (float) 90.4762), new CoordRec((float) 82.5505, (float) 95.2381), - new CoordRec((float) 92.0743, (float) 100), + new CoordRec((float) 92.0743, 100), }; static final CoordRec char37_stroke2[] = { @@ -181,8 +181,8 @@ static final CoordRec char37_stroke2[] = { new CoordRec((float) 63.5029, (float) 28.5714), new CoordRec((float) 58.741, (float) 19.0476), new CoordRec((float) 58.741, (float) 9.5238), - new CoordRec((float) 68.2648, (float) 0), - new CoordRec((float) 77.7886, (float) 0), + new CoordRec((float) 68.2648, 0), + new CoordRec((float) 77.7886, 0), new CoordRec((float) 87.3124, (float) 4.7619), new CoordRec((float) 92.0743, (float) 14.2857), new CoordRec((float) 92.0743, (float) 23.8095), @@ -208,8 +208,8 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 72.6467, (float) 28.5714), new CoordRec((float) 63.1229, (float) 14.2857), new CoordRec((float) 53.599, (float) 4.7619), - new CoordRec((float) 44.0752, (float) 0), - new CoordRec((float) 25.0276, (float) 0), + new CoordRec((float) 44.0752, 0), + new CoordRec((float) 25.0276, 0), new CoordRec((float) 15.5038, (float) 4.7619), new CoordRec((float) 10.7419, (float) 9.5238), new CoordRec((float) 5.98, (float) 19.0476), @@ -221,7 +221,7 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 58.361, (float) 76.1905), new CoordRec((float) 58.361, (float) 85.7143), new CoordRec((float) 53.599, (float) 95.2381), - new CoordRec((float) 44.0752, (float) 100), + new CoordRec((float) 44.0752, 100), new CoordRec((float) 34.5514, (float) 95.2381), new CoordRec((float) 29.7895, (float) 85.7143), new CoordRec((float) 29.7895, (float) 76.1905), @@ -229,8 +229,8 @@ static final CoordRec char38_stroke0[] = { new CoordRec((float) 44.0752, (float) 47.619), new CoordRec((float) 67.8848, (float) 14.2857), new CoordRec((float) 77.4086, (float) 4.7619), - new CoordRec((float) 86.9324, (float) 0), - new CoordRec((float) 96.4562, (float) 0), + new CoordRec((float) 86.9324, 0), + new CoordRec((float) 96.4562, 0), new CoordRec((float) 101.218, (float) 4.7619), new CoordRec((float) 101.218, (float) 9.5238), }; @@ -242,7 +242,7 @@ static final StrokeRec char38[] = { /* char: 39 ''' */ static final CoordRec char39_stroke0[] = { - new CoordRec((float) 4.44, (float) 100), + new CoordRec((float) 4.44, 100), new CoordRec((float) 4.44, (float) 66.6667), }; @@ -315,7 +315,7 @@ static final StrokeRec char42[] = { static final CoordRec char43_stroke0[] = { new CoordRec((float) 48.8371, (float) 85.7143), - new CoordRec((float) 48.8371, (float) 0), + new CoordRec((float) 48.8371, 0), }; static final CoordRec char43_stroke1[] = { @@ -332,7 +332,7 @@ static final StrokeRec char43[] = { static final CoordRec char44_stroke0[] = { new CoordRec((float) 18.2838, (float) 4.7619), - new CoordRec((float) 13.5219, (float) 0), + new CoordRec((float) 13.5219, 0), new CoordRec((float) 8.76, (float) 4.7619), new CoordRec((float) 13.5219, (float) 9.5238), new CoordRec((float) 18.2838, (float) 4.7619), @@ -361,7 +361,7 @@ static final StrokeRec char45[] = { static final CoordRec char46_stroke0[] = { new CoordRec((float) 13.1019, (float) 9.5238), new CoordRec((float) 8.34, (float) 4.7619), - new CoordRec((float) 13.1019, (float) 0), + new CoordRec((float) 13.1019, 0), new CoordRec((float) 17.8638, (float) 4.7619), new CoordRec((float) 13.1019, (float) 9.5238), }; @@ -374,7 +374,7 @@ static final StrokeRec char46[] = { static final CoordRec char47_stroke0[] = { new CoordRec((float) 7.24, (float) -14.2857), - new CoordRec((float) 73.9067, (float) 100), + new CoordRec((float) 73.9067, 100), }; static final StrokeRec char47[] = { @@ -384,23 +384,23 @@ static final StrokeRec char47[] = { /* char: 48 '0' */ static final CoordRec char48_stroke0[] = { - new CoordRec((float) 33.5514, (float) 100), + new CoordRec((float) 33.5514, 100), new CoordRec((float) 19.2657, (float) 95.2381), new CoordRec((float) 9.7419, (float) 80.9524), new CoordRec((float) 4.98, (float) 57.1429), new CoordRec((float) 4.98, (float) 42.8571), new CoordRec((float) 9.7419, (float) 19.0476), new CoordRec((float) 19.2657, (float) 4.7619), - new CoordRec((float) 33.5514, (float) 0), - new CoordRec((float) 43.0752, (float) 0), + new CoordRec((float) 33.5514, 0), + new CoordRec((float) 43.0752, 0), new CoordRec((float) 57.361, (float) 4.7619), new CoordRec((float) 66.8848, (float) 19.0476), new CoordRec((float) 71.6467, (float) 42.8571), new CoordRec((float) 71.6467, (float) 57.1429), new CoordRec((float) 66.8848, (float) 80.9524), new CoordRec((float) 57.361, (float) 95.2381), - new CoordRec((float) 43.0752, (float) 100), - new CoordRec((float) 33.5514, (float) 100), + new CoordRec((float) 43.0752, 100), + new CoordRec((float) 33.5514, 100), }; static final StrokeRec char48[] = { @@ -412,8 +412,8 @@ static final StrokeRec char48[] = { static final CoordRec char49_stroke0[] = { new CoordRec((float) 11.82, (float) 80.9524), new CoordRec((float) 21.3438, (float) 85.7143), - new CoordRec((float) 35.6295, (float) 100), - new CoordRec((float) 35.6295, (float) 0), + new CoordRec((float) 35.6295, 100), + new CoordRec((float) 35.6295, 0), }; static final StrokeRec char49[] = { @@ -427,16 +427,16 @@ static final CoordRec char50_stroke0[] = { new CoordRec((float) 10.1819, (float) 80.9524), new CoordRec((float) 14.9438, (float) 90.4762), new CoordRec((float) 19.7057, (float) 95.2381), - new CoordRec((float) 29.2295, (float) 100), - new CoordRec((float) 48.2771, (float) 100), + new CoordRec((float) 29.2295, 100), + new CoordRec((float) 48.2771, 100), new CoordRec((float) 57.801, (float) 95.2381), new CoordRec((float) 62.5629, (float) 90.4762), new CoordRec((float) 67.3248, (float) 80.9524), new CoordRec((float) 67.3248, (float) 71.4286), new CoordRec((float) 62.5629, (float) 61.9048), new CoordRec((float) 53.039, (float) 47.619), - new CoordRec((float) 5.42, (float) 0), - new CoordRec((float) 72.0867, (float) 0), + new CoordRec((float) 5.42, 0), + new CoordRec((float) 72.0867, 0), }; static final StrokeRec char50[] = { @@ -446,8 +446,8 @@ static final StrokeRec char50[] = { /* char: 51 '3' */ static final CoordRec char51_stroke0[] = { - new CoordRec((float) 14.5238, (float) 100), - new CoordRec((float) 66.9048, (float) 100), + new CoordRec((float) 14.5238, 100), + new CoordRec((float) 66.9048, 100), new CoordRec((float) 38.3333, (float) 61.9048), new CoordRec((float) 52.619, (float) 61.9048), new CoordRec((float) 62.1429, (float) 57.1429), @@ -456,11 +456,11 @@ static final CoordRec char51_stroke0[] = { new CoordRec((float) 71.6667, (float) 28.5714), new CoordRec((float) 66.9048, (float) 14.2857), new CoordRec((float) 57.381, (float) 4.7619), - new CoordRec((float) 43.0952, (float) 0), - new CoordRec((float) 28.8095, (float) 0), + new CoordRec((float) 43.0952, 0), + new CoordRec((float) 28.8095, 0), new CoordRec((float) 14.5238, (float) 4.7619), new CoordRec((float) 9.7619, (float) 9.5238), - new CoordRec((float) 5, (float) 19.0476), + new CoordRec(5, (float) 19.0476), }; static final StrokeRec char51[] = { @@ -470,14 +470,14 @@ static final StrokeRec char51[] = { /* char: 52 '4' */ static final CoordRec char52_stroke0[] = { - new CoordRec((float) 51.499, (float) 100), + new CoordRec((float) 51.499, 100), new CoordRec((float) 3.88, (float) 33.3333), new CoordRec((float) 75.3086, (float) 33.3333), }; static final CoordRec char52_stroke1[] = { - new CoordRec((float) 51.499, (float) 100), - new CoordRec((float) 51.499, (float) 0), + new CoordRec((float) 51.499, 100), + new CoordRec((float) 51.499, 0), }; static final StrokeRec char52[] = { @@ -488,8 +488,8 @@ static final StrokeRec char52[] = { /* char: 53 '5' */ static final CoordRec char53_stroke0[] = { - new CoordRec((float) 62.0029, (float) 100), - new CoordRec((float) 14.3838, (float) 100), + new CoordRec((float) 62.0029, 100), + new CoordRec((float) 14.3838, 100), new CoordRec((float) 9.6219, (float) 57.1429), new CoordRec((float) 14.3838, (float) 61.9048), new CoordRec((float) 28.6695, (float) 66.6667), @@ -500,8 +500,8 @@ static final CoordRec char53_stroke0[] = { new CoordRec((float) 71.5267, (float) 28.5714), new CoordRec((float) 66.7648, (float) 14.2857), new CoordRec((float) 57.241, (float) 4.7619), - new CoordRec((float) 42.9552, (float) 0), - new CoordRec((float) 28.6695, (float) 0), + new CoordRec((float) 42.9552, 0), + new CoordRec((float) 28.6695, 0), new CoordRec((float) 14.3838, (float) 4.7619), new CoordRec((float) 9.6219, (float) 9.5238), new CoordRec((float) 4.86, (float) 19.0476), @@ -516,16 +516,16 @@ static final StrokeRec char53[] = { static final CoordRec char54_stroke0[] = { new CoordRec((float) 62.7229, (float) 85.7143), new CoordRec((float) 57.961, (float) 95.2381), - new CoordRec((float) 43.6752, (float) 100), - new CoordRec((float) 34.1514, (float) 100), + new CoordRec((float) 43.6752, 100), + new CoordRec((float) 34.1514, 100), new CoordRec((float) 19.8657, (float) 95.2381), new CoordRec((float) 10.3419, (float) 80.9524), new CoordRec((float) 5.58, (float) 57.1429), new CoordRec((float) 5.58, (float) 33.3333), new CoordRec((float) 10.3419, (float) 14.2857), new CoordRec((float) 19.8657, (float) 4.7619), - new CoordRec((float) 34.1514, (float) 0), - new CoordRec((float) 38.9133, (float) 0), + new CoordRec((float) 34.1514, 0), + new CoordRec((float) 38.9133, 0), new CoordRec((float) 53.199, (float) 4.7619), new CoordRec((float) 62.7229, (float) 14.2857), new CoordRec((float) 67.4848, (float) 28.5714), @@ -546,13 +546,13 @@ static final StrokeRec char54[] = { /* char: 55 '7' */ static final CoordRec char55_stroke0[] = { - new CoordRec((float) 72.2267, (float) 100), - new CoordRec((float) 24.6076, (float) 0), + new CoordRec((float) 72.2267, 100), + new CoordRec((float) 24.6076, 0), }; static final CoordRec char55_stroke1[] = { - new CoordRec((float) 5.56, (float) 100), - new CoordRec((float) 72.2267, (float) 100), + new CoordRec((float) 5.56, 100), + new CoordRec((float) 72.2267, 100), }; static final StrokeRec char55[] = { @@ -563,7 +563,7 @@ static final StrokeRec char55[] = { /* char: 56 '8' */ static final CoordRec char56_stroke0[] = { - new CoordRec((float) 29.4095, (float) 100), + new CoordRec((float) 29.4095, 100), new CoordRec((float) 15.1238, (float) 95.2381), new CoordRec((float) 10.3619, (float) 85.7143), new CoordRec((float) 10.3619, (float) 76.1905), @@ -576,8 +576,8 @@ static final CoordRec char56_stroke0[] = { new CoordRec((float) 72.2667, (float) 19.0476), new CoordRec((float) 67.5048, (float) 9.5238), new CoordRec((float) 62.7429, (float) 4.7619), - new CoordRec((float) 48.4571, (float) 0), - new CoordRec((float) 29.4095, (float) 0), + new CoordRec((float) 48.4571, 0), + new CoordRec((float) 29.4095, 0), new CoordRec((float) 15.1238, (float) 4.7619), new CoordRec((float) 10.3619, (float) 9.5238), new CoordRec((float) 5.6, (float) 19.0476), @@ -590,8 +590,8 @@ static final CoordRec char56_stroke0[] = { new CoordRec((float) 67.5048, (float) 76.1905), new CoordRec((float) 67.5048, (float) 85.7143), new CoordRec((float) 62.7429, (float) 95.2381), - new CoordRec((float) 48.4571, (float) 100), - new CoordRec((float) 29.4095, (float) 100), + new CoordRec((float) 48.4571, 100), + new CoordRec((float) 29.4095, 100), }; static final StrokeRec char56[] = { @@ -612,16 +612,16 @@ static final CoordRec char57_stroke0[] = { new CoordRec((float) 6.6, (float) 71.4286), new CoordRec((float) 11.3619, (float) 85.7143), new CoordRec((float) 20.8857, (float) 95.2381), - new CoordRec((float) 35.1714, (float) 100), - new CoordRec((float) 39.9333, (float) 100), + new CoordRec((float) 35.1714, 100), + new CoordRec((float) 39.9333, 100), new CoordRec((float) 54.219, (float) 95.2381), new CoordRec((float) 63.7429, (float) 85.7143), new CoordRec((float) 68.5048, (float) 66.6667), new CoordRec((float) 68.5048, (float) 42.8571), new CoordRec((float) 63.7429, (float) 19.0476), new CoordRec((float) 54.219, (float) 4.7619), - new CoordRec((float) 39.9333, (float) 0), - new CoordRec((float) 30.4095, (float) 0), + new CoordRec((float) 39.9333, 0), + new CoordRec((float) 30.4095, 0), new CoordRec((float) 16.1238, (float) 4.7619), new CoordRec((float) 11.3619, (float) 14.2857), }; @@ -643,7 +643,7 @@ static final CoordRec char58_stroke0[] = { static final CoordRec char58_stroke1[] = { new CoordRec((float) 14.0819, (float) 9.5238), new CoordRec((float) 9.32, (float) 4.7619), - new CoordRec((float) 14.0819, (float) 0), + new CoordRec((float) 14.0819, 0), new CoordRec((float) 18.8438, (float) 4.7619), new CoordRec((float) 14.0819, (float) 9.5238), }; @@ -665,7 +665,7 @@ static final CoordRec char59_stroke0[] = { static final CoordRec char59_stroke1[] = { new CoordRec((float) 17.7238, (float) 4.7619), - new CoordRec((float) 12.9619, (float) 0), + new CoordRec((float) 12.9619, 0), new CoordRec((float) 8.2, (float) 4.7619), new CoordRec((float) 12.9619, (float) 9.5238), new CoordRec((float) 17.7238, (float) 4.7619), @@ -684,7 +684,7 @@ static final StrokeRec char59[] = { static final CoordRec char60_stroke0[] = { new CoordRec((float) 79.2505, (float) 85.7143), new CoordRec((float) 3.06, (float) 42.8571), - new CoordRec((float) 79.2505, (float) 0), + new CoordRec((float) 79.2505, 0), }; static final StrokeRec char60[] = { @@ -713,7 +713,7 @@ static final StrokeRec char61[] = { static final CoordRec char62_stroke0[] = { new CoordRec((float) 2.78, (float) 85.7143), new CoordRec((float) 78.9705, (float) 42.8571), - new CoordRec((float) 2.78, (float) 0), + new CoordRec((float) 2.78, 0), }; static final StrokeRec char62[] = { @@ -727,8 +727,8 @@ static final CoordRec char63_stroke0[] = { new CoordRec((float) 8.42, (float) 80.9524), new CoordRec((float) 13.1819, (float) 90.4762), new CoordRec((float) 17.9438, (float) 95.2381), - new CoordRec((float) 27.4676, (float) 100), - new CoordRec((float) 46.5152, (float) 100), + new CoordRec((float) 27.4676, 100), + new CoordRec((float) 46.5152, 100), new CoordRec((float) 56.039, (float) 95.2381), new CoordRec((float) 60.801, (float) 90.4762), new CoordRec((float) 65.5629, (float) 80.9524), @@ -742,7 +742,7 @@ static final CoordRec char63_stroke0[] = { static final CoordRec char63_stroke1[] = { new CoordRec((float) 36.9914, (float) 9.5238), new CoordRec((float) 32.2295, (float) 4.7619), - new CoordRec((float) 36.9914, (float) 0), + new CoordRec((float) 36.9914, 0), new CoordRec((float) 41.7533, (float) 4.7619), new CoordRec((float) 36.9914, (float) 9.5238), }; @@ -795,13 +795,13 @@ static final StrokeRec char64[] = { /* char: 65 'A' */ static final CoordRec char65_stroke0[] = { - new CoordRec((float) 40.5952, (float) 100), - new CoordRec((float) 2.5, (float) 0), + new CoordRec((float) 40.5952, 100), + new CoordRec((float) 2.5, 0), }; static final CoordRec char65_stroke1[] = { - new CoordRec((float) 40.5952, (float) 100), - new CoordRec((float) 78.6905, (float) 0), + new CoordRec((float) 40.5952, 100), + new CoordRec((float) 78.6905, 0), }; static final CoordRec char65_stroke2[] = { @@ -818,13 +818,13 @@ static final StrokeRec char65[] = { /* char: 66 'B' */ static final CoordRec char66_stroke0[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 11.42, (float) 0), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 11.42, 0), }; static final CoordRec char66_stroke1[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 54.2771, (float) 100), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 54.2771, 100), new CoordRec((float) 68.5629, (float) 95.2381), new CoordRec((float) 73.3248, (float) 90.4762), new CoordRec((float) 78.0867, (float) 80.9524), @@ -843,8 +843,8 @@ static final CoordRec char66_stroke2[] = { new CoordRec((float) 78.0867, (float) 19.0476), new CoordRec((float) 73.3248, (float) 9.5238), new CoordRec((float) 68.5629, (float) 4.7619), - new CoordRec((float) 54.2771, (float) 0), - new CoordRec((float) 11.42, (float) 0), + new CoordRec((float) 54.2771, 0), + new CoordRec((float) 11.42, 0), }; static final StrokeRec char66[] = { @@ -859,8 +859,8 @@ static final CoordRec char67_stroke0[] = { new CoordRec((float) 78.0886, (float) 76.1905), new CoordRec((float) 73.3267, (float) 85.7143), new CoordRec((float) 63.8029, (float) 95.2381), - new CoordRec((float) 54.279, (float) 100), - new CoordRec((float) 35.2314, (float) 100), + new CoordRec((float) 54.279, 100), + new CoordRec((float) 35.2314, 100), new CoordRec((float) 25.7076, (float) 95.2381), new CoordRec((float) 16.1838, (float) 85.7143), new CoordRec((float) 11.4219, (float) 76.1905), @@ -869,8 +869,8 @@ static final CoordRec char67_stroke0[] = { new CoordRec((float) 11.4219, (float) 23.8095), new CoordRec((float) 16.1838, (float) 14.2857), new CoordRec((float) 25.7076, (float) 4.7619), - new CoordRec((float) 35.2314, (float) 0), - new CoordRec((float) 54.279, (float) 0), + new CoordRec((float) 35.2314, 0), + new CoordRec((float) 54.279, 0), new CoordRec((float) 63.8029, (float) 4.7619), new CoordRec((float) 73.3267, (float) 14.2857), new CoordRec((float) 78.0886, (float) 23.8095), @@ -883,13 +883,13 @@ static final StrokeRec char67[] = { /* char: 68 'D' */ static final CoordRec char68_stroke0[] = { - new CoordRec((float) 11.96, (float) 100), - new CoordRec((float) 11.96, (float) 0), + new CoordRec((float) 11.96, 100), + new CoordRec((float) 11.96, 0), }; static final CoordRec char68_stroke1[] = { - new CoordRec((float) 11.96, (float) 100), - new CoordRec((float) 45.2933, (float) 100), + new CoordRec((float) 11.96, 100), + new CoordRec((float) 45.2933, 100), new CoordRec((float) 59.579, (float) 95.2381), new CoordRec((float) 69.1029, (float) 85.7143), new CoordRec((float) 73.8648, (float) 76.1905), @@ -898,8 +898,8 @@ static final CoordRec char68_stroke1[] = { new CoordRec((float) 73.8648, (float) 23.8095), new CoordRec((float) 69.1029, (float) 14.2857), new CoordRec((float) 59.579, (float) 4.7619), - new CoordRec((float) 45.2933, (float) 0), - new CoordRec((float) 11.96, (float) 0), + new CoordRec((float) 45.2933, 0), + new CoordRec((float) 11.96, 0), }; static final StrokeRec char68[] = { @@ -910,13 +910,13 @@ static final StrokeRec char68[] = { /* char: 69 'E' */ static final CoordRec char69_stroke0[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 11.42, (float) 0), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 11.42, 0), }; static final CoordRec char69_stroke1[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 73.3248, (float) 100), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 73.3248, 100), }; static final CoordRec char69_stroke2[] = { @@ -925,8 +925,8 @@ static final CoordRec char69_stroke2[] = { }; static final CoordRec char69_stroke3[] = { - new CoordRec((float) 11.42, (float) 0), - new CoordRec((float) 73.3248, (float) 0), + new CoordRec((float) 11.42, 0), + new CoordRec((float) 73.3248, 0), }; static final StrokeRec char69[] = { @@ -939,13 +939,13 @@ static final StrokeRec char69[] = { /* char: 70 'F' */ static final CoordRec char70_stroke0[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 11.42, (float) 0), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 11.42, 0), }; static final CoordRec char70_stroke1[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 73.3248, (float) 100), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 73.3248, 100), }; static final CoordRec char70_stroke2[] = { @@ -965,8 +965,8 @@ static final CoordRec char71_stroke0[] = { new CoordRec((float) 78.4886, (float) 76.1905), new CoordRec((float) 73.7267, (float) 85.7143), new CoordRec((float) 64.2029, (float) 95.2381), - new CoordRec((float) 54.679, (float) 100), - new CoordRec((float) 35.6314, (float) 100), + new CoordRec((float) 54.679, 100), + new CoordRec((float) 35.6314, 100), new CoordRec((float) 26.1076, (float) 95.2381), new CoordRec((float) 16.5838, (float) 85.7143), new CoordRec((float) 11.8219, (float) 76.1905), @@ -975,8 +975,8 @@ static final CoordRec char71_stroke0[] = { new CoordRec((float) 11.8219, (float) 23.8095), new CoordRec((float) 16.5838, (float) 14.2857), new CoordRec((float) 26.1076, (float) 4.7619), - new CoordRec((float) 35.6314, (float) 0), - new CoordRec((float) 54.679, (float) 0), + new CoordRec((float) 35.6314, 0), + new CoordRec((float) 54.679, 0), new CoordRec((float) 64.2029, (float) 4.7619), new CoordRec((float) 73.7267, (float) 14.2857), new CoordRec((float) 78.4886, (float) 23.8095), @@ -996,13 +996,13 @@ static final StrokeRec char71[] = { /* char: 72 'H' */ static final CoordRec char72_stroke0[] = { - new CoordRec((float) 11.42, (float) 100), - new CoordRec((float) 11.42, (float) 0), + new CoordRec((float) 11.42, 100), + new CoordRec((float) 11.42, 0), }; static final CoordRec char72_stroke1[] = { - new CoordRec((float) 78.0867, (float) 100), - new CoordRec((float) 78.0867, (float) 0), + new CoordRec((float) 78.0867, 100), + new CoordRec((float) 78.0867, 0), }; static final CoordRec char72_stroke2[] = { @@ -1019,8 +1019,8 @@ static final StrokeRec char72[] = { /* char: 73 'I' */ static final CoordRec char73_stroke0[] = { - new CoordRec((float) 10.86, (float) 100), - new CoordRec((float) 10.86, (float) 0), + new CoordRec((float) 10.86, 100), + new CoordRec((float) 10.86, 0), }; static final StrokeRec char73[] = { @@ -1030,12 +1030,12 @@ static final StrokeRec char73[] = { /* char: 74 'J' */ static final CoordRec char74_stroke0[] = { - new CoordRec((float) 50.119, (float) 100), + new CoordRec((float) 50.119, 100), new CoordRec((float) 50.119, (float) 23.8095), new CoordRec((float) 45.3571, (float) 9.5238), new CoordRec((float) 40.5952, (float) 4.7619), - new CoordRec((float) 31.0714, (float) 0), - new CoordRec((float) 21.5476, (float) 0), + new CoordRec((float) 31.0714, 0), + new CoordRec((float) 21.5476, 0), new CoordRec((float) 12.0238, (float) 4.7619), new CoordRec((float) 7.2619, (float) 9.5238), new CoordRec((float) 2.5, (float) 23.8095), @@ -1049,18 +1049,18 @@ static final StrokeRec char74[] = { /* char: 75 'K' */ static final CoordRec char75_stroke0[] = { - new CoordRec((float) 11.28, (float) 100), - new CoordRec((float) 11.28, (float) 0), + new CoordRec((float) 11.28, 100), + new CoordRec((float) 11.28, 0), }; static final CoordRec char75_stroke1[] = { - new CoordRec((float) 77.9467, (float) 100), + new CoordRec((float) 77.9467, 100), new CoordRec((float) 11.28, (float) 33.3333), }; static final CoordRec char75_stroke2[] = { new CoordRec((float) 35.0895, (float) 57.1429), - new CoordRec((float) 77.9467, (float) 0), + new CoordRec((float) 77.9467, 0), }; static final StrokeRec char75[] = { @@ -1072,13 +1072,13 @@ static final StrokeRec char75[] = { /* char: 76 'L' */ static final CoordRec char76_stroke0[] = { - new CoordRec((float) 11.68, (float) 100), - new CoordRec((float) 11.68, (float) 0), + new CoordRec((float) 11.68, 100), + new CoordRec((float) 11.68, 0), }; static final CoordRec char76_stroke1[] = { - new CoordRec((float) 11.68, (float) 0), - new CoordRec((float) 68.8229, (float) 0), + new CoordRec((float) 11.68, 0), + new CoordRec((float) 68.8229, 0), }; static final StrokeRec char76[] = { @@ -1089,23 +1089,23 @@ static final StrokeRec char76[] = { /* char: 77 'M' */ static final CoordRec char77_stroke0[] = { - new CoordRec((float) 10.86, (float) 100), - new CoordRec((float) 10.86, (float) 0), + new CoordRec((float) 10.86, 100), + new CoordRec((float) 10.86, 0), }; static final CoordRec char77_stroke1[] = { - new CoordRec((float) 10.86, (float) 100), - new CoordRec((float) 48.9552, (float) 0), + new CoordRec((float) 10.86, 100), + new CoordRec((float) 48.9552, 0), }; static final CoordRec char77_stroke2[] = { - new CoordRec((float) 87.0505, (float) 100), - new CoordRec((float) 48.9552, (float) 0), + new CoordRec((float) 87.0505, 100), + new CoordRec((float) 48.9552, 0), }; static final CoordRec char77_stroke3[] = { - new CoordRec((float) 87.0505, (float) 100), - new CoordRec((float) 87.0505, (float) 0), + new CoordRec((float) 87.0505, 100), + new CoordRec((float) 87.0505, 0), }; static final StrokeRec char77[] = { @@ -1118,18 +1118,18 @@ static final StrokeRec char77[] = { /* char: 78 'N' */ static final CoordRec char78_stroke0[] = { - new CoordRec((float) 11.14, (float) 100), - new CoordRec((float) 11.14, (float) 0), + new CoordRec((float) 11.14, 100), + new CoordRec((float) 11.14, 0), }; static final CoordRec char78_stroke1[] = { - new CoordRec((float) 11.14, (float) 100), - new CoordRec((float) 77.8067, (float) 0), + new CoordRec((float) 11.14, 100), + new CoordRec((float) 77.8067, 0), }; static final CoordRec char78_stroke2[] = { - new CoordRec((float) 77.8067, (float) 100), - new CoordRec((float) 77.8067, (float) 0), + new CoordRec((float) 77.8067, 100), + new CoordRec((float) 77.8067, 0), }; static final StrokeRec char78[] = { @@ -1141,7 +1141,7 @@ static final StrokeRec char78[] = { /* char: 79 'O' */ static final CoordRec char79_stroke0[] = { - new CoordRec((float) 34.8114, (float) 100), + new CoordRec((float) 34.8114, 100), new CoordRec((float) 25.2876, (float) 95.2381), new CoordRec((float) 15.7638, (float) 85.7143), new CoordRec((float) 11.0019, (float) 76.1905), @@ -1150,8 +1150,8 @@ static final CoordRec char79_stroke0[] = { new CoordRec((float) 11.0019, (float) 23.8095), new CoordRec((float) 15.7638, (float) 14.2857), new CoordRec((float) 25.2876, (float) 4.7619), - new CoordRec((float) 34.8114, (float) 0), - new CoordRec((float) 53.859, (float) 0), + new CoordRec((float) 34.8114, 0), + new CoordRec((float) 53.859, 0), new CoordRec((float) 63.3829, (float) 4.7619), new CoordRec((float) 72.9067, (float) 14.2857), new CoordRec((float) 77.6686, (float) 23.8095), @@ -1160,8 +1160,8 @@ static final CoordRec char79_stroke0[] = { new CoordRec((float) 77.6686, (float) 76.1905), new CoordRec((float) 72.9067, (float) 85.7143), new CoordRec((float) 63.3829, (float) 95.2381), - new CoordRec((float) 53.859, (float) 100), - new CoordRec((float) 34.8114, (float) 100), + new CoordRec((float) 53.859, 100), + new CoordRec((float) 34.8114, 100), }; static final StrokeRec char79[] = { @@ -1171,13 +1171,13 @@ static final StrokeRec char79[] = { /* char: 80 'P' */ static final CoordRec char80_stroke0[] = { - new CoordRec((float) 12.1, (float) 100), - new CoordRec((float) 12.1, (float) 0), + new CoordRec((float) 12.1, 100), + new CoordRec((float) 12.1, 0), }; static final CoordRec char80_stroke1[] = { - new CoordRec((float) 12.1, (float) 100), - new CoordRec((float) 54.9571, (float) 100), + new CoordRec((float) 12.1, 100), + new CoordRec((float) 54.9571, 100), new CoordRec((float) 69.2429, (float) 95.2381), new CoordRec((float) 74.0048, (float) 90.4762), new CoordRec((float) 78.7667, (float) 80.9524), @@ -1196,7 +1196,7 @@ static final StrokeRec char80[] = { /* char: 81 'Q' */ static final CoordRec char81_stroke0[] = { - new CoordRec((float) 33.8714, (float) 100), + new CoordRec((float) 33.8714, 100), new CoordRec((float) 24.3476, (float) 95.2381), new CoordRec((float) 14.8238, (float) 85.7143), new CoordRec((float) 10.0619, (float) 76.1905), @@ -1205,8 +1205,8 @@ static final CoordRec char81_stroke0[] = { new CoordRec((float) 10.0619, (float) 23.8095), new CoordRec((float) 14.8238, (float) 14.2857), new CoordRec((float) 24.3476, (float) 4.7619), - new CoordRec((float) 33.8714, (float) 0), - new CoordRec((float) 52.919, (float) 0), + new CoordRec((float) 33.8714, 0), + new CoordRec((float) 52.919, 0), new CoordRec((float) 62.4429, (float) 4.7619), new CoordRec((float) 71.9667, (float) 14.2857), new CoordRec((float) 76.7286, (float) 23.8095), @@ -1215,8 +1215,8 @@ static final CoordRec char81_stroke0[] = { new CoordRec((float) 76.7286, (float) 76.1905), new CoordRec((float) 71.9667, (float) 85.7143), new CoordRec((float) 62.4429, (float) 95.2381), - new CoordRec((float) 52.919, (float) 100), - new CoordRec((float) 33.8714, (float) 100), + new CoordRec((float) 52.919, 100), + new CoordRec((float) 33.8714, 100), }; static final CoordRec char81_stroke1[] = { @@ -1232,13 +1232,13 @@ static final StrokeRec char81[] = { /* char: 82 'R' */ static final CoordRec char82_stroke0[] = { - new CoordRec((float) 11.68, (float) 100), - new CoordRec((float) 11.68, (float) 0), + new CoordRec((float) 11.68, 100), + new CoordRec((float) 11.68, 0), }; static final CoordRec char82_stroke1[] = { - new CoordRec((float) 11.68, (float) 100), - new CoordRec((float) 54.5371, (float) 100), + new CoordRec((float) 11.68, 100), + new CoordRec((float) 54.5371, 100), new CoordRec((float) 68.8229, (float) 95.2381), new CoordRec((float) 73.5848, (float) 90.4762), new CoordRec((float) 78.3467, (float) 80.9524), @@ -1251,7 +1251,7 @@ static final CoordRec char82_stroke1[] = { static final CoordRec char82_stroke2[] = { new CoordRec((float) 45.0133, (float) 52.381), - new CoordRec((float) 78.3467, (float) 0), + new CoordRec((float) 78.3467, 0), }; static final StrokeRec char82[] = { @@ -1265,11 +1265,11 @@ static final StrokeRec char82[] = { static final CoordRec char83_stroke0[] = { new CoordRec((float) 74.6667, (float) 85.7143), new CoordRec((float) 65.1429, (float) 95.2381), - new CoordRec((float) 50.8571, (float) 100), - new CoordRec((float) 31.8095, (float) 100), + new CoordRec((float) 50.8571, 100), + new CoordRec((float) 31.8095, 100), new CoordRec((float) 17.5238, (float) 95.2381), - new CoordRec((float) 8, (float) 85.7143), - new CoordRec((float) 8, (float) 76.1905), + new CoordRec(8, (float) 85.7143), + new CoordRec(8, (float) 76.1905), new CoordRec((float) 12.7619, (float) 66.6667), new CoordRec((float) 17.5238, (float) 61.9048), new CoordRec((float) 27.0476, (float) 57.1429), @@ -1279,10 +1279,10 @@ static final CoordRec char83_stroke0[] = { new CoordRec((float) 74.6667, (float) 28.5714), new CoordRec((float) 74.6667, (float) 14.2857), new CoordRec((float) 65.1429, (float) 4.7619), - new CoordRec((float) 50.8571, (float) 0), - new CoordRec((float) 31.8095, (float) 0), + new CoordRec((float) 50.8571, 0), + new CoordRec((float) 31.8095, 0), new CoordRec((float) 17.5238, (float) 4.7619), - new CoordRec((float) 8, (float) 14.2857), + new CoordRec(8, (float) 14.2857), }; static final StrokeRec char83[] = { @@ -1292,13 +1292,13 @@ static final StrokeRec char83[] = { /* char: 84 'T' */ static final CoordRec char84_stroke0[] = { - new CoordRec((float) 35.6933, (float) 100), - new CoordRec((float) 35.6933, (float) 0), + new CoordRec((float) 35.6933, 100), + new CoordRec((float) 35.6933, 0), }; static final CoordRec char84_stroke1[] = { - new CoordRec((float) 2.36, (float) 100), - new CoordRec((float) 69.0267, (float) 100), + new CoordRec((float) 2.36, 100), + new CoordRec((float) 69.0267, 100), }; static final StrokeRec char84[] = { @@ -1309,16 +1309,16 @@ static final StrokeRec char84[] = { /* char: 85 'U' */ static final CoordRec char85_stroke0[] = { - new CoordRec((float) 11.54, (float) 100), + new CoordRec((float) 11.54, 100), new CoordRec((float) 11.54, (float) 28.5714), new CoordRec((float) 16.3019, (float) 14.2857), new CoordRec((float) 25.8257, (float) 4.7619), - new CoordRec((float) 40.1114, (float) 0), - new CoordRec((float) 49.6352, (float) 0), + new CoordRec((float) 40.1114, 0), + new CoordRec((float) 49.6352, 0), new CoordRec((float) 63.921, (float) 4.7619), new CoordRec((float) 73.4448, (float) 14.2857), new CoordRec((float) 78.2067, (float) 28.5714), - new CoordRec((float) 78.2067, (float) 100), + new CoordRec((float) 78.2067, 100), }; static final StrokeRec char85[] = { @@ -1328,13 +1328,13 @@ static final StrokeRec char85[] = { /* char: 86 'V' */ static final CoordRec char86_stroke0[] = { - new CoordRec((float) 2.36, (float) 100), - new CoordRec((float) 40.4552, (float) 0), + new CoordRec((float) 2.36, 100), + new CoordRec((float) 40.4552, 0), }; static final CoordRec char86_stroke1[] = { - new CoordRec((float) 78.5505, (float) 100), - new CoordRec((float) 40.4552, (float) 0), + new CoordRec((float) 78.5505, 100), + new CoordRec((float) 40.4552, 0), }; static final StrokeRec char86[] = { @@ -1345,23 +1345,23 @@ static final StrokeRec char86[] = { /* char: 87 'W' */ static final CoordRec char87_stroke0[] = { - new CoordRec((float) 2.22, (float) 100), - new CoordRec((float) 26.0295, (float) 0), + new CoordRec((float) 2.22, 100), + new CoordRec((float) 26.0295, 0), }; static final CoordRec char87_stroke1[] = { - new CoordRec((float) 49.839, (float) 100), - new CoordRec((float) 26.0295, (float) 0), + new CoordRec((float) 49.839, 100), + new CoordRec((float) 26.0295, 0), }; static final CoordRec char87_stroke2[] = { - new CoordRec((float) 49.839, (float) 100), - new CoordRec((float) 73.6486, (float) 0), + new CoordRec((float) 49.839, 100), + new CoordRec((float) 73.6486, 0), }; static final CoordRec char87_stroke3[] = { - new CoordRec((float) 97.4581, (float) 100), - new CoordRec((float) 73.6486, (float) 0), + new CoordRec((float) 97.4581, 100), + new CoordRec((float) 73.6486, 0), }; static final StrokeRec char87[] = { @@ -1374,13 +1374,13 @@ static final StrokeRec char87[] = { /* char: 88 'X' */ static final CoordRec char88_stroke0[] = { - new CoordRec((float) 2.5, (float) 100), - new CoordRec((float) 69.1667, (float) 0), + new CoordRec((float) 2.5, 100), + new CoordRec((float) 69.1667, 0), }; static final CoordRec char88_stroke1[] = { - new CoordRec((float) 69.1667, (float) 100), - new CoordRec((float) 2.5, (float) 0), + new CoordRec((float) 69.1667, 100), + new CoordRec((float) 2.5, 0), }; static final StrokeRec char88[] = { @@ -1391,13 +1391,13 @@ static final StrokeRec char88[] = { /* char: 89 'Y' */ static final CoordRec char89_stroke0[] = { - new CoordRec((float) 1.52, (float) 100), + new CoordRec((float) 1.52, 100), new CoordRec((float) 39.6152, (float) 52.381), - new CoordRec((float) 39.6152, (float) 0), + new CoordRec((float) 39.6152, 0), }; static final CoordRec char89_stroke1[] = { - new CoordRec((float) 77.7105, (float) 100), + new CoordRec((float) 77.7105, 100), new CoordRec((float) 39.6152, (float) 52.381), }; @@ -1409,18 +1409,18 @@ static final StrokeRec char89[] = { /* char: 90 'Z' */ static final CoordRec char90_stroke0[] = { - new CoordRec((float) 69.1667, (float) 100), - new CoordRec((float) 2.5, (float) 0), + new CoordRec((float) 69.1667, 100), + new CoordRec((float) 2.5, 0), }; static final CoordRec char90_stroke1[] = { - new CoordRec((float) 2.5, (float) 100), - new CoordRec((float) 69.1667, (float) 100), + new CoordRec((float) 2.5, 100), + new CoordRec((float) 69.1667, 100), }; static final CoordRec char90_stroke2[] = { - new CoordRec((float) 2.5, (float) 0), - new CoordRec((float) 69.1667, (float) 0), + new CoordRec((float) 2.5, 0), + new CoordRec((float) 69.1667, 0), }; static final StrokeRec char90[] = { @@ -1461,7 +1461,7 @@ static final StrokeRec char91[] = { /* char: 92 '\' */ static final CoordRec char92_stroke0[] = { - new CoordRec((float) 5.84, (float) 100), + new CoordRec((float) 5.84, 100), new CoordRec((float) 72.5067, (float) -14.2857), }; @@ -1532,12 +1532,12 @@ static final StrokeRec char95[] = { /* char: 96 '`' */ static final CoordRec char96_stroke0[] = { - new CoordRec((float) 33.0219, (float) 100), + new CoordRec((float) 33.0219, 100), new CoordRec((float) 56.8314, (float) 71.4286), }; static final CoordRec char96_stroke1[] = { - new CoordRec((float) 33.0219, (float) 100), + new CoordRec((float) 33.0219, 100), new CoordRec((float) 28.26, (float) 95.2381), new CoordRec((float) 56.8314, (float) 71.4286), }; @@ -1551,7 +1551,7 @@ static final StrokeRec char96[] = { static final CoordRec char97_stroke0[] = { new CoordRec((float) 63.8229, (float) 66.6667), - new CoordRec((float) 63.8229, (float) 0), + new CoordRec((float) 63.8229, 0), }; static final CoordRec char97_stroke1[] = { @@ -1565,8 +1565,8 @@ static final CoordRec char97_stroke1[] = { new CoordRec((float) 6.68, (float) 28.5714), new CoordRec((float) 11.4419, (float) 14.2857), new CoordRec((float) 20.9657, (float) 4.7619), - new CoordRec((float) 30.4895, (float) 0), - new CoordRec((float) 44.7752, (float) 0), + new CoordRec((float) 30.4895, 0), + new CoordRec((float) 44.7752, 0), new CoordRec((float) 54.299, (float) 4.7619), new CoordRec((float) 63.8229, (float) 14.2857), }; @@ -1579,8 +1579,8 @@ static final StrokeRec char97[] = { /* char: 98 'b' */ static final CoordRec char98_stroke0[] = { - new CoordRec((float) 8.76, (float) 100), - new CoordRec((float) 8.76, (float) 0), + new CoordRec((float) 8.76, 100), + new CoordRec((float) 8.76, 0), }; static final CoordRec char98_stroke1[] = { @@ -1594,8 +1594,8 @@ static final CoordRec char98_stroke1[] = { new CoordRec((float) 65.9029, (float) 28.5714), new CoordRec((float) 61.141, (float) 14.2857), new CoordRec((float) 51.6171, (float) 4.7619), - new CoordRec((float) 42.0933, (float) 0), - new CoordRec((float) 27.8076, (float) 0), + new CoordRec((float) 42.0933, 0), + new CoordRec((float) 27.8076, 0), new CoordRec((float) 18.2838, (float) 4.7619), new CoordRec((float) 8.76, (float) 14.2857), }; @@ -1618,8 +1618,8 @@ static final CoordRec char99_stroke0[] = { new CoordRec((float) 5.52, (float) 28.5714), new CoordRec((float) 10.2819, (float) 14.2857), new CoordRec((float) 19.8057, (float) 4.7619), - new CoordRec((float) 29.3295, (float) 0), - new CoordRec((float) 43.6152, (float) 0), + new CoordRec((float) 29.3295, 0), + new CoordRec((float) 43.6152, 0), new CoordRec((float) 53.139, (float) 4.7619), new CoordRec((float) 62.6629, (float) 14.2857), }; @@ -1631,8 +1631,8 @@ static final StrokeRec char99[] = { /* char: 100 'd' */ static final CoordRec char100_stroke0[] = { - new CoordRec((float) 61.7829, (float) 100), - new CoordRec((float) 61.7829, (float) 0), + new CoordRec((float) 61.7829, 100), + new CoordRec((float) 61.7829, 0), }; static final CoordRec char100_stroke1[] = { @@ -1646,8 +1646,8 @@ static final CoordRec char100_stroke1[] = { new CoordRec((float) 4.64, (float) 28.5714), new CoordRec((float) 9.4019, (float) 14.2857), new CoordRec((float) 18.9257, (float) 4.7619), - new CoordRec((float) 28.4495, (float) 0), - new CoordRec((float) 42.7352, (float) 0), + new CoordRec((float) 28.4495, 0), + new CoordRec((float) 42.7352, 0), new CoordRec((float) 52.259, (float) 4.7619), new CoordRec((float) 61.7829, (float) 14.2857), }; @@ -1673,8 +1673,8 @@ static final CoordRec char101_stroke0[] = { new CoordRec((float) 5.72, (float) 28.5714), new CoordRec((float) 10.4819, (float) 14.2857), new CoordRec((float) 20.0057, (float) 4.7619), - new CoordRec((float) 29.5295, (float) 0), - new CoordRec((float) 43.8152, (float) 0), + new CoordRec((float) 29.5295, 0), + new CoordRec((float) 43.8152, 0), new CoordRec((float) 53.339, (float) 4.7619), new CoordRec((float) 62.8629, (float) 14.2857), }; @@ -1686,11 +1686,11 @@ static final StrokeRec char101[] = { /* char: 102 'f' */ static final CoordRec char102_stroke0[] = { - new CoordRec((float) 38.7752, (float) 100), - new CoordRec((float) 29.2514, (float) 100), + new CoordRec((float) 38.7752, 100), + new CoordRec((float) 29.2514, 100), new CoordRec((float) 19.7276, (float) 95.2381), new CoordRec((float) 14.9657, (float) 80.9524), - new CoordRec((float) 14.9657, (float) 0), + new CoordRec((float) 14.9657, 0), }; static final CoordRec char102_stroke1[] = { @@ -1726,8 +1726,8 @@ static final CoordRec char103_stroke1[] = { new CoordRec((float) 5.36, (float) 28.5714), new CoordRec((float) 10.1219, (float) 14.2857), new CoordRec((float) 19.6457, (float) 4.7619), - new CoordRec((float) 29.1695, (float) 0), - new CoordRec((float) 43.4552, (float) 0), + new CoordRec((float) 29.1695, 0), + new CoordRec((float) 43.4552, 0), new CoordRec((float) 52.979, (float) 4.7619), new CoordRec((float) 62.5029, (float) 14.2857), }; @@ -1740,8 +1740,8 @@ static final StrokeRec char103[] = { /* char: 104 'h' */ static final CoordRec char104_stroke0[] = { - new CoordRec((float) 9.6, (float) 100), - new CoordRec((float) 9.6, (float) 0), + new CoordRec((float) 9.6, 100), + new CoordRec((float) 9.6, 0), }; static final CoordRec char104_stroke1[] = { @@ -1751,7 +1751,7 @@ static final CoordRec char104_stroke1[] = { new CoordRec((float) 47.6952, (float) 66.6667), new CoordRec((float) 57.219, (float) 61.9048), new CoordRec((float) 61.981, (float) 47.619), - new CoordRec((float) 61.981, (float) 0), + new CoordRec((float) 61.981, 0), }; static final StrokeRec char104[] = { @@ -1762,16 +1762,16 @@ static final StrokeRec char104[] = { /* char: 105 'i' */ static final CoordRec char105_stroke0[] = { - new CoordRec((float) 10.02, (float) 100), + new CoordRec((float) 10.02, 100), new CoordRec((float) 14.7819, (float) 95.2381), - new CoordRec((float) 19.5438, (float) 100), + new CoordRec((float) 19.5438, 100), new CoordRec((float) 14.7819, (float) 104.762), - new CoordRec((float) 10.02, (float) 100), + new CoordRec((float) 10.02, 100), }; static final CoordRec char105_stroke1[] = { new CoordRec((float) 14.7819, (float) 66.6667), - new CoordRec((float) 14.7819, (float) 0), + new CoordRec((float) 14.7819, 0), }; static final StrokeRec char105[] = { @@ -1782,11 +1782,11 @@ static final StrokeRec char105[] = { /* char: 106 'j' */ static final CoordRec char106_stroke0[] = { - new CoordRec((float) 17.3876, (float) 100), + new CoordRec((float) 17.3876, 100), new CoordRec((float) 22.1495, (float) 95.2381), - new CoordRec((float) 26.9114, (float) 100), + new CoordRec((float) 26.9114, 100), new CoordRec((float) 22.1495, (float) 104.762), - new CoordRec((float) 17.3876, (float) 100), + new CoordRec((float) 17.3876, 100), }; static final CoordRec char106_stroke1[] = { @@ -1805,8 +1805,8 @@ static final StrokeRec char106[] = { /* char: 107 'k' */ static final CoordRec char107_stroke0[] = { - new CoordRec((float) 9.6, (float) 100), - new CoordRec((float) 9.6, (float) 0), + new CoordRec((float) 9.6, 100), + new CoordRec((float) 9.6, 0), }; static final CoordRec char107_stroke1[] = { @@ -1816,7 +1816,7 @@ static final CoordRec char107_stroke1[] = { static final CoordRec char107_stroke2[] = { new CoordRec((float) 28.6476, (float) 38.0952), - new CoordRec((float) 61.981, (float) 0), + new CoordRec((float) 61.981, 0), }; static final StrokeRec char107[] = { @@ -1828,8 +1828,8 @@ static final StrokeRec char107[] = { /* char: 108 'l' */ static final CoordRec char108_stroke0[] = { - new CoordRec((float) 10.02, (float) 100), - new CoordRec((float) 10.02, (float) 0), + new CoordRec((float) 10.02, 100), + new CoordRec((float) 10.02, 0), }; static final StrokeRec char108[] = { @@ -1840,7 +1840,7 @@ static final StrokeRec char108[] = { static final CoordRec char109_stroke0[] = { new CoordRec((float) 9.6, (float) 66.6667), - new CoordRec((float) 9.6, (float) 0), + new CoordRec((float) 9.6, 0), }; static final CoordRec char109_stroke1[] = { @@ -1850,7 +1850,7 @@ static final CoordRec char109_stroke1[] = { new CoordRec((float) 47.6952, (float) 66.6667), new CoordRec((float) 57.219, (float) 61.9048), new CoordRec((float) 61.981, (float) 47.619), - new CoordRec((float) 61.981, (float) 0), + new CoordRec((float) 61.981, 0), }; static final CoordRec char109_stroke2[] = { @@ -1860,7 +1860,7 @@ static final CoordRec char109_stroke2[] = { new CoordRec((float) 100.076, (float) 66.6667), new CoordRec((float) 109.6, (float) 61.9048), new CoordRec((float) 114.362, (float) 47.619), - new CoordRec((float) 114.362, (float) 0), + new CoordRec((float) 114.362, 0), }; static final StrokeRec char109[] = { @@ -1873,7 +1873,7 @@ static final StrokeRec char109[] = { static final CoordRec char110_stroke0[] = { new CoordRec((float) 9.18, (float) 66.6667), - new CoordRec((float) 9.18, (float) 0), + new CoordRec((float) 9.18, 0), }; static final CoordRec char110_stroke1[] = { @@ -1883,7 +1883,7 @@ static final CoordRec char110_stroke1[] = { new CoordRec((float) 47.2752, (float) 66.6667), new CoordRec((float) 56.799, (float) 61.9048), new CoordRec((float) 61.561, (float) 47.619), - new CoordRec((float) 61.561, (float) 0), + new CoordRec((float) 61.561, 0), }; static final StrokeRec char110[] = { @@ -1901,8 +1901,8 @@ static final CoordRec char111_stroke0[] = { new CoordRec((float) 4.98, (float) 28.5714), new CoordRec((float) 9.7419, (float) 14.2857), new CoordRec((float) 19.2657, (float) 4.7619), - new CoordRec((float) 28.7895, (float) 0), - new CoordRec((float) 43.0752, (float) 0), + new CoordRec((float) 28.7895, 0), + new CoordRec((float) 43.0752, 0), new CoordRec((float) 52.599, (float) 4.7619), new CoordRec((float) 62.1229, (float) 14.2857), new CoordRec((float) 66.8848, (float) 28.5714), @@ -1935,8 +1935,8 @@ static final CoordRec char112_stroke1[] = { new CoordRec((float) 66.6029, (float) 28.5714), new CoordRec((float) 61.841, (float) 14.2857), new CoordRec((float) 52.3171, (float) 4.7619), - new CoordRec((float) 42.7933, (float) 0), - new CoordRec((float) 28.5076, (float) 0), + new CoordRec((float) 42.7933, 0), + new CoordRec((float) 28.5076, 0), new CoordRec((float) 18.9838, (float) 4.7619), new CoordRec((float) 9.46, (float) 14.2857), }; @@ -1964,8 +1964,8 @@ static final CoordRec char113_stroke1[] = { new CoordRec((float) 4.84, (float) 28.5714), new CoordRec((float) 9.6019, (float) 14.2857), new CoordRec((float) 19.1257, (float) 4.7619), - new CoordRec((float) 28.6495, (float) 0), - new CoordRec((float) 42.9352, (float) 0), + new CoordRec((float) 28.6495, 0), + new CoordRec((float) 42.9352, 0), new CoordRec((float) 52.459, (float) 4.7619), new CoordRec((float) 61.9829, (float) 14.2857), }; @@ -1979,7 +1979,7 @@ static final StrokeRec char113[] = { static final CoordRec char114_stroke0[] = { new CoordRec((float) 9.46, (float) 66.6667), - new CoordRec((float) 9.46, (float) 0), + new CoordRec((float) 9.46, 0), }; static final CoordRec char114_stroke1[] = { @@ -2011,8 +2011,8 @@ static final CoordRec char115_stroke0[] = { new CoordRec((float) 57.081, (float) 19.0476), new CoordRec((float) 57.081, (float) 14.2857), new CoordRec((float) 52.319, (float) 4.7619), - new CoordRec((float) 38.0333, (float) 0), - new CoordRec((float) 23.7476, (float) 0), + new CoordRec((float) 38.0333, 0), + new CoordRec((float) 23.7476, 0), new CoordRec((float) 9.4619, (float) 4.7619), new CoordRec((float) 4.7, (float) 14.2857), }; @@ -2024,11 +2024,11 @@ static final StrokeRec char115[] = { /* char: 116 't' */ static final CoordRec char116_stroke0[] = { - new CoordRec((float) 14.8257, (float) 100), + new CoordRec((float) 14.8257, 100), new CoordRec((float) 14.8257, (float) 19.0476), new CoordRec((float) 19.5876, (float) 4.7619), - new CoordRec((float) 29.1114, (float) 0), - new CoordRec((float) 38.6352, (float) 0), + new CoordRec((float) 29.1114, 0), + new CoordRec((float) 38.6352, 0), }; static final CoordRec char116_stroke1[] = { @@ -2047,15 +2047,15 @@ static final CoordRec char117_stroke0[] = { new CoordRec((float) 9.46, (float) 66.6667), new CoordRec((float) 9.46, (float) 19.0476), new CoordRec((float) 14.2219, (float) 4.7619), - new CoordRec((float) 23.7457, (float) 0), - new CoordRec((float) 38.0314, (float) 0), + new CoordRec((float) 23.7457, 0), + new CoordRec((float) 38.0314, 0), new CoordRec((float) 47.5552, (float) 4.7619), new CoordRec((float) 61.841, (float) 19.0476), }; static final CoordRec char117_stroke1[] = { new CoordRec((float) 61.841, (float) 66.6667), - new CoordRec((float) 61.841, (float) 0), + new CoordRec((float) 61.841, 0), }; static final StrokeRec char117[] = { @@ -2067,12 +2067,12 @@ static final StrokeRec char117[] = { static final CoordRec char118_stroke0[] = { new CoordRec((float) 1.8, (float) 66.6667), - new CoordRec((float) 30.3714, (float) 0), + new CoordRec((float) 30.3714, 0), }; static final CoordRec char118_stroke1[] = { new CoordRec((float) 58.9429, (float) 66.6667), - new CoordRec((float) 30.3714, (float) 0), + new CoordRec((float) 30.3714, 0), }; static final StrokeRec char118[] = { @@ -2084,22 +2084,22 @@ static final StrokeRec char118[] = { static final CoordRec char119_stroke0[] = { new CoordRec((float) 2.5, (float) 66.6667), - new CoordRec((float) 21.5476, (float) 0), + new CoordRec((float) 21.5476, 0), }; static final CoordRec char119_stroke1[] = { new CoordRec((float) 40.5952, (float) 66.6667), - new CoordRec((float) 21.5476, (float) 0), + new CoordRec((float) 21.5476, 0), }; static final CoordRec char119_stroke2[] = { new CoordRec((float) 40.5952, (float) 66.6667), - new CoordRec((float) 59.6429, (float) 0), + new CoordRec((float) 59.6429, 0), }; static final CoordRec char119_stroke3[] = { new CoordRec((float) 78.6905, (float) 66.6667), - new CoordRec((float) 59.6429, (float) 0), + new CoordRec((float) 59.6429, 0), }; static final StrokeRec char119[] = { @@ -2113,12 +2113,12 @@ static final StrokeRec char119[] = { static final CoordRec char120_stroke0[] = { new CoordRec((float) 1.66, (float) 66.6667), - new CoordRec((float) 54.041, (float) 0), + new CoordRec((float) 54.041, 0), }; static final CoordRec char120_stroke1[] = { new CoordRec((float) 54.041, (float) 66.6667), - new CoordRec((float) 1.66, (float) 0), + new CoordRec((float) 1.66, 0), }; static final StrokeRec char120[] = { @@ -2130,12 +2130,12 @@ static final StrokeRec char120[] = { static final CoordRec char121_stroke0[] = { new CoordRec((float) 6.5619, (float) 66.6667), - new CoordRec((float) 35.1333, (float) 0), + new CoordRec((float) 35.1333, 0), }; static final CoordRec char121_stroke1[] = { new CoordRec((float) 63.7048, (float) 66.6667), - new CoordRec((float) 35.1333, (float) 0), + new CoordRec((float) 35.1333, 0), new CoordRec((float) 25.6095, (float) -19.0476), new CoordRec((float) 16.0857, (float) -28.5714), new CoordRec((float) 6.5619, (float) -33.3333), @@ -2151,7 +2151,7 @@ static final StrokeRec char121[] = { static final CoordRec char122_stroke0[] = { new CoordRec((float) 56.821, (float) 66.6667), - new CoordRec((float) 4.44, (float) 0), + new CoordRec((float) 4.44, 0), }; static final CoordRec char122_stroke1[] = { @@ -2160,8 +2160,8 @@ static final CoordRec char122_stroke1[] = { }; static final CoordRec char122_stroke2[] = { - new CoordRec((float) 4.44, (float) 0), - new CoordRec((float) 56.821, (float) 0), + new CoordRec((float) 4.44, 0), + new CoordRec((float) 56.821, 0), }; static final StrokeRec char122[] = { @@ -2176,7 +2176,7 @@ static final CoordRec char123_stroke0[] = { new CoordRec((float) 31.1895, (float) 119.048), new CoordRec((float) 21.6657, (float) 114.286), new CoordRec((float) 16.9038, (float) 109.524), - new CoordRec((float) 12.1419, (float) 100), + new CoordRec((float) 12.1419, 100), new CoordRec((float) 12.1419, (float) 90.4762), new CoordRec((float) 16.9038, (float) 80.9524), new CoordRec((float) 21.6657, (float) 76.1905), @@ -2199,7 +2199,7 @@ static final CoordRec char123_stroke1[] = { new CoordRec((float) 31.1895, (float) 23.8095), new CoordRec((float) 31.1895, (float) 14.2857), new CoordRec((float) 26.4276, (float) 4.7619), - new CoordRec((float) 21.6657, (float) 0), + new CoordRec((float) 21.6657, 0), new CoordRec((float) 16.9038, (float) -9.5238), new CoordRec((float) 16.9038, (float) -19.0476), new CoordRec((float) 21.6657, (float) -28.5714), @@ -2241,7 +2241,7 @@ static final CoordRec char125_stroke0[] = { new CoordRec((float) 9.18, (float) 119.048), new CoordRec((float) 18.7038, (float) 114.286), new CoordRec((float) 23.4657, (float) 109.524), - new CoordRec((float) 28.2276, (float) 100), + new CoordRec((float) 28.2276, 100), new CoordRec((float) 28.2276, (float) 90.4762), new CoordRec((float) 23.4657, (float) 80.9524), new CoordRec((float) 18.7038, (float) 76.1905), @@ -2264,7 +2264,7 @@ static final CoordRec char125_stroke1[] = { new CoordRec((float) 9.18, (float) 23.8095), new CoordRec((float) 9.18, (float) 14.2857), new CoordRec((float) 13.9419, (float) 4.7619), - new CoordRec((float) 18.7038, (float) 0), + new CoordRec((float) 18.7038, 0), new CoordRec((float) 23.4657, (float) -9.5238), new CoordRec((float) 23.4657, (float) -19.0476), new CoordRec((float) 18.7038, (float) -28.5714), @@ -2327,7 +2327,7 @@ static final StrokeRec char126[] = { /* char: 127 */ static final CoordRec char127_stroke0[] = { - new CoordRec((float) 52.381, (float) 100), + new CoordRec((float) 52.381, 100), new CoordRec((float) 14.2857, (float) -33.3333), }; @@ -2335,12 +2335,12 @@ static final CoordRec char127_stroke1[] = { new CoordRec((float) 28.5714, (float) 66.6667), new CoordRec((float) 14.2857, (float) 61.9048), new CoordRec((float) 4.7619, (float) 52.381), - new CoordRec((float) 0, (float) 38.0952), - new CoordRec((float) 0, (float) 23.8095), + new CoordRec(0, (float) 38.0952), + new CoordRec(0, (float) 23.8095), new CoordRec((float) 4.7619, (float) 14.2857), new CoordRec((float) 14.2857, (float) 4.7619), - new CoordRec((float) 28.5714, (float) 0), - new CoordRec((float) 38.0952, (float) 0), + new CoordRec((float) 28.5714, 0), + new CoordRec((float) 38.0952, 0), new CoordRec((float) 52.381, (float) 4.7619), new CoordRec((float) 61.9048, (float) 14.2857), new CoordRec((float) 66.6667, (float) 28.5714), @@ -2357,38 +2357,38 @@ static final StrokeRec char127[] = { }; static final StrokeCharRec chars[] = { - new StrokeCharRec( 0, /* char0 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char1 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char2 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char3 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char4 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char5 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char6 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char7 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char8 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char9 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char10 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char11 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char12 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char13 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char14 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char15 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char16 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char17 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char18 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char19 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char20 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char21 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char22 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char23 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char24 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char25 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char26 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char27 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char28 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char29 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char30 */ null, (float) 0, (float) 0 ), - new StrokeCharRec( 0, /* char31 */ null, (float) 0, (float) 0 ), + new StrokeCharRec( 0, /* char0 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char1 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char2 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char3 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char4 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char5 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char6 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char7 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char8 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char9 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char10 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char11 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char12 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char13 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char14 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char15 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char16 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char17 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char18 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char19 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char20 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char21 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char22 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char23 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char24 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char25 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char26 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char27 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char28 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char29 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char30 */ null, 0, 0 ), + new StrokeCharRec( 0, /* char31 */ null, 0, 0 ), new StrokeCharRec( 0, /* char32 */ null, (float) 52.381, (float) 104.762 ), new StrokeCharRec( 2, char33, (float) 13.3819, (float) 26.6238 ), new StrokeCharRec( 2, char34, (float) 23.0676, (float) 51.4352 ), diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java index 515212f0e..59935e358 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java @@ -51,10 +51,10 @@ class StrokeCharRec { public float center; public float right; - public StrokeCharRec(int num_strokes, - StrokeRec[] stroke, - float center, - float right) { + public StrokeCharRec(final int num_strokes, + final StrokeRec[] stroke, + final float center, + final float right) { this.num_strokes = num_strokes; this.stroke = stroke; this.center = center; diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java index 5335c8523..5810ac38a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java @@ -52,11 +52,11 @@ class StrokeFontRec { public float top; public float bottom; - public StrokeFontRec(String name, - int num_chars, - StrokeCharRec[] ch, - float top, - float bottom) { + public StrokeFontRec(final String name, + final int num_chars, + final StrokeCharRec[] ch, + final float top, + final float bottom) { this.name = name; this.num_chars = num_chars; this.ch = ch; diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java index b0c91c696..fcb7c912a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java @@ -49,8 +49,8 @@ class StrokeRec { public int num_coords; public CoordRec[] coord; - public StrokeRec(int num_coords, - CoordRec[] coord) { + public StrokeRec(final int num_coords, + final CoordRec[] coord) { this.num_coords = num_coords; this.coord = coord; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 7c6a40468..4a3e5b2e1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -96,7 +96,7 @@ public class ShaderCode { * * @throws IllegalArgumentException if <code>count</count> and <code>source.length</code> do not match */ - public ShaderCode(int type, int count, CharSequence[][] source) { + public ShaderCode(final int type, final int count, final CharSequence[][] source) { if(source.length != count) { throw new IllegalArgumentException("shader number ("+count+") and sourceFiles array ("+source.length+") of different lenght."); } @@ -126,7 +126,7 @@ public class ShaderCode { * @param count number of shaders * @param binary binary buffer containing the shader binaries, */ - public ShaderCode(int type, int count, int binFormat, Buffer binary) { + public ShaderCode(final int type, final int count, final int binFormat, final Buffer binary) { switch (type) { case GL2ES2.GL_VERTEX_SHADER: case GL2ES2.GL_FRAGMENT_SHADER: @@ -162,7 +162,7 @@ public class ShaderCode { * @throws IllegalArgumentException if <code>count</count> and <code>sourceFiles.length</code> do not match * @see #readShaderSource(Class, String) */ - public static ShaderCode create(GL2ES2 gl, int type, int count, Class<?> context, String[] sourceFiles, boolean mutableStringBuilder) { + public static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, final String[] sourceFiles, final boolean mutableStringBuilder) { if(null != gl && !ShaderUtil.isShaderCompilerAvailable(gl)) { return null; } @@ -174,7 +174,7 @@ public class ShaderCode { for(int i=0; i<sourceFiles.length; i++) { try { shaderSources[i][0] = readShaderSource(context, sourceFiles[i], mutableStringBuilder); - } catch (IOException ioe) { + } catch (final IOException ioe) { throw new RuntimeException("readShaderSource("+sourceFiles[i]+") error: ", ioe); } if(null == shaderSources[i][0]) { @@ -201,12 +201,12 @@ public class ShaderCode { * @see #readShaderBinary(Class, String) * @see ShaderUtil#getShaderBinaryFormats(GL) */ - public static ShaderCode create(int type, int count, Class<?> context, int binFormat, String binaryFile) { + public static ShaderCode create(final int type, final int count, final Class<?> context, int binFormat, final String binaryFile) { ByteBuffer shaderBinary = null; if(null!=binaryFile && 0<=binFormat) { try { shaderBinary = readShaderBinary(context, binaryFile); - } catch (IOException ioe) { + } catch (final IOException ioe) { throw new RuntimeException("readShaderBinary("+binaryFile+") error: ", ioe); } if(null == shaderBinary) { @@ -238,7 +238,7 @@ public class ShaderCode { * * @see #create(GL2ES2, int, Class, String, String, String, boolean) */ - public static String getFileSuffix(boolean binary, int type) { + public static String getFileSuffix(final boolean binary, final int type) { switch (type) { case GL2ES2.GL_VERTEX_SHADER: return binary?SUFFIX_VERTEX_BINARY:SUFFIX_VERTEX_SOURCE; @@ -261,7 +261,7 @@ public class ShaderCode { * * @see #create(GL2ES2, int, Class, String, String, String, boolean) */ - public static String getBinarySubPath(int binFormat) { + public static String getBinarySubPath(final int binFormat) { switch (binFormat) { case GLES2.GL_NVIDIA_PLATFORM_BINARY_NV: return SUB_PATH_NVIDIA; @@ -347,9 +347,9 @@ public class ShaderCode { * @see ShaderUtil#getShaderBinaryFormats(GL) * @see #getBinarySubPath(int) */ - public static ShaderCode create(GL2ES2 gl, int type, int count, Class<?> context, - String srcRoot, String[] srcBasenames, String binRoot, String binBasename, - boolean mutableStringBuilder) { + public static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, + final String srcRoot, final String[] srcBasenames, final String binRoot, final String binBasename, + final boolean mutableStringBuilder) { ShaderCode res = null; final String srcPath[]; String srcPathString = null; @@ -376,10 +376,10 @@ public class ShaderCode { srcPath = null; } if( null!=binBasename ) { - Set<Integer> binFmts = ShaderUtil.getShaderBinaryFormats(gl); + final Set<Integer> binFmts = ShaderUtil.getShaderBinaryFormats(gl); final String binSuffix = getFileSuffix(true, type); - for(Iterator<Integer> iter=binFmts.iterator(); iter.hasNext(); ) { - int bFmt = iter.next().intValue(); + for(final Iterator<Integer> iter=binFmts.iterator(); iter.hasNext(); ) { + final int bFmt = iter.next().intValue(); final String bFmtPath = getBinarySubPath(bFmt); if(null==bFmtPath) continue; binFileName = binRoot + '/' + bFmtPath + '/' + binBasename + "." + binSuffix; @@ -447,8 +447,8 @@ public class ShaderCode { * * @see #create(GL2ES2, int, int, Class, String, String[], String, String) */ - public static ShaderCode create(GL2ES2 gl, int type, Class<?> context, - String srcRoot, String binRoot, String basename, boolean mutableStringBuilder) { + public static ShaderCode create(final GL2ES2 gl, final int type, final Class<?> context, + final String srcRoot, final String binRoot, final String basename, final boolean mutableStringBuilder) { return create(gl, type, 1, context, srcRoot, new String[] { basename }, binRoot, basename, mutableStringBuilder ); } @@ -460,7 +460,7 @@ public class ShaderCode { public int shaderType() { return shaderType; } public String shaderTypeStr() { return shaderTypeStr(shaderType); } - public static String shaderTypeStr(int type) { + public static String shaderTypeStr(final int type) { switch (type) { case GL2ES2.GL_VERTEX_SHADER: return "VERTEX_SHADER"; @@ -480,10 +480,10 @@ public class ShaderCode { public IntBuffer shader() { return shader; } - public boolean compile(GL2ES2 gl) { + public boolean compile(final GL2ES2 gl) { return compile(gl, null); } - public boolean compile(GL2ES2 gl, PrintStream verboseOut) { + public boolean compile(final GL2ES2 gl, final PrintStream verboseOut) { if(isValid()) return true; // Create & Compile the vertex/fragment shader objects @@ -503,7 +503,7 @@ public class ShaderCode { return valid; } - public void destroy(GL2ES2 gl) { + public void destroy(final GL2ES2 gl) { if(isValid()) { if(null!=gl) { ShaderUtil.deleteShader(gl, shader()); @@ -521,7 +521,7 @@ public class ShaderCode { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if(this==obj) { return true; } if(obj instanceof ShaderCode) { return id()==((ShaderCode)obj).id(); @@ -534,7 +534,7 @@ public class ShaderCode { } @Override public String toString() { - StringBuilder buf = new StringBuilder("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: "); + final StringBuilder buf = new StringBuilder("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: "); for(int i=0; i<shader.remaining(); i++) { buf.append(" "+shader.get(i)); } @@ -546,7 +546,7 @@ public class ShaderCode { return buf.toString(); } - public void dumpShaderSource(PrintStream out) { + public void dumpShaderSource(final PrintStream out) { if(null==shaderSource) { out.println("<no shader source>"); return; @@ -560,7 +560,7 @@ public class ShaderCode { if(i>=sourceCount) { out.println("<no shader source>"); } else { - CharSequence[] src = shaderSource[i]; + final CharSequence[] src = shaderSource[i]; int lineno=0; for(int j=0; j<src.length; j++) { @@ -572,7 +572,7 @@ public class ShaderCode { lineno++; out.printf("%4d: %s\n", lineno, line); } - } catch (IOException e) { /* impossible .. StringReader */ } + } catch (final IOException e) { /* impossible .. StringReader */ } } } out.println("--------------------------------------------------------------"); @@ -593,7 +593,7 @@ public class ShaderCode { * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code> */ - public int insertShaderSource(int shaderIdx, String tag, int fromIndex, CharSequence data) { + public int insertShaderSource(final int shaderIdx, final String tag, final int fromIndex, final CharSequence data) { if(null==shaderSource) { throw new IllegalStateException("no shader source"); } @@ -650,7 +650,7 @@ public class ShaderCode { * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code> */ - public int replaceInShaderSource(String oldName, String newName) { + public int replaceInShaderSource(final String oldName, final String newName) { if(null==shaderSource) { throw new IllegalStateException("no shader source"); } @@ -670,9 +670,9 @@ public class ShaderCode { final StringBuilder sb = (StringBuilder)src[j]; int curPos = 0; while(curPos<sb.length()-oldNameLen+1) { - int startIdx = sb.indexOf(oldName, curPos); + final int startIdx = sb.indexOf(oldName, curPos); if(0<=startIdx) { - int endIdx = startIdx + oldNameLen; + final int endIdx = startIdx + oldNameLen; sb.replace(startIdx, endIdx, newName); curPos = startIdx + newNameLen; num++; @@ -698,7 +698,7 @@ public class ShaderCode { * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code> */ - public int insertShaderSource(int shaderIdx, int position, CharSequence data) { + public int insertShaderSource(final int shaderIdx, int position, final CharSequence data) { if(null==shaderSource) { throw new IllegalStateException("no shader source"); } @@ -750,7 +750,7 @@ public class ShaderCode { * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code> * @see IOUtil#getResource(Class, String) */ - public int insertShaderSource(int shaderIdx, int position, Class<?> context, String path) throws IOException { + public int insertShaderSource(final int shaderIdx, final int position, final Class<?> context, final String path) throws IOException { final CharSequence data = readShaderSource(context, path, true); if( null != data ) { return insertShaderSource(shaderIdx, position, data); @@ -760,7 +760,7 @@ public class ShaderCode { } @SuppressWarnings("resource") - private static int readShaderSource(Class<?> context, URLConnection conn, StringBuilder result, int lineno) throws IOException { + private static int readShaderSource(final Class<?> context, final URLConnection conn, final StringBuilder result, int lineno) throws IOException { if(DEBUG_CODE) { if(0 == lineno) { result.append("// "+conn.getURL().toExternalForm()+"\n"); @@ -774,7 +774,7 @@ public class ShaderCode { while ((line = reader.readLine()) != null) { lineno++; if (line.startsWith("#include ")) { - String includeFile = line.substring(9).trim(); + final String includeFile = line.substring(9).trim(); URLConnection nextConn = null; // Try relative of current shader location @@ -805,7 +805,7 @@ public class ShaderCode { * @param result * @throws IOException */ - public static void readShaderSource(Class<?> context, URLConnection conn, StringBuilder result) throws IOException { + public static void readShaderSource(final Class<?> context, final URLConnection conn, final StringBuilder result) throws IOException { readShaderSource(context, conn, result, 0); } @@ -829,12 +829,12 @@ public class ShaderCode { * * @see IOUtil#getResource(Class, String) */ - public static CharSequence readShaderSource(Class<?> context, String path, boolean mutableStringBuilder) throws IOException { - URLConnection conn = IOUtil.getResource(context, path); + public static CharSequence readShaderSource(final Class<?> context, final String path, final boolean mutableStringBuilder) throws IOException { + final URLConnection conn = IOUtil.getResource(context, path); if (conn == null) { return null; } - StringBuilder result = new StringBuilder(); + final StringBuilder result = new StringBuilder(); readShaderSource(context, conn, result); return mutableStringBuilder ? result : result.toString(); } @@ -853,7 +853,7 @@ public class ShaderCode { * * @see IOUtil#getResource(Class, String) */ - public static ByteBuffer readShaderBinary(Class<?> context, String path) throws IOException { + public static ByteBuffer readShaderBinary(final Class<?> context, final String path) throws IOException { final URLConnection conn = IOUtil.getResource(context, path); if (conn == null) { return null; @@ -901,7 +901,7 @@ public class ShaderCode { * @param behavior shall be either {@link #REQUIRE}, {@link #ENABLE}, {@link #DISABLE} or {@link #WARN} * @return the complete extension directive */ - public static String createExtensionDirective(String extensionName, String behavior) { + public static String createExtensionDirective(final String extensionName, final String behavior) { return "#extension " + extensionName + " : " + behavior + "\n"; } @@ -913,7 +913,7 @@ public class ShaderCode { * @param gl a GL context, which must have been made current once * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ - public final int addGLSLVersion(GL2ES2 gl) { + public final int addGLSLVersion(final GL2ES2 gl) { return insertShaderSource(0, 0, gl.getContext().getGLSLVersionString()); } @@ -929,7 +929,7 @@ public class ShaderCode { * @param pos position within this mutable shader source. * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ - public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) { + public final int addDefaultShaderPrecision(final GL2ES2 gl, int pos) { final String defaultPrecision; if( gl.isGLES3() ) { switch ( shaderType ) { @@ -973,7 +973,7 @@ public class ShaderCode { } /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ - public static final boolean requiresDefaultPrecision(GL2ES2 gl) { + public static final boolean requiresDefaultPrecision(final GL2ES2 gl) { if( gl.isGLES() ) { return true; } @@ -981,7 +981,7 @@ public class ShaderCode { } /** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */ - public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) { + public static final boolean requiresGL3DefaultPrecision(final GL2ES2 gl) { if( gl.isGL3() ) { final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); return glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ; @@ -1005,7 +1005,7 @@ public class ShaderCode { * @see #addGLSLVersion(GL2ES2) * @see #addDefaultShaderPrecision(GL2ES2, int) */ - public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, boolean addDefaultPrecision) { + public final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final boolean addDefaultPrecision) { int pos; if( preludeVersion ) { pos = addGLSLVersion(gl); @@ -1031,7 +1031,7 @@ public class ShaderCode { * @see #addGLSLVersion(GL2ES2) * @see #addDefaultShaderPrecision(GL2ES2, int) */ - public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, String esDefaultPrecision) { + public final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final String esDefaultPrecision) { int pos; if( preludeVersion ) { pos = addGLSLVersion(gl); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java index 3ac17b0c5..a9b0bddc6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java @@ -65,7 +65,7 @@ public class ShaderProgram { * * @see #release(GL2ES2, boolean) */ - public synchronized void destroy(GL2ES2 gl) { + public synchronized void destroy(final GL2ES2 gl) { release(gl, true); } @@ -76,7 +76,7 @@ public class ShaderProgram { * * @see #release(GL2ES2, boolean) */ - public synchronized void release(GL2ES2 gl) { + public synchronized void release(final GL2ES2 gl) { release(gl, false); } @@ -84,12 +84,12 @@ public class ShaderProgram { * Detaches all shader codes and deletes the program. * If <code>destroyShaderCode</code> is true it destroys the shader codes as well. */ - public synchronized void release(GL2ES2 gl, boolean destroyShaderCode) { + public synchronized void release(final GL2ES2 gl, final boolean destroyShaderCode) { if( programLinked ) { useProgram(gl, false); } - for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { - ShaderCode shaderCode = iter.next(); + for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { + final ShaderCode shaderCode = iter.next(); if(attachedShaderCode.remove(shaderCode)) { ShaderUtil.detachShader(gl, shaderProgram, shaderCode.shader()); } @@ -115,11 +115,11 @@ public class ShaderProgram { * <p>This command does not compile and attach the shader, * use {@link #add(GL2ES2, ShaderCode)} for this purpose.</p> */ - public synchronized void add(ShaderCode shaderCode) throws GLException { + public synchronized void add(final ShaderCode shaderCode) throws GLException { allShaderCode.add(shaderCode); } - public synchronized boolean contains(ShaderCode shaderCode) { + public synchronized boolean contains(final ShaderCode shaderCode) { return allShaderCode.contains(shaderCode); } @@ -128,9 +128,9 @@ public class ShaderProgram { * @param id * @return */ - public synchronized ShaderCode getShader(int id) { - for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { - ShaderCode shaderCode = iter.next(); + public synchronized ShaderCode getShader(final int id) { + for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { + final ShaderCode shaderCode = iter.next(); if(shaderCode.id() == id) { return shaderCode; } @@ -149,7 +149,7 @@ public class ShaderProgram { * @param gl * @return true if shader program is valid, i.e. not zero */ - public synchronized final boolean init(GL2ES2 gl) { + public synchronized final boolean init(final GL2ES2 gl) { if( 0 == shaderProgram ) { shaderProgram = gl.glCreateProgram(); } @@ -163,7 +163,7 @@ public class ShaderProgram { * * @return true if the shader was successfully added, false if compilation failed. */ - public synchronized boolean add(GL2ES2 gl, ShaderCode shaderCode, PrintStream verboseOut) { + public synchronized boolean add(final GL2ES2 gl, final ShaderCode shaderCode, final PrintStream verboseOut) { if( !init(gl) ) { return false; } if( allShaderCode.add(shaderCode) ) { if( !shaderCode.compile(gl, verboseOut) ) { @@ -195,12 +195,12 @@ public class ShaderProgram { * @see ShaderState#glResetAllVertexAttributes * @see ShaderState#glResetAllVertexAttributes */ - public synchronized boolean replaceShader(GL2ES2 gl, ShaderCode oldShader, ShaderCode newShader, PrintStream verboseOut) { + public synchronized boolean replaceShader(final GL2ES2 gl, final ShaderCode oldShader, final ShaderCode newShader, final PrintStream verboseOut) { if(!init(gl) || !newShader.compile(gl, verboseOut)) { return false; } - boolean shaderWasInUse = inUse(); + final boolean shaderWasInUse = inUse(); if(shaderWasInUse) { useProgram(gl, false); } @@ -238,13 +238,13 @@ public class ShaderProgram { * * @see #init(GL2ES2) */ - public synchronized boolean link(GL2ES2 gl, PrintStream verboseOut) { + public synchronized boolean link(final GL2ES2 gl, final PrintStream verboseOut) { if( !init(gl) ) { programLinked = false; // mark unlinked due to user attempt to [re]link return false; } - for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { + for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { final ShaderCode shaderCode = iter.next(); if(!shaderCode.compile(gl, verboseOut)) { programLinked = false; // mark unlinked due to user attempt to [re]link @@ -264,7 +264,7 @@ public class ShaderProgram { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if(this == obj) { return true; } if(obj instanceof ShaderProgram) { return id()==((ShaderProgram)obj).id(); @@ -283,7 +283,7 @@ public class ShaderProgram { } sb.append("ShaderProgram[id=").append(id); sb.append(", linked="+programLinked+", inUse="+programInUse+", program: "+shaderProgram+","); - for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { + for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) { sb.append(Platform.getNewline()).append(" ").append(iter.next()); } sb.append("]"); @@ -299,11 +299,11 @@ public class ShaderProgram { * Performs {@link GL2ES2#glValidateProgram(int)} via {@link ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream)}. * @see ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream) **/ - public synchronized boolean validateProgram(GL2ES2 gl, PrintStream verboseOut) { + public synchronized boolean validateProgram(final GL2ES2 gl, final PrintStream verboseOut) { return ShaderUtil.isProgramExecStatusValid(gl, shaderProgram, verboseOut); } - public synchronized void useProgram(GL2ES2 gl, boolean on) { + public synchronized void useProgram(final GL2ES2 gl, boolean on) { if(!programLinked) { throw new GLException("Program is not linked"); } if(programInUse==on) { return; } if( 0 == shaderProgram ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index 64dd589b8..c841f2f09 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -41,6 +41,7 @@ import javax.media.opengl.GLUniformData; import jogamp.opengl.Debug; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.opengl.util.GLArrayDataEditable; /** @@ -60,7 +61,7 @@ public class ShaderState { static { Debug.initSingleton(); - DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); + DEBUG = PropertyAccess.isPropertyDefined("jogl.debug.GLSLState", true); } public ShaderState() { @@ -68,12 +69,12 @@ public class ShaderState { public boolean verbose() { return verbose; } - public void setVerbose(boolean v) { verbose = DEBUG || v; } + public void setVerbose(final boolean v) { verbose = DEBUG || v; } /** * Returns the attached user object for the given name to this ShaderState. */ - public final Object getAttachedObject(String name) { + public final Object getAttachedObject(final String name) { return attachedObjectsByString.get(name); } @@ -83,7 +84,7 @@ public class ShaderState { * * @return the previous mapped object or null if none */ - public final Object attachObject(String name, Object obj) { + public final Object attachObject(final String name, final Object obj) { return attachedObjectsByString.put(name, obj); } @@ -92,7 +93,7 @@ public class ShaderState { * * @return the previous mapped object or null if none */ - public final Object detachObject(String name) { + public final Object detachObject(final String name) { return attachedObjectsByString.remove(name); } @@ -103,7 +104,7 @@ public class ShaderState { * * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) */ - public synchronized void useProgram(GL2ES2 gl, boolean on) throws GLException { + public synchronized void useProgram(final GL2ES2 gl, final boolean on) throws GLException { if(null==shaderProgram) { throw new GLException("No program is attached"); } if(on) { if(shaderProgram.linked()) { @@ -154,10 +155,10 @@ public class ShaderState { * * @throws GLException if program was not linked and linking fails */ - public synchronized boolean attachShaderProgram(GL2ES2 gl, ShaderProgram prog, boolean enable) throws GLException { + public synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable) throws GLException { if(verbose) { - int curId = (null!=shaderProgram)?shaderProgram.id():-1; - int newId = (null!=prog)?prog.id():-1; + final int curId = (null!=shaderProgram)?shaderProgram.id():-1; + final int newId = (null!=prog)?prog.id():-1; System.err.println("ShaderState: attachShaderProgram: "+curId+" -> "+newId+" (enable: "+enable+")\n\t"+shaderProgram+"\n\t"+prog); if(DEBUG) { Thread.dumpStack(); @@ -213,7 +214,7 @@ public class ShaderState { * @see #glReleaseAllUniforms * @see #release(GL2ES2, boolean, boolean, boolean) */ - public synchronized void destroy(GL2ES2 gl) { + public synchronized void destroy(final GL2ES2 gl) { release(gl, true, true, true); attachedObjectsByString.clear(); } @@ -225,7 +226,7 @@ public class ShaderState { * @see #glReleaseAllUniforms * @see #release(GL2ES2, boolean, boolean, boolean) */ - public synchronized void releaseAllData(GL2ES2 gl) { + public synchronized void releaseAllData(final GL2ES2 gl) { release(gl, false, false, false); } @@ -234,12 +235,12 @@ public class ShaderState { * @see #glReleaseAllUniforms * @see ShaderProgram#release(GL2ES2, boolean) */ - public synchronized void release(GL2ES2 gl, boolean destroyBoundAttributes, boolean destroyShaderProgram, boolean destroyShaderCode) { + public synchronized void release(final GL2ES2 gl, final boolean destroyBoundAttributes, final boolean destroyShaderProgram, final boolean destroyShaderCode) { if(null!=shaderProgram && shaderProgram.linked() ) { shaderProgram.useProgram(gl, false); } if(destroyBoundAttributes) { - for(Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) { + for(final Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) { iter.next().destroy(gl); } } @@ -265,8 +266,8 @@ public class ShaderState { * @see #getAttribLocation(GL2ES2, String) * @see GL2ES2#glGetAttribLocation(int, String) */ - public int getCachedAttribLocation(String name) { - Integer idx = activeAttribLocationMap.get(name); + public int getCachedAttribLocation(final String name) { + final Integer idx = activeAttribLocationMap.get(name); return (null!=idx)?idx.intValue():-1; } @@ -285,11 +286,11 @@ public class ShaderState { * @see #glResetAllVertexAttributes * @see ShaderProgram#glReplaceShader */ - public GLArrayData getAttribute(String name) { + public GLArrayData getAttribute(final String name) { return activeAttribDataMap.get(name); } - public boolean isActiveAttribute(GLArrayData attribute) { + public boolean isActiveAttribute(final GLArrayData attribute) { return attribute == activeAttribDataMap.get(attribute.getName()); } @@ -313,7 +314,7 @@ public class ShaderState { * @see #getAttribute(String) * @see GLArrayData#associate(Object, boolean) */ - public void ownAttribute(GLArrayData attribute, boolean own) { + public void ownAttribute(final GLArrayData attribute, final boolean own) { if(own) { final int location = getCachedAttribLocation(attribute.getName()); if(0<=location) { @@ -326,7 +327,7 @@ public class ShaderState { attribute.associate(this, own); } - public boolean ownsAttribute(GLArrayData attribute) { + public boolean ownsAttribute(final GLArrayData attribute) { return managedAttributes.contains(attribute); } @@ -343,7 +344,7 @@ public class ShaderState { * @see #getAttribLocation(GL2ES2, String) * @see #getCachedAttribLocation(String) */ - public void bindAttribLocation(GL2ES2 gl, int location, String name) { + public void bindAttribLocation(final GL2ES2 gl, final int location, final String name) { if(null==shaderProgram) throw new GLException("No program is attached"); if(shaderProgram.linked()) throw new GLException("Program is already linked"); final Integer loc = new Integer(location); @@ -366,7 +367,7 @@ public class ShaderState { * @see #getCachedAttribLocation(String) * @see #getAttribute(String) */ - public void bindAttribLocation(GL2ES2 gl, int location, GLArrayData data) { + public void bindAttribLocation(final GL2ES2 gl, final int location, final GLArrayData data) { if(null==shaderProgram) throw new GLException("No program is attached"); if(shaderProgram.linked()) throw new GLException("Program is already linked"); final String name = data.getName(); @@ -391,7 +392,7 @@ public class ShaderState { * @see #bindAttribLocation(GL2ES2, int, String) * @see GL2ES2#glGetAttribLocation(int, String) */ - public int getAttribLocation(GL2ES2 gl, String name) { + public int getAttribLocation(final GL2ES2 gl, final String name) { if(null==shaderProgram) throw new GLException("No program is attached"); int location = getCachedAttribLocation(name); if(0>location) { @@ -431,7 +432,7 @@ public class ShaderState { * @see GL2ES2#glGetAttribLocation(int, String) * @see #getAttribute(String) */ - public int getAttribLocation(GL2ES2 gl, GLArrayData data) { + public int getAttribLocation(final GL2ES2 gl, final GLArrayData data) { if(null==shaderProgram) throw new GLException("No program is attached"); final String name = data.getName(); int location = getCachedAttribLocation(name); @@ -441,7 +442,7 @@ public class ShaderState { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); location = data.setLocation(gl, shaderProgram.program()); if(0<=location) { - Integer idx = new Integer(location); + final Integer idx = new Integer(location); activeAttribLocationMap.put(name, idx); if(DEBUG) { System.err.println("ShaderState: glGetAttribLocation: "+name+", loc: "+location); @@ -464,7 +465,7 @@ public class ShaderState { /** * @return true if the named attribute is enable */ - public final boolean isVertexAttribArrayEnabled(String name) { + public final boolean isVertexAttribArrayEnabled(final String name) { final Boolean v = activedAttribEnabledMap.get(name); return null != v && v.booleanValue(); } @@ -472,11 +473,11 @@ public class ShaderState { /** * @return true if the {@link GLArrayData} attribute is enable */ - public final boolean isVertexAttribArrayEnabled(GLArrayData data) { + public final boolean isVertexAttribArrayEnabled(final GLArrayData data) { return isVertexAttribArrayEnabled(data.getName()); } - private boolean enableVertexAttribArray(GL2ES2 gl, String name, int location) { + private boolean enableVertexAttribArray(final GL2ES2 gl, final String name, int location) { activedAttribEnabledMap.put(name, Boolean.TRUE); if(0>location) { location = getAttribLocation(gl, name); @@ -515,7 +516,7 @@ public class ShaderState { * @see #glVertexAttribPointer * @see #getVertexAttribPointer */ - public boolean enableVertexAttribArray(GL2ES2 gl, String name) { + public boolean enableVertexAttribArray(final GL2ES2 gl, final String name) { return enableVertexAttribArray(gl, name, -1); } @@ -541,7 +542,7 @@ public class ShaderState { * @see #getVertexAttribPointer * @see GLArrayDataEditable#enableBuffer(GL, boolean) */ - public boolean enableVertexAttribArray(GL2ES2 gl, GLArrayData data) { + public boolean enableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) { if(0 > data.getLocation()) { getAttribLocation(gl, data); } else { @@ -551,7 +552,7 @@ public class ShaderState { return enableVertexAttribArray(gl, data.getName(), data.getLocation()); } - private boolean disableVertexAttribArray(GL2ES2 gl, String name, int location) { + private boolean disableVertexAttribArray(final GL2ES2 gl, final String name, int location) { activedAttribEnabledMap.put(name, Boolean.FALSE); if(0>location) { location = getAttribLocation(gl, name); @@ -591,7 +592,7 @@ public class ShaderState { * @see #glVertexAttribPointer * @see #getVertexAttribPointer */ - public boolean disableVertexAttribArray(GL2ES2 gl, String name) { + public boolean disableVertexAttribArray(final GL2ES2 gl, final String name) { return disableVertexAttribArray(gl, name, -1); } @@ -616,7 +617,7 @@ public class ShaderState { * @see #glVertexAttribPointer * @see #getVertexAttribPointer */ - public boolean disableVertexAttribArray(GL2ES2 gl, GLArrayData data) { + public boolean disableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) { if(0 > data.getLocation()) { getAttribLocation(gl, data); } @@ -641,7 +642,7 @@ public class ShaderState { * @see #glVertexAttribPointer * @see #getVertexAttribPointer */ - public boolean vertexAttribPointer(GL2ES2 gl, GLArrayData data) { + public boolean vertexAttribPointer(final GL2ES2 gl, final GLArrayData data) { int location = data.getLocation(); if(0 > location) { location = getAttribLocation(gl, data); @@ -670,12 +671,12 @@ public class ShaderState { * @see #glResetAllVertexAttributes * @see ShaderProgram#glReplaceShader */ - public void releaseAllAttributes(GL2ES2 gl) { + public void releaseAllAttributes(final GL2ES2 gl) { if(null!=shaderProgram) { - for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { + for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { disableVertexAttribArray(gl, iter.next()); } - for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) { + for(final Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) { disableVertexAttribArray(gl, iter.next()); } } @@ -702,8 +703,8 @@ public class ShaderState { * @see #glResetAllVertexAttributes * @see ShaderProgram#glReplaceShader */ - public void disableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState) { - for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) { + public void disableAllVertexAttributeArrays(final GL2ES2 gl, final boolean removeFromState) { + for(final Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) { final String name = iter.next(); if(removeFromState) { activedAttribEnabledMap.remove(name); @@ -715,7 +716,7 @@ public class ShaderState { } } - private final void relocateAttribute(GL2ES2 gl, GLArrayData attribute) { + private final void relocateAttribute(final GL2ES2 gl, final GLArrayData attribute) { // get new location .. note: 'activeAttribLocationMap' is cleared before final String name = attribute.getName(); final int loc = attribute.setLocation(gl, shaderProgram.program()); @@ -760,19 +761,19 @@ public class ShaderState { * * @see #attachShaderProgram(GL2ES2, ShaderProgram) */ - private final void resetAllAttributes(GL2ES2 gl) { + private final void resetAllAttributes(final GL2ES2 gl) { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); activeAttribLocationMap.clear(); for(int i=0; i<managedAttributes.size(); i++) { managedAttributes.get(i).setLocation(-1); } - for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { + for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { relocateAttribute(gl, iter.next()); } } - private final void setAttribute(GL2ES2 gl, GLArrayData attribute) { + private final void setAttribute(final GL2ES2 gl, final GLArrayData attribute) { // get new location .. final String name = attribute.getName(); final int loc = attribute.getLocation(); @@ -798,8 +799,8 @@ public class ShaderState { /** * preserves the attribute location .. (program not linked) */ - private final void setAllAttributes(GL2ES2 gl) { - for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { + private final void setAllAttributes(final GL2ES2 gl) { + for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { setAttribute(gl, iter.next()); } } @@ -814,8 +815,8 @@ public class ShaderState { * @return -1 if there is no such uniform available, * otherwise >= 0 */ - public final int getCachedUniformLocation(String name) { - Integer idx = activeUniformLocationMap.get(name); + public final int getCachedUniformLocation(final String name) { + final Integer idx = activeUniformLocationMap.get(name); return (null!=idx)?idx.intValue():-1; } @@ -833,7 +834,7 @@ public class ShaderState { * * @see #getUniform(String) */ - public void ownUniform(GLUniformData uniform) { + public void ownUniform(final GLUniformData uniform) { final int location = getCachedUniformLocation(uniform.getName()); if(0<=location) { uniform.setLocation(location); @@ -842,7 +843,7 @@ public class ShaderState { managedUniforms.add(uniform); } - public boolean ownsUniform(GLUniformData uniform) { + public boolean ownsUniform(final GLUniformData uniform) { return managedUniforms.contains(uniform); } @@ -865,14 +866,14 @@ public class ShaderState { * @see #getUniformLocation * @see ShaderProgram#glReplaceShader */ - public final int getUniformLocation(GL2ES2 gl, String name) { + public final int getUniformLocation(final GL2ES2 gl, final String name) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); int location = getCachedUniformLocation(name); if(0>location) { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); location = gl.glGetUniformLocation(shaderProgram.program(), name); if(0<=location) { - Integer idx = new Integer(location); + final Integer idx = new Integer(location); activeUniformLocationMap.put(name, idx); } else if(verbose) { System.err.println("ShaderState: glUniform failed, no location for: "+name+", index: "+location); @@ -904,7 +905,7 @@ public class ShaderState { * @see #getUniformLocation * @see ShaderProgram#glReplaceShader */ - public int getUniformLocation(GL2ES2 gl, GLUniformData data) { + public int getUniformLocation(final GL2ES2 gl, final GLUniformData data) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); final String name = data.getName(); int location = getCachedUniformLocation(name); @@ -942,7 +943,7 @@ public class ShaderState { * @see #getUniformLocation * @see ShaderProgram#glReplaceShader */ - public boolean uniform(GL2ES2 gl, GLUniformData data) { + public boolean uniform(final GL2ES2 gl, final GLUniformData data) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); int location = data.getLocation(); if(0>location) { @@ -964,7 +965,7 @@ public class ShaderState { * * @return the GLUniformData object, null if not previously set. */ - public GLUniformData getUniform(String name) { + public GLUniformData getUniform(final String name) { return activeUniformDataMap.get(name); } @@ -972,7 +973,7 @@ public class ShaderState { * Releases all mapped uniform data * and loses all indices */ - public void releaseAllUniforms(GL2ES2 gl) { + public void releaseAllUniforms(final GL2ES2 gl) { activeUniformDataMap.clear(); activeUniformLocationMap.clear(); managedUniforms.clear(); @@ -993,13 +994,13 @@ public class ShaderState { * * @see #attachShaderProgram(GL2ES2, ShaderProgram) */ - private final void resetAllUniforms(GL2ES2 gl) { + private final void resetAllUniforms(final GL2ES2 gl) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); activeUniformLocationMap.clear(); - for(Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) { + for(final Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) { iter.next().setLocation(-1); } - for(Iterator<GLUniformData> iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) { + for(final Iterator<GLUniformData> iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) { final GLUniformData data = iter.next(); final int loc = data.setLocation(gl, shaderProgram.program()); if( 0 <= loc ) { @@ -1013,7 +1014,7 @@ public class ShaderState { } } - public StringBuilder toString(StringBuilder sb, boolean alsoUnlocated) { + public StringBuilder toString(StringBuilder sb, final boolean alsoUnlocated) { if(null==sb) { sb = new StringBuilder(); } @@ -1028,35 +1029,35 @@ public class ShaderState { } sb.append(Platform.getNewline()).append(" enabledAttributes ["); { - Iterator<String> names = activedAttribEnabledMap.keySet().iterator(); - Iterator<Boolean> values = activedAttribEnabledMap.values().iterator(); + final Iterator<String> names = activedAttribEnabledMap.keySet().iterator(); + final Iterator<Boolean> values = activedAttribEnabledMap.values().iterator(); while( names.hasNext() ) { sb.append(Platform.getNewline()).append(" ").append(names.next()).append(": ").append(values.next()); } } sb.append(Platform.getNewline()).append(" ],").append(" activeAttributes ["); - for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { + for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) { final GLArrayData ad = iter.next(); if( alsoUnlocated || 0 <= ad.getLocation() ) { sb.append(Platform.getNewline()).append(" ").append(ad); } } sb.append(Platform.getNewline()).append(" ],").append(" managedAttributes ["); - for(Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) { + for(final Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) { final GLArrayData ad = iter.next(); if( alsoUnlocated || 0 <= ad.getLocation() ) { sb.append(Platform.getNewline()).append(" ").append(ad); } } sb.append(Platform.getNewline()).append(" ],").append(" activeUniforms ["); - for(Iterator<GLUniformData> iter=activeUniformDataMap.values().iterator(); iter.hasNext(); ) { + for(final Iterator<GLUniformData> iter=activeUniformDataMap.values().iterator(); iter.hasNext(); ) { final GLUniformData ud = iter.next(); if( alsoUnlocated || 0 <= ud.getLocation() ) { sb.append(Platform.getNewline()).append(" ").append(ud); } } sb.append(Platform.getNewline()).append(" ],").append(" managedUniforms ["); - for(Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) { + for(final Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) { final GLUniformData ud = iter.next(); if( alsoUnlocated || 0 <= ud.getLocation() ) { sb.append(Platform.getNewline()).append(" ").append(ud); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java index 5cd384c58..b927e8ceb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java @@ -43,49 +43,49 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.GLExtensions; public class ShaderUtil { - public static String getShaderInfoLog(GL _gl, int shaderObj) { + public static String getShaderInfoLog(final GL _gl, final int shaderObj) { final GL2ES2 gl = _gl.getGL2ES2(); - int[] infoLogLength=new int[1]; + final int[] infoLogLength=new int[1]; gl.glGetShaderiv(shaderObj, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0); if(infoLogLength[0]==0) { return "(no info log)"; } - int[] charsWritten=new int[1]; - byte[] infoLogBytes = new byte[infoLogLength[0]]; + final int[] charsWritten=new int[1]; + final byte[] infoLogBytes = new byte[infoLogLength[0]]; gl.glGetShaderInfoLog(shaderObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0); return new String(infoLogBytes, 0, charsWritten[0]); } - public static String getProgramInfoLog(GL _gl, int programObj) { + public static String getProgramInfoLog(final GL _gl, final int programObj) { final GL2ES2 gl = _gl.getGL2ES2(); - int[] infoLogLength=new int[1]; + final int[] infoLogLength=new int[1]; gl.glGetProgramiv(programObj, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0); if(infoLogLength[0]==0) { return "(no info log)"; } - int[] charsWritten=new int[1]; - byte[] infoLogBytes = new byte[infoLogLength[0]]; + final int[] charsWritten=new int[1]; + final byte[] infoLogBytes = new byte[infoLogLength[0]]; gl.glGetProgramInfoLog(programObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0); return new String(infoLogBytes, 0, charsWritten[0]); } - public static boolean isShaderStatusValid(GL _gl, int shaderObj, int name, PrintStream verboseOut) { + public static boolean isShaderStatusValid(final GL _gl, final int shaderObj, final int name, final PrintStream verboseOut) { final GL2ES2 gl = _gl.getGL2ES2(); - int[] ires = new int[1]; + final int[] ires = new int[1]; gl.glGetShaderiv(shaderObj, name, ires, 0); - boolean res = ires[0]==1; + final boolean res = ires[0]==1; if(!res && null!=verboseOut) { verboseOut.println("Shader status invalid: "+ getShaderInfoLog(gl, shaderObj)); } return res; } - public static boolean isShaderStatusValid(GL _gl, IntBuffer shaders, int name, PrintStream verboseOut) { + public static boolean isShaderStatusValid(final GL _gl, final IntBuffer shaders, final int name, final PrintStream verboseOut) { boolean res = true; for (int i = shaders.position(); i < shaders.limit(); i++) { res = isShaderStatusValid(_gl, shaders.get(i), name, verboseOut) && res; @@ -93,15 +93,15 @@ public class ShaderUtil { return res; } - public static boolean isProgramStatusValid(GL _gl, int programObj, int name) { + public static boolean isProgramStatusValid(final GL _gl, final int programObj, final int name) { final GL2ES2 gl = _gl.getGL2ES2(); - int[] ires = new int[1]; + final int[] ires = new int[1]; gl.glGetProgramiv(programObj, name, ires, 0); return ires[0]==1; } - public static boolean isProgramLinkStatusValid(GL _gl, int programObj, PrintStream verboseOut) { + public static boolean isProgramLinkStatusValid(final GL _gl, final int programObj, final PrintStream verboseOut) { final GL2ES2 gl = _gl.getGL2ES2(); if(!gl.glIsProgram(programObj)) { if(null!=verboseOut) { @@ -130,7 +130,7 @@ public class ShaderUtil { * </p> * @see GL2ES2#glValidateProgram(int) **/ - public static boolean isProgramExecStatusValid(GL _gl, int programObj, PrintStream verboseOut) { + public static boolean isProgramExecStatusValid(final GL _gl, final int programObj, final PrintStream verboseOut) { final GL2ES2 gl = _gl.getGL2ES2(); gl.glValidateProgram(programObj); if(!isProgramStatusValid(gl, programObj, GL2ES2.GL_VALIDATE_STATUS)) { @@ -142,7 +142,7 @@ public class ShaderUtil { return true; } - public static void createShader(GL _gl, int type, IntBuffer shaders) { + public static void createShader(final GL _gl, final int type, final IntBuffer shaders) { final GL2ES2 gl = _gl.getGL2ES2(); for (int i = shaders.position(); i < shaders.limit(); i++) { shaders.put(i, gl.glCreateShader(type)); @@ -154,7 +154,7 @@ public class ShaderUtil { * {@link GL2ES2#GL_NUM_SHADER_BINARY_FORMATS} and {@link GL2ES2#GL_SHADER_BINARY_FORMATS} * via {@link GL2ES2#glGetIntegerv(int, int[], int)}. */ - public static Set<Integer> getShaderBinaryFormats(GL _gl) { + public static Set<Integer> getShaderBinaryFormats(final GL _gl) { final GL2ES2 gl = _gl.getGL2ES2(); final ProfileInformation info = getProfileInformation(gl); if(null == info.shaderBinaryFormats) { @@ -166,14 +166,14 @@ public class ShaderUtil { final int err = gl.glGetError(); final int numFormats = GL.GL_NO_ERROR == err ? param[0] : 0; if(numFormats>0) { - int[] formats = new int[numFormats]; + final int[] formats = new int[numFormats]; gl.glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0); for(int i=0; i<numFormats; i++) { info.shaderBinaryFormats.add(new Integer(formats[i])); } } - } catch (GLException gle) { - System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); + } catch (final GLException gle) { + System.err.println("Caught exception on thread "+Thread.currentThread().getName()); gle.printStackTrace(); } } @@ -182,7 +182,7 @@ public class ShaderUtil { } /** Returns true if a hader compiler is available, otherwise false. */ - public static boolean isShaderCompilerAvailable(GL _gl) { + public static boolean isShaderCompilerAvailable(final GL _gl) { final GL2ES2 gl = _gl.getGL2ES2(); final ProfileInformation info = getProfileInformation(gl); if(null==info.shaderCompilerAvailable) { @@ -202,8 +202,8 @@ public class ShaderUtil { } info.shaderCompilerAvailable = new Boolean(v); queryOK = true; - } catch (GLException gle) { - System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); + } catch (final GLException gle) { + System.err.println("Caught exception on thread "+Thread.currentThread().getName()); gle.printStackTrace(); } if(!queryOK) { @@ -219,25 +219,25 @@ public class ShaderUtil { } /** Returns true if GeometryShader is supported, i.e. whether GLContext is ≥ 3.2 or ARB_geometry_shader4 extension is available. */ - public static boolean isGeometryShaderSupported(GL _gl) { + public static boolean isGeometryShaderSupported(final GL _gl) { final GLContext ctx = _gl.getContext(); return ctx.getGLVersionNumber().compareTo(GLContext.Version320) >= 0 || ctx.isExtensionAvailable(GLExtensions.ARB_geometry_shader4); } - public static void shaderSource(GL _gl, int shader, CharSequence[] source) + public static void shaderSource(final GL _gl, final int shader, final CharSequence[] source) { final GL2ES2 gl = _gl.getGL2ES2(); if(!isShaderCompilerAvailable(_gl)) { throw new GLException("No compiler is available"); } - int count = (null!=source)?source.length:0; + final int count = (null!=source)?source.length:0; if(count==0) { throw new GLException("No sources specified"); } - IntBuffer lengths = Buffers.newDirectIntBuffer(count); + final IntBuffer lengths = Buffers.newDirectIntBuffer(count); for(int i=0; i<count; i++) { lengths.put(i, source[i].length()); } @@ -260,10 +260,10 @@ public class ShaderUtil { } } - public static void shaderSource(GL _gl, IntBuffer shaders, CharSequence[][] sources) + public static void shaderSource(final GL _gl, final IntBuffer shaders, final CharSequence[][] sources) { - int sourceNum = (null!=sources)?sources.length:0; - int shaderNum = (null!=shaders)?shaders.remaining():0; + final int sourceNum = (null!=sources)?sources.length:0; + final int shaderNum = (null!=shaders)?shaders.remaining():0; if(shaderNum<=0 || sourceNum<=0 || shaderNum!=sourceNum) { throw new GLException("Invalid number of shaders and/or sources: shaders="+ shaderNum+", sources="+sourceNum); @@ -273,28 +273,28 @@ public class ShaderUtil { } } - public static void shaderBinary(GL _gl, IntBuffer shaders, int binFormat, java.nio.Buffer bin) + public static void shaderBinary(final GL _gl, final IntBuffer shaders, final int binFormat, final java.nio.Buffer bin) { final GL2ES2 gl = _gl.getGL2ES2(); if(getShaderBinaryFormats(gl).size()<=0) { throw new GLException("No binary formats are supported"); } - int shaderNum = shaders.remaining(); + final int shaderNum = shaders.remaining(); if(shaderNum<=0) { throw new GLException("No shaders specified"); } if(null==bin) { throw new GLException("Null shader binary"); } - int binLength = bin.remaining(); + final int binLength = bin.remaining(); if(0>=binLength) { throw new GLException("Empty shader binary (remaining == 0)"); } gl.glShaderBinary(shaderNum, shaders, binFormat, bin, binLength); } - public static void compileShader(GL _gl, IntBuffer shaders) + public static void compileShader(final GL _gl, final IntBuffer shaders) { final GL2ES2 gl = _gl.getGL2ES2(); for (int i = shaders.position(); i < shaders.limit(); i++) { @@ -302,7 +302,7 @@ public class ShaderUtil { } } - public static void attachShader(GL _gl, int program, IntBuffer shaders) + public static void attachShader(final GL _gl, final int program, final IntBuffer shaders) { final GL2ES2 gl = _gl.getGL2ES2(); for (int i = shaders.position(); i < shaders.limit(); i++) { @@ -310,7 +310,7 @@ public class ShaderUtil { } } - public static void detachShader(GL _gl, int program, IntBuffer shaders) + public static void detachShader(final GL _gl, final int program, final IntBuffer shaders) { final GL2ES2 gl = _gl.getGL2ES2(); for (int i = shaders.position(); i < shaders.limit(); i++) { @@ -318,7 +318,7 @@ public class ShaderUtil { } } - public static void deleteShader(GL _gl, IntBuffer shaders) + public static void deleteShader(final GL _gl, final IntBuffer shaders) { final GL2ES2 gl = _gl.getGL2ES2(); for (int i = shaders.position(); i < shaders.limit(); i++) { @@ -327,9 +327,9 @@ public class ShaderUtil { } } - public static boolean createAndLoadShader(GL _gl, IntBuffer shader, int shaderType, - int binFormat, java.nio.Buffer bin, - PrintStream verboseOut) + public static boolean createAndLoadShader(final GL _gl, final IntBuffer shader, final int shaderType, + final int binFormat, final java.nio.Buffer bin, + final PrintStream verboseOut) { final GL2ES2 gl = _gl.getGL2ES2(); int err = gl.glGetError(); // flush previous errors .. @@ -352,9 +352,9 @@ public class ShaderUtil { return err == GL.GL_NO_ERROR; } - public static boolean createAndCompileShader(GL _gl, IntBuffer shader, int shaderType, - CharSequence[][] sources, - PrintStream verboseOut) + public static boolean createAndCompileShader(final GL _gl, final IntBuffer shader, final int shaderType, + final CharSequence[][] sources, + final PrintStream verboseOut) { final GL2ES2 gl = _gl.getGL2ES2(); int err = gl.glGetError(); // flush previous errors .. @@ -390,7 +390,7 @@ public class ShaderUtil { Set<Integer> shaderBinaryFormats = null; } - private static ProfileInformation getProfileInformation(GL gl) { + private static ProfileInformation getProfileInformation(final GL gl) { final GLContext context = gl.getContext(); context.validateCurrent(); ProfileInformation data = (ProfileInformation) context.getAttachedObject(implObjectKey); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java index 2f8884a3a..1ed875f27 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java @@ -37,7 +37,7 @@ public class FixedFuncUtil { * @see ShaderSelectionMode#COLOR_TEXTURE * @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX */ - public static final GL2ES1 wrapFixedFuncEmul(GL gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, boolean force, boolean verbose) { + public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, final boolean force, final boolean verbose) { if(gl.isGL2ES2() && ( !gl.isGL2ES1() || force ) ) { final GL2ES2 es2 = gl.getGL2ES2(); final FixedFuncHook hook = new FixedFuncHook(es2, mode, pmvMatrix); @@ -66,7 +66,7 @@ public class FixedFuncUtil { * @see ShaderSelectionMode#COLOR_TEXTURE * @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX */ - public static final GL2ES1 wrapFixedFuncEmul(GL gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) { + public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) { return wrapFixedFuncEmul(gl, mode, null, false, false); } @@ -90,7 +90,7 @@ public class FixedFuncUtil { * @see javax.media.opengl.fixedfunc.GLPointerFunc#glNormalPointer * @see javax.media.opengl.fixedfunc.GLPointerFunc#glTexCoordPointer */ - public static String getPredefinedArrayIndexName(int glArrayIndex) { + public static String getPredefinedArrayIndexName(final int glArrayIndex) { return GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java index 44fbf1c6d..f113be2b2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java @@ -30,7 +30,7 @@ public abstract class CompileShader { public abstract String getFragmentShaderCompiler(); - public void processOneShader(String resourceName) + public void processOneShader(final String resourceName) throws IOException, UnsupportedEncodingException, InterruptedException { int type = -1; @@ -49,11 +49,11 @@ public abstract class CompileShader { suffixLen = 4; type = GL2ES2.GL_VERTEX_SHADER; } - String justName = basename(resourceName); + final String justName = basename(resourceName); outName = justName.substring(0, justName.length() - suffixLen) + ShaderCode.getFileSuffix(true, type); - URL resourceURL = IOUtil.getResource(null, resourceName).getURL(); - String dirName = dirname(resourceURL.getPath()); + final URL resourceURL = IOUtil.getResource(null, resourceName).getURL(); + final String dirName = dirname(resourceURL.getPath()); outName = dirName + File.separator + "bin" + File.separator + ShaderCode.getBinarySubPath(getBinaryFormat()) + File.separator + @@ -61,19 +61,19 @@ public abstract class CompileShader { processOneShader(resourceName, outName, type); } - public void processOneShader(String resourceName, String outName, int type) + public void processOneShader(final String resourceName, final String outName, final int type) throws IOException, UnsupportedEncodingException, InterruptedException { - URL resourceURL = IOUtil.getResource(null, resourceName).getURL(); - String dirName = dirname(resourceURL.getPath()); + final URL resourceURL = IOUtil.getResource(null, resourceName).getURL(); + final String dirName = dirname(resourceURL.getPath()); - CharSequence shader = ShaderCode.readShaderSource(null, resourceName, false); + final CharSequence shader = ShaderCode.readShaderSource(null, resourceName, false); if(null==shader) { System.err.println("Can't find shader source " + resourceName + " - ignored"); return; } System.err.println("Preprocessing: "+ resourceName+", in dir: "+dirName); - String justName = basename(resourceName); + final String justName = basename(resourceName); String processor; switch (type) { case GL2ES2.GL_VERTEX_SHADER: @@ -85,26 +85,26 @@ public abstract class CompileShader { default: throw new GLException("Unknown shader type: "+type); } - File outputFile = new File(outName); + final File outputFile = new File(outName); // Write shader to a file in java.io.tmpdir - File tmpDir = new File(dirName+File.separator+"tmp"); + final File tmpDir = new File(dirName+File.separator+"tmp"); tmpDir.mkdirs(); - File tmpFile = new File(tmpDir, justName); - Writer writer = new BufferedWriter(new FileWriter(tmpFile)); + final File tmpFile = new File(tmpDir, justName); + final Writer writer = new BufferedWriter(new FileWriter(tmpFile)); writer.write(shader.toString(), 0, shader.length()); writer.flush(); writer.close(); System.err.println("Preprocessed: "+ tmpFile.getAbsolutePath()); - File processorDir = getSDKCompilerDir(); + final File processorDir = getSDKCompilerDir(); System.err.println("SDK: "+ processorDir.getAbsolutePath() + ", compiler: "+processor); System.err.println("Output: "+ outputFile.getAbsolutePath()); // Run the tool - Process process = Runtime.getRuntime().exec(new String[] { + final Process process = Runtime.getRuntime().exec(new String[] { processorDir.getAbsolutePath() + File.separator + processor, tmpFile.getAbsolutePath(), outputFile.getAbsolutePath() @@ -116,7 +116,7 @@ public abstract class CompileShader { // tmpFile.delete(); } - protected static String basename(String path) { + protected static String basename(final String path) { int lastSlash = path.lastIndexOf("/"); if (lastSlash < 0) { lastSlash = path.lastIndexOf("\\"); @@ -130,7 +130,7 @@ public abstract class CompileShader { return basename; } - protected static String dirname(String path) { + protected static String dirname(final String path) { int lastSlash = path.lastIndexOf("/"); if (lastSlash < 0) { lastSlash = path.lastIndexOf("\\"); @@ -144,19 +144,19 @@ public abstract class CompileShader { return dirname; } - public void run(String[] args) { + public void run(final String[] args) { try { for (int i = 0; i < args.length; i++) { processOneShader(args[i]); } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } private static class StreamMonitor implements Runnable { - private InputStream istream; - public StreamMonitor(InputStream stream) { + private final InputStream istream; + public StreamMonitor(final InputStream stream) { istream = stream; new Thread(this, "Output Reader Thread").start(); } @@ -164,7 +164,7 @@ public abstract class CompileShader { @Override public void run() { - byte[] buffer = new byte[4096]; + final byte[] buffer = new byte[4096]; try { int numRead = 0; do { @@ -175,10 +175,10 @@ public abstract class CompileShader { } } while (numRead >= 0); } - catch (IOException e) { + catch (final IOException e) { try { istream.close(); - } catch (IOException e2) { + } catch (final IOException e2) { } // Should allow clean exit when process shuts down } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java index 215cf592b..9ff37c7ee 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java @@ -13,7 +13,7 @@ public class CompileShaderNVidia extends CompileShader { private static final String NVAPSDK; static { - String nvapSDKProp = System.getProperty("NVAPSDK"); + final String nvapSDKProp = System.getProperty("NVAPSDK"); if (nvapSDKProp != null) { NVAPSDK = nvapSDKProp; } else { @@ -51,7 +51,7 @@ public class CompileShaderNVidia extends CompileShader { return "glslf.bat"; } - public static void main(String[] args) { + public static void main(final String[] args) { new CompileShaderNVidia().run(args); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java index 9aadfba93..e694f1b33 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java @@ -42,29 +42,29 @@ package com.jogamp.opengl.util.packrect; import java.util.*; public class Level { - private int width; + private final int width; private int height; - private int yPos; - private LevelSet holder; + private final int yPos; + private final LevelSet holder; - private List<Rect> rects = new ArrayList<Rect>(); + private final List<Rect> rects = new ArrayList<Rect>(); private List<Rect> freeList; private int nextAddX; static class RectXComparator implements Comparator<Rect> { @Override - public int compare(Rect r1, Rect r2) { + public int compare(final Rect r1, final Rect r2) { return r1.x() - r2.x(); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { return this == obj; } } private static final Comparator<Rect> rectXComparator = new RectXComparator(); - public Level(int width, int height, int yPos, LevelSet holder) { + public Level(final int width, final int height, final int yPos, final LevelSet holder) { this.width = width; this.height = height; this.yPos = yPos; @@ -80,7 +80,7 @@ public class Level { in the RectanglePacker and allocation from the free list. More disruptive changes like compaction of the level must be requested explicitly. */ - public boolean add(Rect rect) { + public boolean add(final Rect rect) { if (rect.h() > height) { // See whether it's worth trying to expand vertically if (nextAddX + rect.w() > width) { @@ -108,8 +108,8 @@ public class Level { // See whether we can add from the free list if (freeList != null) { Rect candidate = null; - for (Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = iter.next(); + for (final Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { + final Rect cur = iter.next(); if (cur.canContain(rect)) { candidate = cur; break; @@ -139,7 +139,7 @@ public class Level { } /** Removes the given Rect from this Level. */ - public boolean remove(Rect rect) { + public boolean remove(final Rect rect) { if (!rects.remove(rect)) return false; @@ -165,14 +165,14 @@ public class Level { /** Indicates whether this Level could satisfy an allocation request if it were compacted. */ - public boolean couldAllocateIfCompacted(Rect rect) { + public boolean couldAllocateIfCompacted(final Rect rect) { if (rect.h() > height) return false; if (freeList == null) return false; int freeListWidth = 0; - for (Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = iter.next(); + for (final Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { + final Rect cur = iter.next(); freeListWidth += cur.w(); } // Add on the remaining space at the end @@ -180,12 +180,12 @@ public class Level { return (freeListWidth >= rect.w()); } - public void compact(Object backingStore, BackingStoreManager manager) { + public void compact(final Object backingStore, final BackingStoreManager manager) { Collections.sort(rects, rectXComparator); int nextCompactionDest = 0; manager.beginMovement(backingStore, backingStore); - for (Iterator<Rect> iter = rects.iterator(); iter.hasNext(); ) { - Rect cur = iter.next(); + for (final Iterator<Rect> iter = rects.iterator(); iter.hasNext(); ) { + final Rect cur = iter.next(); if (cur.x() != nextCompactionDest) { manager.move(backingStore, cur, backingStore, new Rect(nextCompactionDest, cur.y(), cur.w(), cur.h(), null)); @@ -203,9 +203,9 @@ public class Level { } /** Visits all Rects contained in this Level. */ - public void visit(RectVisitor visitor) { - for (Iterator<Rect> iter = rects.iterator(); iter.hasNext(); ) { - Rect rect = iter.next(); + public void visit(final RectVisitor visitor) { + for (final Iterator<Rect> iter = rects.iterator(); iter.hasNext(); ) { + final Rect rect = iter.next(); visitor.visit(rect); } } @@ -216,8 +216,8 @@ public class Level { original Rects. */ public void updateRectangleReferences() { for (int i = 0; i < rects.size(); i++) { - Rect cur = rects.get(i); - Rect next = cur.getNextLocation(); + final Rect cur = rects.get(i); + final Rect next = cur.getNextLocation(); next.setPosition(cur.x(), cur.y()); if (cur.w() != next.w() || cur.h() != next.h()) throw new RuntimeException("Unexpected disparity in rectangle sizes during updateRectangleReferences"); @@ -235,8 +235,8 @@ public class Level { Collections.sort(freeList, rectXComparator); int i = 0; while (i < freeList.size() - 1) { - Rect r1 = freeList.get(i); - Rect r2 = freeList.get(i+1); + final Rect r1 = freeList.get(i); + final Rect r2 = freeList.get(i+1); if (r1.maxX() + 1 == r2.x()) { // Coalesce r1 and r2 into one block freeList.remove(i+1); @@ -246,7 +246,7 @@ public class Level { } } // See whether the last block bumps up against the addition point - Rect last = freeList.get(freeList.size() - 1); + final Rect last = freeList.get(freeList.size() - 1); if (last.maxX() + 1 == nextAddX) { nextAddX -= last.w(); freeList.remove(freeList.size() - 1); @@ -262,8 +262,8 @@ public class Level { public void dumpFreeSpace() { int freeListWidth = 0; - for (Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = iter.next(); + for (final Iterator<Rect> iter = freeList.iterator(); iter.hasNext(); ) { + final Rect cur = iter.next(); System.err.println(" Free rectangle at " + cur); freeListWidth += cur.w(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java index 433421f1a..803ca28cf 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java @@ -47,14 +47,14 @@ import java.util.*; public class LevelSet { // Maintained in sorted order by increasing Y coordinate - private List<Level> levels = new ArrayList<Level>(); + private final List<Level> levels = new ArrayList<Level>(); private int nextAddY; - private int w; + private final int w; private int h; /** A LevelSet manages all of the backing store for a region of a specified width and height. */ - public LevelSet(int w, int h) { + public LevelSet(final int w, final int h) { this.w = w; this.h = h; } @@ -66,14 +66,14 @@ public class LevelSet { the LevelSet given its current dimensions, false if not. Caller is responsible for performing compaction, expansion, etc. as a consequence. */ - public boolean add(Rect rect) { + public boolean add(final Rect rect) { if (rect.w() > w) return false; // Go in reverse order through the levels seeing whether we can // trivially satisfy the allocation request for (int i = levels.size() - 1; i >= 0; --i) { - Level level = levels.get(i); + final Level level = levels.get(i); if (level.add(rect)) return true; } @@ -82,7 +82,7 @@ public class LevelSet { // increases the computational complexity of the addition process, // but prevents us from expanding unnecessarily. for (int i = levels.size() - 1; i >= 0; --i) { - Level level = levels.get(i); + final Level level = levels.get(i); if (level.couldAllocateIfCompacted(rect)) return false; } @@ -92,19 +92,19 @@ public class LevelSet { if (nextAddY + rect.h() > h) return false; - Level newLevel = new Level(w, rect.h(), nextAddY, this); + final Level newLevel = new Level(w, rect.h(), nextAddY, this); levels.add(newLevel); nextAddY += rect.h(); - boolean res = newLevel.add(rect); + final boolean res = newLevel.add(rect); if (!res) throw new RuntimeException("Unexpected failure in addition to new Level"); return true; } /** Removes the given Rect from this LevelSet. */ - public boolean remove(Rect rect) { + public boolean remove(final Rect rect) { for (int i = levels.size() - 1; i >= 0; --i) { - Level level = levels.get(i); + final Level level = levels.get(i); if (level.remove(rect)) return true; } @@ -116,14 +116,14 @@ public class LevelSet { if necessary. This is the correct fallback path to {@link #add(Rect)} above. Returns true if allocated successfully, false otherwise (indicating the need to expand the backing store). */ - public boolean compactAndAdd(Rect rect, - Object backingStore, - BackingStoreManager manager) { + public boolean compactAndAdd(final Rect rect, + final Object backingStore, + final BackingStoreManager manager) { for (int i = levels.size() - 1; i >= 0; --i) { - Level level = levels.get(i); + final Level level = levels.get(i); if (level.couldAllocateIfCompacted(rect)) { level.compact(backingStore, manager); - boolean res = level.add(rect); + final boolean res = level.add(rect); if (!res) throw new RuntimeException("Unexpected failure to add after compaction"); return true; @@ -136,7 +136,7 @@ public class LevelSet { /** Indicates whether it's legal to trivially increase the height of the given Level. This is only possible if it's the last Level added and there's enough room in the backing store. */ - public boolean canExpand(Level level, int height) { + public boolean canExpand(final Level level, final int height) { if (levels.isEmpty()) return false; // Should not happen if (levels.get(levels.size() - 1) == level && @@ -145,7 +145,7 @@ public class LevelSet { return false; } - public void expand(Level level, int oldHeight, int newHeight) { + public void expand(final Level level, final int oldHeight, final int newHeight) { nextAddY += (newHeight - oldHeight); } @@ -156,7 +156,7 @@ public class LevelSet { /** Sets the height of this LevelSet. It is only legal to reduce the height to greater than or equal to the currently used height. */ - public void setHeight(int height) throws IllegalArgumentException { + public void setHeight(final int height) throws IllegalArgumentException { if (height < getUsedHeight()) { throw new IllegalArgumentException("May not reduce height below currently used height"); } @@ -170,11 +170,11 @@ public class LevelSet { it may be profitable to perform a compaction. */ public float verticalFragmentationRatio() { int freeHeight = 0; - int usedHeight = getUsedHeight(); + final int usedHeight = getUsedHeight(); if (usedHeight == 0) return 0.0f; - for (Iterator<Level> iter = iterator(); iter.hasNext(); ) { - Level level = iter.next(); + for (final Iterator<Level> iter = iterator(); iter.hasNext(); ) { + final Level level = iter.next(); if (level.isEmpty()) { freeHeight += level.h(); } @@ -187,9 +187,9 @@ public class LevelSet { } /** Visits all Rects contained in this LevelSet. */ - public void visit(RectVisitor visitor) { - for (Iterator<Level> iter = levels.iterator(); iter.hasNext(); ) { - Level level = iter.next(); + public void visit(final RectVisitor visitor) { + for (final Iterator<Level> iter = levels.iterator(); iter.hasNext(); ) { + final Level level = iter.next(); level.visit(visitor); } } @@ -199,8 +199,8 @@ public class LevelSet { update the new Rects in a newly laid-out LevelSet with the original Rects. */ public void updateRectangleReferences() { - for (Iterator<Level> iter = levels.iterator(); iter.hasNext(); ) { - Level level = iter.next(); + for (final Iterator<Level> iter = levels.iterator(); iter.hasNext(); ) { + final Level level = iter.next(); level.updateRectangleReferences(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java index 89f594230..cbf6b933c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java @@ -77,11 +77,11 @@ public class Rect { this(null); } - public Rect(Object userData) { + public Rect(final Object userData) { this(0, 0, 0, 0, userData); } - public Rect(int x, int y, int w, int h, Object userData) { + public Rect(final int x, final int y, final int w, final int h, final Object userData) { setPosition(x, y); setSize(w, h); setUserData(userData); @@ -94,7 +94,7 @@ public class Rect { public Object getUserData() { return userData; } public Rect getNextLocation() { return nextLocation; } - public void setPosition(int x, int y) { + public void setPosition(final int x, final int y) { if (x < 0) throw new IllegalArgumentException("Negative x"); if (y < 0) @@ -103,7 +103,7 @@ public class Rect { this.y = y; } - public void setSize(int w, int h) throws IllegalArgumentException { + public void setSize(final int w, final int h) throws IllegalArgumentException { if (w < 0) throw new IllegalArgumentException("Negative width"); if (h < 0) @@ -112,8 +112,8 @@ public class Rect { this.h = h; } - public void setUserData(Object obj) { userData = obj; } - public void setNextLocation(Rect nextLocation) { this.nextLocation = nextLocation; } + public void setUserData(final Object obj) { userData = obj; } + public void setNextLocation(final Rect nextLocation) { this.nextLocation = nextLocation; } // Helpers for computations. @@ -139,7 +139,7 @@ public class Rect { return y() + h() - 1; } - public boolean canContain(Rect other) { + public boolean canContain(final Rect other) { return (w() >= other.w() && h() >= other.h()); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java index 44faa44b0..65f59ba53 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java @@ -48,34 +48,34 @@ import java.util.*; backing store, when necessary. */ public class RectanglePacker { - private BackingStoreManager manager; + private final BackingStoreManager manager; private Object backingStore; private LevelSet levels; - private float EXPANSION_FACTOR = 0.5f; - private float SHRINK_FACTOR = 0.3f; + private final float EXPANSION_FACTOR = 0.5f; + private final float SHRINK_FACTOR = 0.3f; - private int initialWidth; - private int initialHeight; + private final int initialWidth; + private final int initialHeight; private int maxWidth = -1; private int maxHeight = -1; static class RectHComparator implements Comparator<Rect> { @Override - public int compare(Rect r1, Rect r2) { + public int compare(final Rect r1, final Rect r2) { return r2.h() - r1.h(); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { return this == obj; } } private static final Comparator<Rect> rectHComparator = new RectHComparator(); - public RectanglePacker(BackingStoreManager manager, - int initialWidth, - int initialHeight) { + public RectanglePacker(final BackingStoreManager manager, + final int initialWidth, + final int initialHeight) { this.manager = manager; levels = new LevelSet(initialWidth, initialHeight); this.initialWidth = initialWidth; @@ -95,7 +95,7 @@ public class RectanglePacker { necessary. Setting up a maximum width and height introduces the possibility that additions will fail; these are handled with the BackingStoreManager's allocationFailed notification. */ - public void setMaxSize(int maxWidth, int maxHeight) { + public void setMaxSize(final int maxWidth, final int maxHeight) { this.maxWidth = maxWidth; this.maxHeight = maxHeight; } @@ -107,7 +107,7 @@ public class RectanglePacker { BackingStoreManager#preExpand BackingStoreManager.preExpand} does not clear enough space for the incoming rectangle, then this method will throw a RuntimeException. */ - public void add(Rect rect) throws RuntimeException { + public void add(final Rect rect) throws RuntimeException { // Allocate backing store if we don't have any yet if (backingStore == null) backingStore = manager.allocateBackingStore(levels.w(), levels.h()); @@ -143,12 +143,12 @@ public class RectanglePacker { } /** Removes the given rectangle from this RectanglePacker. */ - public void remove(Rect rect) { + public void remove(final Rect rect) { levels.remove(rect); } /** Visits all Rects contained in this RectanglePacker. */ - public void visit(RectVisitor visitor) { + public void visit(final RectVisitor visitor) { levels.visit(visitor); } @@ -168,7 +168,7 @@ public class RectanglePacker { } // The "cause" rect may be null - private void compactImpl(Rect cause) { + private void compactImpl(final Rect cause) { // Have to either expand, compact or both. Need to figure out what // direction to go. Prefer to expand vertically. Expand // horizontally only if rectangle being added is too wide. FIXME: @@ -205,12 +205,12 @@ public class RectanglePacker { nextLevelSet = new LevelSet(newWidth, newHeight); // Make copies of all existing rectangles - List<Rect> newRects = new ArrayList<Rect>(); - for (Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { - Level level = i1.next(); - for (Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = i2.next(); - Rect newRect = new Rect(0, 0, cur.w(), cur.h(), null); + final List<Rect> newRects = new ArrayList<Rect>(); + for (final Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { + final Level level = i1.next(); + for (final Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { + final Rect cur = i2.next(); + final Rect newRect = new Rect(0, 0, cur.w(), cur.h(), null); cur.setNextLocation(newRect); // Hook up the reverse mapping too for easier replacement newRect.setNextLocation(cur); @@ -222,7 +222,7 @@ public class RectanglePacker { Collections.sort(newRects, rectHComparator); // Try putting all of these rectangles into the new level set done = true; - for (Iterator<Rect> iter = newRects.iterator(); iter.hasNext(); ) { + for (final Iterator<Rect> iter = newRects.iterator(); iter.hasNext(); ) { if (!nextLevelSet.add(iter.next())) { done = false; break; @@ -268,13 +268,13 @@ public class RectanglePacker { // new locations of rectangles on the backing store. Allocate a // new backing store, move the contents over and deallocate the // old one. - Object newBackingStore = manager.allocateBackingStore(nextLevelSet.w(), + final Object newBackingStore = manager.allocateBackingStore(nextLevelSet.w(), nextLevelSet.h()); manager.beginMovement(backingStore, newBackingStore); - for (Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { - Level level = i1.next(); - for (Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = i2.next(); + for (final Iterator<Level> i1 = levels.iterator(); i1.hasNext(); ) { + final Level level = i1.next(); + for (final Iterator<Rect> i2 = level.iterator(); i2.hasNext(); ) { + final Rect cur = i2.next(); manager.move(backingStore, cur, newBackingStore, cur.getNextLocation()); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java new file mode 100644 index 000000000..075da340b --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyeParameter.java @@ -0,0 +1,68 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import com.jogamp.opengl.math.FovHVHalves; + +/** + * Constant parameter for one eye. + */ +public final class EyeParameter { + /** Eye number, <code>0</code> for the left eye and <code>1</code> for the right eye. */ + public final int number; + + /** float[3] eye position vector used to define eye height in meter relative to <i>actor</i>. */ + public final float[] positionOffset; + + /** Field of view in both directions, may not be centered, either in radians or tangent. */ + public final FovHVHalves fovhv; + + /** IPD related horizontal distance from nose to pupil in meter. */ + public final float distNoseToPupilX; + + /** Vertical distance from middle-line to pupil in meter. */ + public final float distMiddleToPupilY; + + /** Z-axis eye relief in meter. */ + public final float eyeReliefZ; + + public EyeParameter(final int number, final float[] positionOffset, final FovHVHalves fovhv, + final float distNoseToPupil, final float verticalDelta, final float eyeRelief) { + this.number = number; + this.positionOffset = new float[3]; + System.arraycopy(positionOffset, 0, this.positionOffset, 0, 3); + this.fovhv = fovhv; + this.distNoseToPupilX = distNoseToPupil; + this.distMiddleToPupilY = verticalDelta; + this.eyeReliefZ = eyeRelief; + } + public final String toString() { + return "EyeParam[num "+number+", posOff["+positionOffset[0]+", "+positionOffset[1]+", "+positionOffset[2]+"], "+fovhv+ + ", distPupil[noseX "+distNoseToPupilX+", middleY "+distMiddleToPupilY+", reliefZ "+eyeReliefZ+"]]"; + } +}
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java new file mode 100644 index 000000000..aa64ff130 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java @@ -0,0 +1,69 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import com.jogamp.opengl.math.Quaternion; + +/** + * Position and orientation of one eye. + */ +public final class EyePose { + /** Eye number, <code>0</code> for the left eye and <code>1</code> for the right eye. */ + public final int number; + + /** float[3] eye position vector. */ + public final float[] position; + + /** Eye orientation */ + public final Quaternion orientation; + + public EyePose(final int number) { + this.number = number; + this.position = new float[3]; + this.orientation = new Quaternion(); + } + public EyePose(final int number, final float[] position, final Quaternion orientation) { + this(number); + set(position, orientation); + } + + /** Set position and orientation of this instance. */ + public final void set(final float[] position, final Quaternion orientation) { + System.arraycopy(position, 0, this.position, 0, 3); + this.orientation.set(orientation); + } + /** Set position and orientation of this instance. */ + public final void setPosition(final float posX, final float posY, final float posZ) { + position[0] = posX; + position[1] = posY; + position[2] = posZ; + } + public final String toString() { + return "EyePose[num "+number+", pos["+position[0]+", "+position[1]+", "+position[2]+"], "+orientation+"]"; + } +}
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java new file mode 100644 index 000000000..9f9ebdf2a --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java @@ -0,0 +1,255 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.RectangleImmutable; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLDrawableHelper.GLEventListenerAction; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.FBObject.Attachment.Type; +import com.jogamp.opengl.util.CustomGLEventListener; + +/** + * {@link StereoClientRenderer} utilizing {@link StereoDeviceRenderer} + * implementing {@link GLEventListener} for convenience. + * <p> + * Implementation renders {@link StereoGLEventListener} + * using one or more {@link FBObject} according to {@link StereoDeviceRenderer#getTextureCount()}. + * </p> + */ +public class StereoClientRenderer implements GLEventListener { + private final GLDrawableHelper helper; + private final StereoDeviceRenderer deviceRenderer; + private final boolean ownsDevice; + private final FBObject[] fbos; + private final int magFilter; + private final int minFilter; + private final boolean usePostprocessing; + + private int numSamples; + private final TextureAttachment[] fboTexs; + + public StereoClientRenderer(final StereoDeviceRenderer deviceRenderer, final boolean ownsDevice, + final int magFilter, final int minFilter, final int numSamples) { + final int fboCount = deviceRenderer.getTextureCount(); + if( 0 > fboCount || 2 < fboCount ) { + throw new IllegalArgumentException("fboCount must be within [0..2], has "+fboCount+", due to "+deviceRenderer); + } + this.helper = new GLDrawableHelper(); + this.deviceRenderer = deviceRenderer; + this.usePostprocessing = deviceRenderer.ppRequired() || deviceRenderer.usesSideBySideStereo() && fboCount > 1; + this.ownsDevice = ownsDevice; + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.numSamples = numSamples; + + this.fbos = new FBObject[fboCount]; + for(int i=0; i<fboCount; i++) { + this.fbos[i] = new FBObject(); + } + this.fboTexs = new TextureAttachment[fboCount]; + } + + private void initFBOs(final GL gl, final DimensionImmutable size) { + for(int i=0; i<fbos.length; i++) { + fbos[i].detachAllColorbuffer(gl); + fbos[i].reset(gl, size.getWidth(), size.getHeight(), numSamples, false); + if( i>0 && fbos[i-1].getNumSamples() != fbos[i].getNumSamples()) { + throw new InternalError("sample size mismatch: \n\t0: "+fbos[i-1]+"\n\t1: "+fbos[i]); + } + numSamples = fbos[i].getNumSamples(); + + if(numSamples>0) { + fbos[i].attachColorbuffer(gl, 0, true); // MSAA requires alpha + fbos[i].attachRenderbuffer(gl, Type.DEPTH, 24); + final FBObject ssink = new FBObject(); + { + ssink.reset(gl, size.getWidth(), size.getHeight()); + ssink.attachTexture2D(gl, 0, false, magFilter, minFilter, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + } + fbos[i].setSamplingSink(ssink); + fbos[i].resetSamplingSink(gl); // validate + fboTexs[i] = fbos[i].getSamplingSink(); + } else { + fboTexs[i] = fbos[i].attachTexture2D(gl, 0, false, magFilter, minFilter, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + fbos[i].attachRenderbuffer(gl, Type.DEPTH, 24); + } + fbos[i].unbind(gl); + System.err.println("FBO["+i+"]: "+fbos[i]); + } + + } + + @SuppressWarnings("unused") + private void resetFBOs(final GL gl, final DimensionImmutable size) { + for(int i=0; i<fbos.length; i++) { + fbos[i].reset(gl, size.getWidth(), size.getHeight(), numSamples, true); + if( i>0 && fbos[i-1].getNumSamples() != fbos[i].getNumSamples()) { + throw new InternalError("sample size mismatch: \n\t0: "+fbos[i-1]+"\n\t1: "+fbos[i]); + } + numSamples = fbos[i].getNumSamples(); + if(numSamples>0) { + fboTexs[i] = fbos[i].getSamplingSink(); + } else { + fboTexs[i] = (TextureAttachment) fbos[i].getColorbuffer(0); + } + } + } + + public final StereoDeviceRenderer getStereoDeviceRenderer() { return deviceRenderer; } + + public final void addGLEventListener(final StereoGLEventListener l) { + helper.addGLEventListener(l); + } + public final void removeGLEventListener(final StereoGLEventListener l) { + helper.removeGLEventListener(l); + } + + @Override + public void init(final GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + deviceRenderer.init(gl); + + // We will do some offscreen rendering, setup FBO... + final DimensionImmutable textureSize = deviceRenderer.getTextureCount() > 1 ? deviceRenderer.getSingleSurfaceSize() : deviceRenderer.getTotalSurfaceSize(); + initFBOs(gl, textureSize); + helper.init(drawable, false); + + gl.setSwapInterval(1); + } + + @Override + public void dispose(final GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + helper.disposeAllGLEventListener(drawable, false); + for(int i=0; i<fbos.length; i++) { + fbos[i].destroy(gl); + fboTexs[i] = null; + } + if( ownsDevice ) { + deviceRenderer.dispose(gl); + } + } + + @Override + public void display(final GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + deviceRenderer.beginFrame(gl); + + if(0 < numSamples) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + + final int fboCount = fbos.length; + final int displayRepeatFlags; + if( 1 == fboCount ) { + displayRepeatFlags = CustomGLEventListener.DISPLAY_DONTCLEAR; + } else { + displayRepeatFlags = 0; + } + + // Update eye pos upfront to have same (almost) results + deviceRenderer.updateEyePose(0); + deviceRenderer.updateEyePose(1); + + if( 1 == fboCount ) { + fbos[0].bind(gl); + } + + for(int eyeNum=0; eyeNum<2; eyeNum++) { + if( 1 < fboCount ) { + fbos[eyeNum].bind(gl); + } + + final StereoDeviceRenderer.Eye eye = deviceRenderer.getEye(eyeNum); + final RectangleImmutable viewport = eye.getViewport(); + gl.glViewport(viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight()); + + final int displayFlags = eyeNum > 0 ? CustomGLEventListener.DISPLAY_REPEAT | displayRepeatFlags : 0; + final GLEventListenerAction reshapeDisplayAction = new GLEventListenerAction() { + public void run(final GLAutoDrawable drawable, final GLEventListener listener) { + final StereoGLEventListener sl = (StereoGLEventListener) listener; + sl.reshapeForEye(drawable, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight(), + eye.getEyeParameter(), eye.getLastEyePose()); + sl.display(drawable, displayFlags); + } }; + helper.runForAllGLEventListener(drawable, reshapeDisplayAction); + + if( 1 < fboCount ) { + fbos[eyeNum].unbind(gl); + } + } + if( 1 == fboCount ) { + fbos[0].unbind(gl); + } + // restore viewport + gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); + + if( usePostprocessing ) { + deviceRenderer.ppBegin(gl); + if( 1 == fboCount ) { + fbos[0].use(gl, fboTexs[0]); + deviceRenderer.ppBothEyes(gl); + fbos[0].unuse(gl); + } else { + fbos[0].use(gl, fboTexs[0]); + deviceRenderer.ppOneEye(gl, 0); + fbos[0].unuse(gl); + fbos[1].use(gl, fboTexs[1]); + deviceRenderer.ppOneEye(gl, 1); + fbos[1].unuse(gl); + } + deviceRenderer.ppEnd(gl); + } + + if( !drawable.getAutoSwapBufferMode() ) { + drawable.swapBuffers(); + } + deviceRenderer.endFrame(gl); + } + + @Override + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { + if( !drawable.getAutoSwapBufferMode() ) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glViewport(0, 0, width, height); + } + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java new file mode 100644 index 000000000..e5c0e3646 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java @@ -0,0 +1,93 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PointImmutable; + +import jogamp.opengl.Debug; + +import com.jogamp.opengl.math.FovHVHalves; + +/** + * Interface describing a native stereoscopic device + */ +public interface StereoDevice { + public static final boolean DEBUG = Debug.debug("StereoDevice"); + + /** + * Default eye position offset for {@link #createRenderer(int, int, float[], FovHVHalves[], float)}. + * <p> + * Default offset is 1.6f <i>up</i> and 5.0f <i>away</i>. + * </p> + */ + public static final float[] DEFAULT_EYE_POSITION_OFFSET = { 0.0f, 1.6f, -5.0f }; + + /** Disposes this {@link StereoDevice}. */ + public void dispose(); + + /** + * If operation within a device spanning virtual desktop, + * returns the device position. + * <p> + * Otherwise simply 0/0. + * </p> + */ + public PointImmutable getPosition(); + + /** + * Returns the required surface size in pixel. + */ + public DimensionImmutable getSurfaceSize(); + + /** + * Returns the device default {@link FovHVHalves} per eye. + */ + public FovHVHalves[] getDefaultFOV(); + + /** Start or stop sensors. Returns true if action was successful, otherwise false. */ + public boolean startSensors(boolean start); + + /** Return true if sensors have been started, false otherwise */ + public boolean getSensorsStarted(); + + /** + * Create a new {@link StereoDeviceRenderer} instance. + * + * @param distortionBits {@link StereoDeviceRenderer} distortion bits, e.g. {@link StereoDeviceRenderer#DISTORTION_BARREL}, etc. + * @param textureCount desired texture count for post-processing, see {@link StereoDeviceRenderer#getTextureCount()} and {@link StereoDeviceRenderer#ppRequired()} + * @param eyePositionOffset eye position offset, e.g. {@link #DEFAULT_EYE_POSITION_OFFSET}. + * @param eyeFov FovHVHalves[2] field-of-view per eye + * @param pixelsPerDisplayPixel + * @param textureUnit + * @return + */ + public StereoDeviceRenderer createRenderer(final int distortionBits, + final int textureCount, final float[] eyePositionOffset, + final FovHVHalves[] eyeFov, final float pixelsPerDisplayPixel, final int textureUnit); +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java new file mode 100644 index 000000000..d9054ce28 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceFactory.java @@ -0,0 +1,64 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import com.jogamp.common.util.ReflectionUtil; + +/** + * Platform agnostic {@link StereoDevice} factory. + */ +public abstract class StereoDeviceFactory { + private static final String OVRStereoDeviceClazzName = "jogamp.opengl.oculusvr.OVRStereoDeviceFactory"; + private static final Object[] ctorArgs; + private static final String isAvailableMethodName = "isAvailable"; + + static { + ctorArgs = new Object[6]; + ctorArgs[0] = null; + + } + public static StereoDeviceFactory createDefaultFactory() { + final ClassLoader cl = StereoDeviceFactory.class.getClassLoader(); + final StereoDeviceFactory sink = createFactory(cl, OVRStereoDeviceClazzName); + if( null == sink ) { + // sink = create(cl, ANYOTHERCLAZZNAME); + } + return sink; + } + + public static StereoDeviceFactory createFactory(final ClassLoader cl, final String implName) { + try { + if(((Boolean)ReflectionUtil.callStaticMethod(implName, isAvailableMethodName, null, null, cl)).booleanValue()) { + return (StereoDeviceFactory) ReflectionUtil.createInstance(implName, cl); + } + } catch (final Throwable t) { if(StereoDevice.DEBUG) { System.err.println("Caught "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } + return null; + } + + public abstract StereoDevice createDevice(final int deviceIndex, final boolean verbose); +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java new file mode 100644 index 000000000..fd94f6bc3 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java @@ -0,0 +1,235 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.RectangleImmutable; +import javax.media.opengl.GL; + +/** + * Stereoscopic device rendering interface. + * <p> + * The following pseudo-code describes how to implement a renderer + * using a {@link StereoDeviceRenderer}. + * See {@link StereoClientRenderer} which implements the following: + * <ul> + * <li>device.{@link #beginFrame(GL)}</li> + * <li>For both eyes:<ul> + * <li>device.{@link #updateEyePose(int)}</li> + * <li>if device.{@link #ppRequired()}: Set the render target, e.g. FBO</li> + * <li>Set the viewport using {@link Eye#getViewport()}</li> + * <li>{@link StereoGLEventListener#reshapeForEye(javax.media.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, EyePose) upstream.reshapeEye(..)}</li> + * <li>{@link StereoGLEventListener#display(javax.media.opengl.GLAutoDrawable, int) upstream.display(..)}.</li> + * </ul></li> + * <li>Reset the viewport</li> + * <li>If device.{@link #ppRequired()}:<ul> + * <li>device.{@link #ppBegin(GL)}</li> + * <li>Use render target, e.g. FBO's texture</li> + * <li>device.{@link #ppBothEyes(GL)} or device.{@link #ppOneEye(GL, int)} for both eyes</li> + * <li>device.{@link #ppEnd(GL)}</li> + * </ul></li> + * <li>device.{@link #endFrame(GL)}</li> + * <ul> + */ +public interface StereoDeviceRenderer { + /** + * Distortion Bit: Barrel distortion compensating lens pincushion distortion + */ + public static final int DISTORTION_BARREL = 1 << 0; + + /** + * Distortion Bit: Chromatic distortion compensating lens chromatic aberration. + */ + public static final int DISTORTION_CHROMATIC = 1 << 1; + + /** + * Distortion Bit: Vignette distortion compensating lens chromatic aberration. + */ + public static final int DISTORTION_VIGNETTE = 1 << 2; + + /** + * Distortion Bit: Timewarp distortion technique to predict + * {@link EyePose} movement to reduce latency. + * <p> + * FIXME: Explanation needs refinement! + * </p> + */ + public static final int DISTORTION_TIMEWARP = 1 << 3; + + + /** Returns the {@link StereoDevice} of this {@link StereoDeviceRenderer} instance. */ + public StereoDevice getDevice(); + + /** + * Interface describing one eye of the stereoscopic device, + * see {@link StereoDeviceRenderer#getEye(int)}. + */ + public static interface Eye { + /** + * Returns the viewport for this eye. + */ + public RectangleImmutable getViewport(); + /** + * Returns the {@link EyeParameter} of this eye. + */ + public EyeParameter getEyeParameter(); + /** + * Returns the last {@link EyePose} of this eye. + */ + public EyePose getLastEyePose(); + } + + /** + * Returns the {@link Eye} instance for the denoted <code>eyeNum</code>. + */ + public Eye getEye(final int eyeNum); + + /** + * Updates the {@link Eye#getLastEyePose()} + * for the denoted <code>eyeNum</code>. + */ + public EyePose updateEyePose(final int eyeNum); + + /** + * Returns distortion compensation bits, e.g. {@link #DISTORTION_BARREL}, + * in case the stereoscopic display requires such, i.e. in case lenses are utilized. + * <p> + * Distortion requires {@link #ppRequired() post-processing}. + * </p> + */ + public int getDistortionBits(); + + /** + * Method returns <code>true</code> if using <i>side-by-side</i> (SBS) + * stereoscopic images, otherwise <code>false</code>. + * <p> + * SBS requires that both eye's images are presented + * <i>side-by-side</i> in the final framebuffer. + * </p> + * <p> + * Either the renderer presents the images <i>side-by-side</i> according to the {@link Eye#getViewport() eye's viewport}, + * or {@link #ppRequired() post-processing} is utilized to merge {@link #getTextureCount() textures} + * to a <i>side-by-side</i> configuration. + * </p> + */ + public boolean usesSideBySideStereo(); + + /** + * Returns the unified surface size of one eye's a single image in pixel units. + */ + public DimensionImmutable getSingleSurfaceSize(); + + /** + * Returns the total surface size required for the complete images in pixel units. + * <p> + * If {@link #usesSideBySideStereo()} the total size spans over both {@link #getSingleSurfaceSize()}, side-by-side. + * </p> + * <p> + * Otherwise the size is equal to {@link #getSingleSurfaceSize()}. + * </p> + */ + public DimensionImmutable getTotalSurfaceSize(); + + /** + * Returns the used texture-image count for post-processing, see {@link #ppRequired()}. + * <p> + * In case the renderer does not support multiple textures for post-processing, + * or no post-processing at all, method returns zero despite the request + * from {@link StereoDevice#createRenderer(int, int, float[], com.jogamp.opengl.math.FovHVHalves[], float)}. + * </p> + */ + public int getTextureCount(); + + /** Returns the desired texture-image unit for post-processing, see {@link #ppRequired()}. */ + public int getTextureUnit(); + + /** Initialize OpenGL related resources */ + public void init(final GL gl); + + /** Release all OpenGL related resources */ + public void dispose(final GL gl); + + /** Notifying that a new frame is about to start. */ + public void beginFrame(final GL gl); + + /** Notifying that the frame has been rendered completely. */ + public void endFrame(final GL gl); + + /** + * Returns <code>true</code> if stereoscopic post-processing is required, + * otherwise <code>false</code>. + * <p> + * Stereoscopic post-processing is usually required if: + * <ul> + * <li>one of the <i>distortion</i> modes are set, i.e. {@link #usesBarrelDistortion()}</li> + * <li>texture-images are being used, see {@link #getTextureCount()}</li> + * </ul> + * </p> + * <p> + * If stereoscopic post-processing is used + * the following post-processing methods must be called to before {@link #endFrame()}: + * <ul> + * <li>{@link #ppBegin(GL)}</li> + * <li>{@link #ppBothEyes(GL)} or {@link #ppOneEye(GL, int)} for both eyes</li> + * <li>{@link #ppEnd(GL)}</li> + * </ul> + * </p> + */ + public boolean ppRequired(); + + /** + * Begin stereoscopic post-processing, see {@link #ppRequired()}. + * <p> + * {@link #updateEyePose(int)} for both eyes must be called upfront + * when rendering upstream {@link StereoGLEventListener}. + * </p> + * + * @param gl + */ + public void ppBegin(final GL gl); + + /** + * Performs stereoscopic post-processing for both eyes, see {@link #ppRequired()}. + * @param gl + */ + public void ppBothEyes(final GL gl); + + /** + * Performs stereoscopic post-processing for one eye, see {@link #ppRequired()}. + * @param gl + * @param eyeNum + */ + public void ppOneEye(final GL gl, final int eyeNum); + + /** + * End stereoscopic post-processing, see {@link #ppRequired()}. + * @param gl + */ + public void ppEnd(final GL gl); + +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java new file mode 100644 index 000000000..ec580cbf9 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java @@ -0,0 +1,74 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.util.CustomGLEventListener; + +/** + * Extended {@link GLEventListener} and {@link CustomGLEventListener} interface + * supporting stereoscopic client rendering. + */ +public interface StereoGLEventListener extends CustomGLEventListener { + /** + * Stereo capable specialization of {@link #reshape(GLAutoDrawable, int, int, int, int)} + * for one {@link StereoDeviceRenderer.Eye}. + * <p> + * Called by the stereo renderer before each {@link #display(GLAutoDrawable)} + * or {@link #display(GLAutoDrawable, int)} call. + * </p> + * <p> + * The client can update it's viewport associated data + * and view volume of the window appropriately. + * </p> + * <p> + * The client shall also update it's projection- and modelview matrices according + * to the given {@link EyeParameter} and {@link EyePose}. + * </p> + * <p> + * For efficiency the GL viewport has already been updated + * via <code>glViewport(x, y, width, height)</code> when this method is called. + * </p> + * + * @param drawable the triggering {@link GLAutoDrawable} + * @param x viewport x-coord in pixel units + * @param y viewport y-coord in pixel units + * @param width viewport width in pixel units + * @param height viewport height in pixel units + * @param eyeParam constant eye parameter, i.e. FOV and IPD + * @param eyePose current eye position and orientation + * @see FloatUtil#makePerspective(float[], int, boolean, com.jogamp.opengl.math.FloatUtil.FovHVHalves, float, float) + */ + public void reshapeForEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, + final EyeParameter eyeParam, final EyePose eyePose); + + +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java new file mode 100644 index 000000000..280d99233 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java @@ -0,0 +1,125 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.stereo; + +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.Quaternion; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.util.CustomGLEventListener; +import com.jogamp.opengl.util.stereo.StereoDeviceRenderer.Eye; + +public class StereoUtil { + + /** See {@link StereoDeviceRenderer#getDistortionBits()}. */ + public static boolean usesBarrelDistortion(final int distortionBits) { return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_BARREL ) ; } + /** See {@link StereoDeviceRenderer#getDistortionBits()}. */ + public static boolean usesTimewarpDistortion(final int distortionBits) { return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_TIMEWARP ) ; } + /** See {@link StereoDeviceRenderer#getDistortionBits()}. */ + public static boolean usesChromaticDistortion(final int distortionBits) { return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_CHROMATIC ) ; } + /** See {@link StereoDeviceRenderer#getDistortionBits()}. */ + public static boolean usesVignetteDistortion(final int distortionBits) { return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_VIGNETTE ) ; } + + /** See {@link StereoDeviceRenderer#getDistortionBits()}. */ + public static String distortionBitsToString(final int distortionBits) { + boolean appendComma = false; + final StringBuilder sb = new StringBuilder(); + if( usesBarrelDistortion(distortionBits) ) { + if( appendComma ) { sb.append(", "); }; + sb.append("barrell"); appendComma=true; + } + if( usesVignetteDistortion(distortionBits) ) { + if( appendComma ) { sb.append(", "); }; + sb.append("vignette"); appendComma=true; + } + if( usesChromaticDistortion(distortionBits) ) { + if( appendComma ) { sb.append(", "); }; + sb.append("chroma"); appendComma=true; + } + if( usesTimewarpDistortion(distortionBits) ) { + if( appendComma ) { sb.append(", "); }; + sb.append("timewarp"); appendComma=true; + } + return sb.toString(); + } + + /** + * Calculates the <i>Side By Side</i>, SBS, projection- and modelview matrix for one eye. + * <p> + * {@link #updateEyePose(int)} must be called upfront. + * </p> + * <p> + * This method merely exist as an example implementation to compute the matrices, + * which shall be adopted by the + * {@link CustomGLEventListener#reshape(javax.media.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, EyePose) upstream client code}. + * </p> + * @param eyeNum eye denominator + * @param zNear frustum near value + * @param zFar frustum far value + * @param mat4Projection float[16] projection matrix result + * @param mat4Modelview float[16] modelview matrix result + */ + public static void getSBSUpstreamPMV(final Eye eye, final float zNear, final float zFar, + final float[] mat4Projection, final float[] mat4Modelview) { + final float[] mat4Tmp1 = new float[16]; + final float[] mat4Tmp2 = new float[16]; + final float[] vec3Tmp1 = new float[3]; + final float[] vec3Tmp2 = new float[3]; + final float[] vec3Tmp3 = new float[3]; + + final EyeParameter eyeParam = eye.getEyeParameter(); + final EyePose eyePose = eye.getLastEyePose(); + + // + // Projection + // + FloatUtil.makePerspective(mat4Projection, 0, true, eyeParam.fovhv, zNear, zFar); + + // + // Modelview + // + final Quaternion rollPitchYaw = new Quaternion(); + // private final float eyeYaw = FloatUtil.PI; // 180 degrees in radians + // rollPitchYaw.rotateByAngleY(eyeYaw); + final float[] shiftedEyePos = rollPitchYaw.rotateVector(vec3Tmp1, 0, eyePose.position, 0); + VectorUtil.addVec3(shiftedEyePos, shiftedEyePos, eyeParam.positionOffset); + + rollPitchYaw.mult(eyePose.orientation); + final float[] up = rollPitchYaw.rotateVector(vec3Tmp2, 0, VectorUtil.VEC3_UNIT_Y, 0); + final float[] forward = rollPitchYaw.rotateVector(vec3Tmp3, 0, VectorUtil.VEC3_UNIT_Z_NEG, 0); + final float[] center = VectorUtil.addVec3(forward, shiftedEyePos, forward); + + final float[] mLookAt = FloatUtil.makeLookAt(mat4Tmp2, 0, shiftedEyePos, 0, center, 0, up, 0, mat4Tmp1); + final float[] mViewAdjust = FloatUtil.makeTranslation(mat4Modelview, true, + eyeParam.distNoseToPupilX, + eyeParam.distMiddleToPupilY, + eyeParam.eyeReliefZ); + + /* mat4Modelview = */ FloatUtil.multMatrix(mViewAdjust, mLookAt); + } + +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java index a2d202d11..f5ef5672f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java @@ -77,7 +77,7 @@ public class ImageSequence implements TextureSequence { } public final void addFrame(final GL gl, final Class<?> context, final String imageResourcePath, final String imageSuffix) throws IOException { - URLConnection urlConn = IOUtil.getResource(context, imageResourcePath); + final URLConnection urlConn = IOUtil.getResource(context, imageResourcePath); if(null != urlConn) { final TextureData texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, imageSuffix); final Texture tex = new Texture(getTextureTarget()); @@ -97,7 +97,7 @@ public class ImageSequence implements TextureSequence { public final boolean getManualStepping() { return manualStepping; } public final TextureSequence.TextureFrame getFrame(final int idx) { return frames.get(idx); } - public void destroy(GL gl) throws GLException { + public void destroy(final GL gl) throws GLException { for(int i=frames.size()-1; i>=0; i--) { frames.get(i).getTexture().destroy(gl); } @@ -133,7 +133,7 @@ public class ImageSequence implements TextureSequence { } @Override - public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException { + public TextureSequence.TextureFrame getNextTexture(final GL gl) throws IllegalStateException { if( !manualStepping ) { frameIdx = ( frameIdx + 1 ) % frames.size(); } @@ -153,7 +153,7 @@ public class ImageSequence implements TextureSequence { private String textureLookupFunctionName = "myTexture2D"; @Override - public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { + public String getTextureLookupFunctionName(final String desiredFuncName) throws IllegalStateException { if(useBuildInTexLookup) { return "texture2D"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index 47be0714e..e7693f4a6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -205,7 +205,7 @@ public class Texture { private static final boolean disableNPOT = Debug.isPropertyDefined("jogl.texture.nonpot", true); private static final boolean disableTexRect = Debug.isPropertyDefined("jogl.texture.notexrect", true); - public Texture(GL gl, TextureData data) throws GLException { + public Texture(final GL gl, final TextureData data) throws GLException { texID = 0; updateImage(gl, data); } @@ -216,7 +216,7 @@ public class Texture { * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, * GL2.GL_TEXTURE_RECTANGLE */ - public Texture(int target) { + public Texture(final int target) { texID = 0; this.target = target; } @@ -278,7 +278,7 @@ public class Texture { * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ - public void enable(GL gl) throws GLException { + public void enable(final GL gl) throws GLException { if( !gl.isGLcore() && GLES2.GL_TEXTURE_EXTERNAL_OES != target) { gl.glEnable(target); } @@ -305,7 +305,7 @@ public class Texture { * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ - public void disable(GL gl) throws GLException { + public void disable(final GL gl) throws GLException { if( !gl.isGLcore() && GLES2.GL_TEXTURE_EXTERNAL_OES != target ) { gl.glDisable(target); } @@ -325,7 +325,7 @@ public class Texture { * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ - public void bind(GL gl) throws GLException { + public void bind(final GL gl) throws GLException { validateTexID(gl, true); gl.glBindTexture(target, texID); } @@ -335,7 +335,7 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void destroy(GL gl) throws GLException { + public void destroy(final GL gl) throws GLException { if(0!=texID) { gl.glDeleteTextures(1, new int[] {texID}, 0); texID = 0; @@ -437,7 +437,7 @@ public class Texture { * * @return the texture coordinates corresponding to the specified sub-image */ - public TextureCoords getSubImageTexCoords(int x1, int y1, int x2, int y2) { + public TextureCoords getSubImageTexCoords(final int x1, final int y1, final int x2, final int y2) { if (target == GL2.GL_TEXTURE_RECTANGLE_ARB) { if (mustFlipVertically) { return new TextureCoords(x1, texHeight - y1, x2, texHeight - y2); @@ -445,12 +445,12 @@ public class Texture { return new TextureCoords(x1, y1, x2, y2); } } else { - float tx1 = (float)x1 / (float)texWidth; - float ty1 = (float)y1 / (float)texHeight; - float tx2 = (float)x2 / (float)texWidth; - float ty2 = (float)y2 / (float)texHeight; + final float tx1 = (float)x1 / (float)texWidth; + final float ty1 = (float)y1 / (float)texHeight; + final float tx2 = (float)x2 / (float)texWidth; + final float ty2 = (float)y2 / (float)texHeight; if (mustFlipVertically) { - float yMax = (float) imgHeight / (float) texHeight; + final float yMax = (float) imgHeight / (float) texHeight; return new TextureCoords(tx1, yMax - ty1, tx2, yMax - ty2); } else { return new TextureCoords(tx1, ty1, tx2, ty2); @@ -464,7 +464,7 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void updateImage(GL gl, TextureData data) throws GLException { + public void updateImage(final GL gl, final TextureData data) throws GLException { updateImage(gl, data, 0); } @@ -487,7 +487,7 @@ public class Texture { * No-op if no change, otherwise generates new {@link TextureCoords}. * </p> */ - public void setMustFlipVertically(boolean v) { + public void setMustFlipVertically(final boolean v) { if( v != mustFlipVertically ) { mustFlipVertically = v; updateTexCoords(); @@ -501,7 +501,7 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void updateImage(GL gl, TextureData data, int targetOverride) throws GLException { + public void updateImage(final GL gl, final TextureData data, final int targetOverride) throws GLException { validateTexID(gl, true); imgWidth = data.getWidth(); @@ -522,7 +522,7 @@ public class Texture { data.setHaveGL12(gl.isExtensionAvailable(GLExtensions.VERSION_1_2)); // Indicates whether both width and height are power of two - boolean isPOT = isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight); + final boolean isPOT = isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight); // Note that automatic mipmap generation doesn't work for // GL_ARB_texture_rectangle @@ -634,7 +634,7 @@ public class Texture { } if (data.getMipmap() && !haveAutoMipmapGeneration) { - int[] align = new int[1]; + final int[] align = new int[1]; gl.glGetIntegerv(GL.GL_UNPACK_ALIGNMENT, align, 0); // save alignment gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, data.getAlignment()); @@ -644,7 +644,7 @@ public class Texture { try { // FIXME: may need check for GLUnsupportedException - GLU glu = GLU.createGLU(gl); + final GLU glu = GLU.createGLU(gl); glu.gluBuild2DMipmaps(texTarget, data.getInternalFormat(), data.getWidth(), data.getHeight(), data.getPixelFormat(), data.getPixelType(), data.getBuffer()); @@ -653,7 +653,7 @@ public class Texture { } } else { checkCompressedTextureExtensions(gl, data); - Buffer[] mipmapData = data.getMipmapData(); + final Buffer[] mipmapData = data.getMipmapData(); if (mipmapData != null) { int width = texWidth; int height = texHeight; @@ -684,7 +684,7 @@ public class Texture { texWidth, texHeight, data.getBorder(), data.getBuffer().capacity(), data.getBuffer()); } else { - ByteBuffer buf = DDSImage.allocateBlankBuffer(texWidth, + final ByteBuffer buf = DDSImage.allocateBlankBuffer(texWidth, texHeight, data.getInternalFormat()); gl.glCompressedTexImage2D(texTarget, 0, data.getInternalFormat(), @@ -710,9 +710,9 @@ public class Texture { } } - int minFilter = (data.getMipmap() ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR); - int magFilter = GL.GL_LINEAR; - int wrapMode = (gl.isExtensionAvailable(GLExtensions.VERSION_1_2) || !gl.isGL2()) ? GL.GL_CLAMP_TO_EDGE : GL2.GL_CLAMP; + final int minFilter = (data.getMipmap() ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR); + final int magFilter = GL.GL_LINEAR; + final int wrapMode = (gl.isExtensionAvailable(GLExtensions.VERSION_1_2) || !gl.isGL2()) ? GL.GL_CLAMP_TO_EDGE : GL2.GL_CLAMP; // REMIND: figure out what to do for GL_TEXTURE_RECTANGLE_ARB if (texTarget != GL2.GL_TEXTURE_RECTANGLE_ARB) { @@ -720,8 +720,8 @@ public class Texture { gl.glTexParameteri(texParamTarget, GL.GL_TEXTURE_MAG_FILTER, magFilter); gl.glTexParameteri(texParamTarget, GL.GL_TEXTURE_WRAP_S, wrapMode); gl.glTexParameteri(texParamTarget, GL.GL_TEXTURE_WRAP_T, wrapMode); - if (this.target == GL2.GL_TEXTURE_CUBE_MAP) { - gl.glTexParameteri(texParamTarget, GL2.GL_TEXTURE_WRAP_R, wrapMode); + if (this.target == GL.GL_TEXTURE_CUBE_MAP) { + gl.glTexParameteri(texParamTarget, GL2ES2.GL_TEXTURE_WRAP_R, wrapMode); } } @@ -758,7 +758,7 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void updateSubImage(GL gl, TextureData data, int mipmapLevel, int x, int y) throws GLException { + public void updateSubImage(final GL gl, final TextureData data, final int mipmapLevel, final int x, final int y) throws GLException { if (usingAutoMipmapGeneration && mipmapLevel != 0) { // When we're using mipmap generation via GL_GENERATE_MIPMAP, we // don't need to update other mipmap levels @@ -798,10 +798,10 @@ public class Texture { * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ - public void updateSubImage(GL gl, TextureData data, int mipmapLevel, - int dstx, int dsty, - int srcx, int srcy, - int width, int height) throws GLException { + public void updateSubImage(final GL gl, final TextureData data, final int mipmapLevel, + final int dstx, final int dsty, + final int srcx, final int srcy, + final int width, final int height) throws GLException { if (data.isDataCompressed()) { throw new GLException("updateSubImage specifying a sub-rectangle is not supported for compressed TextureData"); } @@ -823,8 +823,8 @@ public class Texture { * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ - public void setTexParameterf(GL gl, int parameterName, - float value) { + public void setTexParameterf(final GL gl, final int parameterName, + final float value) { bind(gl); gl.glTexParameterf(target, parameterName, value); } @@ -836,8 +836,8 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void setTexParameterfv(GL gl, int parameterName, - FloatBuffer params) { + public void setTexParameterfv(final GL gl, final int parameterName, + final FloatBuffer params) { bind(gl); gl.glTexParameterfv(target, parameterName, params); } @@ -849,8 +849,8 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void setTexParameterfv(GL gl, int parameterName, - float[] params, int params_offset) { + public void setTexParameterfv(final GL gl, final int parameterName, + final float[] params, final int params_offset) { bind(gl); gl.glTexParameterfv(target, parameterName, params, params_offset); } @@ -865,8 +865,8 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void setTexParameteri(GL gl, int parameterName, - int value) { + public void setTexParameteri(final GL gl, final int parameterName, + final int value) { bind(gl); gl.glTexParameteri(target, parameterName, value); } @@ -878,8 +878,8 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void setTexParameteriv(GL gl, int parameterName, - IntBuffer params) { + public void setTexParameteriv(final GL gl, final int parameterName, + final IntBuffer params) { bind(gl); gl.glTexParameteriv(target, parameterName, params); } @@ -891,8 +891,8 @@ public class Texture { * * @throws GLException if any OpenGL-related errors occurred */ - public void setTexParameteriv(GL gl, int parameterName, - int[] params, int params_offset) { + public void setTexParameteriv(final GL gl, final int parameterName, + final int[] params, final int params_offset) { bind(gl); gl.glTexParameteriv(target, parameterName, params, params_offset); } @@ -908,7 +908,7 @@ public class Texture { * otherwise it may be <code>null</code>. * @see #getTextureObject() */ - public int getTextureObject(GL gl) { + public int getTextureObject(final GL gl) { validateTexID(gl, false); return texID; } @@ -957,7 +957,7 @@ public class Texture { * * @return true if the given value is a power of two, false otherwise */ - private static boolean isPowerOfTwo(int val) { + private static boolean isPowerOfTwo(final int val) { return ((val & (val - 1)) == 0); } @@ -969,7 +969,7 @@ public class Texture { * @param val the value * @return the next power of two */ - private static int nextPowerOfTwo(int val) { + private static int nextPowerOfTwo(final int val) { int ret = 1; while (ret < val) { ret <<= 1; @@ -981,7 +981,7 @@ public class Texture { * Updates the actual image dimensions; usually only called from * <code>updateImage</code>. */ - private void setImageSize(int width, int height, int target) { + private void setImageSize(final int width, final int height, final int target) { imgWidth = width; imgHeight = height; updateTexCoords(); @@ -1010,7 +1010,7 @@ public class Texture { } } - private void updateSubImageImpl(GL gl, TextureData data, int newTarget, int mipmapLevel, + private void updateSubImageImpl(final GL gl, final TextureData data, final int newTarget, final int mipmapLevel, int dstx, int dsty, int srcx, int srcy, int width, int height) throws GLException { data.setHaveEXTABGR(gl.isExtensionAvailable(GLExtensions.EXT_abgr)); @@ -1081,15 +1081,15 @@ public class Texture { data.getInternalFormat(), buffer.remaining(), buffer); } else { - int[] align = { 0 }; - int[] rowLength = { 0 }; - int[] skipRows = { 0 }; - int[] skipPixels = { 0 }; + final int[] align = { 0 }; + final int[] rowLength = { 0 }; + final int[] skipRows = { 0 }; + final int[] skipPixels = { 0 }; gl.glGetIntegerv(GL.GL_UNPACK_ALIGNMENT, align, 0); // save alignment if(gl.isGL2GL3()) { - gl.glGetIntegerv(GL2GL3.GL_UNPACK_ROW_LENGTH, rowLength, 0); // save row length - gl.glGetIntegerv(GL2GL3.GL_UNPACK_SKIP_ROWS, skipRows, 0); // save skipped rows - gl.glGetIntegerv(GL2GL3.GL_UNPACK_SKIP_PIXELS, skipPixels, 0); // save skipped pixels + gl.glGetIntegerv(GL2ES2.GL_UNPACK_ROW_LENGTH, rowLength, 0); // save row length + gl.glGetIntegerv(GL2ES2.GL_UNPACK_SKIP_ROWS, skipRows, 0); // save skipped rows + gl.glGetIntegerv(GL2ES2.GL_UNPACK_SKIP_PIXELS, skipPixels, 0); // save skipped pixels } gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, data.getAlignment()); if (DEBUG && VERBOSE) { @@ -1102,9 +1102,9 @@ public class Texture { System.out.println("height = " + height); } if(gl.isGL2GL3()) { - gl.glPixelStorei(GL2GL3.GL_UNPACK_ROW_LENGTH, rowlen); - gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_ROWS, srcy); - gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_PIXELS, srcx); + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, rowlen); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, srcy); + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, srcx); } else { if ( rowlen!=0 && rowlen!=width && srcy!=0 && srcx!=0 ) { @@ -1118,14 +1118,14 @@ public class Texture { buffer); gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, align[0]); // restore alignment if(gl.isGL2GL3()) { - gl.glPixelStorei(GL2GL3.GL_UNPACK_ROW_LENGTH, rowLength[0]); // restore row length - gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_ROWS, skipRows[0]); // restore skipped rows - gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_PIXELS, skipPixels[0]); // restore skipped pixels + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, rowLength[0]); // restore row length + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, skipRows[0]); // restore skipped rows + gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, skipPixels[0]); // restore skipped pixels } } } - private void checkCompressedTextureExtensions(GL gl, TextureData data) { + private void checkCompressedTextureExtensions(final GL gl, final TextureData data) { if (data.isDataCompressed()) { switch (data.getInternalFormat()) { case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: @@ -1145,10 +1145,10 @@ public class Texture { } } - private boolean validateTexID(GL gl, boolean throwException) { + private boolean validateTexID(final GL gl, final boolean throwException) { if( 0 == texID ) { if( null != gl ) { - int[] tmp = new int[1]; + final int[] tmp = new int[1]; gl.glGenTextures(1, tmp, 0); texID = tmp[0]; if ( 0 == texID && throwException ) { @@ -1162,22 +1162,22 @@ public class Texture { } // Helper routines for disabling certain codepaths - private static boolean haveNPOT(GL gl) { + private static boolean haveNPOT(final GL gl) { return !disableNPOT && gl.isNPOTTextureAvailable(); } - private static boolean haveTexRect(GL gl) { + private static boolean haveTexRect(final GL gl) { return (!disableTexRect && TextureIO.isTexRectEnabled() && gl.isExtensionAvailable(GLExtensions.ARB_texture_rectangle)); } - private static boolean preferTexRect(GL gl) { + private static boolean preferTexRect(final GL gl) { // Prefer GL_ARB_texture_rectangle on ATI hardware on Mac OS X // due to software fallbacks if (NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { - String vendor = gl.glGetString(GL.GL_VENDOR); + final String vendor = gl.glGetString(GL.GL_VENDOR); if (vendor != null && vendor.startsWith("ATI")) { return true; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java index ba59f89c5..17fcc7016 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java @@ -48,14 +48,14 @@ package com.jogamp.opengl.util.texture; public class TextureCoords { // These represent the lower-left point - private float left; - private float bottom; + private final float left; + private final float bottom; // These represent the upper-right point - private float right; - private float top; + private final float right; + private final float top; - public TextureCoords(float left, float bottom, - float right, float top) { + public TextureCoords(final float left, final float bottom, + final float right, final float top) { this.left = left; this.bottom = bottom; this.right = right; @@ -70,7 +70,7 @@ public class TextureCoords { * right top * </pre> */ - public float[] getST_LB_RB_LT_RT(float[] d, int d_off, float ss, float ts) { + public float[] getST_LB_RB_LT_RT(final float[] d, final int d_off, final float ss, final float ts) { d[0+d_off] = left *ss; d[1+d_off] = bottom*ts; d[2+d_off] = right *ss; d[3+d_off] = bottom*ts; d[4+d_off] = left *ss; d[5+d_off] = top *ts; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 5d88a76c0..5b2e4fc00 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -41,6 +41,7 @@ import java.nio.Buffer; import javax.media.opengl.GLProfile; +import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.GLBuffers; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; @@ -123,18 +124,18 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, - int internalFormat, - int width, - int height, - int border, - int pixelFormat, - int pixelType, - boolean mipmap, - boolean dataIsCompressed, - boolean mustFlipVertically, - Buffer buffer, - Flusher flusher) throws IllegalArgumentException { + public TextureData(final GLProfile glp, + final int internalFormat, + final int width, + final int height, + final int border, + final int pixelFormat, + final int pixelType, + final boolean mipmap, + final boolean dataIsCompressed, + final boolean mustFlipVertically, + final Buffer buffer, + final Flusher flusher) throws IllegalArgumentException { this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), mipmap, dataIsCompressed, mustFlipVertically, buffer, flusher); } @@ -178,17 +179,17 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, - int internalFormat, - int width, - int height, - int border, - GLPixelAttributes pixelAttributes, - boolean mipmap, - boolean dataIsCompressed, - boolean mustFlipVertically, - Buffer buffer, - Flusher flusher) throws IllegalArgumentException { + public TextureData(final GLProfile glp, + final int internalFormat, + final int width, + final int height, + final int border, + final GLPixelAttributes pixelAttributes, + final boolean mipmap, + final boolean dataIsCompressed, + final boolean mustFlipVertically, + final Buffer buffer, + final Flusher flusher) throws IllegalArgumentException { if (mipmap && dataIsCompressed) { throw new IllegalArgumentException("Can not generate mipmaps for compressed textures"); } @@ -247,17 +248,17 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, - int internalFormat, - int width, - int height, - int border, - int pixelFormat, - int pixelType, - boolean dataIsCompressed, - boolean mustFlipVertically, - Buffer[] mipmapData, - Flusher flusher) throws IllegalArgumentException { + public TextureData(final GLProfile glp, + final int internalFormat, + final int width, + final int height, + final int border, + final int pixelFormat, + final int pixelType, + final boolean dataIsCompressed, + final boolean mustFlipVertically, + final Buffer[] mipmapData, + final Flusher flusher) throws IllegalArgumentException { this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), dataIsCompressed, mustFlipVertically, mipmapData, flusher); } @@ -300,16 +301,16 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, - int internalFormat, - int width, - int height, - int border, - GLPixelAttributes pixelAttributes, - boolean dataIsCompressed, - boolean mustFlipVertically, - Buffer[] mipmapData, - Flusher flusher) throws IllegalArgumentException { + public TextureData(final GLProfile glp, + final int internalFormat, + final int width, + final int height, + final int border, + final GLPixelAttributes pixelAttributes, + final boolean dataIsCompressed, + final boolean mustFlipVertically, + final Buffer[] mipmapData, + final Flusher flusher) throws IllegalArgumentException { this.glProfile = glp; this.width = width; this.height = height; @@ -318,7 +319,7 @@ public class TextureData { this.internalFormat = internalFormat; this.dataIsCompressed = dataIsCompressed; this.mustFlipVertically = mustFlipVertically; - this.mipmapData = (Buffer[]) mipmapData.clone(); + this.mipmapData = mipmapData.clone(); this.flusher = flusher; alignment = 1; // FIXME: is this correct enough in all situations? for (int i = 0; i < mipmapData.length; i++) { @@ -336,10 +337,10 @@ public class TextureData { * Set the color space of the pixel data, which defaults to {@link ColorSpace#RGB}. * @see #getColorSpace() */ - public void setColorSpace(ColorSpace cs) { pixelCS = cs; } + public void setColorSpace(final ColorSpace cs) { pixelCS = cs; } /** Used only by subclasses */ - protected TextureData(GLProfile glp) { this.glProfile = glp; this.pixelAttributes = GLPixelAttributes.UNDEF; } + protected TextureData(final GLProfile glp) { this.glProfile = glp; this.pixelAttributes = GLPixelAttributes.UNDEF; } /** Returns the width in pixels of the texture data. */ public int getWidth() { return width; } @@ -399,20 +400,20 @@ public class TextureData { } /** Sets the width in pixels of the texture data. */ - public void setWidth(int width) { this.width = width; } + public void setWidth(final int width) { this.width = width; } /** Sets the height in pixels of the texture data. */ - public void setHeight(int height) { this.height = height; } + public void setHeight(final int height) { this.height = height; } /** Sets the border in pixels of the texture data. */ - public void setBorder(int border) { this.border = border; } + public void setBorder(final int border) { this.border = border; } /** Sets the intended OpenGL pixel format of the texture data. */ - public void setPixelAttributes(GLPixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } + public void setPixelAttributes(final GLPixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } /** * Sets the intended OpenGL pixel format component of {@link GLPixelAttributes} of the texture data. * <p> * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. * </p> */ - public void setPixelFormat(int pixelFormat) { + public void setPixelFormat(final int pixelFormat) { if( pixelAttributes.format != pixelFormat ) { pixelAttributes = new GLPixelAttributes(pixelFormat, pixelAttributes.type); } @@ -423,42 +424,42 @@ public class TextureData { * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. * </p> */ - public void setPixelType(int pixelType) { + public void setPixelType(final int pixelType) { if( pixelAttributes.type != pixelType) { pixelAttributes = new GLPixelAttributes(pixelAttributes.format, pixelType); } } /** Sets the intended OpenGL internal format of the texture data. */ - public void setInternalFormat(int internalFormat) { this.internalFormat = internalFormat; } + public void setInternalFormat(final int internalFormat) { this.internalFormat = internalFormat; } /** Sets whether mipmaps should be generated for the texture data. */ - public void setMipmap(boolean mipmap) { this.mipmap = mipmap; } + public void setMipmap(final boolean mipmap) { this.mipmap = mipmap; } /** Sets whether the texture data is in compressed form. */ - public void setIsDataCompressed(boolean compressed) { this.dataIsCompressed = compressed; } + public void setIsDataCompressed(final boolean compressed) { this.dataIsCompressed = compressed; } /** Sets whether the texture coordinates must be flipped vertically for proper display. */ - public void setMustFlipVertically(boolean mustFlipVertically) { this.mustFlipVertically = mustFlipVertically; } + public void setMustFlipVertically(final boolean mustFlipVertically) { this.mustFlipVertically = mustFlipVertically; } /** Sets the texture data. */ - public void setBuffer(Buffer buffer) { + public void setBuffer(final Buffer buffer) { this.buffer = buffer; estimatedMemorySize = estimatedMemorySize(buffer); } /** Sets the required byte alignment for the texture data. */ - public void setAlignment(int alignment) { this.alignment = alignment; } + public void setAlignment(final int alignment) { this.alignment = alignment; } /** Sets the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures. */ - public void setRowLength(int rowLength) { this.rowLength = rowLength; } + public void setRowLength(final int rowLength) { this.rowLength = rowLength; } /** Indicates to this TextureData whether the GL_EXT_abgr extension is available. Used for optimization along some code paths to avoid data copies. */ - public void setHaveEXTABGR(boolean haveEXTABGR) { + public void setHaveEXTABGR(final boolean haveEXTABGR) { this.haveEXTABGR = haveEXTABGR; } /** Indicates to this TextureData whether OpenGL version 1.2 is available. If not, falls back to relatively inefficient code paths for several input data types (several kinds of packed pixel formats, in particular). */ - public void setHaveGL12(boolean haveGL12) { + public void setHaveGL12(final boolean haveGL12) { this.haveGL12 = haveGL12; } @@ -509,10 +510,10 @@ public class TextureData { // Internals only below this point // - protected static int estimatedMemorySize(Buffer buffer) { + protected static int estimatedMemorySize(final Buffer buffer) { if (buffer == null) { return 0; } - return buffer.capacity() * GLBuffers.sizeOfBufferElem(buffer); + return buffer.capacity() * Buffers.sizeOfBufferElem(buffer); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index b2bcd0de3..19f2fc05b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -60,6 +60,7 @@ import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.PixelFormat; import javax.media.opengl.GL; import javax.media.opengl.GL2; +import javax.media.opengl.GL2ES3; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -209,8 +210,8 @@ public class TextureIO { * registered texture providers could read the file * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(GLProfile glp, File file, - boolean mipmap, + public static TextureData newTextureData(final GLProfile glp, final File file, + final boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = IOUtil.getFileSuffix(file); @@ -239,9 +240,9 @@ public class TextureIO { * registered texture providers could read the stream * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(GLProfile glp, InputStream stream, - boolean mipmap, - String fileSuffix) throws IOException { + public static TextureData newTextureData(final GLProfile glp, final InputStream stream, + final boolean mipmap, + final String fileSuffix) throws IOException { return newTextureDataImpl(glp, stream, 0, 0, mipmap, fileSuffix); } @@ -266,8 +267,8 @@ public class TextureIO { * registered texture providers could read the URL * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(GLProfile glp, URL url, - boolean mipmap, + public static TextureData newTextureData(final GLProfile glp, final URL url, + final boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { fileSuffix = IOUtil.getFileSuffix(url.getPath()); @@ -314,10 +315,10 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the file */ - public static TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, + public static TextureData newTextureData(final GLProfile glp, final File file, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, String fileSuffix) throws IOException, IllegalArgumentException { if ((internalFormat == 0) || (pixelFormat == 0)) { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); @@ -362,11 +363,11 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the stream */ - public static TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException, IllegalArgumentException { + public static TextureData newTextureData(final GLProfile glp, final InputStream stream, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException, IllegalArgumentException { if ((internalFormat == 0) || (pixelFormat == 0)) { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); } @@ -406,10 +407,10 @@ public class TextureIO { * pixelFormat was 0 * @throws IOException if an error occurred while reading the URL */ - public static TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, + public static TextureData newTextureData(final GLProfile glp, final URL url, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, String fileSuffix) throws IOException, IllegalArgumentException { if ((internalFormat == 0) || (pixelFormat == 0)) { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); @@ -435,7 +436,7 @@ public class TextureIO { * OpenGL error occurred * @throws IllegalArgumentException if the passed TextureData was null */ - public static Texture newTexture(TextureData data) throws GLException, IllegalArgumentException { + public static Texture newTexture(final TextureData data) throws GLException, IllegalArgumentException { return newTexture(GLContext.getCurrentGL(), data); } @@ -448,7 +449,7 @@ public class TextureIO { * OpenGL error occurred * @throws IllegalArgumentException if the passed TextureData was null */ - public static Texture newTexture(GL gl, TextureData data) throws GLException, IllegalArgumentException { + public static Texture newTexture(final GL gl, final TextureData data) throws GLException, IllegalArgumentException { if (data == null) { throw new IllegalArgumentException("Null TextureData"); } @@ -470,11 +471,11 @@ public class TextureIO { * @throws GLException if no OpenGL context is current or if an * OpenGL error occurred */ - public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException { - GL gl = GLContext.getCurrentGL(); - GLProfile glp = gl.getGLProfile(); - TextureData data = newTextureData(glp, file, mipmap, IOUtil.getFileSuffix(file)); - Texture texture = newTexture(gl, data); + public static Texture newTexture(final File file, final boolean mipmap) throws IOException, GLException { + final GL gl = GLContext.getCurrentGL(); + final GLProfile glp = gl.getGLProfile(); + final TextureData data = newTextureData(glp, file, mipmap, IOUtil.getFileSuffix(file)); + final Texture texture = newTexture(gl, data); data.flush(); return texture; } @@ -499,11 +500,11 @@ public class TextureIO { * @throws GLException if no OpenGL context is current or if an * OpenGL error occurred */ - public static Texture newTexture(InputStream stream, boolean mipmap, String fileSuffix) throws IOException, GLException { - GL gl = GLContext.getCurrentGL(); - GLProfile glp = gl.getGLProfile(); - TextureData data = newTextureData(glp, stream, mipmap, fileSuffix); - Texture texture = newTexture(gl, data); + public static Texture newTexture(final InputStream stream, final boolean mipmap, final String fileSuffix) throws IOException, GLException { + final GL gl = GLContext.getCurrentGL(); + final GLProfile glp = gl.getGLProfile(); + final TextureData data = newTextureData(glp, stream, mipmap, fileSuffix); + final Texture texture = newTexture(gl, data); data.flush(); return texture; } @@ -528,14 +529,14 @@ public class TextureIO { * @throws GLException if no OpenGL context is current or if an * OpenGL error occurred */ - public static Texture newTexture(URL url, boolean mipmap, String fileSuffix) throws IOException, GLException { + public static Texture newTexture(final URL url, final boolean mipmap, String fileSuffix) throws IOException, GLException { if (fileSuffix == null) { fileSuffix = IOUtil.getFileSuffix(url.getPath()); } - GL gl = GLContext.getCurrentGL(); - GLProfile glp = gl.getGLProfile(); - TextureData data = newTextureData(glp, url, mipmap, fileSuffix); - Texture texture = newTexture(gl, data); + final GL gl = GLContext.getCurrentGL(); + final GLProfile glp = gl.getGLProfile(); + final TextureData data = newTextureData(glp, url, mipmap, fileSuffix); + final Texture texture = newTexture(gl, data); data.flush(); return texture; } @@ -549,7 +550,7 @@ public class TextureIO { * @param target the OpenGL target type, eg GL.GL_TEXTURE_2D, * GL.GL_TEXTURE_RECTANGLE_ARB */ - public static Texture newTexture(int target) { + public static Texture newTexture(final int target) { return new Texture(target); } @@ -579,31 +580,31 @@ public class TextureIO { * @throws GLException if no OpenGL context was current or an * OpenGL-related error occurred */ - public static void write(Texture texture, File file) throws IOException, GLException { + public static void write(final Texture texture, final File file) throws IOException, GLException { if (texture.getTarget() != GL.GL_TEXTURE_2D) { throw new GLException("Only GL_TEXTURE_2D textures are supported"); } // First fetch the texture data - GL _gl = GLContext.getCurrentGL(); + final GL _gl = GLContext.getCurrentGL(); if (!_gl.isGL2GL3()) { throw new GLException("Implementation only supports GL2GL3 (Use GLReadBufferUtil and the TextureData variant), have: " + _gl); } - GL2GL3 gl = _gl.getGL2(); + final GL2GL3 gl = _gl.getGL2(); texture.bind(gl); - int internalFormat = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_INTERNAL_FORMAT); - int width = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_WIDTH); - int height = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_HEIGHT); - int border = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_BORDER); + final int internalFormat = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2GL3.GL_TEXTURE_INTERNAL_FORMAT); + final int width = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2GL3.GL_TEXTURE_WIDTH); + final int height = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2GL3.GL_TEXTURE_HEIGHT); + final int border = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_BORDER); TextureData data = null; if (internalFormat == GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT || internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT || internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) { // Fetch using glGetCompressedTexImage - int size = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_COMPRESSED_IMAGE_SIZE); - ByteBuffer res = ByteBuffer.allocate(size); + final int size = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2GL3.GL_TEXTURE_COMPRESSED_IMAGE_SIZE); + final ByteBuffer res = ByteBuffer.allocate(size); gl.glGetCompressedTexImage(GL.GL_TEXTURE_2D, 0, res); data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, false, true, true, res, null); @@ -612,7 +613,7 @@ public class TextureIO { int fetchedFormat = 0; switch (internalFormat) { case GL.GL_RGB: - case GL2.GL_BGR: + case GL2GL3.GL_BGR: case GL.GL_RGB8: bytesPerPixel = 3; fetchedFormat = GL.GL_RGB; @@ -629,19 +630,19 @@ public class TextureIO { } // Fetch using glGetTexImage - int packAlignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT); - int packRowLength = glGetInteger(gl, GL2.GL_PACK_ROW_LENGTH); - int packSkipRows = glGetInteger(gl, GL2.GL_PACK_SKIP_ROWS); - int packSkipPixels = glGetInteger(gl, GL2.GL_PACK_SKIP_PIXELS); - int packSwapBytes = glGetInteger(gl, GL2.GL_PACK_SWAP_BYTES); + final int packAlignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT); + final int packRowLength = glGetInteger(gl, GL2ES3.GL_PACK_ROW_LENGTH); + final int packSkipRows = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_ROWS); + final int packSkipPixels = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_PIXELS); + final int packSwapBytes = glGetInteger(gl, GL2GL3.GL_PACK_SWAP_BYTES); gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1); - gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, 0); - gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, 0); - gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, 0); - gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, 0); + gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0); + gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0); + gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_PIXELS, 0); + gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, 0); - ByteBuffer res = ByteBuffer.allocate((width + (2 * border)) * + final ByteBuffer res = ByteBuffer.allocate((width + (2 * border)) * (height + (2 * border)) * bytesPerPixel); if (DEBUG) { @@ -651,10 +652,10 @@ public class TextureIO { gl.glGetTexImage(GL.GL_TEXTURE_2D, 0, fetchedFormat, GL.GL_UNSIGNED_BYTE, res); gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); - gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, packRowLength); - gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, packSkipRows); - gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels); - gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes); + gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength); + gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, packSkipRows); + gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_PIXELS, packSkipPixels); + gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, packSwapBytes); data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, false, false, false, res, null); @@ -668,9 +669,9 @@ public class TextureIO { write(data, file); } - public static void write(TextureData data, File file) throws IOException, GLException { - for (Iterator<TextureWriter> iter = textureWriters.iterator(); iter.hasNext(); ) { - TextureWriter writer = iter.next(); + public static void write(final TextureData data, final File file) throws IOException, GLException { + for (final Iterator<TextureWriter> iter = textureWriters.iterator(); iter.hasNext(); ) { + final TextureWriter writer = iter.next(); if (writer.write(file, data)) { return; } @@ -689,7 +690,7 @@ public class TextureIO { * The last provider added, will be the first provider to be tested. * </p> */ - public static void addTextureProvider(TextureProvider provider) { + public static void addTextureProvider(final TextureProvider provider) { // Must always add at the front so the ImageIO provider is last, // so we don't accidentally use it instead of a user's possibly // more optimal provider @@ -702,7 +703,7 @@ public class TextureIO { * The last provider added, will be the first provider to be tested. * </p> */ - public static void addTextureWriter(TextureWriter writer) { + public static void addTextureWriter(final TextureWriter writer) { // Must always add at the front so the ImageIO writer is last, // so we don't accidentally use it instead of a user's possibly // more optimal writer @@ -727,7 +728,7 @@ public class TextureIO { the GL_ARB_texture_rectangle extension to be turned off globally for this purpose. The default is that the use of the extension is enabled. */ - public static void setTexRectEnabled(boolean enabled) { + public static void setTexRectEnabled(final boolean enabled) { texRectEnabled = enabled; } @@ -750,10 +751,10 @@ public class TextureIO { if(GLProfile.isAWTAvailable()) { try { // Use reflection to avoid compile-time dependencies on AWT-related classes - TextureProvider provider = (TextureProvider) + final TextureProvider provider = (TextureProvider) Class.forName("com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance(); addTextureProvider(provider); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); } @@ -771,14 +772,14 @@ public class TextureIO { if(GLProfile.isAWTAvailable()) { try { // Use reflection to avoid compile-time dependencies on AWT-related classes - TextureWriter writer = (TextureWriter) + final TextureWriter writer = (TextureWriter) Class.forName("com.jogamp.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance(); addTextureWriter(writer); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); } - } catch (Error e) { + } catch (final Error e) { if (DEBUG) { e.printStackTrace(); } @@ -794,10 +795,10 @@ public class TextureIO { } // Implementation methods - private static TextureData newTextureDataImpl(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, + private static TextureData newTextureDataImpl(final GLProfile glp, final File file, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, String fileSuffix) throws IOException { if (file == null) { throw new IOException("File was null"); @@ -805,9 +806,9 @@ public class TextureIO { fileSuffix = toLowerCase(fileSuffix); - for (Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = iter.next(); - TextureData data = provider.newTextureData(glp, file, + for (final Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { + final TextureProvider provider = iter.next(); + final TextureData data = provider.newTextureData(glp, file, internalFormat, pixelFormat, mipmap, @@ -820,10 +821,10 @@ public class TextureIO { throw new IOException("No suitable reader for given file "+file.getAbsolutePath()); } - private static TextureData newTextureDataImpl(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, + private static TextureData newTextureDataImpl(final GLProfile glp, InputStream stream, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, String fileSuffix) throws IOException { if (stream == null) { throw new IOException("Stream was null"); @@ -836,9 +837,9 @@ public class TextureIO { stream = new BufferedInputStream(stream); } - for (Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = iter.next(); - TextureData data = provider.newTextureData(glp, stream, + for (final Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { + final TextureProvider provider = iter.next(); + final TextureData data = provider.newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, @@ -851,10 +852,10 @@ public class TextureIO { throw new IOException("No suitable reader for given stream"); } - private static TextureData newTextureDataImpl(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, + private static TextureData newTextureDataImpl(final GLProfile glp, final URL url, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, String fileSuffix) throws IOException { if (url == null) { throw new IOException("URL was null"); @@ -862,9 +863,9 @@ public class TextureIO { fileSuffix = toLowerCase(fileSuffix); - for (Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = iter.next(); - TextureData data = provider.newTextureData(glp, url, + for (final Iterator<TextureProvider> iter = textureProviders.iterator(); iter.hasNext(); ) { + final TextureProvider provider = iter.next(); + final TextureData data = provider.newTextureData(glp, url, internalFormat, pixelFormat, mipmap, @@ -881,14 +882,14 @@ public class TextureIO { // DDS provider -- supports files only for now static class DDSTextureProvider implements TextureProvider { @Override - public TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + public TextureData newTextureData(final GLProfile glp, final File file, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { if (DDS.equals(fileSuffix) || DDS.equals(IOUtil.getFileSuffix(file))) { - DDSImage image = DDSImage.read(file); + final DDSImage image = DDSImage.read(file); return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } @@ -896,16 +897,16 @@ public class TextureIO { } @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + public TextureData newTextureData(final GLProfile glp, final InputStream stream, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { if (DDS.equals(fileSuffix) || DDSImage.isDDSImage(stream)) { - byte[] data = IOUtil.copyStream2ByteArray(stream); - ByteBuffer buf = ByteBuffer.wrap(data); - DDSImage image = DDSImage.read(buf); + final byte[] data = IOUtil.copyStream2ByteArray(stream); + final ByteBuffer buf = ByteBuffer.wrap(data); + final DDSImage image = DDSImage.read(buf); return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } @@ -913,12 +914,12 @@ public class TextureIO { } @Override - public TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream stream = new BufferedInputStream(url.openStream()); + public TextureData newTextureData(final GLProfile glp, final URL url, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final InputStream stream = new BufferedInputStream(url.openStream()); try { return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { @@ -926,11 +927,11 @@ public class TextureIO { } } - private TextureData newTextureData(GLProfile glp, final DDSImage image, + private TextureData newTextureData(final GLProfile glp, final DDSImage image, int internalFormat, int pixelFormat, boolean mipmap) { - DDSImage.ImageInfo info = image.getMipMap(0); + final DDSImage.ImageInfo info = image.getMipMap(0); if (pixelFormat == 0) { switch (image.getPixelFormat()) { case DDSImage.D3DFMT_R8G8B8: @@ -967,7 +968,7 @@ public class TextureIO { break; } } - TextureData.Flusher flusher = new TextureData.Flusher() { + final TextureData.Flusher flusher = new TextureData.Flusher() { @Override public void flush() { image.close(); @@ -975,7 +976,7 @@ public class TextureIO { }; TextureData data; if (mipmap && image.getNumMipMaps() > 0) { - Buffer[] mipmapData = new Buffer[image.getNumMipMaps()]; + final Buffer[] mipmapData = new Buffer[image.getNumMipMaps()]; for (int i = 0; i < image.getNumMipMaps(); i++) { mipmapData[i] = image.getMipMap(i).getData(); } @@ -1013,12 +1014,12 @@ public class TextureIO { // Base class for SGI RGB and TGA image providers static abstract class StreamBasedTextureProvider implements TextureProvider { @Override - public TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream inStream = new BufferedInputStream(new FileInputStream(file)); + public TextureData newTextureData(final GLProfile glp, final File file, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final InputStream inStream = new BufferedInputStream(new FileInputStream(file)); try { // The SGIImage and TGAImage implementations use InputStreams // anyway so there isn't much point in having a separate code @@ -1034,12 +1035,12 @@ public class TextureIO { } @Override - public TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream stream = new BufferedInputStream(url.openStream()); + public TextureData newTextureData(final GLProfile glp, final URL url, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final InputStream stream = new BufferedInputStream(url.openStream()); try { return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { @@ -1052,15 +1053,15 @@ public class TextureIO { // SGI RGB image provider static class SGITextureProvider extends StreamBasedTextureProvider { @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, + public TextureData newTextureData(final GLProfile glp, final InputStream stream, int internalFormat, int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + final boolean mipmap, + final String fileSuffix) throws IOException { if (SGI.equals(fileSuffix) || SGI_RGB.equals(fileSuffix) || SGIImage.isSGIImage(stream)) { - SGIImage image = SGIImage.read(stream); + final SGIImage image = SGIImage.read(stream); if (pixelFormat == 0) { pixelFormat = image.getFormat(); } @@ -1088,13 +1089,13 @@ public class TextureIO { // TGA (Targa) image provider static class TGATextureProvider extends StreamBasedTextureProvider { @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, + public TextureData newTextureData(final GLProfile glp, final InputStream stream, int internalFormat, int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + final boolean mipmap, + final String fileSuffix) throws IOException { if (TGA.equals(fileSuffix)) { - TGAImage image = TGAImage.read(glp, stream); + final TGAImage image = TGAImage.read(glp, stream); if (pixelFormat == 0) { pixelFormat = image.getGLFormat(); } @@ -1126,11 +1127,11 @@ public class TextureIO { // PNG image provider static class PNGTextureProvider extends StreamBasedTextureProvider { @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, + public TextureData newTextureData(final GLProfile glp, final InputStream stream, int internalFormat, int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + final boolean mipmap, + final String fileSuffix) throws IOException { if (PNG.equals(fileSuffix)) { final PNGPixelRect image = PNGPixelRect.read(stream, null, true /* directBuffer */, 0 /* destMinStrideInBytes */, true /* destIsGLOriented */); final GLPixelAttributes glpa = GLPixelAttributes.convert(image.getPixelformat(), glp); @@ -1166,13 +1167,13 @@ public class TextureIO { // JPEG image provider static class JPGTextureProvider extends StreamBasedTextureProvider { @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, + public TextureData newTextureData(final GLProfile glp, final InputStream stream, int internalFormat, int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { + final boolean mipmap, + final String fileSuffix) throws IOException { if (JPG.equals(fileSuffix)) { - JPEGImage image = JPEGImage.read(/*glp, */ stream); + final JPEGImage image = JPEGImage.read(/*glp, */ stream); if (pixelFormat == 0) { pixelFormat = image.getGLFormat(); } @@ -1205,8 +1206,8 @@ public class TextureIO { // static class DDSTextureWriter implements TextureWriter { @Override - public boolean write(File file, - TextureData data) throws IOException { + public boolean write(final File file, + final TextureData data) throws IOException { if (DDS.equals(IOUtil.getFileSuffix(file))) { // See whether the DDS writer can handle this TextureData final GLPixelAttributes pixelAttribs = data.getPixelAttributes(); @@ -1239,7 +1240,7 @@ public class TextureIO { mipmaps = new ByteBuffer[] { (ByteBuffer) data.getBuffer() }; } - DDSImage image = DDSImage.createFromData(d3dFormat, + final DDSImage image = DDSImage.createFromData(d3dFormat, data.getWidth(), data.getHeight(), mipmaps); @@ -1256,9 +1257,9 @@ public class TextureIO { // static class SGITextureWriter implements TextureWriter { @Override - public boolean write(File file, - TextureData data) throws IOException { - String fileSuffix = IOUtil.getFileSuffix(file); + public boolean write(final File file, + final TextureData data) throws IOException { + final String fileSuffix = IOUtil.getFileSuffix(file); if (SGI.equals(fileSuffix) || SGI_RGB.equals(fileSuffix)) { // See whether the SGI writer can handle this TextureData @@ -1269,7 +1270,7 @@ public class TextureIO { pixelFormat == GL.GL_RGBA) && (pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { - ByteBuffer buf = ((data.getBuffer() != null) ? + final ByteBuffer buf = ((data.getBuffer() != null) ? (ByteBuffer) data.getBuffer() : (ByteBuffer) data.getMipmapData()[0]); byte[] bytes; @@ -1282,7 +1283,7 @@ public class TextureIO { buf.rewind(); } - SGIImage image = SGIImage.createFromData(data.getWidth(), + final SGIImage image = SGIImage.createFromData(data.getWidth(), data.getHeight(), (pixelFormat == GL.GL_RGBA), bytes); @@ -1302,8 +1303,8 @@ public class TextureIO { static class TGATextureWriter implements TextureWriter { @Override - public boolean write(File file, - TextureData data) throws IOException { + public boolean write(final File file, + final TextureData data) throws IOException { if (TGA.equals(IOUtil.getFileSuffix(file))) { // See whether the TGA writer can handle this TextureData final GLPixelAttributes pixelAttribs = data.getPixelAttributes(); @@ -1311,7 +1312,7 @@ public class TextureIO { final int pixelType = pixelAttribs.type; if ((pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA || - pixelFormat == GL2.GL_BGR || + pixelFormat == GL2GL3.GL_BGR || pixelFormat == GL.GL_BGRA ) && (pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { @@ -1324,16 +1325,16 @@ public class TextureIO { if( pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA ) { // Must reverse order of red and blue channels to get correct results - int skip = ((pixelFormat == GL.GL_RGB) ? 3 : 4); + final int skip = ((pixelFormat == GL.GL_RGB) ? 3 : 4); for (int i = 0; i < buf.remaining(); i += skip) { - byte red = buf.get(i + 0); - byte blue = buf.get(i + 2); + final byte red = buf.get(i + 0); + final byte blue = buf.get(i + 2); buf.put(i + 0, blue); buf.put(i + 2, red); } } - TGAImage image = TGAImage.createFromData(data.getWidth(), + final TGAImage image = TGAImage.createFromData(data.getWidth(), data.getHeight(), (pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA), false, buf); @@ -1353,7 +1354,7 @@ public class TextureIO { static class PNGTextureWriter implements TextureWriter { @Override - public boolean write(File file, TextureData data) throws IOException { + public boolean write(final File file, final TextureData data) throws IOException { if (PNG.equals(IOUtil.getFileSuffix(file))) { // See whether the PNG writer can handle this TextureData final GLPixelAttributes pixelAttribs = data.getPixelAttributes(); @@ -1403,19 +1404,19 @@ public class TextureIO { // Helper routines // - private static int glGetInteger(GL gl, int pname) { - int[] tmp = new int[1]; + private static int glGetInteger(final GL gl, final int pname) { + final int[] tmp = new int[1]; gl.glGetIntegerv(pname, tmp, 0); return tmp[0]; } - private static int glGetTexLevelParameteri(GL2GL3 gl, int target, int level, int pname) { - int[] tmp = new int[1]; + private static int glGetTexLevelParameteri(final GL2GL3 gl, final int target, final int level, final int pname) { + final int[] tmp = new int[1]; gl.glGetTexLevelParameteriv(target, 0, pname, tmp, 0); return tmp[0]; } - private static String toLowerCase(String arg) { + private static String toLowerCase(final String arg) { if (arg == null) { return null; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index ee3b600a5..5add4f695 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -114,11 +114,11 @@ public interface TextureSequence { * to associated related data. */ public static class TextureFrame extends TimeFrameI { - public TextureFrame(Texture t, int pts, int duration) { + public TextureFrame(final Texture t, final int pts, final int duration) { super(pts, duration); texture = t; } - public TextureFrame(Texture t) { + public TextureFrame(final Texture t) { texture = t; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java index d8320c690..467ab41c5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java @@ -53,7 +53,7 @@ public class TextureState { * Returns <code>0</code> is <code>textureTarget</code> is not supported. * </p> */ - public static final int getTextureTargetQueryName(int textureTarget) { + public static final int getTextureTargetQueryName(final int textureTarget) { final int texBindQName; switch(textureTarget) { case GL.GL_TEXTURE_2D: texBindQName = GL.GL_TEXTURE_BINDING_2D; break; @@ -61,7 +61,7 @@ public class TextureState { case GL2ES2.GL_TEXTURE_3D: texBindQName = GL2ES2.GL_TEXTURE_BINDING_3D; break; case GL2GL3.GL_TEXTURE_1D: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D; break; case GL2GL3.GL_TEXTURE_1D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D_ARRAY; break; - case GL2GL3.GL_TEXTURE_2D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_2D_ARRAY; break; + case GL.GL_TEXTURE_2D_ARRAY: texBindQName = GL.GL_TEXTURE_BINDING_2D_ARRAY; break; case GL2GL3.GL_TEXTURE_RECTANGLE: texBindQName = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE; break; case GL2GL3.GL_TEXTURE_BUFFER: texBindQName = GL2GL3.GL_TEXTURE_BINDING_BUFFER; break; case GL3.GL_TEXTURE_2D_MULTISAMPLE: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE; break; @@ -84,9 +84,9 @@ public class TextureState { */ private final int[] state = new int[] { 0, 0, 0, 0, 0, 0 }; - private static final String toHexString(int i) { return "0x"+Integer.toHexString(i); } + private static final String toHexString(final int i) { return "0x"+Integer.toHexString(i); } - private static final int activeTexture(GL gl) { + private static final int activeTexture(final GL gl) { final int[] vi = { 0 }; gl.glGetIntegerv(GL.GL_ACTIVE_TEXTURE, vi, 0); return vi[0]; @@ -99,7 +99,7 @@ public class TextureState { * @param textureTarget * @throws GLException if textureTarget is not supported */ - public TextureState(GL gl, int textureTarget) throws GLException { + public TextureState(final GL gl, final int textureTarget) throws GLException { this(gl, activeTexture(gl), textureTarget); } @@ -111,7 +111,7 @@ public class TextureState { * @param textureTarget * @throws GLException if textureTarget is not supported */ - public TextureState(GL gl, int textureUnit, int textureTarget) throws GLException { + public TextureState(final GL gl, final int textureUnit, final int textureTarget) throws GLException { target = textureTarget; state[0] = textureUnit; final int texBindQName = getTextureTargetQueryName(textureTarget); @@ -132,7 +132,7 @@ public class TextureState { * </p> * @param gl current GL context's GL object */ - public final void restore(GL gl) { + public final void restore(final GL gl) { gl.glActiveTexture(state[0]); gl.glBindTexture(target, state[1]); gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, state[2]); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java index 202c08e4e..ccb3ecc3c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java @@ -113,11 +113,11 @@ public class AWTTextureData extends TextureData { * texture * @param image the image containing the texture data */ - public AWTTextureData(GLProfile glp, - int internalFormat, - int pixelFormat, - boolean mipmap, - BufferedImage image) { + public AWTTextureData(final GLProfile glp, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final BufferedImage image) { super(glp); if (internalFormat == 0) { this.internalFormat = image.getColorModel().hasAlpha() ? GL.GL_RGBA : GL.GL_RGB; @@ -176,7 +176,7 @@ public class AWTTextureData extends TextureData { return buffer; } - private void createFromImage(GLProfile glp, BufferedImage image) { + private void createFromImage(final GLProfile glp, final BufferedImage image) { pixelAttributes = GLPixelAttributes.UNDEF; // Determine from image mustFlipVertically = true; @@ -185,7 +185,7 @@ public class AWTTextureData extends TextureData { int scanlineStride; - SampleModel sm = image.getRaster().getSampleModel(); + final SampleModel sm = image.getRaster().getSampleModel(); if (sm instanceof SinglePixelPackedSampleModel) { scanlineStride = ((SinglePixelPackedSampleModel)sm).getScanlineStride(); @@ -300,7 +300,7 @@ public class AWTTextureData extends TextureData { case BufferedImage.TYPE_BYTE_INDEXED: case BufferedImage.TYPE_CUSTOM: default: - java.awt.image.ColorModel cm = image.getColorModel(); + final java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 3; @@ -362,7 +362,7 @@ public class AWTTextureData extends TextureData { case BufferedImage.TYPE_BYTE_INDEXED: case BufferedImage.TYPE_CUSTOM: default: - java.awt.image.ColorModel cm = image.getColorModel(); + final java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 3; @@ -382,9 +382,9 @@ public class AWTTextureData extends TextureData { createNIOBufferFromImage(image); } - private void setupLazyCustomConversion(BufferedImage image) { + private void setupLazyCustomConversion(final BufferedImage image) { imageForLazyCustomConversion = image; - boolean hasAlpha = image.getColorModel().hasAlpha(); + final boolean hasAlpha = image.getColorModel().hasAlpha(); int pixelFormat = pixelAttributes.format; int pixelType = pixelAttributes.type; if (pixelFormat == 0) { @@ -395,7 +395,7 @@ public class AWTTextureData extends TextureData { // Allow previously-selected pixelType (if any) to override that // we can infer from the DataBuffer - DataBuffer data = image.getRaster().getDataBuffer(); + final DataBuffer data = image.getRaster().getDataBuffer(); if (data instanceof DataBufferByte || isPackedInt(image)) { // Don't use GL_UNSIGNED_INT for BufferedImage packed int images if (pixelType == 0) pixelType = GL.GL_UNSIGNED_BYTE; @@ -405,7 +405,7 @@ public class AWTTextureData extends TextureData { if (pixelType == 0) pixelType = GL.GL_FLOAT; } else if (data instanceof DataBufferInt) { // FIXME: should we support signed ints? - if (pixelType == 0) pixelType = GL2GL3.GL_UNSIGNED_INT; + if (pixelType == 0) pixelType = GL.GL_UNSIGNED_INT; } else if (data instanceof DataBufferShort) { if (pixelType == 0) pixelType = GL.GL_SHORT; } else if (data instanceof DataBufferUShort) { @@ -416,12 +416,12 @@ public class AWTTextureData extends TextureData { pixelAttributes = new GLPixelAttributes(pixelFormat, pixelType); } - private void createFromCustom(BufferedImage image) { - int width = image.getWidth(); - int height = image.getHeight(); + private void createFromCustom(final BufferedImage image) { + final int width = image.getWidth(); + final int height = image.getHeight(); // create a temporary image that is compatible with OpenGL - boolean hasAlpha = image.getColorModel().hasAlpha(); + final boolean hasAlpha = image.getColorModel().hasAlpha(); java.awt.image.ColorModel cm = null; int dataBufferType = image.getRaster().getDataBuffer().getDataType(); // Don't use integer components for packed int images @@ -444,13 +444,13 @@ public class AWTTextureData extends TextureData { } } - boolean premult = cm.isAlphaPremultiplied(); - WritableRaster raster = + final boolean premult = cm.isAlphaPremultiplied(); + final WritableRaster raster = cm.createCompatibleWritableRaster(width, height); - BufferedImage texImage = new BufferedImage(cm, raster, premult, null); + final BufferedImage texImage = new BufferedImage(cm, raster, premult, null); // copy the source image into the temporary image - Graphics2D g = texImage.createGraphics(); + final Graphics2D g = texImage.createGraphics(); g.setComposite(AlphaComposite.Src); g.drawImage(image, 0, 0, null); g.dispose(); @@ -459,8 +459,8 @@ public class AWTTextureData extends TextureData { createNIOBufferFromImage(texImage); } - private boolean isPackedInt(BufferedImage image) { - int imgType = image.getType(); + private boolean isPackedInt(final BufferedImage image) { + final int imgType = image.getType(); return (imgType == BufferedImage.TYPE_INT_RGB || imgType == BufferedImage.TYPE_INT_BGR || imgType == BufferedImage.TYPE_INT_ARGB || @@ -476,11 +476,11 @@ public class AWTTextureData extends TextureData { setupLazyCustomConversion(imageForLazyCustomConversion); } - private void createNIOBufferFromImage(BufferedImage image) { + private void createNIOBufferFromImage(final BufferedImage image) { buffer = wrapImageDataBuffer(image); } - private Buffer wrapImageDataBuffer(BufferedImage image) { + private Buffer wrapImageDataBuffer(final BufferedImage image) { // // Note: Grabbing the DataBuffer will defeat Java2D's image // management mechanism (as of JDK 5/6, at least). This shouldn't @@ -490,7 +490,7 @@ public class AWTTextureData extends TextureData { // it could be. // - DataBuffer data = image.getRaster().getDataBuffer(); + final DataBuffer data = image.getRaster().getDataBuffer(); if (data instanceof DataBufferByte) { return ByteBuffer.wrap(((DataBufferByte) data).getData()); } else if (data instanceof DataBufferDouble) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java index c70f5d0f3..c3b3adc75 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java @@ -59,8 +59,8 @@ public class AWTTextureIO extends TextureIO { * * @see #newTextureData(GLProfile, BufferedImage, boolean) */ - public static TextureData newTextureData(GLProfile glp, BufferedImage image, - boolean mipmap) { + public static TextureData newTextureData(final GLProfile glp, final BufferedImage image, + final boolean mipmap) { return newTextureDataImpl(glp, image, 0, 0, mipmap); } @@ -89,10 +89,10 @@ public class AWTTextureIO extends TextureIO { * @throws IllegalArgumentException if either internalFormat or * pixelFormat was 0 */ - public static TextureData newTextureData(GLProfile glp, BufferedImage image, - int internalFormat, - int pixelFormat, - boolean mipmap) throws IllegalArgumentException { + public static TextureData newTextureData(final GLProfile glp, final BufferedImage image, + final int internalFormat, + final int pixelFormat, + final boolean mipmap) throws IllegalArgumentException { if ((internalFormat == 0) || (pixelFormat == 0)) { throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); } @@ -112,18 +112,18 @@ public class AWTTextureIO extends TextureIO { * @throws GLException if no OpenGL context is current or if an * OpenGL error occurred */ - public static Texture newTexture(GLProfile glp, BufferedImage image, boolean mipmap) throws GLException { - TextureData data = newTextureData(glp, image, mipmap); - Texture texture = newTexture(data); + public static Texture newTexture(final GLProfile glp, final BufferedImage image, final boolean mipmap) throws GLException { + final TextureData data = newTextureData(glp, image, mipmap); + final Texture texture = newTexture(data); data.flush(); return texture; } - private static TextureData newTextureDataImpl(GLProfile glp, - BufferedImage image, - int internalFormat, - int pixelFormat, - boolean mipmap) { + private static TextureData newTextureDataImpl(final GLProfile glp, + final BufferedImage image, + final int internalFormat, + final int pixelFormat, + final boolean mipmap) { return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, image); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java index 7311f20b3..20fc92819 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java @@ -52,6 +52,7 @@ import java.nio.channels.FileChannel; import javax.media.opengl.GL; +import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.GLBuffers; @@ -67,13 +68,13 @@ public class DDSImage { that information in another way. */ public static class ImageInfo { - private ByteBuffer data; - private int width; - private int height; - private boolean isCompressed; - private int compressionFormat; + private final ByteBuffer data; + private final int width; + private final int height; + private final boolean isCompressed; + private final int compressionFormat; - public ImageInfo(ByteBuffer data, int width, int height, boolean compressed, int compressionFormat) { + public ImageInfo(final ByteBuffer data, final int width, final int height, final boolean compressed, final int compressionFormat) { this.data = data; this.width = width; this.height = height; this.isCompressed = compressed; this.compressionFormat = compressionFormat; } @@ -163,7 +164,7 @@ public class DDSImage { @return DDS image object @throws java.io.IOException if an I/O exception occurred */ - public static DDSImage read(String filename) throws IOException { + public static DDSImage read(final String filename) throws IOException { return read(new File(filename)); } @@ -174,8 +175,8 @@ public class DDSImage { @return DDS image object @throws java.io.IOException if an I/O exception occurred */ - public static DDSImage read(File file) throws IOException { - DDSImage image = new DDSImage(); + public static DDSImage read(final File file) throws IOException { + final DDSImage image = new DDSImage(); image.readFromFile(file); return image; } @@ -187,8 +188,8 @@ public class DDSImage { @return DDS image object @throws java.io.IOException if an I/O exception occurred */ - public static DDSImage read(ByteBuffer buf) throws IOException { - DDSImage image = new DDSImage(); + public static DDSImage read(final ByteBuffer buf) throws IOException { + final DDSImage image = new DDSImage(); image.readFromBuffer(buf); return image; } @@ -207,7 +208,7 @@ public class DDSImage { fis = null; } buf = null; - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } } @@ -228,11 +229,11 @@ public class DDSImage { * specified arguments * @return DDS image object */ - public static DDSImage createFromData(int d3dFormat, - int width, - int height, - ByteBuffer[] mipmapData) throws IllegalArgumentException { - DDSImage image = new DDSImage(); + public static DDSImage createFromData(final int d3dFormat, + final int width, + final int height, + final ByteBuffer[] mipmapData) throws IllegalArgumentException { + final DDSImage image = new DDSImage(); image.initFromData(d3dFormat, width, height, mipmapData); return image; } @@ -256,7 +257,7 @@ public class DDSImage { in.mark(4); int magic = 0; for (int i = 0; i < 4; i++) { - int tmp = in.read(); + final int tmp = in.read(); if (tmp < 0) { in.reset(); return false; @@ -272,7 +273,7 @@ public class DDSImage { * @param filename File name to write to * @throws java.io.IOException if an I/O exception occurred */ - public void write(String filename) throws IOException { + public void write(final String filename) throws IOException { write(new File(filename)); } @@ -281,12 +282,12 @@ public class DDSImage { * @param file File object to write to * @throws java.io.IOException if an I/O exception occurred */ - public void write(File file) throws IOException { - FileOutputStream stream = IOUtil.getFileOutputStream(file, true); - FileChannel chan = stream.getChannel(); + public void write(final File file) throws IOException { + final FileOutputStream stream = IOUtil.getFileOutputStream(file, true); + final FileChannel chan = stream.getChannel(); // Create ByteBuffer for header in case the start of our // ByteBuffer isn't actually memory-mapped - ByteBuffer hdr = ByteBuffer.allocate(Header.writtenSize()); + final ByteBuffer hdr = ByteBuffer.allocate(Header.writtenSize()); hdr.order(ByteOrder.LITTLE_ENDIAN); header.write(hdr); hdr.rewind(); @@ -302,12 +303,12 @@ public class DDSImage { * @param flag DDSD_* flags set to test * @return true if flag present or false otherwise */ - public boolean isSurfaceDescFlagSet(int flag) { + public boolean isSurfaceDescFlagSet(final int flag) { return ((header.flags & flag) != 0); } /** Test for presence/absence of pixel format flags (DDPF_*) */ - public boolean isPixelFormatFlagSet(int flag) { + public boolean isPixelFormatFlagSet(final int flag) { return ((header.pfFlags & flag) != 0); } @@ -357,7 +358,7 @@ public class DDSImage { * @param side Side to test * @return true if side present or false otherwise */ - public boolean isCubemapSidePresent(int side) { + public boolean isCubemapSidePresent(final int side) { return isCubemap() && (header.ddsCaps2 & side) != 0; } @@ -402,7 +403,7 @@ public class DDSImage { * @param map Mipmap index * @return Image object */ - public ImageInfo getMipMap(int map) { + public ImageInfo getMipMap(final int map) { return getMipMap( 0, map ); } @@ -412,7 +413,7 @@ public class DDSImage { * @param map Mipmap index * @return Image object */ - public ImageInfo getMipMap(int side, int map) { + public ImageInfo getMipMap(final int side, final int map) { if (!isCubemap() && (side != 0)) { throw new RuntimeException( "Illegal side for 2D texture: " + side ); } @@ -434,7 +435,7 @@ public class DDSImage { } buf.limit(seek + mipMapSizeInBytes(map)); buf.position(seek); - ByteBuffer next = buf.slice(); + final ByteBuffer next = buf.slice(); buf.position(0); buf.limit(buf.capacity()); return new ImageInfo(next, mipMapWidth(map), mipMapHeight(map), isCompressed(), getCompressionFormat()); @@ -454,12 +455,12 @@ public class DDSImage { * @param side Cubemap side or 0 for 2D texture * @return Mipmap image objects set */ - public ImageInfo[] getAllMipMaps( int side ) { + public ImageInfo[] getAllMipMaps( final int side ) { int numLevels = getNumMipMaps(); if (numLevels == 0) { numLevels = 1; } - ImageInfo[] result = new ImageInfo[numLevels]; + final ImageInfo[] result = new ImageInfo[numLevels]; for (int i = 0; i < numLevels; i++) { result[i] = getMipMap(side, i); } @@ -472,9 +473,9 @@ public class DDSImage { @return String format code */ public static String getCompressionFormatName(int compressionFormat) { - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); for (int i = 0; i < 4; i++) { - char c = (char) (compressionFormat & 0xFF); + final char c = (char) (compressionFormat & 0xFF); buf.append(c); compressionFormat = compressionFormat >> 8; } @@ -491,9 +492,9 @@ public class DDSImage { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, or GL_COMPRESSED_RGBA_S3TC_DXT5_EXT. */ - public static ByteBuffer allocateBlankBuffer(int width, - int height, - int openGLInternalFormat) { + public static ByteBuffer allocateBlankBuffer(final int width, + final int height, + final int openGLInternalFormat) { int size = width * height; switch (openGLInternalFormat) { case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: @@ -511,15 +512,15 @@ public class DDSImage { } if (size == 0) size = 1; - return GLBuffers.newDirectByteBuffer(size); + return Buffers.newDirectByteBuffer(size); } public void debugPrint() { - PrintStream tty = System.err; + final PrintStream tty = System.err; tty.println("Compressed texture: " + isCompressed()); if (isCompressed()) { - int fmt = getCompressionFormat(); - String name = getCompressionFormatName(fmt); + final int fmt = getCompressionFormat(); + final String name = getCompressionFormatName(fmt); tty.println("Compression format: 0x" + Integer.toHexString(fmt) + " (" + name + ")"); } tty.println("Width: " + header.width + " Height: " + header.height); @@ -567,7 +568,7 @@ public class DDSImage { tty.println("Raw pixel format flags: 0x" + Integer.toHexString(header.pfFlags)); tty.println("Depth: " + getDepth()); tty.println("Number of mip maps: " + getNumMipMaps()); - int fmt = getPixelFormat(); + final int fmt = getPixelFormat(); tty.print("Pixel format: "); switch (fmt) { case D3DFMT_R8G8B8: tty.println("D3DFMT_R8G8B8"); break; @@ -629,8 +630,8 @@ public class DDSImage { int ddsCapsReserved2; int textureStage; // stage in multitexture cascade - void read(ByteBuffer buf) throws IOException { - int magic = buf.getInt(); + void read(final ByteBuffer buf) throws IOException { + final int magic = buf.getInt(); if (magic != MAGIC) { throw new IOException("Incorrect magic number 0x" + Integer.toHexString(magic) + @@ -671,7 +672,7 @@ public class DDSImage { } // buf must be in little-endian byte order - void write(ByteBuffer buf) { + void write(final ByteBuffer buf) { buf.putInt(MAGIC); buf.putInt(size); buf.putInt(flags); @@ -722,15 +723,15 @@ public class DDSImage { private DDSImage() { } - private void readFromFile(File file) throws IOException { + private void readFromFile(final File file) throws IOException { fis = new FileInputStream(file); chan = fis.getChannel(); - ByteBuffer buf = chan.map(FileChannel.MapMode.READ_ONLY, + final ByteBuffer buf = chan.map(FileChannel.MapMode.READ_ONLY, 0, (int) file.length()); readFromBuffer(buf); } - private void readFromBuffer(ByteBuffer buf) throws IOException { + private void readFromBuffer(final ByteBuffer buf) throws IOException { this.buf = buf; buf.order(ByteOrder.LITTLE_ENDIAN); header = new Header(); @@ -738,10 +739,10 @@ public class DDSImage { fixupHeader(); } - private void initFromData(int d3dFormat, - int width, - int height, - ByteBuffer[] mipmapData) throws IllegalArgumentException { + private void initFromData(final int d3dFormat, + final int width, + final int height, + final ByteBuffer[] mipmapData) throws IllegalArgumentException { // Check size of mipmap data compared against format, width and // height int topmostMipmapSize = width * height; @@ -784,7 +785,7 @@ public class DDSImage { // OK, create one large ByteBuffer to hold all of the mipmap data totalSize += Header.writtenSize(); - ByteBuffer buf = ByteBuffer.allocate(totalSize); + final ByteBuffer buf = ByteBuffer.allocate(totalSize); buf.position(Header.writtenSize()); for (int i = 0; i < mipmapData.length; i++) { buf.put(mipmapData[i]); @@ -845,10 +846,10 @@ public class DDSImage { } } - private static int computeCompressedBlockSize(int width, - int height, - int depth, - int compressionFormat) { + private static int computeCompressedBlockSize(final int width, + final int height, + final int depth, + final int compressionFormat) { int blockSize = ((width + 3)/4) * ((height + 3)/4) * ((depth + 3)/4); switch (compressionFormat) { case D3DFMT_DXT1: blockSize *= 8; break; @@ -857,10 +858,10 @@ public class DDSImage { return blockSize; } - private static int computeBlockSize(int width, - int height, - int depth, - int pixelFormat) { + private static int computeBlockSize(final int width, + final int height, + final int depth, + final int pixelFormat) { int blocksize; switch (pixelFormat) { case D3DFMT_R8G8B8: @@ -883,7 +884,7 @@ public class DDSImage { return blocksize; } - private int mipMapWidth(int map) { + private int mipMapWidth(final int map) { int width = getWidth(); for (int i = 0; i < map; i++) { width >>= 1; @@ -891,7 +892,7 @@ public class DDSImage { return Math.max(width, 1); } - private int mipMapHeight(int map) { + private int mipMapHeight(final int map) { int height = getHeight(); for (int i = 0; i < map; i++) { height >>= 1; @@ -899,11 +900,11 @@ public class DDSImage { return Math.max(height, 1); } - private int mipMapSizeInBytes(int map) { - int width = mipMapWidth(map); - int height = mipMapHeight(map); + private int mipMapSizeInBytes(final int map) { + final int width = mipMapWidth(map); + final int height = mipMapHeight(map); if (isCompressed()) { - int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16); + final int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16); return ((width+3)/4)*((height+3)/4)*blockSize; } else { return width * height * (getDepth() / 8); @@ -924,8 +925,8 @@ public class DDSImage { return size; } - private int sideShiftInBytes(int side) { - int[] sides = { + private int sideShiftInBytes(final int side) { + final int[] sides = { DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_NEGATIVEX, DDSCAPS2_CUBEMAP_POSITIVEY, @@ -935,9 +936,9 @@ public class DDSImage { }; int shift = 0; - int sideSize = sideSizeInBytes(); + final int sideSize = sideSizeInBytes(); for (int i = 0; i < sides.length; i++) { - int temp = sides[i]; + final int temp = sides[i]; if ((temp & side) != 0) { return shift; } @@ -948,7 +949,7 @@ public class DDSImage { throw new RuntimeException("Illegal side: " + side); } - private boolean printIfRecognized(PrintStream tty, int flags, int flag, String what) { + private boolean printIfRecognized(final PrintStream tty, final int flags, final int flag, final String what) { if ((flags & flag) != 0) { tty.println(what); return true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java index 2081788ba..66a486f9b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java @@ -51,12 +51,12 @@ public class JPEGImage { * @return * @throws IOException */ - public static JPEGImage read(InputStream in, ColorSpace cs) throws IOException { + public static JPEGImage read(final InputStream in, final ColorSpace cs) throws IOException { return new JPEGImage(in, cs); } /** Reads a JPEG image from the specified InputStream, using the {@link ColorSpace#RGB}. */ - public static JPEGImage read(InputStream in) throws IOException { + public static JPEGImage read(final InputStream in) throws IOException { return new JPEGImage(in, ColorSpace.RGB); } @@ -68,7 +68,7 @@ public class JPEGImage { final ColorSpace storageCS; ByteBuffer data = null; - JPEGColorSink(ColorSpace storageCM) { + JPEGColorSink(final ColorSpace storageCM) { this.storageCS = storageCM; switch(storageCS) { case RGB: @@ -81,7 +81,7 @@ public class JPEGImage { } @Override - public final ColorSpace allocate(int width, int height, ColorSpace sourceCM, int sourceComponents) throws RuntimeException { + public final ColorSpace allocate(final int width, final int height, final ColorSpace sourceCM, final int sourceComponents) throws RuntimeException { this.width = width; this.height = height; this.sourceComponents = sourceComponents; @@ -91,7 +91,7 @@ public class JPEGImage { } @Override - public final void storeRGB(int x, int y, byte r, byte g, byte b) { + public final void storeRGB(final int x, final int y, final byte r, final byte g, final byte b) { int i = ( ( height - y - 1 ) * width + x ) * storageComponents; data.put(i++, r); data.put(i++, g); @@ -100,12 +100,12 @@ public class JPEGImage { } @Override - public final void store2(int x, int y, byte c1, byte c2) { + public final void store2(final int x, final int y, final byte c1, final byte c2) { throw new RuntimeException("not supported yet"); } @Override - public final void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr) { + public final void storeYCbCr(final int x, final int y, final byte Y, final byte Cb, final byte Cr) { int i = ( ( height - y - 1 ) * width + x ) * storageComponents; data.put(i++, Y); data.put(i++, Cb); @@ -118,7 +118,7 @@ public class JPEGImage { } }; - private JPEGImage(InputStream in, ColorSpace cs) throws IOException { + private JPEGImage(final InputStream in, final ColorSpace cs) throws IOException { pixelStorage = new JPEGColorSink(cs); final JPEGDecoder decoder = new JPEGDecoder(); decoder.parse(in); @@ -139,9 +139,9 @@ public class JPEGImage { } decoder.clear(null); } - private JPEGColorSink pixelStorage; + private final JPEGColorSink pixelStorage; private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; - private boolean reversedChannels; + private final boolean reversedChannels; private final ByteBuffer data; /** Returns the color space of the pixel data */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java index 3c90d96e4..f121478e7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java @@ -76,7 +76,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput */ DataInputStream dataIn; - public LEDataInputStream(InputStream in) + public LEDataInputStream(final InputStream in) { super(in); dataIn = new DataInputStream(in); @@ -90,32 +90,32 @@ public class LEDataInputStream extends FilterInputStream implements DataInput } @Override - public synchronized final int read(byte b[]) throws IOException + public synchronized final int read(final byte b[]) throws IOException { return dataIn.read(b, 0, b.length); } @Override - public synchronized final int read(byte b[], int off, int len) throws IOException + public synchronized final int read(final byte b[], final int off, final int len) throws IOException { - int rl = dataIn.read(b, off, len); + final int rl = dataIn.read(b, off, len); return rl; } @Override - public final void readFully(byte b[]) throws IOException + public final void readFully(final byte b[]) throws IOException { dataIn.readFully(b, 0, b.length); } @Override - public final void readFully(byte b[], int off, int len) throws IOException + public final void readFully(final byte b[], final int off, final int len) throws IOException { dataIn.readFully(b, off, len); } @Override - public final int skipBytes(int n) throws IOException + public final int skipBytes(final int n) throws IOException { return dataIn.skipBytes(n); } @@ -123,7 +123,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final boolean readBoolean() throws IOException { - int ch = dataIn.read(); + final int ch = dataIn.read(); if (ch < 0) throw new EOFException(); return (ch != 0); @@ -132,7 +132,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final byte readByte() throws IOException { - int ch = dataIn.read(); + final int ch = dataIn.read(); if (ch < 0) throw new EOFException(); return (byte)(ch); @@ -141,7 +141,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final int readUnsignedByte() throws IOException { - int ch = dataIn.read(); + final int ch = dataIn.read(); if (ch < 0) throw new EOFException(); return ch; @@ -150,8 +150,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final short readShort() throws IOException { - int ch1 = dataIn.read(); - int ch2 = dataIn.read(); + final int ch1 = dataIn.read(); + final int ch2 = dataIn.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (short)((ch1 << 0) + (ch2 << 8)); @@ -160,8 +160,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final int readUnsignedShort() throws IOException { - int ch1 = dataIn.read(); - int ch2 = dataIn.read(); + final int ch1 = dataIn.read(); + final int ch2 = dataIn.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (ch1 << 0) + (ch2 << 8); @@ -170,8 +170,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final char readChar() throws IOException { - int ch1 = dataIn.read(); - int ch2 = dataIn.read(); + final int ch1 = dataIn.read(); + final int ch2 = dataIn.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (char)((ch1 << 0) + (ch2 << 8)); @@ -180,10 +180,10 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final int readInt() throws IOException { - int ch1 = dataIn.read(); - int ch2 = dataIn.read(); - int ch3 = dataIn.read(); - int ch4 = dataIn.read(); + final int ch1 = dataIn.read(); + final int ch2 = dataIn.read(); + final int ch3 = dataIn.read(); + final int ch4 = dataIn.read(); if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException(); return ((ch1 << 0) + (ch2 << 8) + (ch3 << 16) + (ch4 << 24)); @@ -192,9 +192,9 @@ public class LEDataInputStream extends FilterInputStream implements DataInput @Override public final long readLong() throws IOException { - int i1 = readInt(); - int i2 = readInt(); - return ((long)i1 & 0xFFFFFFFFL) + ((long)i2 << 32); + final int i1 = readInt(); + final int i2 = readInt(); + return (i1 & 0xFFFFFFFFL) + ((long)i2 << 32); } @Override @@ -233,7 +233,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput * dont call this it is not implemented * @return empty new string **/ - public final static String readUTF(DataInput in) throws IOException + public final static String readUTF(final DataInput in) throws IOException { return new String(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java index 93b097500..add177546 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java @@ -72,7 +72,7 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput */ DataOutputStream dataOut; - public LEDataOutputStream(OutputStream out) + public LEDataOutputStream(final OutputStream out) { super(out); dataOut = new DataOutputStream(out); @@ -86,44 +86,44 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput } @Override - public synchronized final void write(byte b[]) throws IOException + public synchronized final void write(final byte b[]) throws IOException { dataOut.write(b, 0, b.length); } @Override - public synchronized final void write(byte b[], int off, int len) throws IOException + public synchronized final void write(final byte b[], final int off, final int len) throws IOException { dataOut.write(b, off, len); } @Override - public final void write(int b) throws IOException + public final void write(final int b) throws IOException { dataOut.write(b); } @Override - public final void writeBoolean(boolean v) throws IOException + public final void writeBoolean(final boolean v) throws IOException { dataOut.writeBoolean(v); } @Override - public final void writeByte(int v) throws IOException + public final void writeByte(final int v) throws IOException { dataOut.writeByte(v); } /** Don't call this -- not implemented */ @Override - public final void writeBytes(String s) throws IOException + public final void writeBytes(final String s) throws IOException { throw new UnsupportedOperationException(); } @Override - public final void writeChar(int v) throws IOException + public final void writeChar(final int v) throws IOException { dataOut.writeChar(((v >> 8) & 0xff) | ((v & 0xff) << 8)); @@ -131,25 +131,25 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput /** Don't call this -- not implemented */ @Override - public final void writeChars(String s) throws IOException + public final void writeChars(final String s) throws IOException { throw new UnsupportedOperationException(); } @Override - public final void writeDouble(double v) throws IOException + public final void writeDouble(final double v) throws IOException { writeLong(Double.doubleToRawLongBits(v)); } @Override - public final void writeFloat(float v) throws IOException + public final void writeFloat(final float v) throws IOException { writeInt(Float.floatToRawIntBits(v)); } @Override - public final void writeInt(int v) throws IOException + public final void writeInt(final int v) throws IOException { dataOut.writeInt((v >>> 24) | ((v >>> 8) & 0xff00) | @@ -158,14 +158,14 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput } @Override - public final void writeLong(long v) throws IOException + public final void writeLong(final long v) throws IOException { writeInt((int) v); writeInt((int) (v >>> 32)); } @Override - public final void writeShort(int v) throws IOException + public final void writeShort(final int v) throws IOException { dataOut.writeShort(((v >> 8) & 0xff) | ((v & 0xff) << 8)); @@ -173,7 +173,7 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput /** Don't call this -- not implemented */ @Override - public final void writeUTF(String s) throws IOException + public final void writeUTF(final String s) throws IOException { throw new UnsupportedOperationException(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java index cabf4ebc5..461ddceb8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java @@ -63,7 +63,7 @@ public class NetPbmTextureWriter implements TextureWriter { * magic 7 - PAM binary RGB or RGBA * </pre> */ - public NetPbmTextureWriter(int magic) { + public NetPbmTextureWriter(final int magic) { switch(magic) { case 0: case 6: @@ -85,7 +85,7 @@ public class NetPbmTextureWriter implements TextureWriter { public String getSuffix() { return (magic==6)?PPM:PAM; } @Override - public boolean write(File file, TextureData data) throws IOException { + public boolean write(final File file, final TextureData data) throws IOException { boolean res; final int magic_old = magic; @@ -107,12 +107,12 @@ public class NetPbmTextureWriter implements TextureWriter { return res; } - private boolean writeImpl(File file, TextureData data) throws IOException { + private boolean writeImpl(final File file, final TextureData data) throws IOException { int pixelFormat = data.getPixelFormat(); final int pixelType = data.getPixelType(); if ((pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA || - pixelFormat == GL2.GL_BGR || + pixelFormat == GL2GL3.GL_BGR || pixelFormat == GL.GL_BGRA ) && (pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { @@ -123,13 +123,13 @@ public class NetPbmTextureWriter implements TextureWriter { } buf.rewind(); - int comps = ( pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA ) ? 4 : 3 ; + final int comps = ( pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA ) ? 4 : 3 ; - if( pixelFormat == GL2.GL_BGR || pixelFormat == GL.GL_BGRA ) { + if( pixelFormat == GL2GL3.GL_BGR || pixelFormat == GL.GL_BGRA ) { // Must reverse order of red and blue channels to get correct results for (int i = 0; i < buf.remaining(); i += comps) { - byte red = buf.get(i + 0); - byte blue = buf.get(i + 2); + final byte red = buf.get(i + 0); + final byte blue = buf.get(i + 2); buf.put(i + 0, blue); buf.put(i + 2, red); } @@ -141,9 +141,9 @@ public class NetPbmTextureWriter implements TextureWriter { throw new IOException("NetPbmTextureWriter magic 6 (PPM) doesn't RGBA pixel format, use magic 7 (PAM)"); } - FileOutputStream fos = IOUtil.getFileOutputStream(file, true); + final FileOutputStream fos = IOUtil.getFileOutputStream(file, true); - StringBuilder header = new StringBuilder(); + final StringBuilder header = new StringBuilder(); header.append("P"); header.append(magic); header.append("\n"); @@ -173,7 +173,7 @@ public class NetPbmTextureWriter implements TextureWriter { fos.write(header.toString().getBytes()); - FileChannel fosc = fos.getChannel(); + final FileChannel fosc = fos.getChannel(); fosc.write(buf); fosc.force(true); fosc.close(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java index cbc8e652f..27549dfe3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java @@ -54,7 +54,7 @@ import com.jogamp.common.util.IOUtil; */ public class SGIImage { - private Header header; + private final Header header; private int format; private byte[] data; // Used for decoding RLE-compressed images @@ -105,7 +105,7 @@ public class SGIImage { magic = MAGIC; } - Header(DataInputStream in) throws IOException { + Header(final DataInputStream in) throws IOException { magic = in.readShort(); storage = in.readByte(); bpc = in.readByte(); @@ -116,13 +116,13 @@ public class SGIImage { pixmin = in.readInt(); pixmax = in.readInt(); dummy = in.readInt(); - byte[] tmpname = new byte[80]; + final byte[] tmpname = new byte[80]; in.read(tmpname); int numChars = 0; while (tmpname[numChars++] != 0); imagename = new String(tmpname, 0, numChars); colormap = in.readInt(); - byte[] tmp = new byte[404]; + final byte[] tmp = new byte[404]; in.read(tmp); } @@ -142,21 +142,21 @@ public class SGIImage { } } - private SGIImage(Header header) { + private SGIImage(final Header header) { this.header = header; } /** Reads an SGI image from the specified file. */ - public static SGIImage read(String filename) throws IOException { + public static SGIImage read(final String filename) throws IOException { return read(new FileInputStream(filename)); } /** Reads an SGI image from the specified InputStream. */ - public static SGIImage read(InputStream in) throws IOException { - DataInputStream dIn = new DataInputStream(new BufferedInputStream(in)); + public static SGIImage read(final InputStream in) throws IOException { + final DataInputStream dIn = new DataInputStream(new BufferedInputStream(in)); - Header header = new Header(dIn); - SGIImage res = new SGIImage(header); + final Header header = new Header(dIn); + final SGIImage res = new SGIImage(header); res.decodeImage(dIn); return res; } @@ -164,28 +164,28 @@ public class SGIImage { /** Writes this SGIImage to the specified file name. If flipVertically is set, outputs the scanlines from top to bottom rather than the default bottom to top order. */ - public void write(String filename, boolean flipVertically) throws IOException { + public void write(final String filename, final boolean flipVertically) throws IOException { write(new File(filename), flipVertically); } /** Writes this SGIImage to the specified file. If flipVertically is set, outputs the scanlines from top to bottom rather than the default bottom to top order. */ - public void write(File file, boolean flipVertically) throws IOException { + public void write(final File file, final boolean flipVertically) throws IOException { writeImage(file, data, header.xsize, header.ysize, header.zsize, flipVertically); } /** Creates an SGIImage from the specified data in either RGB or RGBA format. */ - public static SGIImage createFromData(int width, - int height, - boolean hasAlpha, - byte[] data) { - Header header = new Header(); + public static SGIImage createFromData(final int width, + final int height, + final boolean hasAlpha, + final byte[] data) { + final Header header = new Header(); header.xsize = (short) width; header.ysize = (short) height; header.zsize = (short) (hasAlpha ? 4 : 3); - SGIImage image = new SGIImage(header); + final SGIImage image = new SGIImage(header); image.data = data; return image; } @@ -201,9 +201,9 @@ public class SGIImage { if (!in.markSupported()) { throw new IOException("Can not test non-destructively whether given InputStream is an SGI RGB image"); } - DataInputStream dIn = new DataInputStream(in); + final DataInputStream dIn = new DataInputStream(in); dIn.mark(4); - short magic = dIn.readShort(); + final short magic = dIn.readShort(); dIn.reset(); return (magic == MAGIC); } @@ -236,10 +236,10 @@ public class SGIImage { // Internals only below this point // - private void decodeImage(DataInputStream in) throws IOException { + private void decodeImage(final DataInputStream in) throws IOException { if (header.storage == 1) { // Read RLE compression data; row starts and sizes - int x = header.ysize * header.zsize; + final int x = header.ysize * header.zsize; rowStart = new int[x]; rowSize = new int[x]; rleEnd = 4 * 2 * x + 512; @@ -253,16 +253,16 @@ public class SGIImage { } tmpData = readAll(in); - int xsize = header.xsize; - int ysize = header.ysize; - int zsize = header.zsize; + final int xsize = header.xsize; + final int ysize = header.ysize; + final int zsize = header.zsize; int lptr = 0; data = new byte[xsize * ysize * 4]; - byte[] rbuf = new byte[xsize]; - byte[] gbuf = new byte[xsize]; - byte[] bbuf = new byte[xsize]; - byte[] abuf = new byte[xsize]; + final byte[] rbuf = new byte[xsize]; + final byte[] gbuf = new byte[xsize]; + final byte[] bbuf = new byte[xsize]; + final byte[] abuf = new byte[xsize]; for (int y = 0; y < ysize; y++) { if (zsize >= 4) { getRow(rbuf, y, 0); @@ -293,15 +293,15 @@ public class SGIImage { header.zsize = 4; } - private void getRow(byte[] buf, int y, int z) { + private void getRow(final byte[] buf, final int y, final int z) { if (header.storage == 1) { - int offs = rowStart[y + z * header.ysize] - rleEnd; + final int offs = rowStart[y + z * header.ysize] - rleEnd; System.arraycopy(tmpData, offs, tmpRead, 0, rowSize[y + z * header.ysize]); int iPtr = 0; int oPtr = 0; for (;;) { byte pixel = tmpRead[iPtr++]; - int count = (int) (pixel & 0x7F); + int count = pixel & 0x7F; if (count == 0) { return; } @@ -317,12 +317,12 @@ public class SGIImage { } } } else { - int offs = (y * header.xsize) + (z * header.xsize * header.ysize); + final int offs = (y * header.xsize) + (z * header.xsize * header.ysize); System.arraycopy(tmpData, offs, buf, 0, header.xsize); } } - private void bwtorgba(byte[] b, byte[] dest, int lptr) { + private void bwtorgba(final byte[] b, final byte[] dest, final int lptr) { for (int i = 0; i < b.length; i++) { dest[4 * i + lptr + 0] = b[i]; dest[4 * i + lptr + 1] = b[i]; @@ -331,7 +331,7 @@ public class SGIImage { } } - private void latorgba(byte[] b, byte[] a, byte[] dest, int lptr) { + private void latorgba(final byte[] b, final byte[] a, final byte[] dest, final int lptr) { for (int i = 0; i < b.length; i++) { dest[4 * i + lptr + 0] = b[i]; dest[4 * i + lptr + 1] = b[i]; @@ -340,7 +340,7 @@ public class SGIImage { } } - private void rgbtorgba(byte[] r, byte[] g, byte[] b, byte[] dest, int lptr) { + private void rgbtorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] dest, final int lptr) { for (int i = 0; i < b.length; i++) { dest[4 * i + lptr + 0] = r[i]; dest[4 * i + lptr + 1] = g[i]; @@ -349,7 +349,7 @@ public class SGIImage { } } - private void rgbatorgba(byte[] r, byte[] g, byte[] b, byte[] a, byte[] dest, int lptr) { + private void rgbatorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] a, final byte[] dest, final int lptr) { for (int i = 0; i < b.length; i++) { dest[4 * i + lptr + 0] = r[i]; dest[4 * i + lptr + 1] = g[i]; @@ -358,19 +358,19 @@ public class SGIImage { } } - private static byte imgref(byte[] i, - int x, - int y, - int z, - int xs, - int ys, - int zs) { + private static byte imgref(final byte[] i, + final int x, + final int y, + final int z, + final int xs, + final int ys, + final int zs) { return i[(xs*ys*z)+(xs*y)+x]; } - private void writeHeader(DataOutputStream stream, - int xsize, int ysize, int zsize, boolean rle) throws IOException { + private void writeHeader(final DataOutputStream stream, + final int xsize, final int ysize, final int zsize, final boolean rle) throws IOException { // effects: outputs the 512-byte IRIS RGB header to STREAM, using xsize, // ysize, and depth as the dimensions of the image. NOTE that // the following defaults are used: @@ -415,14 +415,14 @@ public class SGIImage { stream.write(0); } - private void writeImage(File file, + private void writeImage(final File file, byte[] data, - int xsize, - int ysize, - int zsize, - boolean yflip) throws IOException { + final int xsize, + final int ysize, + final int zsize, + final boolean yflip) throws IOException { // Input data is in RGBRGBRGB or RGBARGBARGBA format; first unswizzle it - byte[] tmpData = new byte[xsize * ysize * zsize]; + final byte[] tmpData = new byte[xsize * ysize * zsize]; int dest = 0; for (int i = 0; i < zsize; i++) { for (int j = i; j < (xsize * ysize * zsize); j += zsize) { @@ -447,8 +447,8 @@ public class SGIImage { // x axis). // Build the offset tables - int[] starttab = new int[ysize * zsize]; - int[] lengthtab = new int[ysize * zsize]; + final int[] starttab = new int[ysize * zsize]; + final int[] lengthtab = new int[ysize * zsize]; // Temporary buffer for holding RLE data. // Note that this makes the assumption that RLE-compressed data will @@ -459,8 +459,8 @@ public class SGIImage { // empirical evidence here; the break-even point seems to be a look- // ahead of 3. (That is, if the three values following this one are all // the same as the current value, switch to repeat mode.) - int lookahead = 3; - byte[] rlebuf = new byte[2 * xsize * ysize * zsize]; + final int lookahead = 3; + final byte[] rlebuf = new byte[2 * xsize * ysize * zsize]; int cur_loc = 0; // current offset location. int ptr = 0; @@ -475,7 +475,7 @@ public class SGIImage { yincr = -1; } - boolean DEBUG = false; + final boolean DEBUG = false; for (int z = 0; z < zsize; z++) { for (int y = ystart; y != yend; y += yincr) { @@ -485,7 +485,7 @@ public class SGIImage { byte count = 0; boolean repeat_mode = false; boolean should_switch = false; - int start_ptr = ptr; + final int start_ptr = ptr; int num_ptr = ptr++; byte repeat_val = 0; @@ -566,7 +566,7 @@ public class SGIImage { x++; } // output this row's length into the length table - int rowlen = ptr - start_ptr; + final int rowlen = ptr - start_ptr; if (yflip) lengthtab[ysize*z+(ysize-y-1)] = rowlen; else @@ -587,11 +587,11 @@ public class SGIImage { if (DEBUG) System.err.println("total_size was " + total_size); - DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(IOUtil.getFileOutputStream(file, true))); + final DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(IOUtil.getFileOutputStream(file, true))); writeHeader(stream, xsize, ysize, zsize, true); - int SIZEOF_INT = 4; + final int SIZEOF_INT = 4; for (int i = 0; i < (ysize * zsize); i++) stream.writeInt(starttab[i] + 512 + (2 * ysize * zsize * SIZEOF_INT)); for (int i = 0; i < (ysize * zsize); i++) @@ -602,7 +602,7 @@ public class SGIImage { stream.close(); } - private byte[] readAll(DataInputStream in) throws IOException { + private byte[] readAll(final DataInputStream in) throws IOException { byte[] dest = new byte[16384]; int pos = 0; int numRead = 0; @@ -613,7 +613,7 @@ public class SGIImage { numRead = in.read(dest, pos, dest.length - pos); if (pos == dest.length) { // Resize destination buffer - byte[] newDest = new byte[2 * dest.length]; + final byte[] newDest = new byte[2 * dest.length]; System.arraycopy(dest, 0, newDest, 0, pos); dest = newDest; } @@ -626,7 +626,7 @@ public class SGIImage { // Trim destination buffer if (pos != dest.length) { - byte[] finalDest = new byte[pos]; + final byte[] finalDest = new byte[pos]; System.arraycopy(dest, 0, finalDest, 0, pos); dest = finalDest; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java index 15cd63eb3..28823abb3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java @@ -71,12 +71,12 @@ import com.jogamp.common.util.IOUtil; */ public class TGAImage { - private Header header; + private final Header header; private int format; private int bpp; private ByteBuffer data; - private TGAImage(Header header) { + private TGAImage(final Header header) { this.header = header; } @@ -114,7 +114,7 @@ public class TGAImage { public final static int I_FOURWAY = 2; /** Type of this TGA file format */ - private int tgaType; + private final int tgaType; /** initial TGA image data fields */ private int idLength; // byte value @@ -142,7 +142,7 @@ public class TGAImage { tgaType = TYPE_OLD; // dont try and get footer. } - Header(LEDataInputStream in) throws IOException { + Header(final LEDataInputStream in) throws IOException { tgaType = TYPE_OLD; // dont try and get footer. // initial header fields @@ -220,24 +220,24 @@ public class TGAImage { public int size() { return 18 + idLength; } // buf must be in little-endian byte order - private void write(ByteBuffer buf) { + private void write(final ByteBuffer buf) { buf.put((byte) idLength); buf.put((byte) colorMapType); buf.put((byte) imageType); buf.putShort((short) firstEntryIndex); buf.putShort((short) colorMapLength); - buf.put((byte) colorMapEntrySize); + buf.put(colorMapEntrySize); buf.putShort((short) xOrigin); buf.putShort((short) yOrigin); buf.putShort((short) width); buf.putShort((short) height); - buf.put((byte) pixelDepth); - buf.put((byte) imageDescriptor); + buf.put(pixelDepth); + buf.put(imageDescriptor); if (idLength > 0) { try { - byte[] chars = imageID.getBytes("US-ASCII"); + final byte[] chars = imageID.getBytes("US-ASCII"); buf.put(chars); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } } @@ -250,7 +250,7 @@ public class TGAImage { * it into the JimiImage structure. This was taken from the * prototype and modified for the new Jimi structure */ - private void decodeImage(GLProfile glp, LEDataInputStream dIn) throws IOException { + private void decodeImage(final GLProfile glp, final LEDataInputStream dIn) throws IOException { switch (header.imageType()) { case Header.UCOLORMAPPED: throw new IOException("TGADecoder Uncompressed Colormapped images not supported"); @@ -294,14 +294,14 @@ public class TGAImage { * This assumes that the body is for a 24 bit or 32 bit for a * RGB or ARGB image respectively. */ - private void decodeRGBImageU24_32(GLProfile glp, LEDataInputStream dIn) throws IOException { + private void decodeRGBImageU24_32(final GLProfile glp, final LEDataInputStream dIn) throws IOException { setupImage24_32(glp); int i; // row index int y; // output row index - int rawWidth = header.width() * bpp; - byte[] rawBuf = new byte[rawWidth]; - byte[] tmpData = new byte[rawWidth * header.height()]; + final int rawWidth = header.width() * bpp; + final byte[] rawBuf = new byte[rawWidth]; + final byte[] tmpData = new byte[rawWidth * header.height()]; for (i = 0; i < header.height(); ++i) { dIn.readFully(rawBuf, 0, rawWidth); @@ -323,12 +323,12 @@ public class TGAImage { * This assumes that the body is for a 24 bit or 32 bit for a * RGB or ARGB image respectively. */ - private void decodeRGBImageRLE24_32(GLProfile glp, LEDataInputStream dIn) throws IOException { + private void decodeRGBImageRLE24_32(final GLProfile glp, final LEDataInputStream dIn) throws IOException { setupImage24_32(glp); - byte[] pixel = new byte[bpp]; - int rawWidth = header.width() * bpp; - byte[] tmpData = new byte[rawWidth * header.height()]; + final byte[] pixel = new byte[bpp]; + final int rawWidth = header.width() * bpp; + final byte[] tmpData = new byte[rawWidth * header.height()]; int i = 0, j; int packet, len; while (i < tmpData.length) { @@ -348,7 +348,7 @@ public class TGAImage { data = ByteBuffer.wrap(tmpData); } - private void setupImage24_32(GLProfile glp) { + private void setupImage24_32(final GLProfile glp) { bpp = header.pixelDepth / 8; switch (header.pixelDepth) { case 24: @@ -367,7 +367,7 @@ public class TGAImage { } } - private static void swapBGR(byte[] data, int bWidth, int height, int bpp) { + private static void swapBGR(final byte[] data, final int bWidth, final int height, final int bpp) { byte r,b; int k; for(int i=0; i<height; ++i) { @@ -398,30 +398,30 @@ public class TGAImage { public ByteBuffer getData() { return data; } /** Reads a Targa image from the specified file. */ - public static TGAImage read(GLProfile glp, String filename) throws IOException { + public static TGAImage read(final GLProfile glp, final String filename) throws IOException { return read(glp, new FileInputStream(filename)); } /** Reads a Targa image from the specified InputStream. */ - public static TGAImage read(GLProfile glp, InputStream in) throws IOException { - LEDataInputStream dIn = new LEDataInputStream(new BufferedInputStream(in)); + public static TGAImage read(final GLProfile glp, final InputStream in) throws IOException { + final LEDataInputStream dIn = new LEDataInputStream(new BufferedInputStream(in)); - Header header = new Header(dIn); - TGAImage res = new TGAImage(header); + final Header header = new Header(dIn); + final TGAImage res = new TGAImage(header); res.decodeImage(glp, dIn); return res; } /** Writes the image in Targa format to the specified file name. */ - public void write(String filename) throws IOException { + public void write(final String filename) throws IOException { write(new File(filename)); } /** Writes the image in Targa format to the specified file. */ - public void write(File file) throws IOException { - FileOutputStream stream = IOUtil.getFileOutputStream(file, true); - FileChannel chan = stream.getChannel(); - ByteBuffer buf = ByteBuffer.allocate(header.size()); + public void write(final File file) throws IOException { + final FileOutputStream stream = IOUtil.getFileOutputStream(file, true); + final FileChannel chan = stream.getChannel(); + final ByteBuffer buf = ByteBuffer.allocate(header.size()); buf.order(ByteOrder.LITTLE_ENDIAN); header.write(buf); buf.rewind(); @@ -437,19 +437,19 @@ public class TGAImage { data with the passed ByteBuffer. Assumes the data is already in the correct byte order for writing to disk, i.e., BGR or BGRA. */ - public static TGAImage createFromData(int width, - int height, - boolean hasAlpha, - boolean topToBottom, - ByteBuffer data) { - Header header = new Header(); + public static TGAImage createFromData(final int width, + final int height, + final boolean hasAlpha, + final boolean topToBottom, + final ByteBuffer data) { + final Header header = new Header(); header.imageType = Header.UTRUECOLOR; header.width = width; header.height = height; header.pixelDepth = (byte) (hasAlpha ? 32 : 24); header.imageDescriptor = (byte) (topToBottom ? Header.ID_TOPTOBOTTOM : 0); // Note ID not supported - TGAImage ret = new TGAImage(header); + final TGAImage ret = new TGAImage(header); ret.data = data; return ret; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java index 18ad429d2..4174adf52 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java @@ -55,12 +55,12 @@ public class IIOTextureProvider implements TextureProvider { private static final boolean DEBUG = Debug.debug("TextureIO"); @Override - public TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - BufferedImage img = ImageIO.read(file); + public TextureData newTextureData(final GLProfile glp, final File file, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final BufferedImage img = ImageIO.read(file); if (img == null) { return null; } @@ -72,12 +72,12 @@ public class IIOTextureProvider implements TextureProvider { } @Override - public TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - BufferedImage img = ImageIO.read(stream); + public TextureData newTextureData(final GLProfile glp, final InputStream stream, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final BufferedImage img = ImageIO.read(stream); if (img == null) { return null; } @@ -89,12 +89,12 @@ public class IIOTextureProvider implements TextureProvider { } @Override - public TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream stream = url.openStream(); + public TextureData newTextureData(final GLProfile glp, final URL url, + final int internalFormat, + final int pixelFormat, + final boolean mipmap, + final String fileSuffix) throws IOException { + final InputStream stream = url.openStream(); try { return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); } finally { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java index be82e4fb8..60ac5680e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java @@ -54,10 +54,10 @@ import com.jogamp.opengl.util.texture.spi.*; public class IIOTextureWriter implements TextureWriter { @Override - public boolean write(File file, - TextureData data) throws IOException { - int pixelFormat = data.getPixelFormat(); - int pixelType = data.getPixelType(); + public boolean write(final File file, + final TextureData data) throws IOException { + final int pixelFormat = data.getPixelFormat(); + final int pixelType = data.getPixelType(); if ((pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA) && (pixelType == GL.GL_BYTE || @@ -68,7 +68,7 @@ public class IIOTextureWriter implements TextureWriter { (pixelFormat == GL.GL_RGB) ? BufferedImage.TYPE_3BYTE_BGR : BufferedImage.TYPE_4BYTE_ABGR); - byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); + final byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); ByteBuffer buf = (ByteBuffer) data.getBuffer(); if (buf == null) { buf = (ByteBuffer) data.getMipmapData()[0]; @@ -80,17 +80,17 @@ public class IIOTextureWriter implements TextureWriter { // Swizzle image components to be correct if (pixelFormat == GL.GL_RGB) { for (int i = 0; i < imageData.length; i += 3) { - byte red = imageData[i + 0]; - byte blue = imageData[i + 2]; + final byte red = imageData[i + 0]; + final byte blue = imageData[i + 2]; imageData[i + 0] = blue; imageData[i + 2] = red; } } else { for (int i = 0; i < imageData.length; i += 4) { - byte red = imageData[i + 0]; - byte green = imageData[i + 1]; - byte blue = imageData[i + 2]; - byte alpha = imageData[i + 3]; + final byte red = imageData[i + 0]; + final byte green = imageData[i + 1]; + final byte blue = imageData[i + 2]; + final byte alpha = imageData[i + 3]; imageData[i + 0] = alpha; imageData[i + 1] = blue; imageData[i + 2] = green; @@ -104,9 +104,9 @@ public class IIOTextureWriter implements TextureWriter { // Happened to notice that writing RGBA images to JPEGS is broken if (TextureIO.JPG.equals(IOUtil.getFileSuffix(file)) && image.getType() == BufferedImage.TYPE_4BYTE_ABGR) { - BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(), + final BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR); - Graphics g = tmpImage.getGraphics(); + final Graphics g = tmpImage.getGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); image = tmpImage; |