jogl in matlab

Hi,

I am trying to use jogl from Matlab 2007b (Matlab contains jogl by default). When I run Gears demo from Matlab before loading opengl (command opengl info e.g.), demo works fine. if opengl is loaded, then demo does not work and exception is thrown:

Exception in thread “AWT-EventQueue-0” javax.media.opengl.GLException: Unable to set pixel format 5 for device context 0xffffffff920107e1: error code 0
at com.sun.opengl.impl.windows.WindowsGLDrawable.choosePixelFormat(WindowsGLDrawable.java:281)
at com.sun.opengl.impl.windows.WindowsOnscreenGLDrawable.lockSurface(WindowsOnscreenGLDrawable.java:202)
at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(WindowsOnscreenGLContext.java:57)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:127)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:258)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)
at java.awt.Component.dispatchEventImpl(Component.java:4489)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

I tried to set pixel format to value which Matlab selects with opengl info command (I inherited DefaultGLCapabilitiesChooser for doing it), but problem remains.

I use WinXP with Ati Radeon9550/X1050. Has anybody idea, where should be problem or where am I wrong?

This is only a guess, but have you tried upgrading the version of JOGL? Looking in the WindowsGLDrawable code, it looks like the current code should handle a third-party library choosing a pixel format, if that’s what is happening.

Yes I have tried new version of jogl, but problem remains:

JOGL specification version 1.1.1-rc7
JOGL implementation version 1.1.1-rc7
JOGL implementation vendor Sun Microsystems, Inc.
OGLUtilities.UNDEFINED = 0
OGLUtilities.WINDOW = 1
OGLUtilities.PBUFFER = 2
OGLUtilities.TEXTURE = 3
OGLUtilities.FLIP_BACKBUFFER = 4
OGLUtilities.FBOBJECT = 5
Checking for Java2D/OpenGL support
Java2D support: default GraphicsConfiguration = sun.awt.Win32GraphicsConfig
JOGL/Java2D integration disabled
GLCanvas.addNotify()
Using AWT thread for performing OpenGL work in javax.media.opengl implementation
AWT-EventQueue-0: Using ChoosePixelFormat because multisampling not requested
Desired: GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red: 8, Green: 8, Blue: 8, Alpha: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
Available 0: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
Available 1: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false ]
Available 2: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
Available 3: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false ]
Available 4: GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
Available 5: GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false ]

Window system’s recommended choice: 4
Choosing window system’s recommended choice of 4
GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
AWT-EventQueue-0: Chosen pixel format (4):
GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
AWT-EventQueue-0: SetPixelFormat failed: current context = 0, current DC = 0
AWT-EventQueue-0: GetPixelFormat(hdc 0x4c010538) returns 0

and on resizing frame exception from my first post is thrown

third-party library for selecting pixel format is not used, matlab calls function setpixelformat, which is accessible in windows.

Sorry, but I don’t know what could be happening. Perhaps Matlab is doing something strange with its window management. However in theory it shouldn’t be able to interfere with what JOGL is doing. I would suggest you contact MATLAB support.

on windows, for some device context can be pixel format set only once. trying to set pixel format to same device context again throws Exception. I think, it is the problem. JOGL is trying to set pixel format for existing device context with existing pixel format. Is there any workaround how to say JOGL: don’t select pixel format, it is already done ?

You’re right, those are the rules, but the current build of JOGL should be smart enough to detect this situation, bail out of its pixel format selection process and just use the pixel format chosen by Matlab. This isn’t the case here; no pixel format was chosen by the time we got into JOGL’s pixel format selection code. You’re using a GLCanvas which creates its own OpenGL drawable and context, and it doesn’t look like Matlab is interfering with that. However I don’t know why it can’t set the pixel format on the newly created window. Have you specified -Dsun.java2d.noddraw=true to the underlying JVM that Matlab runs?

I found it is a driver bug. the newest one can render it, but in this new version RenderMode(selection) does not work well with my card. World is unfair…:slight_smile:

thank you for help,
Pavel

I am curious for why you are trying to use jogl with matlab?

I personally tried using matlab with OpenGL/C application using the matlab remote component it works fine and i am betting that it would be of better performance that jogl. Anyway if it helps my test results showed that the connection to matlab in realtime is expensive!