Hi All,
Cutting a long story short, I’m having a bit of a mare with jogl and threads at the moment and I’d like a sanity check please.
In brief, I have multiple threads which were making calls to SwingUtilities.invokeLater followed by some opengl calls to create and populate a display list. This was working fine when I had a java HCI and all my opengl was in C++. Now I have jogl in the equation (in the form of world wind) and it’s completly broken this mechanism for rendering from the C++. I’ve taken the C++ and world wind out of the equation now and added the code below to the display method of the jogl gears demo and it still won’t work. Basicaly, the list ID returned from gl.glGenLists(1); is always 0 if it’s called via invokeLater. The gl error comes back as invalid operation.
Any pointers in the right direction would be greatly appreciated please.
Thanks,
Jon.
int listId = gl.glGenLists(1);
if(listId == 0) {
System.out.println("Pre invokeLater listId == 0 : Event Dispatch Thread ? " + SwingUtilities.isEventDispatchThread() + ", Threading.isOpenGLThread() ? " + Threading.isOpenGLThread() + ", Threading.isSingleThreaded() ? " + Threading.isSingleThreaded() );
} else {
System.out.println("Pre invokeLater listId != 0 : " + listId + " : Event Dispatch Thread ? " + SwingUtilities.isEventDispatchThread() + ", Threading.isOpenGLThread() ? " + Threading.isOpenGLThread() + ", Threading.isSingleThreaded() ? " + Threading.isSingleThreaded() );
}
gl.glDeleteLists(listId,1);
// Try again with invokeLater
//
//Threading.invokeOnOpenGLThread
SwingUtilities.invokeLater
(new Runnable() {
public void run() {
int listId2 = gl.glGenLists(1);
if(listId2 == 0) {
System.out.println("invokeLater listId2 == 0 : Event Dispatch Thread ? " + SwingUtilities.isEventDispatchThread() + ", Threading.isOpenGLThread() ? " + Threading.isOpenGLThread() + ", Threading.isSingleThreaded() ? " + Threading.isSingleThreaded() );
} else {
System.out.println("invokeLater listId2 != 0 : " + listId2 + " : Event Dispatch Thread ? " + SwingUtilities.isEventDispatchThread() + ", Threading.isOpenGLThread() ? " + Threading.isOpenGLThread() + ", Threading.isSingleThreaded() ? " + Threading.isSingleThreaded() );
}
gl.glDeleteLists(listId2,1);
}
});