From 19a60a7a0632ddb16a9203adde35194bdacb9be2 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Mon, 28 Dec 2020 15:22:38 -0500 Subject: [PATCH] Make tools compile successfully under MSVC --- .gitignore | 4 ++++ CMakeLists.txt | 3 +-- data/dummy | 0 extern/CMakeLists.txt | 10 ++++++++++ platforms/windows/main.cpp.in | 2 ++ tools/common/include/commoneditor.hpp | 8 ++++---- tools/common/include/undostack.hpp | 1 + tools/common/src/commoneditor.cpp | 6 +++--- tools/common/src/debugpass.cpp | 10 +++++----- tools/modelcompiler/CMakeLists.txt | 8 ++------ 10 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 data/dummy diff --git a/.gitignore b/.gitignore index 4cddea4..402438c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ extern/SPIRV-Cross/external/ +out/ +.vs/ + build/ *build/ +CMakeSettings.json .DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c4662a..f3c4c2d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.17) -project(PrismEngine - LANGUAGES CXX) +project(PrismEngine) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) diff --git a/data/dummy b/data/dummy new file mode 100644 index 0000000..e69de29 diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index f8093c1..472482d 100755 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -97,3 +97,13 @@ target_link_libraries(opusfile add_subdirectory(portaudio) endif() + +if(BUILD_TOOLS) + FetchContent_Declare( + assimp + GIT_REPOSITORY https://github.com/assimp/assimp + GIT_TAG v5.0.1 + ) + + FetchContent_MakeAvailable(assimp) +endif() \ No newline at end of file diff --git a/platforms/windows/main.cpp.in b/platforms/windows/main.cpp.in index 0e061ad..08cde24 100755 --- a/platforms/windows/main.cpp.in +++ b/platforms/windows/main.cpp.in @@ -42,6 +42,8 @@ wchar_t* convertToUnicode(const char* str) { return buf; } +void platform::force_quit() {} + int platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) { RECT wr = {rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); diff --git a/tools/common/include/commoneditor.hpp b/tools/common/include/commoneditor.hpp index 87a5d29..804dccb 100755 --- a/tools/common/include/commoneditor.hpp +++ b/tools/common/include/commoneditor.hpp @@ -181,14 +181,14 @@ public: } GFXTexture* get_asset_thumbnail(const file::Path path) { - if(asset_thumbnails.count(path)) { - return asset_thumbnails[path]; + if(asset_thumbnails.count(path.string())) { + return asset_thumbnails[path.string()]; } else { auto [asset, block] = assetm->load_asset_generic(path); // store as dummy texture, as to stop infinite reload because of failure (e.g. out of date model) if(asset == nullptr) { - asset_thumbnails[path] = engine->get_renderer()->dummyTexture; + asset_thumbnails[path.string()] = engine->get_renderer()->dummyTexture; return engine->get_renderer()->dummyTexture; } @@ -344,7 +344,7 @@ inline void editPath(const char* label, std::string& path, bool editable = true, if(ImGui::Button("...")) { platform::open_dialog(false, [&path, &on_selected](std::string p) { - path = file::get_relative_path(file::Domain::App, p); + path = file::get_relative_path(file::Domain::App, p).string(); if(on_selected != nullptr) on_selected(); diff --git a/tools/common/include/undostack.hpp b/tools/common/include/undostack.hpp index b4a5f80..543074c 100755 --- a/tools/common/include/undostack.hpp +++ b/tools/common/include/undostack.hpp @@ -2,6 +2,7 @@ #include #include +#include class Command { public: diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index 6158548..3e0510e 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -51,13 +51,13 @@ CommonEditor::CommonEditor(std::string id) : id(id) { #ifdef PLATFORM_MACOS file::set_domain_path(file::Domain::App, "../../../data"); #else - file::set_domain_path(Domain::App, "data"); + file::set_domain_path(file::Domain::App, "data"); #endif file::set_domain_path(file::Domain::Internal, "{resource_dir}/shaders"); ImGuiIO& io = ImGui::GetIO(); - iniFileName = file::get_writeable_directory() / "imgui.ini"; + iniFileName = (file::get_writeable_directory() / "imgui.ini").string(); io.IniFilename = iniFileName.c_str(); @@ -805,7 +805,7 @@ void CommonEditor::drawAssets() { ImGui::Separator(); if(ImGui::Button("Regenerate thumbnail")) { - asset_thumbnails.erase(asset_thumbnails.find(file::app_domain / p)); + asset_thumbnails.erase(asset_thumbnails.find((file::app_domain / p).string())); } ImGui::EndPopup(); diff --git a/tools/common/src/debugpass.cpp b/tools/common/src/debugpass.cpp index 6a24b77..34e1b64 100755 --- a/tools/common/src/debugpass.cpp +++ b/tools/common/src/debugpass.cpp @@ -226,7 +226,7 @@ void DebugPass::draw_arrow(GFXCommandBuffer* commandBuffer, Vector3 color, Matri commandBuffer->set_vertex_buffer(arrowMesh->position_buffer, 0, 0); commandBuffer->set_index_buffer(arrowMesh->index_buffer, IndexType::UINT32); - commandBuffer->draw_indexed(arrowMesh->num_indices, 0, 0); + commandBuffer->draw_indexed(arrowMesh->num_indices, 0, 0, 0); } void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { @@ -335,7 +335,7 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { commandBuffer->set_vertex_buffer(cubeMesh->position_buffer, 0, 0); commandBuffer->set_index_buffer(cubeMesh->index_buffer, IndexType::UINT32); - commandBuffer->draw_indexed(cubeMesh->num_indices, 0, 0); + commandBuffer->draw_indexed(cubeMesh->num_indices, 0, 0, 0); } commandBuffer->set_graphics_pipeline(billboard_pipeline); @@ -352,7 +352,7 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { commandBuffer->bind_texture(bill.texture, 2); commandBuffer->set_push_constant(&pc, sizeof(BillPushConstant)); - commandBuffer->draw_indexed(4, 0, 0); + commandBuffer->draw_indexed(4, 0, 0, 0); } commandBuffer->set_graphics_pipeline(arrow_pipeline); @@ -408,7 +408,7 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { if(renderable.mesh) { for (auto& part : renderable.mesh->parts) - commandBuffer->draw_indexed(part.index_count, part.index_offset, part.vertex_offset); + commandBuffer->draw_indexed(part.index_count, part.index_offset, part.vertex_offset, 0); } } } @@ -542,7 +542,7 @@ void DebugPass::get_selected_object(int x, int y, std::functionset_push_constant(&pc, sizeof(PC)); for (auto& part : mesh->parts) - commandBuffer->draw_indexed(part.index_count, part.index_offset, part.vertex_offset); + commandBuffer->draw_indexed(part.index_count, part.index_offset, part.vertex_offset, 0); } engine->get_gfx()->submit(commandBuffer); diff --git a/tools/modelcompiler/CMakeLists.txt b/tools/modelcompiler/CMakeLists.txt index 912eae2..acbbbe3 100755 --- a/tools/modelcompiler/CMakeLists.txt +++ b/tools/modelcompiler/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(assimp REQUIRED) - add_platform_executable( TARGET ModelCompiler APP_CLASS ModelEditor @@ -11,9 +9,7 @@ target_link_libraries(ModelCompiler PUBLIC Core EditorCommon PRIVATE - ${ASSIMP_LIBRARIES}) + assimp) target_include_directories(ModelCompiler PUBLIC - include - PRIVATE - ${ASSIMP_INCLUDE_DIRS}) + include) set_engine_properties(ModelCompiler)