From dbf61f36b04d7921197d447430a66e4635d65beb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Sep 2009 15:18:19 -0700 Subject: Test (demos.GLNewtRun) NEWT: Native window parenting (X11: OK); AWTWindow external Frame OK --- src/demos/GLNewtRun.java | 193 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100755 src/demos/GLNewtRun.java (limited to 'src/demos/GLNewtRun.java') diff --git a/src/demos/GLNewtRun.java b/src/demos/GLNewtRun.java new file mode 100755 index 0000000..a5315cf --- /dev/null +++ b/src/demos/GLNewtRun.java @@ -0,0 +1,193 @@ +package demos; + +import java.util.*; +import java.lang.reflect.*; + +import javax.media.opengl.*; +import javax.media.nativewindow.*; + +import com.sun.javafx.newt.*; +import com.sun.javafx.newt.opengl.*; + +public class GLNewtRun implements WindowListener, KeyListener, MouseListener { + + static GLWindow window; + static volatile boolean quit = false; + + public void windowResized(WindowEvent e) { } + + public void windowMoved(WindowEvent e) { } + + public void windowGainedFocus(WindowEvent e) { } + + public void windowLostFocus(WindowEvent e) { } + + public void windowDestroyNotify(WindowEvent e) { + quit = true; + } + + public void keyPressed(KeyEvent e) { + System.out.println(e); + if(e.getKeyChar()=='f') { + window.setFullscreen(!window.isFullscreen()); + } else if(e.getKeyChar()=='q') { + quit = true; + } + } + public void keyReleased(KeyEvent e) { + System.out.println(e); + } + public void keyTyped(KeyEvent e) { + System.out.println(e); + } + + public void mouseClicked(MouseEvent e) { + System.out.println(" mouseevent: "+e); + switch(e.getClickCount()) { + case 1: + if(e.getButton()>MouseEvent.BUTTON1) { + window.setFullscreen(!window.isFullscreen()); + } + break; + default: + quit=true; + break; + } + } + 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 void mouseWheelMoved(MouseEvent e) { + } + + public boolean shouldQuit() { return quit; } + + public static void main(String[] args) { + boolean parented = false; + boolean useAWTTestFrame = false; + boolean useAWT = false; + boolean undecorated = false; + boolean fullscreen = false; + int width = 800; + int height = 480; + String glProfileStr = null; + + if(0==args.length) { + throw new RuntimeException("Usage: "+GLNewtRun.class+" "); + } + + GLNewtRun listener = new GLNewtRun(); + + int i=0; + while(i