aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java24
-rw-r--r--src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java24
-rw-r--r--src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java24
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java62
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java12
5 files changed, 97 insertions, 49 deletions
diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java
index 7430dcd38..f30cda4f3 100644
--- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java
+++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java
@@ -27,6 +27,7 @@ import com.jogamp.opengl.GLRunnable;
import com.jogamp.opengl.GLUniformData;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
@@ -90,26 +91,29 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable {
private int fcount = 0, lastm = 0;
private final int fint = 1;
- public void init() {
+ @Override
+public void init() {
setSize(APPLET_WIDTH, APPLET_HEIGHT);
setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT));
width = APPLET_WIDTH;
height = APPLET_HEIGHT;
}
- public void start() {
+ @Override
+public void start() {
thread = new InterruptSource.Thread(null, this, "Animation Thread");
thread.start();
}
- public void run() {
+ @Override
+public void run() {
int noDelays = 0;
// Number of frames with a delay of 0 ms before the
// animation thread yields to other running threads.
final int NO_DELAYS_PER_YIELD = 15;
final int TIMEOUT_SECONDS = 2;
- long beforeTime = System.nanoTime();
+ long beforeTime = Clock.currentNanos();
long overSleepTime = 0L;
millisOffset = System.currentTimeMillis();
@@ -125,13 +129,14 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable {
if (frameCount == 1) {
EventQueue.invokeLater(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
requestFocusInWindow();
}
});
}
- final long afterTime = System.nanoTime();
+ final long afterTime = Clock.currentNanos();
final long timeDiff = afterTime - beforeTime;
final long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
if (sleepTime > 0) { // some time left in this cycle
@@ -139,7 +144,7 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable {
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
noDelays = 0; // Got some sleep, not delaying anymore
} catch (final InterruptedException ex) { }
- overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
+ overSleepTime = (Clock.currentNanos() - afterTime) - sleepTime;
} else { // sleepTime <= 0; the frame took longer than the period
overSleepTime = 0L;
noDelays++;
@@ -148,7 +153,7 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable {
noDelays = 0;
}
}
- beforeTime = System.nanoTime();
+ beforeTime = Clock.currentNanos();
}
}
@@ -418,7 +423,8 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable {
// This allows to close the frame.
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(final WindowEvent e) {
+ @Override
+ public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java
index b31a5f410..15826a8c0 100644
--- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java
+++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java
@@ -27,6 +27,7 @@ import com.jogamp.opengl.GLRunnable;
import com.jogamp.opengl.GLUniformData;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
@@ -92,26 +93,29 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable {
private int fcount = 0, lastm = 0;
private final int fint = 1;
- public void init() {
+ @Override
+public void init() {
setSize(APPLET_WIDTH, APPLET_HEIGHT);
setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT));
width = APPLET_WIDTH;
height = APPLET_HEIGHT;
}
- public void start() {
+ @Override
+public void start() {
thread = new InterruptSource.Thread(null, this, "Animation Thread");
thread.start();
}
- public void run() {
+ @Override
+public void run() {
int noDelays = 0;
// Number of frames with a delay of 0 ms before the
// animation thread yields to other running threads.
final int NO_DELAYS_PER_YIELD = 15;
final int TIMEOUT_SECONDS = 2;
- long beforeTime = System.nanoTime();
+ long beforeTime = Clock.currentNanos();
long overSleepTime = 0L;
millisOffset = System.currentTimeMillis();
@@ -127,13 +131,14 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable {
if (frameCount == 1) {
EventQueue.invokeLater(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
requestFocusInWindow();
}
});
}
- final long afterTime = System.nanoTime();
+ final long afterTime = Clock.currentNanos();
final long timeDiff = afterTime - beforeTime;
final long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
if (sleepTime > 0) { // some time left in this cycle
@@ -141,7 +146,7 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable {
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
noDelays = 0; // Got some sleep, not delaying anymore
} catch (final InterruptedException ex) { }
- overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
+ overSleepTime = (Clock.currentNanos() - afterTime) - sleepTime;
} else { // sleepTime <= 0; the frame took longer than the period
overSleepTime = 0L;
noDelays++;
@@ -150,7 +155,7 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable {
noDelays = 0;
}
}
- beforeTime = System.nanoTime();
+ beforeTime = Clock.currentNanos();
}
}
@@ -417,7 +422,8 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable {
// This allows to close the frame.
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(final WindowEvent e) {
+ @Override
+ public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java
index d0e4448cc..31ff4193c 100644
--- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java
+++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java
@@ -20,6 +20,7 @@ import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.awt.NewtCanvasAWT;
@@ -73,7 +74,8 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
private final long frameRatePeriod = 1000000000L / TARGET_FPS;
private int frameCount;
- public void init() {
+ @Override
+public void init() {
setSize(APPLET_WIDTH, APPLET_HEIGHT);
setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT));
width = APPLET_WIDTH;
@@ -81,27 +83,30 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
initGL();
}
- public void start() {
+ @Override
+public void start() {
initDraw();
thread = new InterruptSource.Thread(null, this, "Animation Thread");
thread.start();
}
- public void run() {
+ @Override
+public void run() {
int noDelays = 0;
// Number of frames with a delay of 0 ms before the
// animation thread yields to other running threads.
final int NO_DELAYS_PER_YIELD = 15;
final int TIMEOUT_SECONDS = 2;
- long beforeTime = System.nanoTime();
+ long beforeTime = Clock.currentNanos();
long overSleepTime = 0L;
frameCount = 1;
while (Thread.currentThread() == thread) {
if (frameCount == 1) {
EventQueue.invokeLater(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
requestFocusInWindow();
}
});
@@ -117,7 +122,7 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
e.printStackTrace();
}
- final long afterTime = System.nanoTime();
+ final long afterTime = Clock.currentNanos();
final long timeDiff = afterTime - beforeTime;
final long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
if (sleepTime > 0) { // some time left in this cycle
@@ -125,7 +130,7 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
noDelays = 0; // Got some sleep, not delaying anymore
} catch (final InterruptedException ex) { }
- overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
+ overSleepTime = (Clock.currentNanos() - afterTime) - sleepTime;
} else { // sleepTime <= 0; the frame took longer than the period
overSleepTime = 0L;
noDelays++;
@@ -134,7 +139,7 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
noDelays = 0;
}
}
- beforeTime = System.nanoTime();
+ beforeTime = Clock.currentNanos();
}
}
@@ -262,7 +267,8 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable {
// This allows to close the frame.
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(final WindowEvent e) {
+ @Override
+ public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java
index 58a7a72c1..35970bc1e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java
@@ -55,6 +55,7 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.common.util.awt.AWTEDTExecutor;
@@ -216,12 +217,14 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
}
// All AWT Mods on AWT-EDT, especially due to the follow-up complicated code!
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
+ @Override
public void run() {
frame.setTitle("MiniPApplet");
} } );
if (fullScreen) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
frame.setUndecorated(true);
frame.setBackground(Color.GRAY);
@@ -235,6 +238,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
}
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
frame.setLayout(null);
frame.add(applet);
@@ -273,7 +277,8 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
frame.add(this);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(final WindowEvent e) {
+ @Override
+ public void windowClosing(final WindowEvent e) {
try {
dispose();
} catch (final Exception ex) {
@@ -283,6 +288,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
});
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
frame.setVisible(true);
} } );
@@ -301,6 +307,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
canvas.setBounds(0, 0, width, height);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
MiniPApplet.this.setLayout(new BorderLayout());
MiniPApplet.this.add(canvas, BorderLayout.CENTER);
@@ -339,6 +346,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
// Setting up animation again
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
MiniPApplet.this.setLayout(new BorderLayout());
MiniPApplet.this.add(canvas, BorderLayout.CENTER);
@@ -378,6 +386,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
frame = null;
} else {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
MiniPApplet.this.remove(canvas);
frame.remove(MiniPApplet.this);
@@ -391,6 +400,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
void draw(final GL2 gl) {
if( !osxCALayerAWTModBug || !justInitialized ) {
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
+ @Override
public void run() {
frame.setTitle("frame " + frameCount);
} } );
@@ -409,7 +419,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
System.out.println(OPENGL_EXTENSIONS);
final int[] temp = { 0 };
- gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, temp, 0);
+ gl.glGetIntegerv(GL.GL_MAX_SAMPLES, temp, 0);
System.out.println("Maximum number of samples supported by the hardware: " + temp[0]);
System.out.println("Frame: "+frame);
System.out.println("Applet: "+MiniPApplet.this);
@@ -475,7 +485,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
}
void clock() {
- final long afterTime = System.nanoTime();
+ final long afterTime = Clock.currentNanos();
final long timeDiff = afterTime - beforeTime;
final long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
@@ -484,13 +494,13 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
} catch (final InterruptedException ex) { }
- overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
+ overSleepTime = (Clock.currentNanos() - afterTime) - sleepTime;
} else { // sleepTime <= 0; the frame took longer than the period
overSleepTime = 0L;
}
- beforeTime = System.nanoTime();
+ beforeTime = Clock.currentNanos();
}
class SimpleListener implements GLEventListener {
@@ -512,31 +522,36 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int w, final int h) { }
}
- public void mouseDragged(final MouseEvent ev) {
+ @Override
+ public void mouseDragged(final MouseEvent ev) {
if (printEventInfo) {
System.err.println("Mouse dragged event: " + ev);
}
}
- public void mouseMoved(final MouseEvent ev) {
+ @Override
+ public void mouseMoved(final MouseEvent ev) {
if (printEventInfo) {
System.err.println("Mouse moved event: " + ev);
}
}
- public void keyPressed(final KeyEvent ev) {
+ @Override
+ public void keyPressed(final KeyEvent ev) {
if (printEventInfo) {
System.err.println("Key pressed event: " + ev);
}
}
- public void keyReleased(final KeyEvent ev) {
+ @Override
+ public void keyReleased(final KeyEvent ev) {
if (printEventInfo) {
System.err.println("Key released event: " + ev);
}
}
- public void keyTyped(final KeyEvent ev) {
+ @Override
+ public void keyTyped(final KeyEvent ev) {
if (printEventInfo) {
System.err.println("Key typed event: " + ev);
}
@@ -550,7 +565,8 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
private TimerTask task = null;
private volatile boolean shouldRun;
- protected String getBaseName(final String prefix) {
+ @Override
+ protected String getBaseName(final String prefix) {
return "Custom" + prefix + "Animator" ;
}
@@ -566,11 +582,13 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
shouldRun = true;
}
- public final synchronized boolean isStarted() {
+ @Override
+ public final synchronized boolean isStarted() {
return (timer != null);
}
- public final synchronized boolean isAnimating() {
+ @Override
+ public final synchronized boolean isAnimating() {
return (timer != null) && (task != null);
}
@@ -581,7 +599,8 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
task = new TimerTask() {
private boolean firstRun = true;
- public void run() {
+ @Override
+ public void run() {
if (firstRun) {
Thread.currentThread().setName("OPENGL");
firstRun = false;
@@ -604,7 +623,8 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
timer.schedule(task, 0, 1);
}
- public synchronized boolean start() {
+ @Override
+ public synchronized boolean start() {
if (timer != null) {
return false;
}
@@ -614,7 +634,8 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
}
/** Stops this CustomAnimator. */
- public synchronized boolean stop() {
+ @Override
+ public synchronized boolean stop() {
if (timer == null) {
return false;
}
@@ -634,9 +655,12 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase {
return true;
}
- public final synchronized boolean isPaused() { return false; }
- public synchronized boolean resume() { return false; }
- public synchronized boolean pause() { return false; }
+ @Override
+ public final synchronized boolean isPaused() { return false; }
+ @Override
+ public synchronized boolean resume() { return false; }
+ @Override
+ public synchronized boolean pause() { return false; }
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
index 1956e6fb7..88e51db8b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java
@@ -43,6 +43,7 @@ import com.jogamp.opengl.GLUniformData;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.os.Clock;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
@@ -158,6 +159,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
public boolean usesFullScreenMode() { return mUsesFullScreenMode; }
class TimeShiftKeys extends KeyAdapter {
+ @Override
public void keyPressed(final KeyEvent e) {
if(KeyEvent.VK_RIGHT == e.getKeyCode()) {
skipFrames(120);
@@ -223,6 +225,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
return mCaps;
}
+ @Override
public void init(final GLAutoDrawable drawable) {
if(drawable instanceof GLWindow) {
final GLWindow glw = (GLWindow) drawable;
@@ -308,16 +311,17 @@ public class ElektronenMultiplizierer implements GLEventListener {
// if NO music is used sync to mainloop start ...
// (add up current time due to possible turned back start time by skip frames)
- mFrameSkipAverageFramerateTimeStart += System.nanoTime();
+ mFrameSkipAverageFramerateTimeStart += Clock.currentNanos();
// mBaseMusic = new BaseMusic(BaseGlobalEnvironment.getInstance().getMusicFileName());
// mBaseMusic.init();
// mBaseMusic.play();
}
+ @Override
public void display(final GLAutoDrawable drawable) {
if (wantsFrameSkip()) {
- mFrameSkipAverageFramerateTimeEnd = System.nanoTime();
+ mFrameSkipAverageFramerateTimeEnd = Clock.currentNanos();
final double tDesiredFrameRate = getDesiredFramerate();
final double tSingleFrameTime = 1000000000.0f/tDesiredFrameRate;
final double tElapsedTime = mFrameSkipAverageFramerateTimeEnd - mFrameSkipAverageFramerateTimeStart;
@@ -342,7 +346,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
// //if music IS used sync to first second of music ...
// if (BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()>0 && !mMusicSyncStartTimeInitialized) {
// BaseLogging.getInstance().info("Synching to BaseMusic ...");
-// mFrameSkipAverageFramerateTimeStart = (long)(System.nanoTime()-((double)BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()*1000000.0d));
+// mFrameSkipAverageFramerateTimeStart = (long)(Clock.currentNanos()-((double)BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()*1000000.0d));
// mMusicSyncStartTimeInitialized = true;
// }
// }
@@ -470,6 +474,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
mFrameCounter++;
}
+ @Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -493,6 +498,7 @@ public class ElektronenMultiplizierer implements GLEventListener {
gl.glViewport(0, 0, width, height);
}
+ @Override
public void dispose(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
gl.glDeleteFramebuffers(1, new int[] { mFrameBufferObjectID }, 0);