Jump to content

turning ImGui C++ demo to C#


photo

Recommended Posts

Posted

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
Posted

Kireita

Right now we are doing some internal engine API changes, so it would be possible to create such integration sample in C#. I hope that it would be available in API in 2.14 and we can return back to this sample after release.

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

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
Posted

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
Posted

@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
Posted

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

Best regards,
Alexander

  • Like 2
  • Thanks 1
Posted
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
  • 5 months later...
Posted (edited)

How can I cast Unigine Image for ImGui.Image(...) ?

Edited by Ugly1-1
Posted

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
  • 4 months later...
Posted

If anyone needs it, here's the updated .CS for ImGuiImpl.cs for Unigine 2.15.
You will also need to take the imgui.basemat (taken from the 2.15 3rd party demo in the browser).

ImGuiImpl.cs imgui.basemat

  • Like 2
  • 1 year later...
Posted

Hello everyone, 

where can I find ImGui demo with Unigine? I search engine, which can plot some data for science and engineering

×
×
  • Create New...