summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-03 22:52:10 +0000
committerSven Gothel <[email protected]>2009-06-03 22:52:10 +0000
commitbf12062676c11ee4df156a694a941fe85e9d828c (patch)
treed7307f9d14bcce17e413d701a545173dcf349ec1
parenta1c838f382cef1c0fac5ec291f74e71cf791f8be (diff)
GLInfo and RedSquare demos: Use main thread for only one GL instance
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@339 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
-rwxr-xr-xjava-macosx.sh3
-rwxr-xr-xsrc/demos/GLInfo.java30
-rwxr-xr-xsrc/demos/es1/RedSquare.java24
-rwxr-xr-xsrc/demos/es2/RedSquare.java24
4 files changed, 54 insertions, 27 deletions
diff --git a/java-macosx.sh b/java-macosx.sh
new file mode 100755
index 0000000..d2e2125
--- /dev/null
+++ b/java-macosx.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+java -XstartOnFirstThread -Djava.awt.headless=true $*
diff --git a/src/demos/GLInfo.java b/src/demos/GLInfo.java
index d222944..157860e 100755
--- a/src/demos/GLInfo.java
+++ b/src/demos/GLInfo.java
@@ -17,7 +17,7 @@ public class GLInfo extends Thread implements GLEventListener {
super();
}
- private void start(String glprofile, int type) {
+ private void init(String glprofile, int type) {
int width = 256;
int height = 256;
glp = GLProfile.GetProfile(glprofile);
@@ -41,27 +41,41 @@ public class GLInfo extends Thread implements GLEventListener {
}
window = GLWindow.create(nWindow, caps);
+ System.err.println(glp+" GLWindow : "+window);
+
window.addGLEventListener(this);
// Size OpenGL to Video Surface
window.setSize(width, height);
// window.setFullscreen(true);
- start();
} catch (Throwable t) {
t.printStackTrace();
}
}
+ private void runInThread(String glprofile, int type) {
+ init(glprofile, type);
+ run();
+ }
+
+ private void start(String glprofile, int type) {
+ init(glprofile, type);
+ start();
+ }
public void run() {
try {
- System.err.println(glp+" GLInfo.run()");
+ System.err.println(glp+" GLInfo.run() 1");
window.setVisible(true);
+ System.err.println(glp+" GLInfo.run() 2");
+
window.display();
+ System.err.println(glp+" GLInfo.run() 3");
+
try {
Thread.sleep(500);
} catch (Exception e) {}
@@ -138,19 +152,17 @@ public class GLInfo extends Thread implements GLEventListener {
public static void main(String[] args) {
String glprofile = null;
int type = USE_NEWT ;
- int num=0;
for(int i=args.length-1; i>=0; i--) {
if(args[i].equals("-awt")) {
type |= USE_AWT;
}
if(args[i].startsWith("-GL")) {
+ if(null!=glprofile) {
+ new GLInfo().start(glprofile, type);
+ }
glprofile=args[i].substring(1);
- new GLInfo().start(glprofile, type);
- num++;
}
}
- if(0==num) {
- new GLInfo().start(glprofile, type);
- }
+ new GLInfo().runInThread(glprofile, type);
}
}
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index eb6275d..0a59101 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -70,7 +70,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public void mouseWheelMoved(MouseEvent e) {
}
- private void start(String glprofile, int type) {
+ private void init(String glprofile, int type) {
int width = 800;
int height = 480;
glp = GLProfile.GetProfile(glprofile);
@@ -102,13 +102,21 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
// Size OpenGL to Video Surface
window.setSize(width, height);
// window.setFullscreen(true);
-
- start();
} catch (Throwable t) {
t.printStackTrace();
}
}
+ private void runInThread(String glprofile, int type) {
+ init(glprofile, type);
+ run();
+ }
+
+ private void start(String glprofile, int type) {
+ init(glprofile, type);
+ start();
+ }
+
public void run() {
System.err.println(glp+" RedSquare.run()");
try {
@@ -222,19 +230,17 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public static void main(String[] args) {
String glprofile = null;
int type = USE_NEWT ;
- int num=0;
for(int i=args.length-1; i>=0; i--) {
if(args[i].equals("-awt")) {
type |= USE_AWT;
}
if(args[i].startsWith("-GL")) {
+ if(null!=glprofile) {
+ new RedSquare().start(glprofile, type);
+ }
glprofile=args[i].substring(1);
- new RedSquare().start(glprofile, type);
- num++;
}
}
- if(0==num) {
- new RedSquare().start(glprofile, type);
- }
+ new RedSquare().runInThread(glprofile, type);
}
}
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
index a01a41a..37ef2be 100755
--- a/src/demos/es2/RedSquare.java
+++ b/src/demos/es2/RedSquare.java
@@ -50,7 +50,7 @@ public class RedSquare extends Thread implements MouseListener, GLEventListener
public void mouseWheelMoved(MouseEvent e) {
}
- private void start(String glprofile, int type) {
+ private void init(String glprofile, int type) {
int width = 800;
int height = 480;
glp = GLProfile.GetProfile(glprofile);
@@ -79,13 +79,21 @@ public class RedSquare extends Thread implements MouseListener, GLEventListener
// Size OpenGL to Video Surface
window.setSize(width, height);
// window.setFullscreen(true);
-
- start();
} catch (Throwable t) {
t.printStackTrace();
}
}
+ private void runInThread(String glprofile, int type) {
+ init(glprofile, type);
+ run();
+ }
+
+ private void start(String glprofile, int type) {
+ init(glprofile, type);
+ start();
+ }
+
public void run() {
System.err.println(glp+" RedSquare.run()");
try {
@@ -255,19 +263,17 @@ public class RedSquare extends Thread implements MouseListener, GLEventListener
public static void main(String[] args) {
String glprofile = null;
int type = USE_NEWT ;
- int num=0;
for(int i=args.length-1; i>=0; i--) {
if(args[i].equals("-awt")) {
type |= USE_AWT;
}
if(args[i].startsWith("-GL")) {
+ if(null!=glprofile) {
+ new RedSquare().start(glprofile, type);
+ }
glprofile=args[i].substring(1);
- new RedSquare().start(glprofile, type);
- num++;
}
}
- if(0==num) {
- new RedSquare().start(glprofile, type);
- }
+ new RedSquare().runInThread(glprofile, type);
}
}