diff --git a/.gitmodules b/.gitmodules index b044f920..cfc1cab8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "external/microprofile/microprofile"] path = external/microprofile/microprofile url = https://github.com/jonasmr/microprofile.git +[submodule "imgui"] + path = external/imgui/imgui + url = https://github.com/ocornut/imgui.git diff --git a/cmake_options.cmake b/cmake_options.cmake index d0d10cb0..b6362cf1 100644 --- a/cmake_options.cmake +++ b/cmake_options.cmake @@ -6,6 +6,7 @@ option(BUILD_VIEWER "Build GUI data viewer") option(ENABLE_SCRIPT_DEBUG "Enable verbose script execution") option(ENABLE_PROFILING "Enable detailed profiling metrics") +option(ENABLE_IMGUI "Enable imgui plugin") option(TEST_DATA "Enable tests that require game data") diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index de3bbe45..9c4fa96e 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,3 +1,7 @@ if(ENABLE_PROFILING) add_subdirectory(microprofile) endif() + +if(ENABLE_IMGUI) + add_subdirectory(imgui) +endif() diff --git a/external/imgui/CMakeLists.txt b/external/imgui/CMakeLists.txt new file mode 100644 index 00000000..700dc127 --- /dev/null +++ b/external/imgui/CMakeLists.txt @@ -0,0 +1,58 @@ +add_library(imgui EXCLUDE_FROM_ALL + rw_imconfig.h + imgui/imgui.h + imgui/imgui.cpp + imgui/imgui_demo.cpp + imgui/imgui_draw.cpp + imgui/imgui_internal.h + imgui/imgui_widgets.cpp + imgui/imstb_rectpack.h + imgui/imstb_textedit.h + imgui/imstb_truetype.h +) + +target_include_directories(imgui SYSTEM + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}/imgui" +) + +target_compile_definitions(imgui + PUBLIC + IMGUI_USER_CONFIG="${CMAKE_CURRENT_SOURCE_DIR}/rw_imconfig.h" +) + +add_library(imgui::core ALIAS imgui) + +openrw_target_apply_options( + TARGET imgui +) + +add_library(imgui_sdl_gl3 EXCLUDE_FROM_ALL + imgui/examples/imgui_impl_opengl3.h + imgui/examples/imgui_impl_opengl3.cpp + imgui/examples/imgui_impl_sdl.h + imgui/examples/imgui_impl_sdl.cpp +) + +target_include_directories(imgui_sdl_gl3 SYSTEM + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}/imgui/examples" +) + +target_link_libraries(imgui_sdl_gl3 + PUBLIC + imgui::core + SDL2::SDL2 +) + +# FIXME: extract gl loader to target + add property to get header +target_compile_definitions(imgui_sdl_gl3 + PRIVATE + "IMGUI_IMPL_OPENGL_LOADER_CUSTOM=\"${OpenRW_SOURCE_DIR}/rwcore/gl/gl_core_3_3.h\"" +) + +add_library(imgui::sdl_gl3 ALIAS imgui_sdl_gl3) + +openrw_target_apply_options( + TARGET imgui_sdl_gl3 +) diff --git a/external/imgui/imgui b/external/imgui/imgui new file mode 160000 index 00000000..801645d3 --- /dev/null +++ b/external/imgui/imgui @@ -0,0 +1 @@ +Subproject commit 801645d35092c8da0eeabe71d7c1997c47aa3648 diff --git a/external/imgui/rw_imconfig.h b/external/imgui/rw_imconfig.h new file mode 100644 index 00000000..f6d6482d --- /dev/null +++ b/external/imgui/rw_imconfig.h @@ -0,0 +1,9 @@ +#ifndef RW_IMCONFIG_H +#define RW_IMCONFIG_H + +// Disable imgui assertions when not in debug mode +#ifndef RW_DEBUG +#define IM_ASSERT(MSG) //FIXME(madebr): remove comment +#endif + +#endif // RW_IMCONFIG_H