Doing headless or offscreen rendering

Will jme3 run and render on a headless server? The application will need to work without a user logged into the server (for security reasons).

We are using jme in a non-game application that we want to generate scene shots on the server and save them for reporting purposes. Our application is currently using jme2 and it works fine as a standalone but we have troubles getting the application to work on a server with the requirements stated above. We use the LWJGL renderer. If we upgrade to jme3, will we be able to get it working?

Any help or ideas will be appreciated. Thanks.

As there will be nothing to render your pictures I’m afraid that won’t work. Headless means rendering is disabled. You still need a GPU but you could use an AWT context and do off screen rendering to avoid having a window open while still creating a real OpenGL context with a GPU to render.

Thanks for the quick reply normen.

If the server has a GPU and JmeContext.Type.Canvas is used, will application render? Again, one of the requirements is to not allow a user log into the server.

Only if the canvas is actually opened, look at the AwtPanels and TestRenderToMemory tests, the AWT context allows only rendering in an offscreen context without a window.

@normen said: Only if the canvas is actually opened, look at the AwtPanels and TestRenderToMemory tests, the AWT context allows only rendering in an offscreen context without a window.

actually wouldn#t a locally running X server also be required? else the awt stuff will probably fail.

@Empire Phoenix said: actually wouldn#t a locally running X server also be required? else the awt stuff will probably fail.

You never open an AWT window when you do it the way I mean.

I modified a copy of the TestRenderToMemory class and made it save the image rather than displaying; got rid of the JFrame as well. It’s working if I manually running. It even worked when running from an ssh terminal after exporting the DISPLAY variable (we use a linux server).

I setup it up to run at server boot up (not when a user logs in) and I ran into the same issue we were facing when running on it on the server. The problem seems to be in the native code of the lwjgl library when it tries to initialize the OpenGL context.

I tried both headless and headful jvm (-Djava.awt.headless=true|false) and each gave me a different error but none seemed to make a different.

Would the JOGL renderer work? I was going to try it but I didn’t know where to make the setting change.

Well your system does need a properly installed OpenGL driver, I don’t know how this works in Linux without an X server though.

In short, no there is no way around, also some AWT classes do static initializers that need a X11 server running, hence my comment on running X11 less as being problematic.
If you manage to avoid those that should not be an issue.

But why don’t you just let the local terminal autologin and startx ? then after x startup start the rest.

But why don't you just let the local terminal autologin and startx ? then after x startup start the rest.

The application will have to run like a background service. We tried and the autologin approach worked but it is against company policy.

I am almost sure you can get a GL context on Linux without X11… But as said, I don’t know how, I guess :google: is you friend…

Well if you company is prohibiting you from work, I cannot really help you there.

@normen said: I am almost sure you can get a GL context on Linux without X11.. But as said, I don't know how, I guess :google: is you friend..

http://www.opengl.org/wiki/Creating_an_OpenGL_Context#Create_Context_with_Attributes

the this may not work is a big warning for me, as there is no gurantee it will work later on the server after a update ect.
Anyway this will probably need a bit of rewriting in the jme3 core to get access to the necessary context attribtures.