diff options
author | Sven Gothel <[email protected]> | 2008-05-30 13:40:34 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-05-30 13:40:34 +0000 |
commit | 7bd453d23c6b14bb075a67446b7c74f25cd72743 (patch) | |
tree | 6b03bb2798e96d0b51aa8c77c99cfb5eecb4bd4e | |
parent | fde7845cbef3074561d5489cc086be60d8f6416d (diff) |
adapted es1 demos to the new and proper 'newt' handling.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@236 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
-rwxr-xr-x | src/demos/es1/RedSquare.java | 34 | ||||
-rwxr-xr-x | src/demos/es1/angeles/Main.java | 34 |
2 files changed, 60 insertions, 8 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java index 8bea190..f0e0fa1 100755 --- a/src/demos/es1/RedSquare.java +++ b/src/demos/es1/RedSquare.java @@ -7,11 +7,37 @@ import com.sun.opengl.util.*; import com.sun.javafx.newt.*; -public class RedSquare { +public class RedSquare implements MouseListener { + + public boolean quit = false; + + public void mouseClicked(MouseEvent e) { + if(e.getClickCount()>1) { + quit=true; + } + } + public void mouseEntered(MouseEvent e) { + } + public void mouseExited(MouseEvent e) { + } + public void mousePressed(MouseEvent e) { + } + public void mouseReleased(MouseEvent e) { + } + public void mouseMoved(MouseEvent e) { + } + public void mouseDragged(MouseEvent e) { + } + public static void main(String[] args) { System.out.println("RedSquare.main()"); try { - Window window = Window.create(0); // dummy VisualID + Display display = new Display(); + Screen screen = new Screen(display); + Window window = Window.create(screen, 0); // dummy VisualID + + RedSquare ml = new RedSquare(); + window.addMouseListener(ml); // Size OpenGL to Video Surface int width = 800; @@ -29,7 +55,7 @@ public class RedSquare { caps.setGreenBits(5); caps.setBlueBits(5); caps.setDepthBits(16); - GLDrawable drawable = factory.getGLDrawable(new Long(window.getWindowHandle()), caps, null); + GLDrawable drawable = factory.getGLDrawable(window.getHandles(), caps, null); drawable.setRealized(true); GLContext context = drawable.createContext(null); context.makeCurrent(); @@ -75,7 +101,7 @@ public class RedSquare { long startTime = System.currentTimeMillis(); long curTime; int ang = 0; - while ((System.currentTimeMillis() - startTime) < 10000) { + while (!ml.quit && (System.currentTimeMillis() - startTime) < 20000) { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Set location in front of camera diff --git a/src/demos/es1/angeles/Main.java b/src/demos/es1/angeles/Main.java index 1afe46d..66592be 100755 --- a/src/demos/es1/angeles/Main.java +++ b/src/demos/es1/angeles/Main.java @@ -4,11 +4,37 @@ import java.nio.*; import javax.media.opengl.*; import com.sun.javafx.newt.*; -public class Main { +public class Main implements MouseListener { + + public boolean quit = false; + + public void mouseClicked(MouseEvent e) { + if(e.getClickCount()>1) { + quit=true; + } + } + public void mouseEntered(MouseEvent e) { + } + public void mouseExited(MouseEvent e) { + } + public void mousePressed(MouseEvent e) { + } + public void mouseReleased(MouseEvent e) { + } + public void mouseMoved(MouseEvent e) { + } + public void mouseDragged(MouseEvent e) { + } + public static void main(String[] args) { System.out.println("Angeles Main"); try { - Window window = Window.create(0); // dummy VisualID + Display display = new Display(); + Screen screen = new Screen(display); + Window window = Window.create(screen, 0); // dummy VisualID + + Main ml = new Main(); + window.addMouseListener(ml); // Size OpenGL to Video Surface int width = 800; @@ -26,7 +52,7 @@ public class Main { caps.setGreenBits(5); caps.setBlueBits(5); caps.setDepthBits(16); - GLDrawable drawable = factory.getGLDrawable(new Long(window.getWindowHandle()), caps, null); + GLDrawable drawable = factory.getGLDrawable(window.getHandles(), caps, null); drawable.setRealized(true); GLContext context = drawable.createContext(null); context.makeCurrent(); @@ -51,7 +77,7 @@ public class Main { // Thread.sleep(10); // } catch(InterruptedException ie) {} curTime = System.currentTimeMillis(); - } while ((curTime - startTime) < 115000); + } while (!ml.quit && (curTime - startTime) < 215000); // Shut things down cooperatively context.release(); |