Added compilation framework for IMGUI example on linux (#340)

This commit is contained in:
Matteo De Carlo
2021-11-05 09:30:24 +01:00
committed by GitHub
parent f275f4690b
commit 571ac00bc0
4 changed files with 39 additions and 24 deletions
+11 -6
View File
@@ -23,12 +23,17 @@ endif()
add_subdirectory(WickedEngine)
option(WICKED_TESTS "Build WickedEngine tests" ON)
if (WICKED_TESTS)
add_subdirectory(Tests)
endif()
option(WICKED_EDITOR "Build WickedEngine editor" ON)
if (WICKED_EDITOR)
add_subdirectory(Editor)
add_subdirectory(Editor)
endif()
option(WICKED_TESTS "Build WickedEngine tests" ON)
if (WICKED_TESTS)
add_subdirectory(Tests)
endif()
option(WICKED_IMGUI_EXAMPLE "Build WickedEngine imgui example" ON)
if (WICKED_TESTS)
add_subdirectory(Example_ImGui)
endif()
+21 -11
View File
@@ -4,9 +4,20 @@ endif ()
set (SOURCE_FILES
stdafx.cpp
Tests.cpp
Tests.h
Example_ImGui.cpp
Example_ImGui.h
stdafx.h
ImGui/imconfig.h
ImGui/imgui.cpp
ImGui/imgui.h
ImGui/imgui_demo.cpp
ImGui/imgui_draw.cpp
ImGui/imgui_internal.h
ImGui/imgui_tables.cpp
ImGui/imgui_widgets.cpp
ImGui/imstb_rectpack.h
ImGui/imstb_textedit.h
ImGui/imstb_truetype.h
)
if (WIN32)
@@ -16,9 +27,9 @@ if (WIN32)
Tests.rc
)
add_executable(Tests WIN32 ${SOURCE_FILES})
add_executable(Example_ImGui WIN32 ${SOURCE_FILES})
target_link_libraries(Tests PUBLIC
target_link_libraries(Example_ImGui PUBLIC
WickedEngine_Windows
)
else()
@@ -26,16 +37,16 @@ else()
main_SDL2.cpp
)
add_executable(Tests ${SOURCE_FILES})
add_executable(Example_ImGui ${SOURCE_FILES})
target_link_libraries(Tests PUBLIC
target_link_libraries(Example_ImGui PUBLIC
WickedEngine
Threads::Threads
)
# Copy shaders to build and source folders just to be safe:
add_custom_command(
TARGET Tests POST_BUILD
TARGET Example_ImGui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/WickedEngine/shaders/spirv ${CMAKE_CURRENT_SOURCE_DIR}/shaders/spirv
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/WickedEngine/shaders/spirv ${CMAKE_CURRENT_BINARY_DIR}/shaders/spirv
)
@@ -43,14 +54,13 @@ else()
endif ()
if (MSVC)
set_property(TARGET Tests PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
set_property(TARGET Example_ImGui PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif ()
# Copy content to build folder:
add_custom_command(
TARGET Tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_BINARY_DIR}/images
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/sound ${CMAKE_CURRENT_BINARY_DIR}/sound
TARGET Example_ImGui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/WickedEngine/${LIB_DXCOMPILER} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Content ${CMAKE_CURRENT_BINARY_DIR}/../Content
)
+3 -3
View File
@@ -64,9 +64,9 @@ bool ImGui_Impl_CreateDeviceObjects()
imguiInputLayout.elements =
{
{ "POSITION", 0, FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), INPUT_PER_VERTEX_DATA },
{ "TEXCOORD", 0, FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), INPUT_PER_VERTEX_DATA },
{ "COLOR", 0, FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), INPUT_PER_VERTEX_DATA },
{ "POSITION", 0, FORMAT_R32G32_FLOAT, 0, (uint32_t)IM_OFFSETOF(ImDrawVert, pos), INPUT_PER_VERTEX_DATA },
{ "TEXCOORD", 0, FORMAT_R32G32_FLOAT, 0, (uint32_t)IM_OFFSETOF(ImDrawVert, uv), INPUT_PER_VERTEX_DATA },
{ "COLOR", 0, FORMAT_R8G8B8A8_UNORM, 0, (uint32_t)IM_OFFSETOF(ImDrawVert, col), INPUT_PER_VERTEX_DATA },
};
// Create pipeline
+4 -4
View File
@@ -5,7 +5,7 @@
#include <SDL2/SDL.h>
#include "sdl2.h"
int sdl_loop(Tests &tests)
int sdl_loop(Example_ImGui &tests)
{
SDL_Event event;
@@ -50,7 +50,7 @@ int sdl_loop(Tests &tests)
int main(int argc, char *argv[])
{
Tests tests;
Example_ImGui exampleImGui;
// TODO: Place code here.
wiStartupArguments::Parse(argc, argv);
@@ -69,9 +69,9 @@ int main(int argc, char *argv[])
throw sdl2::SDLError("Error creating window");
}
tests.SetWindow(window.get());
exampleImGui.SetWindow(window.get());
int ret = sdl_loop(tests);
int ret = sdl_loop(exampleImGui);
SDL_Quit();
return ret;