diff --git a/src/Editor/Window/PlayView.cpp b/src/Editor/Window/PlayView.cpp index c0627e9..c35579c 100644 --- a/src/Editor/Window/PlayView.cpp +++ b/src/Editor/Window/PlayView.cpp @@ -5,7 +5,7 @@ using namespace Seele; using namespace Seele::Editor; -PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath) +PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath) : GameView(graphics, window, createInfo, dllPath) {} PlayView::~PlayView() {} diff --git a/src/Editor/Window/PlayView.h b/src/Editor/Window/PlayView.h index f236117..e62a612 100644 --- a/src/Editor/Window/PlayView.h +++ b/src/Editor/Window/PlayView.h @@ -5,7 +5,7 @@ namespace Seele { namespace Editor { class PlayView : public GameView { public: - PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath); + PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath); virtual ~PlayView(); virtual void beginUpdate() override; virtual void update() override; diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 67bf009..db06781 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -71,7 +71,7 @@ int main() { .offset = {0, 0}, }, }; - OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); + OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath); sceneView->setFocused(); // OInspectorView inspectorView = new Editor::InspectorView(graphics, window, // ViewportCreateInfo{ diff --git a/src/Engine/Graphics/slang-compile.cpp b/src/Engine/Graphics/slang-compile.cpp index d45f096..d45fdfa 100644 --- a/src/Engine/Graphics/slang-compile.cpp +++ b/src/Engine/Graphics/slang-compile.cpp @@ -93,7 +93,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg targetDesc.format = target; sessionDesc.targetCount = 1; sessionDesc.targets = &targetDesc; - StaticArray searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/generated/"}; + StaticArray searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/game", "shaders/generated/"}; sessionDesc.searchPaths = searchPaths.data(); sessionDesc.searchPathCount = searchPaths.size(); diff --git a/src/Engine/Platform/Linux/GameInterface.cpp b/src/Engine/Platform/Linux/GameInterface.cpp index bb690a3..9eb22c7 100644 --- a/src/Engine/Platform/Linux/GameInterface.cpp +++ b/src/Engine/Platform/Linux/GameInterface.cpp @@ -2,7 +2,7 @@ using namespace Seele; -GameInterface::GameInterface(std::string soPath) : lib(NULL), soPath(soPath) {} +GameInterface::GameInterface(std::filesystem::path soPath) : lib(NULL), soPath(soPath) {} GameInterface::~GameInterface() {} @@ -13,7 +13,7 @@ void GameInterface::reload() { destroyInstance(game); dlclose(lib); } - lib = dlopen(soPath.c_str(), RTLD_NOW); + lib = dlopen(soPath.string().c_str(), RTLD_NOW); createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); game = createInstance(); diff --git a/src/Engine/Platform/Linux/GameInterface.h b/src/Engine/Platform/Linux/GameInterface.h index 7b0a2d9..d55ed02 100644 --- a/src/Engine/Platform/Linux/GameInterface.h +++ b/src/Engine/Platform/Linux/GameInterface.h @@ -1,18 +1,19 @@ #pragma once #include "Game.h" +#include "filesystem" #include "dlfcn.h" namespace Seele { class GameInterface { public: - GameInterface(std::string soPath); + GameInterface(std::filesystem::path soPath); ~GameInterface(); Game* getGame(); void reload(); private: void* lib; - std::string soPath; + std::filesystem::path soPath; Game* game; Game* (*createInstance)() = nullptr; void (*destroyInstance)(Game*) = nullptr; diff --git a/src/Engine/Platform/Windows/GameInterface.cpp b/src/Engine/Platform/Windows/GameInterface.cpp index ca044fd..85f58df 100644 --- a/src/Engine/Platform/Windows/GameInterface.cpp +++ b/src/Engine/Platform/Windows/GameInterface.cpp @@ -3,7 +3,7 @@ using namespace Seele; -GameInterface::GameInterface(std::string dllPath) : dllPath(dllPath) {} +GameInterface::GameInterface(std::filesystem::path dllPath) : dllPath(dllPath) {} GameInterface::~GameInterface() {} @@ -14,7 +14,8 @@ void GameInterface::reload() { destroyInstance(game); FreeLibrary(lib); } - lib = LoadLibraryA(dllPath.c_str()); + std::filesystem::copy(dllPath.parent_path().parent_path() / "res" / "shaders", "./shaders/game", std::filesystem::copy_options::overwrite_existing); + lib = LoadLibraryA(dllPath.string().c_str()); createInstance = (decltype(createInstance))GetProcAddress(lib, "createInstance"); destroyInstance = (decltype(destroyInstance))GetProcAddress(lib, "destroyInstance"); game = createInstance(); diff --git a/src/Engine/Platform/Windows/GameInterface.h b/src/Engine/Platform/Windows/GameInterface.h index 3e69149..b9094e2 100644 --- a/src/Engine/Platform/Windows/GameInterface.h +++ b/src/Engine/Platform/Windows/GameInterface.h @@ -2,18 +2,19 @@ #include "Game.h" #define NOIME #include "Windows.h" +#include namespace Seele { class GameInterface { public: - GameInterface(std::string dllPath); + GameInterface(std::filesystem::path dllPath); ~GameInterface(); Game* getGame(); void reload(); private: HMODULE lib = NULL; - std::string dllPath; + std::filesystem::path dllPath; Game* game; Game* (*createInstance)() = nullptr; void (*destroyInstance)(Game*) = nullptr; diff --git a/src/Engine/Window/GameView.cpp b/src/Engine/Window/GameView.cpp index 8c28137..abe1248 100644 --- a/src/Engine/Window/GameView.cpp +++ b/src/Engine/Window/GameView.cpp @@ -19,7 +19,7 @@ using namespace Seele; -GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath) +GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath) : View(graphics, window, createInfo, "Game"), graphics(graphics), scene(new Scene(graphics)), gameInterface(dllPath) { reloadGame(); renderGraph.addPass(new CachedDepthPass(graphics, scene)); diff --git a/src/Engine/Window/GameView.h b/src/Engine/Window/GameView.h index b788e1e..27a4011 100644 --- a/src/Engine/Window/GameView.h +++ b/src/Engine/Window/GameView.h @@ -12,7 +12,7 @@ namespace Seele { class GameView : public View { public: - GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath); + GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath); virtual ~GameView(); virtual void beginUpdate() override; virtual void update() override;