summaryrefslogtreecommitdiffstats
path: root/src/demos/es2
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/es2')
-rwxr-xr-xsrc/demos/es2/RedSquare.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
index bcbae3d..5f120a5 100755
--- a/src/demos/es2/RedSquare.java
+++ b/src/demos/es2/RedSquare.java
@@ -1,6 +1,7 @@
package demos.es2;
import java.nio.*;
+import java.util.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.media.nativewindow.*;
@@ -66,10 +67,6 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
public void mouseWheelMoved(MouseEvent e) {
}
- private void runInMain() {
- run();
- }
-
public void run() {
System.err.println(glp+" RedSquare.run()");
int width = 800;
@@ -259,20 +256,41 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
public static int USE_AWT = 1 << 0;
public static void main(String[] args) {
- String glprofile = null;
int type = USE_NEWT ;
+ List threads = new ArrayList();
for(int i=0; i<args.length; i++) {
if(args[i].equals("-awt")) {
- type = USE_AWT;
+ type |= USE_AWT;
}
if(args[i].startsWith("-GL")) {
- if(null!=glprofile) {
- new RedSquare(glprofile, type).start();
- type = USE_NEWT ;
+ threads.add(new RedSquare(args[i].substring(1), type));
+ }
+ }
+ if(threads.size()==0) {
+ threads.add(new RedSquare(null, type));
+ }
+ Thread firstT = (Thread) threads.remove(0);
+
+ for(Iterator i = threads.iterator(); i.hasNext(); ) {
+ ((Thread)i.next()).start();
+ }
+
+ // always run the first on main ..
+ firstT.run();
+
+ boolean done = false;
+
+ while(!done) {
+ int aliveCount = 0;
+ for(Iterator i = threads.iterator(); i.hasNext(); ) {
+ if ( ((Thread)i.next()).isAlive() ) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ie) {}
+ aliveCount++;
}
- glprofile=args[i].substring(1);
}
+ done = 0==aliveCount ;
}
- new RedSquare(glprofile, type).runInMain();
}
}