FrontendCommon: Drop imgui deps for libretro build
This commit is contained in:
parent
6bbbb96d4b
commit
0af22825ad
|
@ -21,7 +21,7 @@ if(WIN32)
|
|||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(duckstation_libretro PRIVATE core common imgui glad scmversion frontend-common vulkan-loader libretro-common)
|
||||
target_link_libraries(duckstation_libretro PRIVATE core common glad scmversion frontend-common vulkan-loader libretro-common)
|
||||
|
||||
# no lib prefix
|
||||
set_target_properties(duckstation_libretro PROPERTIES PREFIX "")
|
||||
|
|
|
@ -1,64 +1,78 @@
|
|||
add_library(frontend-common
|
||||
common_host_interface.cpp
|
||||
common_host_interface.h
|
||||
controller_interface.cpp
|
||||
controller_interface.h
|
||||
game_list.cpp
|
||||
game_list.h
|
||||
game_settings.cpp
|
||||
game_settings.h
|
||||
icon.cpp
|
||||
icon.h
|
||||
imgui_styles.cpp
|
||||
imgui_styles.h
|
||||
ini_settings_interface.cpp
|
||||
ini_settings_interface.h
|
||||
opengl_host_display.cpp
|
||||
opengl_host_display.h
|
||||
save_state_selector_ui.cpp
|
||||
save_state_selector_ui.h
|
||||
vulkan_host_display.cpp
|
||||
vulkan_host_display.h
|
||||
)
|
||||
|
||||
target_link_libraries(frontend-common PUBLIC core common imgui simpleini tinyxml2 scmversion glad vulkan-loader)
|
||||
target_link_libraries(frontend-common PUBLIC core common glad vulkan-loader)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(frontend-common PRIVATE
|
||||
d3d11_host_display.cpp
|
||||
d3d11_host_display.h
|
||||
xinput_controller_interface.cpp
|
||||
xinput_controller_interface.h
|
||||
)
|
||||
target_link_libraries(frontend-common PRIVATE d3d11.lib dxgi.lib)
|
||||
endif()
|
||||
|
||||
if(SDL2_FOUND AND NOT BUILD_LIBRETRO_CORE)
|
||||
target_sources(frontend-common PRIVATE
|
||||
sdl_audio_stream.cpp
|
||||
sdl_audio_stream.h
|
||||
sdl_controller_interface.cpp
|
||||
sdl_controller_interface.h
|
||||
sdl_initializer.cpp
|
||||
sdl_initializer.h
|
||||
if(NOT BUILD_LIBRETRO_CORE)
|
||||
target_sources(frontend-common PRIVATE
|
||||
common_host_interface.cpp
|
||||
common_host_interface.h
|
||||
controller_interface.cpp
|
||||
controller_interface.h
|
||||
game_list.cpp
|
||||
game_list.h
|
||||
game_settings.cpp
|
||||
game_settings.h
|
||||
icon.cpp
|
||||
icon.h
|
||||
imgui_styles.cpp
|
||||
imgui_styles.h
|
||||
ini_settings_interface.cpp
|
||||
ini_settings_interface.h
|
||||
save_state_selector_ui.cpp
|
||||
save_state_selector_ui.h
|
||||
)
|
||||
target_compile_definitions(frontend-common PUBLIC "WITH_SDL2=1")
|
||||
target_include_directories(frontend-common PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(frontend-common PRIVATE ${SDL2_LIBRARIES})
|
||||
|
||||
# Copy bundled SDL2 to output on Windows.
|
||||
if(WIN32)
|
||||
add_custom_command(TARGET frontend-common POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2_DLL_PATH}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SDL2.dll")
|
||||
target_sources(frontend-common PRIVATE
|
||||
xinput_controller_interface.cpp
|
||||
xinput_controller_interface.h
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(frontend-common PRIVATE "WITH_IMGUI=1")
|
||||
target_link_libraries(frontend-common PUBLIC imgui simpleini tinyxml2 scmversion)
|
||||
|
||||
if(SDL2_FOUND)
|
||||
target_sources(frontend-common PRIVATE
|
||||
sdl_audio_stream.cpp
|
||||
sdl_audio_stream.h
|
||||
sdl_controller_interface.cpp
|
||||
sdl_controller_interface.h
|
||||
sdl_initializer.cpp
|
||||
sdl_initializer.h
|
||||
)
|
||||
target_compile_definitions(frontend-common PUBLIC "WITH_SDL2=1")
|
||||
target_include_directories(frontend-common PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(frontend-common PRIVATE ${SDL2_LIBRARIES})
|
||||
|
||||
# Copy bundled SDL2 to output on Windows.
|
||||
if(WIN32)
|
||||
add_custom_command(TARGET frontend-common POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2_DLL_PATH}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SDL2.dll")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_DISCORD_PRESENCE AND NOT BUILD_LIBRETRO_CORE)
|
||||
target_compile_definitions(frontend-common PUBLIC -DWITH_DISCORD_PRESENCE=1)
|
||||
target_link_libraries(frontend-common PRIVATE discord-rpc)
|
||||
endif()
|
||||
|
||||
# Copy the provided data directory to the output directory.
|
||||
add_custom_command(TARGET frontend-common POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DISCORD_PRESENCE AND NOT BUILD_LIBRETRO_CORE)
|
||||
target_compile_definitions(frontend-common PUBLIC -DWITH_DISCORD_PRESENCE=1)
|
||||
target_link_libraries(frontend-common PRIVATE discord-rpc)
|
||||
endif()
|
||||
|
||||
# Copy the provided data directory to the output directory.
|
||||
add_custom_command(TARGET frontend-common POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
#include <array>
|
||||
#ifndef LIBRETRO
|
||||
#include <dxgi1_5.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
#endif
|
||||
#ifdef WITH_IMGUI
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
#endif
|
||||
Log_SetChannel(D3D11HostDisplay);
|
||||
|
||||
|
@ -298,7 +300,7 @@ bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
|
|||
if (!CreateResources())
|
||||
return false;
|
||||
|
||||
#ifndef LIBRETRO
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext() && !CreateImGuiContext())
|
||||
return false;
|
||||
#endif
|
||||
|
@ -308,7 +310,7 @@ bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
|
|||
|
||||
void D3D11HostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
#ifndef LIBRETRO
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
DestroyImGuiContext();
|
||||
#endif
|
||||
|
@ -532,9 +534,9 @@ void D3D11HostDisplay::DestroyResources()
|
|||
m_display_rasterizer_state.Reset();
|
||||
}
|
||||
|
||||
#ifndef LIBRETRO
|
||||
bool D3D11HostDisplay::CreateImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
|
||||
|
@ -542,14 +544,16 @@ bool D3D11HostDisplay::CreateImGuiContext()
|
|||
return false;
|
||||
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void D3D11HostDisplay::DestroyImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool D3D11HostDisplay::Render()
|
||||
{
|
||||
|
@ -560,8 +564,10 @@ bool D3D11HostDisplay::Render()
|
|||
|
||||
RenderDisplay();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
RenderImGui();
|
||||
#endif
|
||||
|
||||
RenderSoftwareCursor();
|
||||
|
||||
|
@ -570,8 +576,10 @@ bool D3D11HostDisplay::Render()
|
|||
else
|
||||
m_swap_chain->Present(BoolToUInt32(m_vsync), 0);
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
#endif
|
||||
#else
|
||||
RenderDisplay();
|
||||
RenderSoftwareCursor();
|
||||
|
@ -580,15 +588,13 @@ bool D3D11HostDisplay::Render()
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef LIBRETRO
|
||||
|
||||
void D3D11HostDisplay::RenderImGui()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void D3D11HostDisplay::RenderDisplay()
|
||||
{
|
||||
|
|
|
@ -65,20 +65,17 @@ protected:
|
|||
virtual bool CreateResources();
|
||||
virtual void DestroyResources();
|
||||
|
||||
#ifndef LIBRETRO
|
||||
virtual bool CreateImGuiContext();
|
||||
virtual void DestroyImGuiContext();
|
||||
|
||||
#ifndef LIBRETRO
|
||||
bool CreateSwapChain();
|
||||
bool CreateSwapChainRTV();
|
||||
#endif
|
||||
|
||||
void RenderDisplay();
|
||||
void RenderSoftwareCursor();
|
||||
|
||||
#ifndef LIBRETRO
|
||||
void RenderImGui();
|
||||
#endif
|
||||
|
||||
void RenderDisplay(s32 left, s32 top, s32 width, s32 height, void* texture_handle, u32 texture_width,
|
||||
s32 texture_height, s32 texture_view_x, s32 texture_view_y, s32 texture_view_width,
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
@ -273,7 +273,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;_ITERATOR_DEBUG_LEVEL=1;WIN32;_DEBUGFAST;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;_ITERATOR_DEBUG_LEVEL=1;WIN32;_DEBUGFAST;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
@ -304,7 +304,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
@ -332,7 +332,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;_ITERATOR_DEBUG_LEVEL=1;WIN32;_DEBUGFAST;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;_ITERATOR_DEBUG_LEVEL=1;WIN32;_DEBUGFAST;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
@ -365,7 +365,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
|
@ -395,7 +395,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
|
@ -427,7 +427,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
|
@ -457,7 +457,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WITH_IMGUI=1;WITH_SDL2=1;WITH_DISCORD_PRESENCE=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\discord-rpc\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#include "opengl_host_display.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/log.h"
|
||||
#include "imgui.h"
|
||||
#include <array>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <tuple>
|
||||
#ifdef WITH_IMGUI
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#endif
|
||||
Log_SetChannel(LibretroOpenGLHostDisplay);
|
||||
|
||||
namespace FrontendCommon {
|
||||
|
@ -219,8 +221,10 @@ bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_dir
|
|||
if (!CreateResources())
|
||||
return false;
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext() && !CreateImGuiContext())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -246,8 +250,10 @@ void OpenGLHostDisplay::DestroyRenderDevice()
|
|||
if (!m_gl_context)
|
||||
return;
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
DestroyImGuiContext();
|
||||
#endif
|
||||
|
||||
DestroyResources();
|
||||
|
||||
|
@ -269,11 +275,13 @@ bool OpenGLHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
|||
m_window_info.surface_width = m_gl_context->GetSurfaceWidth();
|
||||
m_window_info.surface_height = m_gl_context->GetSurfaceHeight();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -287,11 +295,13 @@ void OpenGLHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
|
|||
m_window_info.surface_width = m_gl_context->GetSurfaceWidth();
|
||||
m_window_info.surface_height = m_gl_context->GetSurfaceHeight();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::DestroyRenderSurface()
|
||||
|
@ -306,6 +316,7 @@ void OpenGLHostDisplay::DestroyRenderSurface()
|
|||
|
||||
bool OpenGLHostDisplay::CreateImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
|
||||
|
@ -313,12 +324,15 @@ bool OpenGLHostDisplay::CreateImGuiContext()
|
|||
return false;
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::DestroyImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OpenGLHostDisplay::CreateResources()
|
||||
|
@ -424,24 +438,30 @@ bool OpenGLHostDisplay::Render()
|
|||
|
||||
RenderDisplay();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
RenderImGui();
|
||||
#endif
|
||||
|
||||
RenderSoftwareCursor();
|
||||
|
||||
m_gl_context->SwapBuffers();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::RenderImGui()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
GL::Program::ResetLastProgram();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::RenderDisplay()
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
#include "common/vulkan/stream_buffer.h"
|
||||
#include "common/vulkan/swap_chain.h"
|
||||
#include "common/vulkan/util.h"
|
||||
#include <array>
|
||||
#ifdef WITH_IMGUI
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#include <array>
|
||||
#endif
|
||||
Log_SetChannel(VulkanHostDisplay);
|
||||
|
||||
namespace FrontendCommon {
|
||||
|
@ -134,11 +136,13 @@ bool VulkanHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
|||
m_window_info.surface_width = m_swap_chain->GetWidth();
|
||||
m_window_info.surface_height = m_swap_chain->GetHeight();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -153,11 +157,13 @@ void VulkanHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
|
|||
m_window_info.surface_width = m_swap_chain->GetWidth();
|
||||
m_window_info.surface_height = m_swap_chain->GetHeight();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VulkanHostDisplay::DestroyRenderSurface()
|
||||
|
@ -250,8 +256,10 @@ bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_dir
|
|||
if (!CreateResources())
|
||||
return false;
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext() && !CreateImGuiContext())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -400,7 +408,9 @@ void VulkanHostDisplay::DestroyResources()
|
|||
|
||||
void VulkanHostDisplay::DestroyImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
void VulkanHostDisplay::DestroyRenderDevice()
|
||||
|
@ -410,8 +420,10 @@ void VulkanHostDisplay::DestroyRenderDevice()
|
|||
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
DestroyImGuiContext();
|
||||
#endif
|
||||
|
||||
DestroyResources();
|
||||
|
||||
|
@ -432,6 +444,7 @@ bool VulkanHostDisplay::DoneRenderContextCurrent()
|
|||
|
||||
bool VulkanHostDisplay::CreateImGuiContext()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
|
||||
|
@ -454,6 +467,8 @@ bool VulkanHostDisplay::CreateImGuiContext()
|
|||
}
|
||||
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -499,8 +514,10 @@ bool VulkanHostDisplay::Render()
|
|||
|
||||
RenderDisplay();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
RenderImGui();
|
||||
#endif
|
||||
|
||||
RenderSoftwareCursor();
|
||||
|
||||
|
@ -513,8 +530,10 @@ bool VulkanHostDisplay::Render()
|
|||
m_swap_chain->GetCurrentImageIndex());
|
||||
g_vulkan_context->MoveToNextCommandBuffer();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
if (ImGui::GetCurrentContext())
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -565,8 +584,10 @@ void VulkanHostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height,
|
|||
|
||||
void VulkanHostDisplay::RenderImGui()
|
||||
{
|
||||
#ifdef WITH_IMGUI
|
||||
ImGui::Render();
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), g_vulkan_context->GetCurrentCommandBuffer());
|
||||
#endif
|
||||
}
|
||||
|
||||
void VulkanHostDisplay::RenderSoftwareCursor()
|
||||
|
|
Loading…
Reference in New Issue