Bugzilla – Attachment 788 Details for
Bug 1310
Removing and re-adding a GLJPanel results in small image being rendered
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Sample program that shows the problem.
JoglPanel.java (text/x-java), 3.21 KB, created by
willemv
on 2016-06-01 16:13:51 CEST
(
hide
)
Description:
Sample program that shows the problem.
Filename:
MIME Type:
Creator:
willemv
Created:
2016-06-01 16:13:51 CEST
Size:
3.21 KB
patch
obsolete
>package samples; > >import java.awt.BorderLayout; >import java.awt.Container; >import java.awt.Dimension; >import java.awt.GridLayout; >import java.awt.event.ActionEvent; >import java.awt.event.WindowAdapter; >import java.awt.event.WindowEvent; > >import javax.swing.AbstractAction; >import javax.swing.JFrame; >import javax.swing.JPanel; >import javax.swing.JToolBar; >import javax.swing.WindowConstants; > >import com.jogamp.opengl.GL; >import com.jogamp.opengl.GL2; >import com.jogamp.opengl.GLAutoDrawable; >import com.jogamp.opengl.GLEventListener; >import com.jogamp.opengl.awt.GLJPanel; >import com.jogamp.opengl.util.FPSAnimator; > >/** > * This sample shows how a map overview can be implemented for an ILspView. > * The map overview is overlaid on the main view. It shows a polygon which > * bounds the area of the world that is visible in the main view. > */ >public class JoglPanel { > > public static void main(String[] args) { > JFrame frame = new JFrame("Testing"); > frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); > Container content = frame.getContentPane(); > content.setLayout(new BorderLayout()); > > JToolBar toolbar = new JToolBar(); > > final JPanel container = new JPanel(); > container.setLayout(new GridLayout(1, 1)); > final GLJPanel glJPanel = new GLJPanel(); > glJPanel.setPreferredSize(new Dimension(200, 200)); > container.add(glJPanel); > > toolbar.add(new AbstractAction("Remove and add") { > @Override > public void actionPerformed(ActionEvent e) { > container.removeAll(); > container.add(glJPanel); > glJPanel.invalidate(); > glJPanel.repaint(); > } > }); > > > glJPanel.addGLEventListener(new GLEventListener() { > > private double theta = 0; > private double s = 0; > private double c = 0; > @Override > public void display(GLAutoDrawable drawable) { > update(); > render(drawable); > } > > @Override > public void dispose(GLAutoDrawable drawable) { > } > > @Override > public void init(GLAutoDrawable drawable) { > } > > @Override > public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { > } > > private void update() { > theta += 0.01; > s = Math.sin(theta); > c = Math.cos(theta); > } > > private void render(GLAutoDrawable drawable) { > GL2 gl = drawable.getGL().getGL2(); > > gl.glClear(GL.GL_COLOR_BUFFER_BIT); > > // draw a triangle filling the window > gl.glBegin(GL.GL_TRIANGLES); > gl.glColor3f(1, 0, 0); > gl.glVertex2d(-c, -c); > gl.glColor3f(0, 1, 0); > gl.glVertex2d(0, c); > gl.glColor3f(0, 0, 1); > gl.glVertex2d(s, -s); > gl.glEnd(); > }}); > > > content.add(toolbar, BorderLayout.NORTH); > content.add(container, BorderLayout.CENTER); > > frame.pack(); > frame.setLocationRelativeTo(null); > frame.setVisible(true); > > > final FPSAnimator animator = new FPSAnimator(glJPanel, 60); > animator.start(); > > frame.addWindowListener(new WindowAdapter() { > @Override > public void windowClosing(WindowEvent e) { > animator.stop(); > } > }); > } >}
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 1310
: 788