Advertisement
lukejessee

JoglTestApp.java

Jul 17th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. package test;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.GraphicsConfiguration;
  5. import java.awt.GraphicsDevice;
  6. import java.awt.GraphicsEnvironment;
  7. import java.awt.Rectangle;
  8. import javax.media.opengl.GLAutoDrawable;
  9. import javax.media.opengl.GLEventListener;
  10. import javax.media.opengl.awt.GLCanvas;
  11. import javax.swing.JFrame;
  12. import javax.swing.SwingUtilities;
  13.  
  14. import com.jogamp.opengl.util.FPSAnimator;
  15.  
  16. public class JoglTestApp extends JFrame {
  17.     private static final long serialVersionUID = 6532471436226849515L;
  18.  
  19.     public static void main(String[] args) {
  20.         GraphicsEnvironment ge = GraphicsEnvironment
  21.                 .getLocalGraphicsEnvironment();
  22.         GraphicsDevice[] gs = ge.getScreenDevices();
  23.  
  24.         for (GraphicsDevice device : gs) {
  25.             for (GraphicsConfiguration config : device.getConfigurations()) {
  26.                 final JoglTestApp app = new JoglTestApp(config.getBounds());
  27.                 SwingUtilities.invokeLater(new Runnable() {
  28.                     public void run() {
  29.                         app.setVisible(true);
  30.                     }
  31.                 });
  32.             }
  33.         }
  34.     }
  35.  
  36.     public JoglTestApp(Rectangle rect) {
  37.         super("Test Application");
  38.  
  39.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  40.         GLCanvas glcanvas = new GLCanvas();
  41.         glcanvas.addGLEventListener(new GLEventListener() {
  42.             @Override
  43.             public void display(GLAutoDrawable arg0) {
  44.             }
  45.  
  46.             @Override
  47.             public void dispose(GLAutoDrawable arg0) {
  48.             }
  49.  
  50.             @Override
  51.             public void init(GLAutoDrawable arg0) {
  52.             }
  53.  
  54.             @Override
  55.             public void reshape(GLAutoDrawable arg0, int arg1, int arg2,
  56.                     int arg3, int arg4) {
  57.             }
  58.         });
  59.        
  60.         getContentPane().add(glcanvas, BorderLayout.CENTER);
  61.         FPSAnimator animator = new FPSAnimator(glcanvas, 30);
  62.         animator.start();
  63.         setSize(200, 200);
  64.         setLocation(rect.x, rect.y);
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement