Page 1 of 1

C4 integration - crash after initializing Noesis

Posted: 22 Aug 2014, 23:37
by Rastar
It took me some time to get my Noesis plugin for C4 building, but that's working now. I am able to initialize NoesisGUI, however C4 crashes when trying to draw some some primitives in its own interface (read: UI) manager.

I am not issuing any render calls to Noesis, but if I make the call to InitSystems() during the initialization, C4 crashes soon after. Unfortunately, debugging doesn't give any clues.

Any ideas what might be going wrong? What exactly is happening during the call to InitSystems()? Especially, which OpenGL calls are done there?

Thanks for your help!

Re: C4 integration - crash after initializing Noesis

Posted: 23 Aug 2014, 07:24
by Rastar
Oh, and a second question: According to the integration docs, stencils have to be enabled for NoesisGUI. Now, C4 enables and disables stencils during rendering based on the light types used, so I can't just turn them on once in the beginning. Is it sufficient if I turn on stencils just before calling the Noesis render methods (and turn them off afterwards)?

Re: C4 integration - crash after initializing Noesis

Posted: 24 Aug 2014, 23:47
by jsantos
Hi!

Does it also happen if you save & restore the GL state (following the LeadWerk wrapper code) ? Apart from those states at init time, we create two buffers:
V(glGenBuffers(1, &mDynamicVB.vbo));
V(glBindBuffer(GL_ARRAY_BUFFER, mDynamicVB.vbo));
V(glBufferData(GL_ARRAY_BUFFER, DynamicVBSize, 0, GL_STREAM_DRAW));

V(glGenBuffers(1, &mDynamicIB.ibo));
V(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mDynamicIB.ibo));
V(glBufferData(GL_ELEMENT_ARRAY_BUFFER, DynamicIBSize, 0, GL_STREAM_DRAW));
If this doesn't help you I can provide you access to the initialization code.

Regarding the stencil, you don't have to care about enabling / disabling it. NoeisGUI does that internally. The only thing that you need to guarantee is that the active frame buffer was created with a stencil surface attached.

Re: C4 integration - crash after initializing Noesis

Posted: 25 Aug 2014, 07:34
by Rastar
I haven't implemented the state change code yet, I will have to modify the engine's sources for that. However, I thought that the saving/restoring of OpenGL state has to be done around the render calls - I don't even get that far.

By "active framebuffer" you mean the one that the engine renders to, correct? I will check again if that carries a stencil buffer.

Re: C4 integration - crash after initializing Noesis

Posted: 25 Aug 2014, 12:59
by jsantos
I haven't implemented the state change code yet, I will have to modify the engine's sources for that. However, I thought that the saving/restoring of OpenGL state has to be done around the render calls - I don't even get that far.
Then, that could explain the crashes in C4. We also modify the state at Init time. Why do you need to modify the engine's sources? You can do the Saving/Restoring in the wrapper, just before calling Noesis.
By "active framebuffer" you mean the one that the engine renders to, correct? I will check again if that carries a stencil buffer.
The active framebuffer is the one that is bound when you call the Render function. We send draws to that buffer.