SetPixelFormat error when loading a GL rendering scene (AWTGLCanvas)

Started by broumbroum, October 07, 2008, 15:37:30

Previous topic - Next topic

broumbroum

Hi ! I'm new here but I used to report on javagaming.org, where I found out LWJGL and the open GL Java binding frameworks (as well as JOGL and other ports).
Now I'm implementing the LWJGL in my API and I've been focusing on how to allow the user to switch from applet mode to full-screen and other GUI tricks. It arised that the main problem for OpenGL is to look at what Thread is using the context and when a Thread can create a new context.
Such problematic had to be solved at first because I couldn't create any GLcontext from within my own Timer utility. I found out the solution was to use SWING-AWT-EDT Thread to create a GLContext by calling update(Graphics) (which calls paintGL()) and THEN SWITCH TO  my own Thread. Btw, the solution was in the LWJGL AWTGLCanvas source files, thanks to koders.com delivery.
And now, there has been some similar errors at Canvas initialization time with the pixelFormat.
Unhandled exception occurred, skipping paint(): org.lwjgl.LWJGLException: SetPixelFormat failed (0)

The solution is about the same trick as above, call SWING-AWT-EDT, i.e. SwingUtilities.invokeAndWait(Runnable) or SwingUtilities.invokeLater(Runnable), to create the Canvas.

For some information about the same problematic, here's one of the last posts I've found herein : http://lwjgl.org/forum/index.php/topic,1186.msg7983.html#msg7983
;D