Bug 50

Summary: Creating a GLCanvas from the AWT thread fails
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 1   
Hardware: All   
OS: windows   
Type: DEFECT SCM Refs:
Workaround: ---
Attachments: Modified gears demo demonstrating issue (and new thread workaround)

Description Sven Gothel 2010-03-24 07:46:04 CET


---- Reported by fsk456 2003-11-20 00:16:59 ----

Creating a GLCanvas inside the AWT thread (e.g. from a swing component),
fails when a resize/reshape of the GLCanvas is triggered.

Example:
I open a JFrame with a JButton inside that, when pressed, triggers the creation
of a GLCanvas that is added to the frame's content pane.
When the creation of the GLCanvas triggers a reshape (I call setSize), I get the
following exception:
net.java.games.jogl.GLException: Unable to lock surface  
(stack trace at end).
 
A workaround that I found is to create a new thread in the actionPerformed of
the button-listener (AWT thread), create the GLCanvas in the new thread, while
the AWT thread is waiting for the new thread to finish.

I've got a modifed gears demo that shows the issue.
I'll try to attach it to this issue.



--- The full stack trace ---
net.java.games.jogl.GLException: Unable to lock surface
	at
net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.lockSurface(WindowsOnscreenGLContext.java:155)
	at
net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:107)
	at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:199)
	at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:105)
	at java.awt.Component.setBounds(Component.java:1664)
	at java.awt.Component.resize(Component.java:1601)
	at java.awt.Component.setSize(Component.java:1593)
	at Gears.startGears(Gears.java:74)
	at Gears$1.actionPerformed(Gears.java:46)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
	at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
	at java.awt.Component.processMouseEvent(Component.java:5100)
	at java.awt.Component.processEvent(Component.java:4897)
	at java.awt.Container.processEvent(Container.java:1569)
	at java.awt.Component.dispatchEventImpl(Component.java:3615)
	at java.awt.Container.dispatchEventImpl(Container.java:1627)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
	at java.awt.Container.dispatchEventImpl(Container.java:1613)
	at java.awt.Window.dispatchEventImpl(Window.java:1606)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)



---- Additional Comments From fsk456 2003-11-20 00:19:16 ----

Created an attachment
Modified gears demo demonstrating issue (and new thread workaround)




---- Additional Comments From kbr 2005-01-30 23:51:07 ----

This issue has been fixed in one of the more recent JOGL builds. The root cause
was probably proper understanding of exactly when the underlying AWT component
had been realized. Since I don't know the exact root cause I'm marking it "works
for me"; please open another bug if similar problems surface.




--- Bug imported by sgothel@jausoft.com 2010-03-24 07:46 EDT  ---

This bug was previously known as _bug_ 50 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=50
Imported an attachment (id=12)

The original submitter of attachment 12 [details] is unknown.
   Reassigning to the person who moved it here: sgothel@jausoft.com.