optimize dx11 engine
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user