Bugzilla – Attachment 183 Details for
Bug 439
GLCanvas flickers and displays its background or its scene alternately
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Update Main.java to work properly
Main.java (text/plain), 2.73 KB, created by
Sven Gothel
on 2010-11-27 00:01:33 CET
(
hide
)
Description:
Update Main.java to work properly
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2010-11-27 00:01:33 CET
Size:
2.73 KB
patch
obsolete
>import java.awt.Color; >import java.awt.Component; >import java.awt.Frame; >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.BoxLayout; > >public class Main >{ > static CanvasListener listener = new CanvasListener(); > > public static void main(String[] args) > { > GLProfile.initSingleton(false); > > GLProfile profile = GLProfile.getMaxFixedFunc(); > GLCapabilities caps = new GLCapabilities(profile); > GLCanvas canvas = new GLCanvas(caps); > canvas.setBackground(Color.yellow); > canvas.addGLEventListener(listener); > > final Frame topLevelFrame = new Frame(); > topLevelFrame.addWindowListener(new WindowAdapter() { > public void windowClosing(WindowEvent e) { > System.err.println("closing"); > topLevelFrame.dispose(); > } > public void windowClosed(WindowEvent e) { > System.err.println("closed"); > } > }); > topLevelFrame.setLayout(new BoxLayout(topLevelFrame, BoxLayout.Y_AXIS)); > > topLevelFrame.add(canvas); > > // Revalidate size/layout. > // Always validate if component added/removed. > // Ensure 1st paint of GLCanvas will have a valid size, hence drawable gets created. > topLevelFrame.setSize(400, 300); > topLevelFrame.validate(); > > topLevelFrame.setVisible(true); > > // Animator animator = new Animator(canvas); > // animator.start(); > > // canvas.display(); > } >} > >class CanvasListener implements GLEventListener >{ > @Override > public void display(GLAutoDrawable arg0) > { > GL2 gl = arg0.getGL().getGL2(); > gl.glClearColor(1.0f, 0.0f, 0.0f, 0.5f); > gl.glClear(GL.GL_COLOR_BUFFER_BIT); > > System.out.println("display"); > } > > @Override > public void dispose(GLAutoDrawable arg0) > { > } > > @Override > public void init(GLAutoDrawable arg0) > { > Component canvas = (Component) arg0; > System.out.println(canvas.getSize().toString()); > } > > @Override > public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, >int arg4) > { > } >} >
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 439
:
180
| 183