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::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() {}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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{
+1 -1
View File
@@ -93,7 +93,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
targetDesc.format = target;
sessionDesc.targetCount = 1;
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.searchPathCount = searchPaths.size();
+2 -2
View File
@@ -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();
+3 -2
View File
@@ -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;
@@ -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();
+3 -2
View File
@@ -2,18 +2,19 @@
#include "Game.h"
#define NOIME
#include "Windows.h"
#include <filesystem>
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;
+1 -1
View File
@@ -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));
+1 -1
View File
@@ -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;