Created
July 11, 2012 13:51
-
-
Save hfaulds/3090470 to your computer and use it in GitHub Desktop.
Simpler Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
import javax.media.opengl.GL; | |
import javax.media.opengl.GL2; | |
import javax.media.opengl.GLAutoDrawable; | |
import javax.media.opengl.GLCapabilities; | |
import javax.media.opengl.GLEventListener; | |
import javax.media.opengl.GLProfile; | |
import javax.media.opengl.awt.GLCanvas; | |
import javax.swing.JFrame; | |
import javax.swing.SwingUtilities; | |
import com.jogamp.opengl.util.FPSAnimator; | |
@SuppressWarnings("serial") | |
public class Main extends JFrame implements GLEventListener { | |
GLCanvas canvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); | |
FPSAnimator animator = new FPSAnimator(canvas, 20); | |
public Main() { | |
this.addWindowListener(new WindowAdapter() { | |
public void windowClosing(WindowEvent e) { | |
dispose(); | |
System.exit(0); | |
} | |
}); | |
canvas.addGLEventListener(this); | |
this.add(canvas); | |
this.setSize(1280 , 720); | |
this.setVisible(true); | |
animator.start(); | |
} | |
@Override | |
public void display(final GLAutoDrawable drawable) { | |
GL2 gl = drawable.getGL().getGL2(); | |
gl.glClear(GL.GL_COLOR_BUFFER_BIT); | |
gl.glClear(GL.GL_DEPTH_BUFFER_BIT); | |
gl.glLoadIdentity(); | |
} | |
@Override | |
public void dispose(GLAutoDrawable drawable) { | |
} | |
@Override | |
public void init(GLAutoDrawable drawable) { | |
} | |
@Override | |
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { | |
} | |
public static void main(String ... args) { | |
SwingUtilities.invokeLater(new Runnable() { | |
public void run() { | |
new Main(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment