Linux rendering from command line

Hey,
I’m wondering if anyone knows of a way to render graphics using JOGL without initializing a GUI. For example, I’d like to render graphics using Linux from an app running from a command line. The images would be rendered and written as png image files to the hard drive.

Thanks.

yes its possible if you use a pbuffer for rendering:
http://www.java-gaming.org/forums/index.php?topic=16328.0

we have a simple GLWorker for doing headless gl work in the NetBeans OpenGL Pack (like compiling shaders), all you have to do is to provide a GLRunnable and call work().
https://netbeans-opengl-pack.dev.java.net/source/browse/netbeans-opengl-pack/trunk/jogl-utils/src/com/mbien/engine/util/

(it wasn’t designed to be reusable but you get the idea)

Thanks for the help. Your solution appears to work on my Windows box running an NVidia card. However, there appears to be a problem on my Red Hat box running an ATI card. Here is the error I receive:

Exception in thread “main” javax.media.opengl.GLException: javax.media.opengl.GLException: pbuffer creation error: glXChooseFBConfig() failed
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.maybeDoSingleThreadedWorkaround(X11GLDrawableFactory.java:652)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.createGLPbuffer(X11GLDrawableFactory.java:313)
at gfi_mapper.Main.main(Main.java:32)
Caused by: javax.media.opengl.GLException: pbuffer creation error: glXChooseFBConfig() failed
at com.sun.opengl.impl.x11.X11PbufferGLDrawable.createPbuffer(X11PbufferGLDrawable.java:126)
at com.sun.opengl.impl.x11.X11PbufferGLDrawable.(X11PbufferGLDrawable.java:73)
at com.sun.opengl.impl.x11.X11GLDrawableFactory$2.run(X11GLDrawableFactory.java:306)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
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)

does GLDrawableFactory.getFactory().canCreateGLPbuffer() return true?

we have a fallback mode which uses in those situations an GLCanvas as drawable but this is not possible in headless mode :confused:

It does return true.

The pbuffer support on ATI cards under Linux has been buggy for a few driver revisions. It prevents for example to use GLJPanel on such configuration.

I’m afraid the only solution until the issue is fixed is to use GLCanvas or switch to software rendering…

What do you mean by software rendering?

I mean mesa drivers, sorry.

What do you mean by mesa drivers?

This is an implementation of OpenGL. It’s very robust, but does not provide any hardware acceleration.
Website: http://www.mesa3d.org/

I think there are packages for any Linux distributions.

GLJPanel should work with the latest ATI drivers (release 8.8). The pbuffer support has been fixed.
Your code should work then.