Skip to content

Commit

Permalink
Add HELLOIMGUI_WITH_REMOTE_DISPLAY
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Apr 18, 2024
1 parent 30351dd commit 2fb2b44
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions external/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SDL
SDL2-*/
qtimgui/
netImgui/
imgui-ws/
2 changes: 2 additions & 0 deletions hello_imgui_cmake/hello_imgui_build_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ endfunction()
###################################################################################################
function(him_with_netimgui)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_WITH_NETIMGUI)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_WITH_REMOTE_DISPLAY)

# message(STATUS "HelloImGui: downloading and building netImgui")
# include(FetchContent)
Expand Down Expand Up @@ -1070,6 +1071,7 @@ endfunction()
###################################################################################################
function(him_with_imguiws)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_WITH_IMGUIWS)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_WITH_REMOTE_DISPLAY)

# Add imgui-ws to the project
set(IMGUIWS_DIR ${HELLOIMGUI_BASEPATH}/external/imgui-ws CACHE STRING "" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions src/hello_imgui/impl/hello_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ std::string RendererBackendTypeToString(RendererBackendType rendererBackendType)
std::string GetBackendDescription()
{
const auto& params = GetRunnerParams();
#ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY
if (params->remoteParams.enableRemoting)
return "Remote";
#endif
std::string platformBackend = PlatformBackendTypeToString(params->platformBackendType);
std::string rendererBackend = RendererBackendTypeToString(params->rendererBackendType);
return platformBackend + " - " + rendererBackend;
Expand Down
12 changes: 8 additions & 4 deletions src/hello_imgui/internal/backend_impls/abstract_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ float _DefaultOsFontRenderingScale()
fontSizeIncreaseFactor = (float) NSScreen.mainScreen.backingScaleFactor;
#endif

#ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY
if (HelloImGui::GetRunnerParams()->remoteParams.enableRemoting)
fontSizeIncreaseFactor = 1.f;
#endif

return 1.0f / fontSizeIncreaseFactor;
}

Expand All @@ -381,10 +386,7 @@ void AbstractRunner::SetupDpiAwareParams()

if (params.dpiAwareParams.fontRenderingScale == 0.f)
{
if (params.remoteParams.enableRemoting)
params.dpiAwareParams.fontRenderingScale = 1.f;
else
params.dpiAwareParams.fontRenderingScale = _DefaultOsFontRenderingScale();
params.dpiAwareParams.fontRenderingScale = _DefaultOsFontRenderingScale();
}
ImGui::GetIO().FontGlobalScale = params.dpiAwareParams.fontRenderingScale;

Expand Down Expand Up @@ -965,11 +967,13 @@ void AbstractRunner::CreateFramesAndRender()
}

// Transmit window size to remote server (if needed)
#ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY
if ((mIdxFrame > 3) && params.remoteParams.transmitWindowSize)
{
auto windowSize = params.appWindowParams.windowGeometry.size;
mRemoteDisplayHandler.TransmitWindowSizeToDisplay(windowSize);
}
#endif
} // SCOPED_RELEASE_GIL_ON_MAIN_THREAD end

if(foldable_region) // Handle idling
Expand Down
2 changes: 2 additions & 0 deletions src/hello_imgui/internal/backend_impls/runner_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ void ChooseBackendTypesIfSelectedAsFirstAvailable(RunnerParams* runnerParams)

void ChooseNullBackendsIfUsingRemote(RunnerParams* runnerParams)
{
#ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY
if (runnerParams->remoteParams.enableRemoting)
{
runnerParams->platformBackendType = PlatformBackendType::Null;
runnerParams->rendererBackendType = RendererBackendType::Null;
}
#endif
}


Expand Down
3 changes: 1 addition & 2 deletions src/hello_imgui/remote_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace HelloImGui
// RemoteParams is a struct that contains the settings for displaying the application on a remote device.
// using https://github.com/sammyfreg/netImgui
// or using https://github.com/ggerganov/imgui-ws
// Those feature are experimental and not supported with the standard version of HelloImGui.
// (they require specific versions of netImgui and imgui-ws, and will not compile with their standard versions)
// Those features are experimental and not supported with the standard version of HelloImGui,
struct RemoteParams
{
bool enableRemoting = false;
Expand Down
5 changes: 3 additions & 2 deletions src/hello_imgui/runner_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ struct RunnerParams
// (only used on emscripten: 0 stands for "let the app or the browser decide")
int emscripten_fps = 0;

// Parameters for Remote display (experimental, unsupported)
RemoteParams remoteParams;
#ifdef HELLOIMGUI_WITH_REMOTE_DISPLAY
RemoteParams remoteParams; // Parameters for Remote display (experimental, unsupported)
#endif
};
// @@md

Expand Down

0 comments on commit 2fb2b44

Please sign in to comment.