copy shaders from game to engine

This commit is contained in:
Dynamitos
2025-04-11 13:49:37 +02:00
parent 5a54530a48
commit 708ab36377
10 changed files with 17 additions and 14 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
using namespace Seele; using namespace Seele;
using namespace Seele::Editor; 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) {} : GameView(graphics, window, createInfo, dllPath) {}
PlayView::~PlayView() {} PlayView::~PlayView() {}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace Seele {
namespace Editor { namespace Editor {
class PlayView : public GameView { class PlayView : public GameView {
public: 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 ~PlayView();
virtual void beginUpdate() override; virtual void beginUpdate() override;
virtual void update() override; virtual void update() override;
+1 -1
View File
@@ -71,7 +71,7 @@ int main() {
.offset = {0, 0}, .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(); sceneView->setFocused();
// OInspectorView inspectorView = new Editor::InspectorView(graphics, window, // OInspectorView inspectorView = new Editor::InspectorView(graphics, window,
// ViewportCreateInfo{ // ViewportCreateInfo{
+1 -1
View File
@@ -93,7 +93,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
targetDesc.format = target; targetDesc.format = target;
sessionDesc.targetCount = 1; sessionDesc.targetCount = 1;
sessionDesc.targets = &targetDesc; sessionDesc.targets = &targetDesc;
StaticArray<const char*, 5> searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/generated/"}; StaticArray<const char*, 6> searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/game", "shaders/generated/"};
sessionDesc.searchPaths = searchPaths.data(); sessionDesc.searchPaths = searchPaths.data();
sessionDesc.searchPathCount = searchPaths.size(); sessionDesc.searchPathCount = searchPaths.size();
+2 -2
View File
@@ -2,7 +2,7 @@
using namespace Seele; using namespace Seele;
GameInterface::GameInterface(std::string soPath) : lib(NULL), soPath(soPath) {} GameInterface::GameInterface(std::filesystem::path soPath) : lib(NULL), soPath(soPath) {}
GameInterface::~GameInterface() {} GameInterface::~GameInterface() {}
@@ -13,7 +13,7 @@ void GameInterface::reload() {
destroyInstance(game); destroyInstance(game);
dlclose(lib); dlclose(lib);
} }
lib = dlopen(soPath.c_str(), RTLD_NOW); lib = dlopen(soPath.string().c_str(), RTLD_NOW);
createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); createInstance = (decltype(createInstance))dlsym(lib, "createInstance");
destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance");
game = createInstance(); game = createInstance();
+3 -2
View File
@@ -1,18 +1,19 @@
#pragma once #pragma once
#include "Game.h" #include "Game.h"
#include "filesystem"
#include "dlfcn.h" #include "dlfcn.h"
namespace Seele { namespace Seele {
class GameInterface { class GameInterface {
public: public:
GameInterface(std::string soPath); GameInterface(std::filesystem::path soPath);
~GameInterface(); ~GameInterface();
Game* getGame(); Game* getGame();
void reload(); void reload();
private: private:
void* lib; void* lib;
std::string soPath; std::filesystem::path soPath;
Game* game; Game* game;
Game* (*createInstance)() = nullptr; Game* (*createInstance)() = nullptr;
void (*destroyInstance)(Game*) = nullptr; void (*destroyInstance)(Game*) = nullptr;
@@ -3,7 +3,7 @@
using namespace Seele; using namespace Seele;
GameInterface::GameInterface(std::string dllPath) : dllPath(dllPath) {} GameInterface::GameInterface(std::filesystem::path dllPath) : dllPath(dllPath) {}
GameInterface::~GameInterface() {} GameInterface::~GameInterface() {}
@@ -14,7 +14,8 @@ void GameInterface::reload() {
destroyInstance(game); destroyInstance(game);
FreeLibrary(lib); 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"); createInstance = (decltype(createInstance))GetProcAddress(lib, "createInstance");
destroyInstance = (decltype(destroyInstance))GetProcAddress(lib, "destroyInstance"); destroyInstance = (decltype(destroyInstance))GetProcAddress(lib, "destroyInstance");
game = createInstance(); game = createInstance();
+3 -2
View File
@@ -2,18 +2,19 @@
#include "Game.h" #include "Game.h"
#define NOIME #define NOIME
#include "Windows.h" #include "Windows.h"
#include <filesystem>
namespace Seele { namespace Seele {
class GameInterface { class GameInterface {
public: public:
GameInterface(std::string dllPath); GameInterface(std::filesystem::path dllPath);
~GameInterface(); ~GameInterface();
Game* getGame(); Game* getGame();
void reload(); void reload();
private: private:
HMODULE lib = NULL; HMODULE lib = NULL;
std::string dllPath; std::filesystem::path dllPath;
Game* game; Game* game;
Game* (*createInstance)() = nullptr; Game* (*createInstance)() = nullptr;
void (*destroyInstance)(Game*) = nullptr; void (*destroyInstance)(Game*) = nullptr;
+1 -1
View File
@@ -19,7 +19,7 @@
using namespace Seele; 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) { : View(graphics, window, createInfo, "Game"), graphics(graphics), scene(new Scene(graphics)), gameInterface(dllPath) {
reloadGame(); reloadGame();
renderGraph.addPass(new CachedDepthPass(graphics, scene)); renderGraph.addPass(new CachedDepthPass(graphics, scene));
+1 -1
View File
@@ -12,7 +12,7 @@
namespace Seele { namespace Seele {
class GameView : public View { class GameView : public View {
public: 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 ~GameView();
virtual void beginUpdate() override; virtual void beginUpdate() override;
virtual void update() override; virtual void update() override;