Advertisement
lukejessee

JoglTestApp.java - NEWT

Jul 17th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. package test;
  2.  
  3. import java.awt.GraphicsConfiguration;
  4. import java.awt.GraphicsDevice;
  5. import java.awt.GraphicsEnvironment;
  6. import java.awt.Rectangle;
  7. import javax.media.opengl.GLAutoDrawable;
  8. import javax.media.opengl.GLCapabilities;
  9. import javax.media.opengl.GLEventListener;
  10. import javax.swing.SwingUtilities;
  11.  
  12. import com.jogamp.newt.opengl.GLWindow;
  13. import com.jogamp.opengl.util.FPSAnimator;
  14.  
  15. public class JoglTestApp {
  16.     private static final long serialVersionUID = 6532471436226849515L;
  17.  
  18.     public static void main(String[] args) {
  19.         GraphicsEnvironment ge = GraphicsEnvironment
  20.                 .getLocalGraphicsEnvironment();
  21.         GraphicsDevice[] gs = ge.getScreenDevices();
  22.        
  23.         for (GraphicsDevice device : gs) {
  24.             for (GraphicsConfiguration config : device.getConfigurations()) {
  25.                 final JoglTestApp app = new JoglTestApp(config.getBounds());
  26.                 SwingUtilities.invokeLater(new Runnable() {
  27.                     public void run() {
  28.                         app.setVisible(true);
  29.                     }
  30.                 });
  31.             }
  32.         }
  33.     }
  34.  
  35.     protected void setVisible(boolean b) {
  36.         glWindow.setVisible(b);
  37.     }
  38.  
  39.     public JoglTestApp(Rectangle rect) {
  40.         glWindow = GLWindow.create(new GLCapabilities(null));
  41.         glWindow.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.         FPSAnimator animator = new FPSAnimator(glWindow, 30);
  61.         animator.start();
  62.         glWindow.setSize(200, 200);
  63.         glWindow.setPosition(rect.x+100, rect.y+100);
  64.     }
  65.    
  66.     GLWindow glWindow;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement