Skip to content
Sammyfreg edited this page Aug 22, 2020 · 15 revisions

Integration

Setup

  1. Copy the sources files in .\Code\Client\ to your codebase and add them to your build process.
  2. (Optional) Generate the solutions with .\Build\GenerateProject.bat after downloading the sources from the netImgui Git depot.
    • Note : Outputed to .\Build\projects\

Integration

  1. Edit 'NetImgui_Config.h' with the valid path to your Dear ImGui header file : #include <imgui.h>.

    • Note : Your project should now compile
  2. On platforms without support for either Winsocks or POSIX, the functions declared in 'NetImgui_Network.h' needs to be implemented.

    • Allows data exchange between the netImgui server and your application using socket connection.
    • 'NetImgui_NetworkWin32.cpp' can be used as a reference.

Note : All memory allocations done by the netImgui client code are using the Dear ImGui allocator.

Changes to codebase

Very few changes needed when displaying same local Dear ImGui content on the remote netImgui server.

Note 1: 'vs2019_netImgui_Sample.sln' offers a good example of integrating netImgui to a codebase, 'SampleBasic.cpp' source file in particular.

1. [Init]
  • In your program startup, add a call to : NetImgui::Startup()
2. [Connect]
  • In your program startup (or potentially elsewhere), add a call to : NetImgui::ConnectToApp() or NetImgui::ConnectFromApp()

  • Note 1: Connection can be initiated from either the Server (ConnectFromApp) or Client (ConnectToApp), it is up to the integrater to decide which one they prefer.

  • Note 2: When initializing a connection, a new communication thread will be created using std::thread by default. A custom threading implementation can be used instead, by providing a callback function to the connection function.

  • Note 3: The connection status can be determined with : NetImgui::IsConnected() and NetImgui::IsConnectionPending().

3. [Send Texture]

Upon creation of the Dear ImGui Font texture, netImgui also needs to be made aware of it, using NetImgui::SendDataTexture().

  • Note 1: Other textures used by your Dear ImGui menus also need to be forwarded to the netImgui server.

  • Note 2: Updating the textures can either be done before or after establishing a connection to the netImgui server.

4. [Step Draw]

In your codebase, replace calls to these functions :

  • ImGui::NewFrame() with NetImgui::NewFrame()

  • ImGui::Render() / ImGui::EndFrame() with NetImGui::EndFrame() .

  • Note 1 (Important): When remote drawing, we don't need to update the Dear ImGui content evert frame. If your UI drawing code can easily handle skipping drawing a frame, you can let NetImgui::NewFrame() know and it will returns false when it doesn't need to be refreshed. You can also rely on NetImgui::IsDrawing() to know if we are expecting to draw at the moment.

  • Note 2: NetImgui::IsDrawingRemote() can be used to customize the content when drawing Dear ImGui content.

  • Note 3: It is possible to have content displayed simultaneously on the remote netImgui server and locally, with distinct content on each output. The Sample SampleDualUI has more information.

5. [Step Shutdown]

In your program shutdown, add a call to : NetImgui::Shutdown()

Clone this wiki locally