import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; /** * A minimal program that draws with JOGL in an AWT Frame. * * @author Wade Walker */ public class OneTriangleAWT { static { GLProfile.initSingleton( true ); } public static void main( String [] args ) { // GLProfile glprofile = GLProfile.getDefault(); GLProfile glprofile = GLProfile.get(GLProfile.GL2); GLCapabilities glcapabilities = new GLCapabilities( glprofile ); final GLCanvas glcanvas = new GLCanvas( glcapabilities ); glcanvas.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 Frame frame = new Frame( "One Triangle AWT" ); frame.add( glcanvas ); frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent windowevent ) { frame.remove( glcanvas ); frame.dispose(); System.exit( 0 ); } }); frame.setSize( 640, 480 ); frame.setVisible( true ); GLDrawableFactory usine = glcanvas.getFactory(); GLCapabilitiesImmutable glci = glcanvas.getChosenGLCapabilities(); GLCapabilitiesChooser glcc = new DefaultGLCapabilitiesChooser(); AbstractGraphicsDevice agd = usine.getDefaultDevice(); GLPbuffer pbuffer = usine.createGLPbuffer(agd, glci, glcc, 256, 256, null); GLContext context = pbuffer.getContext(); context.makeCurrent(); GL2 gl = pbuffer.getContext().getGL().getGL2(); String extensions = gl.glGetString(GL.GL_EXTENSIONS); String[] tabExtensions = extensions.split(" "); SortedSet setExtensions = new TreeSet(); Collections.addAll(setExtensions, tabExtensions); System.out.println(setExtensions); } }