Using an externally created OpenGL context to render jME


I’m trying to use jME in a plugin architecture (XBMC). To create a visualisation that renders in the background.

I am kind of bridging the gap between a XBMC’s C++ plugin system and jME. JNI bridged this initial gap quite well.

XBMC creates and initialises the OpenGL context. I finally found GLContext.loadOpenGLLibrary and GLContext.useContext and it appears to initialise lwjgl properly now.

But the call to the “SimpleApplication.start” is causing jME to create a window. I need to to use whatever XBMC provides, the existing OpenGL context and whatever the window is.

XBMC does provide width and height, and whatever window jME creates is to those specifications, it’s just an external window to the XBMC container.

I extended LwjglDisplay, I was hoping I could intervene in the “createContext” call to prevent the “Display” from creating a window, but I don’t know how to tell it to stop creating a window, or what calls to use to initialise lwjgl to use the existing context / drawing surface.

Looking at existing XBMC (C++) visualisations, they don’t manage OpenGL, so I don’t think any “JmeContext” needs to manage recreation of contexts, it looks like it should be managed by XBMC. And it is very eager at destroying plugins too.

(The version of jME I am using is 3.0.0beta, I am kinda stuck to that version as it is a 3rd-party extension of jME) I don’t know if this is a lwjgl or jME thing anyway.

(I also need at some point to stop telling it be multi-threaded as there is a “render” call from XBMC that tells the system to render I believe.)

1 Like

I might suggest, to render in jme headless to a framebuffer, and copy the resulting frames over to the native context, if performance is not the greatest concern.

You shouldn’t extend LwjglDisplay for this but LwjglContext. The purpose of the class would be to wrap an existing OpenGL context and provide the neccesary info to jME3 like input, resolution, etc.

What kind of “3rd party extension”?

I really didn’t want to get into mentioning the extension of jME, as I’m not entirely sure it’s relevant. But it’s MikuMikuStudio (MMS), which says it’s jME 3.0.0beta when it is invoked.

I am attempting to use this to create a Visualisation for XBMC that renders the Vocaloid avatars, that use the correct motion (assuming the user provides it!), to dance with the music they select. However I don’t believe this causes a problem with what I’m trying to do.

While I’ve had some experience of OpenGL it’s always been in C++. I’ve had a very small amount of experience in jME, mainly just to get it to create a few basic objects, then I’d do some GLSL coding.

As to using jme headless, me and my pride (sorry… arrogance) must admit to being clueless now.

The furthest I have got is setting the “JmeContext.Type.Headless” when calling the application start().

As much help as possible will be very much appreciated. When I get something finally dancing I will put this onto bitbucket, after a refactor and the MMS owner is happy.