lemmy101
Topic Author
Posts: 5
Joined: 10 Jan 2019, 20:20

Integration with existing GL context

13 Oct 2020, 17:24

So we have a java game that's using the lwjgl library to provide opengl support. Never been happy with our proprietry ui support and looking into options.

I'm looking into if noesis will work for us, however the samples don't seem to answer my question. I looked at Integration, Integration GLUT etc, but can't see any evidence of a way to use another pre-existing opengl context for noesis. To be clear, since lwjgl is an external library, I'm assuming we'd need to ship in a pointer to the existing gl context to get it to render the ui onto the game's framebuffer? It's not really practical for us to get noesis to create the gl context and pass it into lwjgl without making big changes to it.

I'll admit I'm really more familiar with how DX works, so am I misunderstanding something about how opengl operates and this will all just magically work without the need to do this? as it seems the RenderDevice class creates a new device / context internally and has no options to do otherwise.

Ideally we'd do:

lwjgl native: creates opengl context, passes handle to java.
java: passes handle to dll that will interact with noesis
noesis integration dll: initializes noesis with the passed handle.

Tags:
 
User avatar
jsantos
Site Admin
Posts: 2921
Joined: 20 Jan 2012, 17:18
Contact:

Re: Integration with existing GL context

13 Oct 2020, 17:43

In our architecture, a RenderDevice does not create a context (OpenGL context, D3D11 device), it is passed at creation time.
D3D11RenderDevice(ID3D11DeviceContext* context, bool sRGB = false);
GLRenderDevice(bool sRGB = false);
In the case of OpenGL, the context cannot be passed, it is assumed to be already active. This is exactly, what the Integration GLUT sample is doing. The context is created by GLUT, not Noesis.

For the rest of examples, we use our Application Framework, our application framework (optional, not part of the core) exposes a 'RenderContext' base class for implementing the initialization needed for each renderer.
 
lemmy101
Topic Author
Posts: 5
Joined: 10 Jan 2019, 20:20

Re: Integration with existing GL context

13 Oct 2020, 19:03

Great thanks for the information!
 
User avatar
jsantos
Site Admin
Posts: 2921
Joined: 20 Jan 2012, 17:18
Contact:

Re: Integration with existing GL context

14 Oct 2020, 11:11

Please, let us know if you need more help with the renderer integration.
 
lemmy101
Topic Author
Posts: 5
Joined: 10 Jan 2019, 20:20

Re: Integration with existing GL context

15 Oct 2020, 12:18

Thanks! I called the native code from the NoesisInit function in the glut integration demo, after lwjgl initializes the window and openGL, and all seemed to work ok with the noesis calls - but then I get a JVM crash a little later after leaving the native code, during initialization of unrelated java stuff for the game, that I can only imagine is something to do with threading (the point the JVM dies is random and is happening in native code while java is processing lines 100% unrelated to gfx that differ each run.)

Sadly I don't really have much to go on here. Java's jvm crash reports are rather opaque. No information on where in native code is going wrong, just that its an access violation exception. I can only assume that lwjgl's native code is doing something noesis doesn't like, or noesis has set up something that it doesn't like, so am not really sure I can progress with this idea at this point.

I hate java lol biggest regret that we used it for this game.
 
User avatar
jsantos
Site Admin
Posts: 2921
Joined: 20 Jan 2012, 17:18
Contact:

Re: Integration with existing GL context

15 Oct 2020, 14:34

Sorry about it, I can't help you with Java crashes but I would try commenting all lines in native code and add incrementally to discover what's causing the crash.

Good luck! 😉
 
lemmy101
Topic Author
Posts: 5
Joined: 10 Jan 2019, 20:20

Re: Integration with existing GL context

15 Oct 2020, 15:32

Thanks! Of course I'd never have expected you to help with java side of things. Unfortunately the line that causes the crash later is:

_view->GetRenderer()->Init(NoesisApp::GLFactory::CreateDevice(false));

;) so pretty much the most important line of the bunch.
 
User avatar
jsantos
Site Admin
Posts: 2921
Joined: 20 Jan 2012, 17:18
Contact:

Re: Integration with existing GL context

15 Oct 2020, 19:05

Yes, I see...

Inside that Init, we are creating GPU resources and changing the state, maybe you need to restore it?

Who is online

Users browsing this forum: Bing [Bot] and 4 guests