summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-14 18:14:02 +0000
committerSven Gothel <[email protected]>2009-06-14 18:14:02 +0000
commit1e1137d2565c9b0978a05ac4e62ae897e43413b9 (patch)
tree9d1cf60e68d514fde47901eabc9e435244ec76b4
parenta4f42ce7895ec5f58bf4494dcb21325e1d5201d4 (diff)
Comply with JOGL2 changes revision 1947
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@346 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
-rwxr-xr-xsrc/demos/es1/RedSquare.java40
-rwxr-xr-xsrc/demos/es2/RedSquare.java40
2 files changed, 58 insertions, 22 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 24da987..a7ede75 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -1,6 +1,7 @@
package demos.es1;
import java.nio.*;
+import java.util.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.media.nativewindow.*;
@@ -74,10 +75,6 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public void mouseWheelMoved(MouseEvent e) {
}
- private void runInMain() {
- run();
- }
-
public void run() {
System.err.println(glp+" RedSquare.run() 0");
int width = 800;
@@ -214,20 +211,41 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
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();
}
}
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();
}
}