Bugzilla – Attachment 240 Details for
Bug 460
NPE using the GLCanvas.getFactory() method with minimal setup.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Working example using a Frame.
OneTriangleAWT.java (text/plain), 2.78 KB, created by
François Coupal
on 2011-03-07 16:36:12 CET
(
hide
)
Description:
Working example using a Frame.
Filename:
MIME Type:
Creator:
François Coupal
Created:
2011-03-07 16:36:12 CET
Size:
2.78 KB
patch
obsolete
>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<String> setExtensions = new TreeSet<String>(); > Collections.addAll(setExtensions, tabExtensions); > System.out.println(setExtensions); > } >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 460
:
238
|
239
| 240