Skip to content

Commit

Permalink
seperate window manager backend from imgui frontend
Browse files Browse the repository at this point in the history
this allows for different backends to be used for imgui with ease.
  • Loading branch information
ITotalJustice committed Apr 24, 2022
1 parent 6d6f570 commit af798af
Show file tree
Hide file tree
Showing 7 changed files with 689 additions and 538 deletions.
15 changes: 5 additions & 10 deletions src/frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,25 @@ add_library(imgui
${imgui_SOURCE_DIR}/imgui_demo.cpp
)

target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR}/ ${imgui_SOURCE_DIR}/backends)

# the backend we want
find_package(SDL2 CONFIG REQUIRED)
target_sources(imgui PRIVATE ${imgui_SOURCE_DIR}/backends/imgui_impl_sdl.cpp ${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer.cpp)
target_link_libraries(imgui PRIVATE SDL2::SDL2)
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})

# memory editor
add_library(imgui_club INTERFACE)
target_include_directories(imgui INTERFACE ${imgui_club_SOURCE_DIR}/imgui_memory_editor)
# fetch imgui is done!

# always include backend after fetching imgui
add_subdirectory(backend)

add_executable(main
main.cpp
system.cpp
debugger/io.cpp
)

find_package(SDL2 CONFIG REQUIRED)

target_link_libraries(main PRIVATE GBA)
target_link_libraries(main PRIVATE SDL2::SDL2)
target_link_libraries(main PRIVATE SDL2::SDL2main)
target_link_libraries(main PRIVATE imgui imgui_club)
target_link_libraries(main PRIVATE backend)

set(FOUND_MINIZIP FALSE)

Expand Down
3 changes: 3 additions & 0 deletions src/frontend/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.20.0)

add_subdirectory(sdl2)
23 changes: 23 additions & 0 deletions src/frontend/backend/sdl2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.20.0)

add_library(backend
backend_sdl2.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer.cpp
)

target_include_directories(backend PRIVATE
${imgui_SOURCE_DIR}/backends
)

target_include_directories(backend PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

find_package(SDL2 CONFIG REQUIRED)

target_link_libraries(backend PRIVATE imgui)
target_link_libraries(backend PRIVATE SDL2::SDL2)
target_link_libraries(backend PRIVATE GBA)

target_apply_lto_in_release(backend)
Loading

0 comments on commit af798af

Please sign in to comment.