summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/demos/es1/RedSquare.java38
-rwxr-xr-xsrc/demos/es2/RedSquare.java40
2 files changed, 31 insertions, 47 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 7541e0f..24da987 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -17,9 +17,13 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
private GLProfile glp;
private GLU glu;
private boolean quit = false;
+ private String glprofile;
+ private int type;
- public RedSquare() {
+ public RedSquare(String glprofile, int type) {
super();
+ this.glprofile=glprofile;
+ this.type=type;
}
public void windowResized(WindowEvent e) {
@@ -70,11 +74,15 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public void mouseWheelMoved(MouseEvent e) {
}
- private void init(String glprofile, int type) {
+ private void runInMain() {
+ run();
+ }
+
+ public void run() {
+ System.err.println(glp+" RedSquare.run() 0");
int width = 800;
int height = 480;
glp = GLProfile.GetProfile(glprofile);
- System.err.println(glp+" RedSquare.init() 1");
try {
GLCapabilities caps = new GLCapabilities(glp);
@@ -99,24 +107,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
// window.setFullscreen(true);
window.setVisible(true);
window.enablePerfLog(true);
- } 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() 0");
- try {
do {
window.display();
} while (!quit && window.getDuration() < 20000) ;
@@ -227,15 +218,16 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
int type = USE_NEWT ;
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().start(glprofile, type);
+ new RedSquare(glprofile, type).start();
+ type = USE_NEWT ;
}
glprofile=args[i].substring(1);
}
}
- new RedSquare().runInThread(glprofile, type);
+ new RedSquare(glprofile, type).runInMain();
}
}
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
index 246eced..bcbae3d 100755
--- a/src/demos/es2/RedSquare.java
+++ b/src/demos/es2/RedSquare.java
@@ -19,9 +19,13 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
private boolean quit = false;
private long startTime;
private long curTime;
-
- public RedSquare() {
+ private String glprofile;
+ private int type;
+
+ public RedSquare(String glprofile, int type) {
super();
+ this.glprofile=glprofile;
+ this.type=type;
}
public void windowResized(WindowEvent e) { }
@@ -62,11 +66,15 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
public void mouseWheelMoved(MouseEvent e) {
}
- private void init(String glprofile, int type) {
+ private void runInMain() {
+ run();
+ }
+
+ public void run() {
+ System.err.println(glp+" RedSquare.run()");
int width = 800;
int height = 480;
glp = GLProfile.GetProfile(glprofile);
- System.err.println(glp+" RedSquare.start()");
try {
GLCapabilities caps = new GLCapabilities(glp);
@@ -89,24 +97,7 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
// window.setFullscreen(true);
window.setVisible(true);
window.enablePerfLog(true);
- } 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 {
startTime = System.currentTimeMillis();
while (!quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) {
@@ -272,15 +263,16 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
int type = USE_NEWT ;
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().start(glprofile, type);
+ new RedSquare(glprofile, type).start();
+ type = USE_NEWT ;
}
glprofile=args[i].substring(1);
}
}
- new RedSquare().runInThread(glprofile, type);
+ new RedSquare(glprofile, type).runInMain();
}
}