diff --git a/CMakeLists.txt b/CMakeLists.txt index 803c30de..87b0f04e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,12 @@ option(HELLOIMGUI_HAS_NULL "Null rendering backend" OFF) # for testing and remo option(HELLOIMGUI_NULL_BACKEND "Use Null rendering/platform backend" OFF) # # do not remove this line (used by the script that generates the documentation) +#------------------------------------------------------------------------------ +# Options / Remoting +#------------------------------------------------------------------------------ +# Using https://github.com/sammyfreg/netImgui, you can use HelloImGui with remote rendering +# (this is useful for example to render ImGui on a remote device, or to render ImGui in a web browser) +option(HELLOIMGUI_WITH_NETIMGUI "Use netImgui for remote rendering" OFF) #------------------------------------------------------------------------------ # Options / Freetype diff --git a/CMakePresets.json b/CMakePresets.json index f96aafca..fdaaa20c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -29,14 +29,16 @@ "HELLOIMGUI_HAS_VULKAN": "ON", "HELLOIMGUI_HAS_DIRECTX11": "ON", "HELLOIMGUI_HAS_DIRECTX12": "ON", - "HELLOIMGUI_HAS_NULL": "ON" + "HELLOIMGUI_HAS_NULL": "ON", + "HELLOIMGUI_WITH_NETIMGUI": "ON" } }, { - "name": "build_null_backend", - "description": "Build with null backend.", + "name": "build_netimgui", + "description": "Build with netImgui.", "cacheVariables": { - "HELLOIMGUI_NULL_BACKEND": "ON" + "HELLOIMGUI_NULL_BACKEND": "ON", + "HELLOIMGUI_WITH_NETIMGUI": "ON" } }, { diff --git a/external/.gitignore b/external/.gitignore index fea25349..972ae40c 100644 --- a/external/.gitignore +++ b/external/.gitignore @@ -1,3 +1,4 @@ SDL SDL2-*/ qtimgui/ +netImgui/ diff --git a/hello_imgui_cmake/hello_imgui_build_lib.cmake b/hello_imgui_cmake/hello_imgui_build_lib.cmake index f53da250..eac7c56a 100644 --- a/hello_imgui_cmake/hello_imgui_build_lib.cmake +++ b/hello_imgui_cmake/hello_imgui_build_lib.cmake @@ -1031,6 +1031,42 @@ function(_him_fetch_glfw_if_needed) endfunction() +################################################################################################### +# Remoting with https://github.com/sammyfreg/netImgui: API = him_with_netimgui +################################################################################################### +function(him_with_netimgui) + target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_WITH_NETIMGUI) + +# message(STATUS "HelloImGui: downloading and building netImgui") +# include(FetchContent) +# # Set(FETCHCONTENT_QUIET FALSE) +# FetchContent_Declare(net_imgui +# GIT_REPOSITORY https://github.com/pthom/netImgui.git +# GIT_TAG cmake_multiplatform +# GIT_PROGRESS TRUE +# ) +# FetchContent_MakeAvailable(net_imgui) + + + # Add netImgui to the project + set(NETIMGUI_DIR ${HELLOIMGUI_BASEPATH}/external/netImgui CACHE STRING "" FORCE) + set(NETIMGUI_BUILD_IMGUI OFF CACHE BOOL "" FORCE) + set(NETIMGUI_BUILD_CLIENT ON CACHE BOOL "" FORCE) + set(NETIMGUI_BUILD_SERVER_LIB ON CACHE BOOL "" FORCE) + + #set(NETIMGUI_BUILD_SERVER_APP_SOKOL ON CACHE BOOL "" FORCE) + set(NETIMGUI_BUILD_SERVER_APP_SOKOL OFF CACHE BOOL "" FORCE) + set(NETIMGUI_SERVER_APP_BACKEND_GLFW_GL3 ON CACHE BOOL "" FORCE) + + set(NETIMGUI_BUILD_SAMPLES OFF CACHE BOOL "" FORCE) + add_subdirectory(${NETIMGUI_DIR} netimgui) + + target_link_libraries(${HELLOIMGUI_TARGET} PUBLIC net_imgui_client) + him_add_installable_dependency(net_imgui_client) +endfunction() + + + ################################################################################################### # Miscellaneous: API = him_add_misc_options ################################################################################################### @@ -1083,8 +1119,9 @@ function(him_log_configuration) =========================================================================== Hello ImGui build options: =========================================================================== - Platform Backend(s): ${active_platform_backends} - Rendering Backend(s): ${active_rendering_backends} + Platform Backend(s): ${active_platform_backends} + Rendering Backend(s): ${active_rendering_backends} + Use netImGui: ${HELLOIMGUI_WITH_NETIMGUI} --------------------------------------------------------------------------- Options: HELLOIMGUI_USE_FREETYPE: ${HELLOIMGUI_USE_FREETYPE} (${HELLOIMGUI_FREETYPE_SELECTED_INFO}) @@ -1185,6 +1222,10 @@ function(him_main_add_hello_imgui_library) target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_HAS_NULL) endif() + if (HELLOIMGUI_WITH_NETIMGUI) + him_with_netimgui() + endif() + him_add_apple_options() him_add_linux_options() him_add_windows_options() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e57ac50e..57c198ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,3 +6,6 @@ endif() if(HELLOIMGUI_BUILD_TESTS) add_subdirectory(hello_imgui_tests) endif() +if(HELLOIMGUI_WITH_NETIMGUI AND HELLOIMGUI_HAS_OPENGL3 AND HELLOIMGUI_USE_GLFW3) + add_subdirectory(netimgui_remote_display) +endif() diff --git a/src/hello_imgui/impl/hello_imgui.cpp b/src/hello_imgui/impl/hello_imgui.cpp index aec1a945..b43194af 100644 --- a/src/hello_imgui/impl/hello_imgui.cpp +++ b/src/hello_imgui/impl/hello_imgui.cpp @@ -197,6 +197,8 @@ std::string PlatformBackendTypeToString(PlatformBackendType platformBackendType) return "Glfw"; else if (platformBackendType == PlatformBackendType::Sdl) return "Sdl"; + else if (platformBackendType == PlatformBackendType::Null) + return "Null"; else return "Unknown platform backend"; } @@ -213,6 +215,8 @@ std::string RendererBackendTypeToString(RendererBackendType rendererBackendType) return "DirectX11"; else if (rendererBackendType == RendererBackendType::DirectX12) return "DirectX12"; + else if (rendererBackendType == RendererBackendType::Null) + return "Null"; else return "Unknown renderer backend"; } @@ -220,6 +224,8 @@ std::string RendererBackendTypeToString(RendererBackendType rendererBackendType) std::string GetBackendDescription() { const auto& params = GetRunnerParams(); + if (params->remoteParams.enableRemoting) + return "Remote"; std::string platformBackend = PlatformBackendTypeToString(params->platformBackendType); std::string rendererBackend = RendererBackendTypeToString(params->rendererBackendType); return platformBackend + " - " + rendererBackend; diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 0c545d3a..623e5045 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -21,11 +21,16 @@ #define SCOPED_RELEASE_GIL_ON_MAIN_THREAD #endif +#ifdef HELLOIMGUI_WITH_NETIMGUI +#include "NetImgui_Api.h" +#endif + #include #include #include #include #include +#include #if __APPLE__ #include @@ -676,8 +681,97 @@ void AbstractRunner::Setup() style.Colors[ImGuiCol_TitleBgCollapsed].w = 1.f; } params.callbacks.SetupImGuiStyle(); + +#ifdef HELLOIMGUI_WITH_NETIMGUI + if (params.remoteParams.enableRemoting) + { + if (!NetImGui_Connect()) + { + IM_ASSERT(false && "NetImGui_Connect() failed! Please launch the server/display app before!"); + exit(1); + } + } +#endif +} + + +void AbstractRunner::NetImGui_LogConnectionStatusOnce() +{ + if (! params.remoteParams.enableRemoting) + return; +#ifdef HELLOIMGUI_WITH_NETIMGUI + // Log connection status and return + if (NetImgui::IsConnectionPending()) + { + static bool wasMessageShown = false; + if (!wasMessageShown) + { + wasMessageShown = true; + printf("Waiting for NetImgui connection...\n"); + } + } + else if (NetImgui::IsConnected()) + { + static bool wasMessageShown = false; + if (!wasMessageShown) + { + wasMessageShown = true; + printf("Connected to NetImgui server\n"); + } + } +#endif } + +bool AbstractRunner::NetImGui_Connect() +{ +#ifdef HELLOIMGUI_WITH_NETIMGUI + // 0. Startup NetImgui + NetImgui::Startup(); + // 1. Connect to NetImgui server + std::string clientName = params.remoteParams.clientName; + if (clientName.empty()) + clientName = params.appWindowParams.windowTitle; + if (clientName.empty()) + clientName = "HelloImGui"; + bool clientActiveImmediately = NetImgui::ConnectToApp(clientName.c_str(), params.remoteParams.serverHost.c_str(), params.remoteParams.serverPort); + + // 2. Wait a bit for the connection to be established (this is optional, just to display the messages after) + if (!clientActiveImmediately) + { + printf("Sleeping 0.1s to wait for NetImgui connection...\n"); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + // 3. Log connection status (this is optional also, since this is called also inside CreateFramesAndRender) + NetImGui_LogConnectionStatusOnce(); + if (!NetImgui::IsConnected() && !NetImgui::IsConnectionPending()) + { + printf("Connection to NetImgui server failed!\n"); + return false; + } + + // 4. Send Font texture to NetImgui server + const ImFontAtlas* pFonts = ImGui::GetIO().Fonts; + if( pFonts->TexPixelsAlpha8) // && (pFonts->TexPixelsAlpha8 != client.mpFontTextureData || client.mFontTextureID != pFonts->TexID )) + { + uint8_t* pPixelData(nullptr); int width(0), height(0); + ImGui::GetIO().Fonts->GetTexDataAsAlpha8(&pPixelData, &width, &height); + NetImgui::SendDataTexture(pFonts->TexID, pPixelData, static_cast(width), static_cast(height), NetImgui::eTexFormat::kTexFmtA8); + } + if( pFonts->TexPixelsRGBA32) // && (pFonts->TexPixelsAlpha8 != client.mpFontTextureData || client.mFontTextureID != pFonts->TexID )) + { + uint8_t* pPixelData(nullptr); int width(0), height(0); + ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pPixelData, &width, &height); + NetImgui::SendDataTexture(pFonts->TexID, pPixelData, static_cast(width), static_cast(height), NetImgui::eTexFormat::kTexFmtRGBA8); + } + return true; +#else + return false; +#endif +} + + void AbstractRunner::SetLayoutResetIfNeeded() { if (params.imGuiWindowParams.defaultImGuiWindowType == DefaultImGuiWindowType::ProvideFullScreenDockSpace) @@ -771,6 +865,11 @@ void AbstractRunner::CreateFramesAndRender() // (it is here only to make the code more readable, and to enable to collapse blocks of code) constexpr bool foldable_region = true; +#ifdef HELLOIMGUI_WITH_NETIMGUI + if (params.remoteParams.enableRemoting) + NetImGui_LogConnectionStatusOnce(); +#endif + if (foldable_region) // Update frame rate stats { _UpdateFrameRateStats(); @@ -1137,6 +1236,13 @@ void AbstractRunner::TearDown(bool gotException) if (params.useImGuiTestEngine) TestEngineCallbacks::TearDown_ImGuiContextDestroyed(); #endif + +#ifdef HELLOIMGUI_WITH_NETIMGUI + if (params.remoteParams.enableRemoting) + { + NetImgui::Shutdown(); + } +#endif } diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.h b/src/hello_imgui/internal/backend_impls/abstract_runner.h index cf6bef1b..d4881b3b 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.h +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.h @@ -98,6 +98,9 @@ class AbstractRunner void LayoutSettings_Load(); void LayoutSettings_Save(); + bool NetImGui_Connect(); + void NetImGui_LogConnectionStatusOnce(); + public: BackendApi::WindowPointer mWindow = nullptr; protected: diff --git a/src/hello_imgui/internal/backend_impls/runner_factory.cpp b/src/hello_imgui/internal/backend_impls/runner_factory.cpp index e49394a3..e6625416 100644 --- a/src/hello_imgui/internal/backend_impls/runner_factory.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_factory.cpp @@ -39,10 +39,20 @@ void ChooseBackendTypesIfSelectedAsFirstAvailable(RunnerParams* runnerParams) } } +void ChooseNullBackendsIfUsingRemote(RunnerParams* runnerParams) +{ + if (runnerParams->remoteParams.enableRemoting) + { + runnerParams->platformBackendType = PlatformBackendType::Null; + runnerParams->rendererBackendType = RendererBackendType::Null; + } +} + std::unique_ptr FactorRunner(RunnerParams& params) { ChooseBackendTypesIfSelectedAsFirstAvailable(¶ms); + ChooseNullBackendsIfUsingRemote(¶ms); if (params.platformBackendType == PlatformBackendType::Glfw) { #ifdef HELLOIMGUI_USE_GLFW3 diff --git a/src/hello_imgui/runner_params.h b/src/hello_imgui/runner_params.h index a7ea9c99..af4498fd 100644 --- a/src/hello_imgui/runner_params.h +++ b/src/hello_imgui/runner_params.h @@ -133,6 +133,36 @@ struct FpsIdling // -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- + +// @@md#NetImGuiParams + +// NetImGuiParams is a struct that contains the settings for displaying the application on a remote device. +// using https://github.com/sammyfreg/netImgui +// (This will only work if the application is compiled with the option -DHELLOIMGUI_WITH_NETIMGUI=ON) +struct NetImGuiParams +{ + bool enableRemoting = false; + + // Name of the client (if empty, will use params.appWindowParams.windowTitle) + // (The client is the app that contains the application logic) + std::string clientName = ""; + + // The server host (if empty, will use "localhost") + // The server is the app that simply displays the application on a remote device + std::string serverHost = "localhost"; + // The server port (default is 8888) + uint32_t serverPort = 8888; + + // The client port (default is 8889) + // This is unused since it is the client (i.e. the app logic) that connects to the server, + // using NetImgui::ConnectToApp + uint32_t clientPort = 8889; +}; + +// @@md + +// -------------------------------------------------------------------------------------------------------------------- // @@md#RunnerParams @@ -195,6 +225,8 @@ struct RunnerParams // Only useful when multiple rendering backend are compiled and available. RendererBackendType rendererBackendType = RendererBackendType::FirstAvailable; + // --------------- RemoteParams ------------------- + NetImGuiParams remoteParams; // --------------- Settings ------------------- diff --git a/src/netimgui_remote_display/CMakeLists.txt b/src/netimgui_remote_display/CMakeLists.txt new file mode 100644 index 00000000..5059d715 --- /dev/null +++ b/src/netimgui_remote_display/CMakeLists.txt @@ -0,0 +1,18 @@ +if (NOT HELLOIMGUI_WITH_NETIMGUI) + message(FATAL_ERROR "HELLOIMGUI_WITH_NETIMGUI is not enabled") +endif() +if (NOT HELLOIMGUI_HAS_OPENGL3) + message(FATAL_ERROR "HELLOIMGUI_HAS_OPENGL3 is not enabled, and required for hello_imgui_remote_display") +endif() +if (NOT HELLOIMGUI_USE_GLFW3) + message(FATAL_ERROR "HELLOIMGUI_USE_GLFW3 is not enabled, and required for hello_imgui_remote_display") +endif() + + +set(hal_gl3_cpp_file ${NETIMGUI_DIR}/Code/ServerApp/Source/GlfwGL3/NetImguiServer_HAL_GL3.cpp) +set(sources ${hal_gl3_cpp_file} netimgui_remote_display.cpp NetImguiServer_HAL_Glfw.cpp) +hello_imgui_add_app(netimgui_remote_display ${sources}) +target_compile_definitions(net_imgui_server_lib PUBLIC NETIMGUI_SERVER_APP_BACKEND_GLFW_GL3=1) +target_link_libraries(netimgui_remote_display PRIVATE net_imgui_server_lib) +find_package(OpenGL REQUIRED) +target_link_libraries(netimgui_remote_display PRIVATE OpenGL::GL) diff --git a/src/netimgui_remote_display/NetImguiServer_HAL_Glfw.cpp b/src/netimgui_remote_display/NetImguiServer_HAL_Glfw.cpp new file mode 100644 index 00000000..b198b713 --- /dev/null +++ b/src/netimgui_remote_display/NetImguiServer_HAL_Glfw.cpp @@ -0,0 +1,113 @@ +#include "NetImguiServer_App.h" + +#if HAL_API_PLATFORM_GLFW_GL3 + +#include +#include "hello_imgui/hello_imgui.h" +#include + + +namespace NetImguiServer { namespace App +{ + +//================================================================================================= +// HAL STARTUP +// Additional initialisation that are platform specific +//================================================================================================= +bool HAL_Startup(const char* CmdLine) +{ + IM_UNUSED(CmdLine); + return true; +} + +//================================================================================================= +// HAL SHUTDOWN +// Prepare for shutdown of application, with platform specific code +//================================================================================================= +void HAL_Shutdown() +{ +} + +//================================================================================================= +// HAL GET SOCKET INFO +// Take a platform specific socket (based on the NetImguiNetworkXXX.cpp implementation) and +// fetch informations about the client IP connected +//================================================================================================= +bool HAL_GetSocketInfo(NetImgui::Internal::Network::SocketInfo* pClientSocket, char* pOutHostname, size_t HostNameLen, int& outPort) +{ +#ifdef _WIN32 + sockaddr socketAdr; + int sizeSocket(sizeof(sockaddr)); + SOCKET* pClientSocketWin = reinterpret_cast(pClientSocket); + if( getsockname(*pClientSocketWin, &socketAdr, &sizeSocket) == 0 ) + { + char zPortBuffer[32]; + if( getnameinfo(&socketAdr, sizeSocket, pOutHostname, static_cast(HostNameLen), zPortBuffer, sizeof(zPortBuffer), NI_NUMERICSERV) == 0 ) + { + outPort = atoi(zPortBuffer); + return true; + } + } +#endif + return false; +} + +//================================================================================================= +// HAL GET USER SETTING FOLDER +// Request the directory where to the 'shared config' clients should be saved +// Return 'nullptr' to disable this feature +//================================================================================================= +const char* HAL_GetUserSettingFolder() +{ + static std::string result = HelloImGui::IniFolderLocation(HelloImGui::IniFolderType::AppUserConfigFolder); + return result.c_str(); +} + +//================================================================================================= +// HAL GET CLIPBOARD UPDATED +// Detect when clipboard had a content change and we should refetch it on the Server and +// forward it to the Clients +//================================================================================================= +bool HAL_GetClipboardUpdated() +{ + auto updateClipboardEverySecond = []() -> bool + { + static std::chrono::steady_clock::time_point sLastCheck = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); + if( (now - sLastCheck) > std::chrono::seconds(1) ) + { + sLastCheck = now; + return true; + } + else + { + return false; + } + }; + +#ifdef HELLOIMGUI_USE_GLFW3 + GLFWwindow* mainWindow = (GLFWwindow*)HelloImGui::GetRunnerParams()->backendPointers.glfwWindow; + if (! mainWindow) + return updateClipboardEverySecond(); + else + { + static std::string lastClipboardContent; + const char* clipboardContent = glfwGetClipboardString(mainWindow); + if (clipboardContent && lastClipboardContent != clipboardContent) + { + lastClipboardContent = clipboardContent; + return true; + } + else + { + return false; + } + } +#else + return updateClipboardEverySecond(); +#endif +} + +}} // namespace NetImguiServer { namespace App + +#endif // HAL_API_PLATFORM_WIN32DX11 \ No newline at end of file diff --git a/src/netimgui_remote_display/netimgui_remote_display.cpp b/src/netimgui_remote_display/netimgui_remote_display.cpp new file mode 100644 index 00000000..03b75020 --- /dev/null +++ b/src/netimgui_remote_display/netimgui_remote_display.cpp @@ -0,0 +1,150 @@ +#include "NetImguiServer_App.h" + + + +// @SAMPLE_EDIT +// Note: The 'imgui_impl_opengl3_loader.h' included by Dear Imgui Backend has been replaced +// with our own version without stripped symbol. The server App needs a few extra +// function that are not shipped with Dear ImGui. +// The unstripped version comes from : https://github.com/dearimgui/gl3w_stripped/releases + +#include +#include "NetImguiServer_UI.h" +#include "hello_imgui/hello_imgui.h" +//#include "backends/imgui_impl_opengl3.cpp" +//#include "backends/imgui_impl_glfw.cpp" +////================================================================================================= + +// +//#include "imgui.h" +//#include "imgui_impl_glfw.h" +//#include "imgui_impl_opengl3.h" +//#include +//#if defined(IMGUI_IMPL_OPENGL_ES2) +//#include +//#endif +//#include // Will drag system OpenGL headers + +int main(int argc, char **argv) +{ + auto init_net_imgui_server = [&]() + { + // Start the NetImgui server + std::string cmdArgs; + for (size_t i = 0; i < size_t(argc); ++i) + cmdArgs += std::string(argv[i]) + " "; + if (!cmdArgs.empty()) + cmdArgs.pop_back(); + if (! NetImguiServer::App::Startup(cmdArgs.c_str())) + return 1; + }; + + auto handle_dpi_awareness = []() + { + // @SAMPLE_EDIT (DPI Awareness) + + // float scaleX, scaleY; + // ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); + // glfwGetWindowContentScale(bd->Window, &scaleX, &scaleY); + // + // float maxScale = scaleX > scaleY ? scaleX : scaleY; + // float windowDPI = (float)(NetImguiServer::UI::kWindowDPIDefault) * maxScale; // = kWindowDPIDefault=96 + // NetImguiServer::UI::SetWindowDPI((int)windowDPI); + // ImGui::GetIO().FontGlobalScale = NetImguiServer::UI::GetFontDPIScale(); + + + // HelloImGui::GetRunnerParams()->dpiAwareParams.fontRenderingScale; + // HelloImGui::GetRunnerParams()->dpiAwareParams.dpiWindowSizeFactor; + // HelloImGui::GetRunnerParams()->dpiAwareParams.DpiFontLoadingFactor(); + float windowDPI = HelloImGui::GetRunnerParams()->dpiAwareParams.fontRenderingScale + * (float)(NetImguiServer::UI::kWindowDPIDefault); // 96 + NetImguiServer::UI::SetWindowDPI((int)windowDPI); + + }; + + + // Runner Params + HelloImGui::RunnerParams runnerParams; + + runnerParams.callbacks.PostInit = [&init_net_imgui_server]() { + init_net_imgui_server(); + //ImGui::GetIO().ConfigFlags = ImGui::GetIO().ConfigFlags | ImGuiConfigFlags_DockingEnable; + }; + + runnerParams.callbacks.PreNewFrame = [&handle_dpi_awareness]() { + // Request each client to update their drawing content + NetImguiServer::App::UpdateRemoteContent(); + handle_dpi_awareness(); + }; + + runnerParams.callbacks.BeforeImGuiRender = []() { + ImVec4 clear_color = NetImguiServer::UI::DrawImguiContent(); + HelloImGui::GetRunnerParams()->imGuiWindowParams.backgroundColor = clear_color; + }; + + + runnerParams.callbacks.BeforeExit = []() { + NetImguiServer::App::Shutdown(); + }; + + runnerParams.imGuiWindowParams.defaultImGuiWindowType = HelloImGui::DefaultImGuiWindowType::NoDefaultWindow; + +// runnerParams.dpiAwareParams.dpiWindowSizeFactor = 1.0f; +// runnerParams.dpiAwareParams.fontRenderingScale = 1.0f; + + // Start the HelloImGui runner + HelloImGui::Run(runnerParams); +} + +/* +int main(int argc, char **argv) +{ + + while (ok && !glfwWindowShouldClose(window)) + //========================================================================================= + { + glfwPollEvents(); + + + //========================================================================================= + // @SAMPLE_EDIT (Invoke our own Imgui content drawing, instead of the sample code) + clear_color = NetImguiServer::UI::DrawImguiContent(); + IM_UNUSED(show_demo_window); + IM_UNUSED(show_another_window); + //========================================================================================= + + // Rendering + ImGui::Render(); + int display_w, display_h; + glfwGetFramebufferSize(window, &display_w, &display_h); + glViewport(0, 0, display_w, display_h); + glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); + glClear(GL_COLOR_BUFFER_BIT); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + // Update and Render additional Platform Windows + // (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere. + // For this specific demo app we could also call glfwMakeContextCurrent(window) directly) + if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) + { + GLFWwindow* backup_current_context = glfwGetCurrentContext(); + ImGui::UpdatePlatformWindows(); + ImGui::RenderPlatformWindowsDefault(); + glfwMakeContextCurrent(backup_current_context); + } + + glfwSwapBuffers(window); + } + + // Cleanup + NetImguiServer::App::Shutdown(); // @SAMPLE_EDIT (Deallocate resources) + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); + + glfwDestroyWindow(window); + glfwTerminate(); + + return 0; +} +*/