-
Notifications
You must be signed in to change notification settings - Fork 56
Home
- Generate the solutions with
netImgui\Build\GenerateProject.bat
.- Note : Outputed to '*.\netImgui\Build_projects*'
- Open the solution
vs2019_netImgui_Server.sln
and build the netImgui server application.- Note : Outputed to '*netImgui\Build_bin*'
- Copy the sources files in
.\netImgui\Code\Client\
to your codebase and add them to your build process.- Note : When only targetting Windows OS, the netImgui compiled libraries can be used for linking instead
-
Edit 'NetImgui_Api.h' with the valid path to Dear ImGui header file :
#include <imgui.h>
.- Note : Your project should now compile on Windows
-
On platforms other than Windows, functions declared in 'NetImgui_Network.h' need 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.
Very few changes needed when displaying same local Dear ImGui content on the remote netImgui server.
Note : 'vs2019_netImgui_Sample.sln' offers a good example of integrating netImgui to a codebase, 'SampleClient.cpp' source file in particular.
- In your program startup, add a call to :
NetImgui::Startup()
-
In your program startup (or potentially elsewhere), add a call to :
NetImgui::Connect(...)
-
Note 1: When connecting, a client name and the IP/Port address of the netImgui server application needs to be specified. This will start a new communication thread using
std::thread
by default, but a custom threading implementation can be used when providing a callback function. -
Note 2: The status of connection can be determined with :
NetImgui::IsConnected()
Upon creation of the Dear ImGui Font texture, netImgui also need to be made aware of it, with a call to : NetImgui::SendDataTexture(...)
-
Note 1: When using other textures in your Dear ImGui menus, also send them to netImgui server.
-
Note 2: Updating the textures can be done before establishing a connection to the netImgui server.
In you codebase and netImgui is connected, replace calls to ImGui::NewFrame()
with NetImgui::NewFrame()
and ImGui::Render()
with NetImGui::EndFrame()
.
-
Note 1: 'NetImgui::NewFrame()' will return false when not waiting for a new frame, in which case, all Imgui drawing should be skipped. If this requires too much code change, you can instead call 'ImGui::NewFrame() / ImGui::Render()' normally and ignore the results.
-
Note 2: These two functions can help keeping the logic clean, when Imgui menus should only be displayed either locally or remotely, but not both.
bool Imgui_NewFrame()
{
if( NetImgui::IsConnected() )
{
return NetImgui::NewFrame();
}
ImGui::NewFrame();
return true;
}
void Imgui_EndFrame()
{
if( NetImgui::IsRemoteDraw() )
{
NetImgui::EndFrame();
}
else
{
ImGui::Render();
}
}
-
Note 3:
NetImgui::IsRemoteDraw()
can be used to customize the content when drawing ImGui menus. -
Note 4: It is possible to both have content displayed on the netImgui server application and some different content in your own application, simultaneously.
In your program shutdown, add a call to : NetImgui::Shutdown()