Jump to content

turning ImGui C++ demo to C#


photo

Recommended Posts

Hey there,

some time ago the devs of unigine gave us a ImGui demo in C++ and i am currently trying to turn it in to C# with the help of a existing c# wrapper of ImGui called mellinoe/ImGui.NET: An ImGui wrapper for .NET. (github.com) i am currently sitting at 34 errors i cannot solve because i don't know how they work in the C++ counterpart.

i hope some of you can help me with this.

here is my imgui implementation so far: ImGuiImpl.cs AppSystemLogic.cs it is pretty much a carbon copy of the original implementation but in C#

i also added the imgui C++ prototype just in case anybody doesn't have it.

thanks for your time and i hope somebody can help me with this.

imgui_cpp_prototype.zip

  • Thanks 1
Link to comment

Hi ! Thanks for providing that C++ Imgui demo, I've been looking for a while to integrate imgui in my unigine projects.

When/where did the devs release that demo ? I didn't find anything on the forum last year when I first try to integrate it myself.

I'm having problems to make it work tho.

the imgui interface is displayed just fine, but the last frame that was rendered before I open any imgui window, just keeps faintly appearing when I move the camera.

you can see it quite clearly at the center of this screenshot, this is what the camera rended before I opened the imgui demo window and moved the camera around.

 

error.thumb.png.15c64d8753624414e2b91746c18f99ec.png

 

Anybody got the same problem ? I'm running the demo in an empty project with Unigine 2.13 sim on Linux.

 

 

  • Like 1
Link to comment

Hi Coppel.Damien,

Add this line:

RenderState::setScissorTest(0.0f, 0.0f, 1.0f, 1.0f);

in the static void draw_callback() function here:

		global_vtx_offset += cmd_list->VtxBuffer.Size;
		global_idx_offset += cmd_list->IdxBuffer.Size;
	}

	RenderState::setScissorTest(0.0f, 0.0f, 1.0f, 1.0f); // place it here!
}
render_target->disable();
imgui_mesh->unbind();


Best regards,
Alexander

  • Like 1
Link to comment

@alexanderThank you very much, this is perfect. Everything is working fine now :)

Is there any way to make the implementation work without modifying main.cpp ? Or do you have any hint to make mouse capture work without interfering with the engine cycle ?

  • Like 1
Link to comment
2 hours ago, alexander said:

Hi Kireita,

I've made a sample of integration of the ImGui to C#.
It will work on the release version of SDK 2.14.
So, wait for release :)

imgui_csharp.zip 862.5 kB · 0 downloads

Best regards,
Alexander

**Sreams like baby**

thank you! this is so awesome, i guess i have to wait until 2.14 is released so i can test it right?

i hope my code helped to make this possible i was checking what i was getting wrong and boy... i didn't even get 40% right XD i am so sorry if this costed you guys a lot of time but i thank you for this!

sorry for being annoying, i hope i can make some other integrations possible with you guys :D.

 

  • Like 1
  • Thanks 1
Link to comment
  • 5 months later...

Hello,

In this sample engine textures are used for rendering. You need to convert image to texture and then use in ImGui.Image(...). To convert a texture to a pointer, you can use GCHandle. In render callback you need to restore texture from pointer and set to material. Separate materials should be used for different textures. The attachment contains modified files for this sample. Please change path of image in AppSystemLogic to your test image.

ImGuiImpl.csAppSystemLogic.cs

  • Like 2
Link to comment
  • 4 months later...
  • 1 year later...
×
×
  • Create New...