Hi,
I have an application which needs to replace the default Java system queue with a custom one. However, GLCanvas freezes up when I "push" the custom event queue. I've also tried using GLJPanel, but then I get the "Error making context current" exception. I'm using the latest jogl (v2.0-rc3?) from the git repository on a Windows XP box. Linux (SUSE) works. I'm compiling the java app with jdk1.6.0_01. Any ideas on how to get this to work or a workaround? I've included a small Java program which also causes the error. To create the error just select "Start Queue" under the Queue menu. Once the new queue is installed (i.e. pushed), the GLCanvas does not redraw itself so you see the image of whatever window was above it, i.e. just swirl a window above the gl canvas. The display method is being entered, but the call to glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT ) within the display routine does nothing. Thanks, Martin // beginning of program import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JPopupMenu; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.Component; import java.awt.BorderLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.EventQueue; import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GL2; import javax.media.opengl.GLContext; import javax.media.opengl.Threading; import javax.media.opengl.awt.GLJPanel; public class JOGL_EventQueue_test extends JFrame { TestQueue testQueue = null; public static void main(String[] args) { try { JOGL_EventQueue_test jogl_EventQueue_test = new JOGL_EventQueue_test(); jogl_EventQueue_test.setVisible(true); } catch (Exception e) { System.out.println("Exception occurred "+e.getMessage()); } } JOGL_EventQueue_test() throws Exception { // set window stuff setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400,400); setLocationRelativeTo(null); // create a menu bar CreateMenuBar(); // create work area CreateWorkArea(); } void CreateMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Queue"); JPopupMenu popupMenu = menu.getPopupMenu(); popupMenu.setLightWeightPopupEnabled(false); menuBar.add(menu); JMenuItem menuItem = new JMenuItem("Start Queue"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (testQueue == null) { System.out.println("Starting queue."); testQueue = new TestQueue(); testQueue.Start(); } } }); menu.add(menuItem); menuItem = new JMenuItem("End Queue"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (testQueue != null) { System.out.println("Ending queue."); testQueue.Stop(); testQueue = null; } } }); menu.add(menuItem); setJMenuBar(menuBar); } void CreateWorkArea() { // create the canvas TestGLCanvas testGLCanvas = new TestGLCanvas(); // return the work area getContentPane().add(testGLCanvas,BorderLayout.CENTER); } class TestQueue extends EventQueue { void Start() { java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().push(this); } /* method */ void Stop() { pop(); } } class TestGLCanvas extends /*GLJPanel*/ GLCanvas implements GLEventListener { TestGLCanvas() { addGLEventListener(this); } public void init(GLAutoDrawable drawable) { System.out.println("hello init"); if (!Threading.isOpenGLThread() || getContext() != GLContext.getCurrent()) { System.out.println("Not set up appropriately."); return; } drawable.getGL().getGL2().glClearColor(1.0f,1.0f,1.0f,1.f); } public void dispose(GLAutoDrawable drawable) { System.out.println("hello dispose"); } public void display(GLAutoDrawable drawable) { System.out.println("hello display"); if (!Threading.isOpenGLThread() || getContext() != GLContext.getCurrent()) { System.out.println("Not set up appropriately."); return; } drawable.getGL().getGL2().glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT ); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { System.out.println("hello reshape"); } } } |
Free forum by Nabble | Edit this page |