Created
November 3, 2013 19:56
-
-
Save Kurt-P/7294121 to your computer and use it in GitHub Desktop.
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 javax.media.opengl.GLAutoDrawable; | |
import javax.media.opengl.GLEventListener; | |
import javax.media.opengl.GLProfile; | |
import javax.media.opengl.GLCapabilities; | |
import javax.media.opengl.awt.GLJPanel; | |
import javax.swing.JFrame; | |
import java.awt.BorderLayout; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
/** | |
* A minimal program that draws with JOGL in a Swing JFrame using the AWT GLJPanel. | |
* | |
* @author Wade Walker | |
*/ | |
public class OneTriangleSwingGLJPanel { | |
public static void main( String [] args ) { | |
GLProfile glprofile = GLProfile.getDefault(); | |
GLCapabilities glcapabilities = new GLCapabilities( glprofile ); | |
GLJPanel gljpanel = new GLJPanel( glcapabilities ); | |
gljpanel.addGLEventListener( new GLEventListener() { | |
@Override | |
public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) { | |
OneTriangle.setup( glautodrawable.getGL().getGL2(), width, height ); | |
} | |
@Override | |
public void init( GLAutoDrawable glautodrawable ) { | |
} | |
@Override | |
public void dispose( GLAutoDrawable glautodrawable ) { | |
} | |
@Override | |
public void display( GLAutoDrawable glautodrawable ) { | |
OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getWidth(), glautodrawable.getHeight() ); | |
} | |
}); | |
final JFrame jframe = new JFrame( "One Triangle Swing GLJPanel" ); | |
jframe.addWindowListener( new WindowAdapter() { | |
public void windowClosing( WindowEvent windowevent ) { | |
jframe.dispose(); | |
System.exit( 0 ); | |
} | |
}); | |
jframe.getContentPane().add( gljpanel, BorderLayout.CENTER ); | |
jframe.setSize( 640, 480 ); | |
jframe.setVisible( true ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment