From 813bee6047759fd38aeaf59e14d9eeea782c00c0 Mon Sep 17 00:00:00 2001 From: offtkp Date: Thu, 21 Mar 2024 18:28:51 +0200 Subject: [PATCH] Even more stuff --- CMakeLists.txt | 3 + core | 2 +- include/hydra/core/wrapper.hxx | 37 ++++++++++ include/hydra/dynlib/dynlib.hxx | 90 +++++++++++++++++++++++ include/hydra/sdl3/window.hxx | 31 ++++---- src/app.cxx | 2 +- src/hydra/core/imports.cxx | 91 +++++++++++++++++++++++ src/hydra/core/wrapper.cxx | 78 ++++++++++++++++++++ src/hydra/qt/main_window.cxx | 24 ++++--- src/hydra/sdl3/common.cxx | 93 +++++++++++++++++++++++- src/hydra/sdl3/opengl.cxx | 124 ++++++++++++++++++++++++++++++++ src/hydra/sdl3/vulkan.cxx | 20 ++---- 12 files changed, 554 insertions(+), 41 deletions(-) create mode 100644 include/hydra/core/wrapper.hxx create mode 100644 include/hydra/dynlib/dynlib.hxx create mode 100644 src/hydra/core/imports.cxx create mode 100644 src/hydra/core/wrapper.cxx create mode 100644 src/hydra/sdl3/opengl.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d6c2b94..363aefc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,7 @@ set(HYDRA_QT_FILES ) set(HYDRA_IMGUI_FILES + src/hydra/sdl3/opengl.cxx src/hydra/sdl3/vulkan.cxx src/hydra/sdl3/common.cxx vendored/imgui/backends/imgui_impl_sdl3.cpp @@ -189,6 +190,8 @@ set(HYDRA_IMGUI_FILES set(HYDRA_COMMON_FILES src/main.cxx + src/hydra/core/wrapper.cxx + src/hydra/core/imports.cxx src/hydra/common/version.cxx src/hydra/common/settings.cxx vendored/argparse/argparse.c diff --git a/core b/core index ec880863..c78e816d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ec880863d67e8e626b7a3b39ed03de1bca5689e0 +Subproject commit c78e816d22d001c2789a972b18df061e4e31e280 diff --git a/include/hydra/core/wrapper.hxx b/include/hydra/core/wrapper.hxx new file mode 100644 index 00000000..027dfa1e --- /dev/null +++ b/include/hydra/core/wrapper.hxx @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +namespace hydra::core +{ + struct Wrapper final + { + private: + using hcGetCoreInfoPtr = void (*)(HcCoreInfo* coreInfo); + using hcCreatePtr = HcResult (*)(HcEnvironmentInfo* environmentInfo); + using hcDestroyPtr = HcResult (*)(const HcDestroyInfo* destroyInfo); + using hcResetPtr = HcResult (*)(const HcResetInfo* resetInfo); + using hcSetRunStatePtr = HcResult (*)(const HcRunStateInfo* runInfo); + using hcLoadContentPtr = HcResult (*)(const HcContentLoadInfo* info); + using hcGetErrorPtr = const char* (*)(); + + public: + Wrapper(const std::filesystem::path& path); + ~Wrapper(); + + bool okay() const; + + hcGetCoreInfoPtr hcGetCoreInfo; + hcCreatePtr hcCreate; + hcDestroyPtr hcDestroy; + hcResetPtr hcReset; + hcSetRunStatePtr hcSetRunState; + hcLoadContentPtr hcLoadContent; + hcGetErrorPtr hcGetError; + + private: + hydra::dynlib::handle_t handle; + }; +} // namespace hydra::core \ No newline at end of file diff --git a/include/hydra/dynlib/dynlib.hxx b/include/hydra/dynlib/dynlib.hxx new file mode 100644 index 00000000..0c495902 --- /dev/null +++ b/include/hydra/dynlib/dynlib.hxx @@ -0,0 +1,90 @@ +#if defined(HYDRA_LIBDL) +#include +#elif defined(HYDRA_WINDOWS) +#include +#endif + +#include +#include +#include + +namespace hydra::dynlib +{ + typedef void* handle_t; + + inline handle_t open(const std::filesystem::path& path) + { +#if defined(HYDRA_LIBDL) + return dlopen(path.string().c_str(), RTLD_LAZY); +#elif defined(HYDRA_WINDOWS) + std::string spath = path.string(); + std::wstring wpath = std::wstring(spath.c_str(), spath.c_str() + spath.size()); + printf("Trying to convert string to wstring to load library with loadlibraryw, this is " + "untested\n"); + return (void*)LoadLibraryW(wpath.c_str()); +#else +#pragma message("dynlib_open not implemented for this platform") +#error dynlib_open not implemented for this platform + return nullptr; +#endif + } + + inline void* symbol(handle_t handle, const char* name) + { +#if defined(HYDRA_LIBDL) + return dlsym(handle, name); +#elif defined(HYDRA_WINDOWS) + return (void*)GetProcAddress((HMODULE)handle, name); +#else +#pragma message("dynlib_get_symbol not implemented for this platform") +#error dynlib_get_symbol not implemented for this platform + return nullptr; +#endif + } + + inline void close(handle_t handle) + { +#if defined(HYDRA_LIBDL) + dlclose(handle); +#elif defined(HYDRA_WINDOWS) + FreeLibrary((HMODULE)handle); +#else +#pragma message("dynlib_close not implemented for this platform") +#error dynlib_close not implemented for this platform +#endif + } + + inline std::string_view extension() + { +#if defined(HYDRA_LINUX) || defined(HYDRA_ANDROID) || defined(HYDRA_FREEBSD) + return ".so"; +#elif defined(HYDRA_WEB) + return ".wasm"; +#elif defined(HYDRA_MACOS) + return ".dylib"; +#elif defined(HYDRA_WINDOWS) + return ".dll"; +#else +#pragma message("dynlib_get_extension not implemented for this platform") +#error dynlib_get_extension not implemented for this platform + return ""; +#endif + } + + inline std::string error() + { +#if defined(HYDRA_LIBDL) + return dlerror(); +#elif defined(HYDRA_WINDOWS) + // DWORD error = GetLastError(); + // LPVOID buffer; + // FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, + // 0, + // (LPWSTR)&buffer, 0, NULL); + // std::string ret = (char*)buffer; + // LocalFree(buffer); + // return ret; + return ""; // TODO: fix +#endif + } +} // namespace hydra::dynlib \ No newline at end of file diff --git a/include/hydra/sdl3/window.hxx b/include/hydra/sdl3/window.hxx index 89e5b4d1..a3ee70f6 100644 --- a/include/hydra/sdl3/window.hxx +++ b/include/hydra/sdl3/window.hxx @@ -1,5 +1,6 @@ #pragma once +#include #include namespace hydra @@ -8,35 +9,35 @@ namespace hydra { struct Context { + HcRendererType rendererType; SDL_Window* window; void* inner; }; + Context* init(const HcEnvironmentInfo* createInfo); + void present(Context* context); + void shutdown(Context* context); + namespace Vk { - Context* init(); + Context* init(const HcEnvironmentInfo* createInfo); + void present(Context* context); void shutdown(Context* context); - void startFrame(Context* context); - void endFrame(Context* context); } // namespace Vk namespace Gl { - Context* init(); + Context* init(const HcEnvironmentInfo* createInfo); + void present(Context* context); void shutdown(Context* context); - void startFrame(Context* context); - void endFrame(Context* context); } // namespace Gl - namespace Common + enum class EventResult { - enum class EventResult - { - Continue, - Quit - }; + Continue, + Quit + }; - EventResult poll(Context* context); - } // namespace Common - } // namespace SDL3 + EventResult poll(Context* context); + } // namespace SDL3 } // namespace hydra \ No newline at end of file diff --git a/src/app.cxx b/src/app.cxx index ea791e8e..dacf723e 100644 --- a/src/app.cxx +++ b/src/app.cxx @@ -188,7 +188,7 @@ int imgui_main(int argc, char* argv[]) while (result != hydra::SDL3::EventResult::Quit) #endif { - result = hydra::SDL3::Common::Poll(window); + result = hydra::SDL3::Poll(window); hydra::SDL3::Renderer::StartFrame(ctx); ImGuiIO& io = ImGui::GetIO(); diff --git a/src/hydra/core/imports.cxx b/src/hydra/core/imports.cxx new file mode 100644 index 00000000..c13407c5 --- /dev/null +++ b/src/hydra/core/imports.cxx @@ -0,0 +1,91 @@ +// Define the hydra core API imports + +#include "compatibility.hxx" +#include +#include + +extern "C" { + +void hydra_hcGetHostInfo(HcHostInfo* hostInfo) +{ + printf("STUB: hcGetHostInfo\n"); +} + +HcResult hydra_hcGetInputsSync(const HcInputRequest* const* requests, int requestCount, + const int64_t* const* values) +{ + printf("STUB: hcGetInputsSync\n"); + return HC_SUCCESS; +} + +HcResult hydra_hcReconfigureEnvironment(const HcEnvironmentInfo* environmentInfo) +{ + printf("STUB: hcReconfigureEnvironment\n"); + return HC_SUCCESS; +} + +HcResult hydra_hcPushSamples(const HcAudioData* audioData) +{ + printf("STUB: hcPushSamples\n"); + return HC_SUCCESS; +} + +HcResult hydra_hcSwPushVideoFrame(const HcImageData* image) +{ + printf("STUB: hcSwPushVideoFrame\n"); + return HC_SUCCESS; +} + +HcResult hydra_hcGlMakeCurrent() +{ + printf("STUB: hcGlMakeCurrent\n"); + return HC_SUCCESS; +} + +HcResult hydra_hcGlSwapBuffers() +{ + printf("STUB: hcGlSwapBuffers\n"); + return HC_SUCCESS; +} + +void* hydra_hcGlGetProcAddress(const char* name) +{ + printf("STUB: hcGlGetProcAddress\n"); + return nullptr; +} + +HcResult hydra_hcSetCallbacks(const HcCallbacks* callbacks) +{ + printf("STUB: hcSetCallbacks\n"); + return HC_SUCCESS; +} + +void* hydra_GetAddress(const char* name) +{ + uint32_t hash = hydra::str_hash(name); + + switch (hash) + { + case hydra::str_hash("hcGetHostInfo"): + return (void*)hydra_hcGetHostInfo; + case hydra::str_hash("hcGetInputsSync"): + return (void*)hydra_hcGetInputsSync; + case hydra::str_hash("hcReconfigureEnvironment"): + return (void*)hydra_hcReconfigureEnvironment; + case hydra::str_hash("hcPushSamples"): + return (void*)hydra_hcPushSamples; + case hydra::str_hash("hcSwPushVideoFrame"): + return (void*)hydra_hcSwPushVideoFrame; + case hydra::str_hash("hcGlMakeCurrent"): + return (void*)hydra_hcGlMakeCurrent; + case hydra::str_hash("hcGlSwapBuffers"): + return (void*)hydra_hcGlSwapBuffers; + case hydra::str_hash("hcGlGetProcAddress"): + return (void*)hydra_hcGlGetProcAddress; + case hydra::str_hash("hcSetCallbacks"): + return (void*)hydra_hcSetCallbacks; + default: + return nullptr; + } +} +} \ No newline at end of file diff --git a/src/hydra/core/wrapper.cxx b/src/hydra/core/wrapper.cxx new file mode 100644 index 00000000..555a5926 --- /dev/null +++ b/src/hydra/core/wrapper.cxx @@ -0,0 +1,78 @@ +#include +#include +#include + +extern "C" void* hydra_GetAddress(const char* name); + +namespace hydra::core +{ + + Wrapper::Wrapper(const std::filesystem::path& path) : handle(nullptr) + { + if (!std::filesystem::exists(path) || !std::filesystem::is_regular_file(path)) + { + hydra::panic("Core not found: {}", path.string()); + return; + } + + if (path.extension() != hydra::dynlib::extension()) + { + hydra::panic("Not a dynamic library: {}", path.string()); + return; + } + + handle = hydra::dynlib::open(path); + if (!handle) + { + hydra::panic("Failed to load core: {}\nError: {}", path.string(), + hydra::dynlib::error()); + return; + } + + hcGetCoreInfo = (hcGetCoreInfoPtr)hydra::dynlib::symbol(handle, "hcGetCoreInfo"); + hcCreate = (hcCreatePtr)hydra::dynlib::symbol(handle, "hcCreate"); + hcDestroy = (hcDestroyPtr)hydra::dynlib::symbol(handle, "hcDestroy"); + hcReset = (hcResetPtr)hydra::dynlib::symbol(handle, "hcReset"); + hcSetRunState = (hcSetRunStatePtr)hydra::dynlib::symbol(handle, "hcSetRunState"); + hcLoadContent = (hcLoadContentPtr)hydra::dynlib::symbol(handle, "hcLoadContent"); + hcGetError = (hcGetErrorPtr)hydra::dynlib::symbol(handle, "hcGetError"); + + if (!hcGetCoreInfo || !hcCreate || !hcDestroy || !hcReset || !hcSetRunState || + !hcLoadContent || !hcGetError) + { + hydra::log("Failed to load core functions: {}\nError: {}", path.string(), + hydra::dynlib::error()); + hydra::dynlib::close(handle); + handle = nullptr; + } + + void* (*hcInternalLoadFunctions)(void* (*loadFunctionPtr)(const char*)) = + (decltype(hcInternalLoadFunctions))hydra::dynlib::symbol(handle, + "hcInternalLoadFunctions"); + if (hcInternalLoadFunctions) + { + hcInternalLoadFunctions(hydra_GetAddress); + } + else + { + hydra::log("Failed to load internal functions: {}\nError: {}", path.string(), + hydra::dynlib::error()); + hydra::dynlib::close(handle); + handle = nullptr; + } + } + + Wrapper::~Wrapper() + { + if (handle) + { + hydra::dynlib::close(handle); + } + } + + bool Wrapper::okay() const + { + return handle != nullptr; + } + +} // namespace hydra::core \ No newline at end of file diff --git a/src/hydra/qt/main_window.cxx b/src/hydra/qt/main_window.cxx index 7b20f4ab..0fe9ceec 100644 --- a/src/hydra/qt/main_window.cxx +++ b/src/hydra/qt/main_window.cxx @@ -1,3 +1,5 @@ +#include "hydra/core.h" +#include "hydra/core/wrapper.hxx" #include #include #include @@ -38,16 +40,22 @@ namespace hydra::qt resize(settings::Config::get().windowWidth, settings::Config::get().windowHeight); std::thread t([this] { - SDL3::Context* ctx = hydra::SDL3::Vk::init(); - while (1) + printf("TODO: check if self driven\n"); + hydra::core::Wrapper wrapper( + "/home/offtkp/other/hydra_examples/build/libhydra_triangle_selfdriven_gl.so"); + HcVideoInfo videoInfo{}; + HcAudioInfo audioInfo{}; + HcEnvironmentInfo environmentInfo{}; + environmentInfo.video = &videoInfo; + environmentInfo.audio = &audioInfo; + wrapper.hcCreate(&environmentInfo); + SDL3::Context* ctx = hydra::SDL3::init(&environmentInfo); + SDL3::EventResult result = SDL3::EventResult::Continue; + while (result != SDL3::EventResult::Quit) { - hydra::SDL3::Common::poll(ctx); - hydra::SDL3::Vk::startFrame(ctx); - ImGui::Begin("Hello, world!"); - ImGui::Button("Hello, world!"); - ImGui::End(); - hydra::SDL3::Vk::endFrame(ctx); + result = hydra::SDL3::poll(ctx); } + hydra::SDL3::shutdown(ctx); }); t.detach(); } diff --git a/src/hydra/sdl3/common.cxx b/src/hydra/sdl3/common.cxx index fa11b1da..8fe647a5 100644 --- a/src/hydra/sdl3/common.cxx +++ b/src/hydra/sdl3/common.cxx @@ -1,10 +1,99 @@ #include "backends/imgui_impl_sdl3.h" #include +#include #include #include -namespace hydra::SDL3::Common +namespace hydra::SDL3 { + Context* init(const HcEnvironmentInfo* environmentInfo) + { + if (!environmentInfo || !environmentInfo->video) + { + hydra::panic("Invalid environment info"); + return nullptr; + } + + if (SDL_Init(SDL_INIT_VIDEO) != 0) + { + hydra::panic("SDL_Init: {}", SDL_GetError()); + } + + SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); + + switch (environmentInfo->video->rendererType) + { + case HC_RENDERER_TYPE_OPENGL: + { + return Gl::init(environmentInfo); + } + case HC_RENDERER_TYPE_VULKAN: + { + return Vk::init(environmentInfo); + } + default: + { + hydra::panic("Unknown renderer type: {}", + (int)environmentInfo->video->rendererType); + return nullptr; + } + } + } + + void present(Context* context) + { + if (!context || !context->window) + { + hydra::panic("Invalid context"); + return; + } + + switch (context->rendererType) + { + case HC_RENDERER_TYPE_OPENGL: + { + Gl::present(context); + break; + } + case HC_RENDERER_TYPE_VULKAN: + { + Vk::present(context); + break; + } + default: + { + hydra::panic("Unknown renderer type: {}", (int)context->rendererType); + } + } + } + + void shutdown(Context* context) + { + if (!context || !context->window) + { + hydra::panic("Invalid context"); + return; + } + + switch (context->rendererType) + { + case HC_RENDERER_TYPE_OPENGL: + { + Gl::shutdown(context); + break; + } + case HC_RENDERER_TYPE_VULKAN: + { + Vk::shutdown(context); + break; + } + default: + { + hydra::panic("Unknown renderer type: {}", (int)context->rendererType); + } + } + } + EventResult poll(Context* ctx) { EventResult result = EventResult::Continue; @@ -62,4 +151,4 @@ namespace hydra::SDL3::Common return result; } -} // namespace hydra::SDL3::Common \ No newline at end of file +} // namespace hydra::SDL3 \ No newline at end of file diff --git a/src/hydra/sdl3/opengl.cxx b/src/hydra/sdl3/opengl.cxx new file mode 100644 index 00000000..12364c10 --- /dev/null +++ b/src/hydra/sdl3/opengl.cxx @@ -0,0 +1,124 @@ +#include "backends/imgui_impl_sdl3.h" +#include "hydra/core.h" +#include "SDL_video.h" + +#include +#include + +#include +#include +#include + +namespace hydra::SDL3::Gl +{ + + Context* init(const HcEnvironmentInfo* environmentInfo) + { + if (!environmentInfo || !environmentInfo->video) + { + hydra::panic("Invalid environment info"); + return nullptr; + } + + if (environmentInfo->video->rendererType != HC_RENDERER_TYPE_OPENGL) + { + hydra::panic("Expected OpenGL renderer type"); + return nullptr; + } + + int major = 0, minor = 0; + switch (environmentInfo->video->rendererVersion) + { + case HC_OPENGL_VERSION_1_0: + case HC_OPENGL_VERSION_1_1: + case HC_OPENGL_VERSION_1_2: + case HC_OPENGL_VERSION_1_3: + case HC_OPENGL_VERSION_1_4: + case HC_OPENGL_VERSION_1_5: + case HC_OPENGL_VERSION_2_0: + case HC_OPENGL_VERSION_2_1: + case HC_OPENGL_VERSION_3_0: + case HC_OPENGL_VERSION_3_1: + case HC_OPENGL_VERSION_3_2: + case HC_OPENGL_VERSION_3_3: + case HC_OPENGL_VERSION_4_0: + case HC_OPENGL_VERSION_4_1: + case HC_OPENGL_VERSION_4_2: + case HC_OPENGL_VERSION_4_3: + case HC_OPENGL_VERSION_4_4: + case HC_OPENGL_VERSION_4_5: + case HC_OPENGL_VERSION_4_6: + major = (int)environmentInfo->video->rendererVersion >> 16; + minor = (int)environmentInfo->video->rendererVersion & 0xFFFF; + break; + default: + hydra::panic("Unknown OpenGL version: {}", + (int)environmentInfo->video->rendererVersion); + return nullptr; + } + + switch (environmentInfo->video->format) + { + case HC_PIXEL_FORMAT_ABGR32: + case HC_PIXEL_FORMAT_ARGB32: + case HC_PIXEL_FORMAT_BGRA32: + case HC_PIXEL_FORMAT_RGBA32: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + break; + case HC_PIXEL_FORMAT_RGB24: + case HC_PIXEL_FORMAT_BGR24: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); + break; + case HC_PIXEL_FORMAT_RGB565: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); + break; + case HC_PIXEL_FORMAT_RGBA5551: + case HC_PIXEL_FORMAT_ARGB1555: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1); + break; + default: + hydra::panic("Unknown pixel format: {}", (int)environmentInfo->video->format); + return nullptr; + } + + Context* ctx = new Context(); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + int width = environmentInfo->video->width; + int height = environmentInfo->video->height; + + uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY; + ctx->window = SDL_CreateWindow(hydra::common::version().c_str(), width, height, flags); + + SDL_SetWindowPosition(ctx->window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + + return ctx; + } + + void present(Context* context) + { + printf("TODO: present"); + } + + void shutdown(Context* context) + { + printf("TODO: shutdown\n"); + } + +} // namespace hydra::SDL3::Gl \ No newline at end of file diff --git a/src/hydra/sdl3/vulkan.cxx b/src/hydra/sdl3/vulkan.cxx index 0571017b..cf06b38c 100644 --- a/src/hydra/sdl3/vulkan.cxx +++ b/src/hydra/sdl3/vulkan.cxx @@ -1,5 +1,7 @@ #include "backends/imgui_impl_sdl3.h" #include "backends/imgui_impl_vulkan.h" +#include "hydra/common/version.hxx" +#include "hydra/core.h" #include #include #include @@ -412,19 +414,14 @@ static void framePresent(hydra::SDL3::Context* context, ImGui_ImplVulkanH_Window namespace hydra::SDL3::Vk { - Context* init() + Context* init(const HcEnvironmentInfo* info) { Context* context = new Context(); InnerContext* ctx = new InnerContext(); context->inner = ctx; - if (SDL_Init(SDL_INIT_VIDEO) != 0) - { - hydra::panic("SDL_Init: {}", SDL_GetError()); - } - uint32_t flags = SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY; - context->window = SDL_CreateWindow("hydra", 1270, 720, flags); + context->window = SDL_CreateWindow(hydra::common::version().c_str(), 1280, 720, flags); if (!context->window) { @@ -485,7 +482,7 @@ namespace hydra::SDL3::Vk return context; } - void Shutdown(Context* context) + void shutdown(Context* context) { InnerContext* ctx = (InnerContext*)context->inner; VkResult result = vkDeviceWaitIdle(ctx->device); @@ -519,7 +516,7 @@ namespace hydra::SDL3::Vk delete context; } - void startFrame(Context* context) + void present(Context* context) { InnerContext* ctx = (InnerContext*)context->inner; // Resize swap chain? @@ -541,11 +538,6 @@ namespace hydra::SDL3::Vk ImGui_ImplVulkan_NewFrame(); ImGui_ImplSDL3_NewFrame(); ImGui::NewFrame(); - } - - void endFrame(Context* context) - { - InnerContext* ctx = (InnerContext*)context->inner; ImGui::Render(); ImDrawData* draw_data = ImGui::GetDrawData(); const bool is_minimized =