diff --git a/.vscode/launch.json b/.vscode/launch.json index c784074..39f778c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,10 +8,10 @@ "name": "Editor", "type": "cppvsdbg", "request": "launch", - "program": "${workspaceRoot}/bin/Debug/Editor.exe", + "program": "${workspaceRoot}/bin/Editor.exe", "args": [], "stopAtEntry": false, - "cwd": "${workspaceRoot}/bin/Debug", + "cwd": "${workspaceRoot}/bin", "console": "internalConsole", "environment": [], "symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64", diff --git a/.vscode/settings.json b/.vscode/settings.json index 8ac89d6..45297e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "telemetry.enableTelemetry": false, - "cmake.buildDirectory": "${workspaceFolder}/bin/${buildType}", + "cmake.buildDirectory": "${workspaceFolder}/bin", "files.associations": { "*.h": "cpp", "*.ush": "hlsl", diff --git a/CMakeLists.txt b/CMakeLists.txt index c3be367..efea014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,13 +39,15 @@ project (Seele) include(cmake/Superbuild.cmake) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) #Workaround for vs, because it places artifacts into an additional subfolder -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(Boost_USE_STATIC_LIBS OFF) if(WIN32) @@ -113,6 +115,7 @@ target_precompile_headers(Engine if(MSVC) set(_CRT_SECURE_NO_WARNINGS) target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-") + target_compile_options(Editor PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-") target_sources(Engine INTERFACE $ $ diff --git a/cmake-variants.json b/cmake-variants.json index ed05d0c..d83b2aa 100644 --- a/cmake-variants.json +++ b/cmake-variants.json @@ -6,20 +6,17 @@ "debug": { "short": "Debug", "long": "Enable debugging and validation", - "buildType": "Debug", - "settings": { - "CMAKE_DEBUG_POSTFIX": "d", - "CMAKE_BUILD_TYPE": "Debug" - } + "buildType": "Debug" }, "release": { "short": "Release", "long": "Optimize binary for speed", - "buildType": "Release", - "settings": { - "CMAKE_DEBUG_POSTFIX": "", - "CMAKE_BUILD_TYPE": "Release" - } + "buildType": "Release" + }, + "relwithdebinfo": { + "short": "RelWithDebInfo", + "long": "Release with debug symbols", + "buildType": "RelWithDebInfo" } } }, diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index c201b9c..d20f463 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -19,12 +19,19 @@ extern AssetRegistry* instance; int main() { + + std::string outputPath = "C:/Users/Dynamitos/TrackClearGame"; + std::string cmakePath = "C:/Users/Dynamitos/TrackClearGame/cmake"; + std::string gameName = "TrackClear"; + std::string sourcePath = "C:/Users/Dynamitos/TrackClear/"; + std::string binaryPath = "C:/Users/Dynamitos/TrackClear/bin/TrackClear.dll"; + Gfx::PGraphics graphics = new Vulkan::Graphics(); GraphicsInitializer initializer; graphics->init(initializer); PWindowManager windowManager = new WindowManager(); - AssetRegistry::init(std::string("C:\\Users\\Dynamitos\\TrackClear\\Assets"), graphics); + AssetRegistry::init(std::string("C:/Users/Dynamitos/TrackClear/Assets"), graphics); AssetImporter::init(graphics, instance); AssetImporter::importFont(FontImportArgs{ .filePath = "./fonts/Calibri.ttf", @@ -213,7 +220,7 @@ int main() sceneViewInfo.dimensions.size.y = 720; sceneViewInfo.dimensions.offset.x = 0; sceneViewInfo.dimensions.offset.y = 0; - PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, "C:\\Users\\Dynamitos\\TrackClear\\bin\\TrackCleard.dll"); + PGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath); //ViewportCreateInfo inspectorViewInfo; //inspectorViewInfo.dimensions.size.x = 640; @@ -226,9 +233,18 @@ int main() window->render(); //export game - std::string outputPath = "C:\\Users\\Dynamitos\\TrackClearGame"; - - std::system("cmake --configure"); + + std::filesystem::create_directories(outputPath); + std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath, binaryPath).c_str()); + std::system(std::format("cmake -S {} -B {}", cmakePath, cmakePath).c_str()); + std::system(std::format("cmake --build {}", cmakePath).c_str()); + std::filesystem::copy(std::filesystem::path(sourcePath) / "Assets", std::filesystem::path(outputPath) / "Assets", std::filesystem::copy_options::recursive); + std::filesystem::copy("shaders", std::filesystem::path(outputPath) / "shaders", std::filesystem::copy_options::recursive); + std::filesystem::copy("textures", std::filesystem::path(outputPath) / "textures", std::filesystem::copy_options::recursive); + std::filesystem::copy_file("assimp-vc143-mt.dll", std::filesystem::path(outputPath) / "assimp-vc143-mt.dll"); + std::filesystem::copy_file("slang.dll", std::filesystem::path(outputPath) / "slang.dll"); + std::filesystem::copy_file("slang-glslang.dll", std::filesystem::path(outputPath) / "slang-glslang.dll"); + std::filesystem::copy_file("slang-llvm.dll", std::filesystem::path(outputPath) / "slang-llvm.dll"); return 0; } \ No newline at end of file diff --git a/src/Engine/Asset/MaterialAsset.cpp b/src/Engine/Asset/MaterialAsset.cpp index 60d5dc3..4a9d04c 100644 --- a/src/Engine/Asset/MaterialAsset.cpp +++ b/src/Engine/Asset/MaterialAsset.cpp @@ -26,5 +26,6 @@ void MaterialAsset::load(ArchiveBuffer& buffer) { material = new Material(); material->load(buffer); + material->compile(); } diff --git a/src/Engine/Concepts.h b/src/Engine/Concepts.h index ead3805..fab95fd 100644 --- a/src/Engine/Concepts.h +++ b/src/Engine/Concepts.h @@ -7,10 +7,12 @@ template concept invocable = std::invocable; template -concept serializable = requires(T t, Archive& a) +concept serializable = requires(const T t, Archive& a) { - t->save(a); - t->load(a); + t.save(a); +} && requires(T t, Archive& a) +{ + t.load(a); }; template concept enumeration = std::is_enum_v; diff --git a/src/Engine/Material/Material.cpp b/src/Engine/Material/Material.cpp index 8e9dac2..4ebf122 100644 --- a/src/Engine/Material/Material.cpp +++ b/src/Engine/Material/Material.cpp @@ -52,8 +52,9 @@ Gfx::PDescriptorSet Material::createDescriptorSet() void Material::save(ArchiveBuffer& buffer) const { MaterialInterface::save(buffer); - Serialization::save(buffer,materialName); + Serialization::save(buffer, materialName); Serialization::save(buffer, layout->getSetIndex()); + Serialization::save2(buffer, brdf); const auto& bindings = layout->getBindings(); Serialization::save(buffer, bindings.size()); for (const auto& binding : bindings) @@ -73,6 +74,7 @@ void Material::load(ArchiveBuffer& buffer) Serialization::load(buffer, materialName); uint32 setIndex; Serialization::load(buffer, setIndex); + Serialization::load2(buffer, brdf); uint64 numBindings; Serialization::load(buffer, numBindings); layout = graphics->createDescriptorLayout(); diff --git a/src/Engine/Serialization/ArchiveBuffer.h b/src/Engine/Serialization/ArchiveBuffer.h index 78cb487..1ac820c 100644 --- a/src/Engine/Serialization/ArchiveBuffer.h +++ b/src/Engine/Serialization/ArchiveBuffer.h @@ -65,6 +65,16 @@ namespace Serialization { buffer.readBytes(&type, sizeof(type)); } + template + static void save2(ArchiveBuffer& buffer, const T& type) requires(serializable) + { + type.save(buffer); + } + template + static void load2(ArchiveBuffer& buffer, T& type) requires(serializable) + { + type.load(buffer); + } //template //static void save(ArchiveBuffer& buffer, const T& type) //{ diff --git a/src/Engine/Window/GameView.cpp b/src/Engine/Window/GameView.cpp index d3801a7..e15ad3d 100644 --- a/src/Engine/Window/GameView.cpp +++ b/src/Engine/Window/GameView.cpp @@ -19,11 +19,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate SkyboxRenderPass(graphics) )) { - scene = new Scene(graphics); - gameInterface.reload(instance); - - systemGraph = new SystemGraph(); - gameInterface.getGame()->setupScene(scene, systemGraph); + reloadGame(); renderGraph.updateViewport(viewport); } @@ -74,6 +70,15 @@ void GameView::render() }); } +void GameView::reloadGame() +{ + scene = new Scene(graphics); + gameInterface.reload(instance); + + systemGraph = new SystemGraph(); + gameInterface.getGame()->setupScene(scene, systemGraph); +} + void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier) { scene->view([=](Component::KeyboardInput& input) @@ -99,6 +104,10 @@ void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier) // showDebug = !showDebug; // debugPassData.vertices.clear(); //} + if(code == KeyCode::KEY_R && action == InputAction::PRESS) + { + reloadGame(); + } input.keys[code] = action != InputAction::RELEASE; }); diff --git a/src/Engine/Window/GameView.h b/src/Engine/Window/GameView.h index 0d70c6c..2968817 100644 --- a/src/Engine/Window/GameView.h +++ b/src/Engine/Window/GameView.h @@ -20,6 +20,8 @@ public: virtual void prepareRender() override; virtual void render() override; + + void reloadGame(); private: GameInterface gameInterface; RenderGraph<