JSandusky / ImGuiCLI

C++/CLI wrapper for DearImGui Viewports branch
MIT License
6 stars 3 forks source link

ZBuffer problems #2

Closed KakCAT closed 6 years ago

KakCAT commented 6 years ago

I'm having problems when mixing ImGui and ZBuffer

I've modified your sample (just removed the extra docked dialogs, only 'demo' and 'debug' panels appear) and added a rotating cube:

https://pastebin.com/0nq0inat

When pressing the mouse left button, ImGui initializes and ZBuffer is somehow lost. Do you know if I need a special flag to pass to ImGui in order to conserve ZBuffer?

note: explicitely clearing the zbuffer before myRender doesn't work either. ( i.e. GraphicsDevice.Clear (ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Red,1,0); )

JSandusky commented 6 years ago

It's the DepthStencilView attachment, it's not being tracked in the ImGui stuff - so as soon as the ImGui windows appear it gets lost and SharpDX/MonoGame has no way of knowing someone else messed with that state.

Fixing.

JSandusky commented 6 years ago

Commit ce2ad83a1661b48cb702365cfc99d87926323cd6 should fix this.

I managed the GraphicsDevice Viewports (MonoGame side) like a complete moron in that sample code I posted. With viewports set up correctly (just set one up for you to use in myRender()):

fixed

Not closing as fixed just yet, I don't think the viewport hassle should actually be there.

JSandusky commented 6 years ago

Closing this as fixed now.

This case, as well as the reverse where you render your scene first and then draw the ImGui, should be fully functional.

You might have to fiddle your GraphicsDevice Clear calls around and setup viewports, but that should be all. The ImGuiCli side now no longer does any clearing of the backbuffer, which is probably what forced you to use the render ordering you're using.


FYI: If you don't intend to use the docking you don't need to use the RootDock function. You can just create windows via ImGuiCli.Begin(...) and ImGuiCli.End().

Docking makes more sense to use if you intend to do your MonoGame rendering into render-targets that you draw with ImGuiCli.Image(myRenderTarget)

KakCAT commented 6 years ago

Thanks a lot, it's working now both drawing before and after.

Yes, the order was reversed because I was experimenting trying to get around the bug and afterwards I forgot to notify the problem. The RootDock is a mixture between experimentation and lack of knowledge :)