1
0

optimize dx11 engine

This commit is contained in:
2026-01-05 16:51:58 +08:00
parent 7110becf66
commit 52916db08f
10 changed files with 152 additions and 117 deletions

View File

@@ -1,5 +1,4 @@
#include "dll_loader.hpp"
#include <basalt_char.hpp>
#include <stdexcept>
#include <filesystem>
@@ -9,16 +8,18 @@
#include <unistd.h>
#endif
using ::Basalt::Shared::Char::BSStringView;
namespace Basalt::Presenter {
static std::filesystem::path get_executable() {
#if defined(BASALT_OS_WINDOWS)
wchar_t buffer[MAX_PATH];
DWORD hr = GetModuleFileNameW(NULL, buffer, MAX_PATH);
if (hr == 0) {
throw std::runtime_error("Failed to get executable path");
} else {
if (hr > 0 && hr < MAX_PATH) {
return std::filesystem::path(buffer);
} else {
throw std::runtime_error("Failed to get executable path");
}
#else
char buffer[PATH_MAX];
@@ -32,7 +33,7 @@ namespace Basalt::Presenter {
#endif
}
DllLoader::DllLoader(DllKind kind, const std::basic_string_view<BSCHAR> filename) {
DllLoader::DllLoader(DllKind kind, const BSStringView& filename) {
// Build DLL full path
auto dll_path = get_executable().parent_path();
dll_path /= BSTEXT("plugin");

View File

@@ -25,7 +25,7 @@ namespace Basalt::Presenter {
#endif
public:
DllLoader(DllKind kind, const std::basic_string_view<BSCHAR> filename);
DllLoader(DllKind kind, const Shared::Char::BSStringView& filename);
~DllLoader();
private:

View File

@@ -8,12 +8,14 @@ namespace Shared = ::Basalt::Shared;
int main(int argc, char* argv[]) {
auto engine_dll = Presenter::DllLoader(Presenter::DllKind::Engine, BSTEXT("BasaltDirectX11Engine"));
auto* engine = engine_dll.CreateInstance<Shared::Engine::IEngine>();
Shared::Engine::EngineConfig engine_config{.is_headless = false, .title = BSTEXT("Fuck You"), .width = 800, .height = 600};
Shared::Engine::EngineConfig engine_config{.headless = false, .title = BSTEXT("Fuck You"), .width = 800, .height = 600};
engine->Startup(std::move(engine_config));
while (true) {
engine->Tick();
if (engine->Tick()) break;
}
engine->Shutdown();
engine_dll.DestroyInstance(engine);
}