Created
July 11, 2012 10:49
-
-
Save hfaulds/3089608 to your computer and use it in GitHub Desktop.
JOGL JDK 1.7 Mac Bug Source
This file contains hidden or 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.Dimension; | |
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 com.jogamp.opengl.util.FPSAnimator; | |
@SuppressWarnings("serial") | |
public class Main extends JFrame implements GLEventListener { | |
GLCanvas canvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); | |
public Main() { | |
this.addWindowListener(new WindowAdapter() { | |
public void windowClosing(WindowEvent e) { | |
dispose(); | |
System.exit(0); | |
} | |
}); | |
FPSAnimator animator = new FPSAnimator(canvas, 20); | |
canvas.addGLEventListener(this); | |
this.add(canvas); | |
this.setSize(1280 , 720); | |
this.setVisible(true); | |
canvas.requestFocus(); | |
animator.start(); | |
} | |
@Override | |
public void display(GLAutoDrawable drawable) { | |
GL2 gl = drawable.getGL().getGL2(); | |
gl.glClear(GL.GL_COLOR_BUFFER_BIT); | |
gl.glClear(GL.GL_DEPTH_BUFFER_BIT); | |
gl.glLoadIdentity(); | |
System.out.println(); | |
System.out.println(canvas.getWidth() + " " + canvas.getHeight()); | |
System.out.println(drawable.getWidth() + " " + drawable.getHeight()); | |
canvas.setPreferredSize(new Dimension(drawable.getWidth(), drawable.getHeight())); | |
} | |
@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) { | |
display(drawable); | |
System.out.println(width + " " + height); | |
} | |
public static void main(String ... args) { | |
new Main(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment