diff --git a/private/sdl_gpu_test/0_triangle_with_texcoords/app.cpp b/private/sdl_gpu_test/0_triangle_with_texcoords/app.cpp index 96b8033..c6c8e99 100644 --- a/private/sdl_gpu_test/0_triangle_with_texcoords/app.cpp +++ b/private/sdl_gpu_test/0_triangle_with_texcoords/app.cpp @@ -12,7 +12,7 @@ struct Vertex glm::vec2 texCoord; }; -void TriangleWithTexcoordsApp::init(std::span args) +void TriangleWithTexcoordsApp::init(const AppInitArgs& args) { Application::init(args); @@ -88,9 +88,9 @@ void TriangleWithTexcoordsApp::init(std::span args) uploadVertexData(mVertexBuffer, std::span(vertices.begin(), vertices.end())); } -void TriangleWithTexcoordsApp::update() +void TriangleWithTexcoordsApp::update(const AppUpdateArgs& args) { - Application::update(); + Application::update(args); sdlpp::GPUCommandBuffer cmdBuffer = mDevice.acquireCommandBuffer(); Uint32 swapchainWidth = 0, swapchainHeight = 0; diff --git a/private/sdl_gpu_test/0_triangle_with_texcoords/app.hpp b/private/sdl_gpu_test/0_triangle_with_texcoords/app.hpp index e3eccf8..c952273 100644 --- a/private/sdl_gpu_test/0_triangle_with_texcoords/app.hpp +++ b/private/sdl_gpu_test/0_triangle_with_texcoords/app.hpp @@ -14,8 +14,8 @@ private: sdlpp::GPUBuffer mVertexBuffer; sdlpp::GPUGraphicsPipeline mPipeline; public: - void init(std::span args) override; - void update() override; + void init(const AppInitArgs& args) override; + void update(const AppUpdateArgs& args) override; }; } // namespace sdl_gpu_test diff --git a/private/sdl_gpu_test/application.cpp b/private/sdl_gpu_test/application.cpp index a515045..46ded9a 100644 --- a/private/sdl_gpu_test/application.cpp +++ b/private/sdl_gpu_test/application.cpp @@ -6,7 +6,7 @@ namespace sdl_gpu_test { -void Application::init(std::span args) +void Application::init(const AppInitArgs& args) { mWindow.create({ .title = "SDL_gpu Test", @@ -19,22 +19,24 @@ void Application::init(std::span args) }); mDevice.claimWindow(mWindow); - fs::path executablePath = fs::absolute(fs::path(args[0])).parent_path(); + fs::path executablePath = fs::absolute(fs::path(args.programArgs[0])).parent_path(); mFileSystem.emplaceAdapter>(executablePath.parent_path() / "assets"); } -void Application::cleanup() +void Application::cleanup(const AppCleanupArgs&) { } -void Application::update() +void Application::update(const AppUpdateArgs&) { } void Application::run(std::span args) { - init(args); + init({ + .programArgs = args + }); while (mRunning) { std::optional event; @@ -45,9 +47,9 @@ void Application::run(std::span args) [](const auto&) {} // default handler }, *event); } - update(); + update({}); } - cleanup(); + cleanup({}); } diff --git a/private/sdl_gpu_test/application.hpp b/private/sdl_gpu_test/application.hpp index 988142b..883e953 100644 --- a/private/sdl_gpu_test/application.hpp +++ b/private/sdl_gpu_test/application.hpp @@ -14,6 +14,21 @@ namespace sdl_gpu_test { +struct AppInitArgs +{ + std::span programArgs; +}; + +struct AppCleanupArgs +{ + +}; + +struct AppUpdateArgs +{ + +}; + class Application { protected: @@ -24,9 +39,9 @@ protected: public: virtual ~Application() noexcept = default; - virtual void init(std::span args); - virtual void cleanup(); - virtual void update(); + virtual void init(const AppInitArgs& args); + virtual void cleanup(const AppCleanupArgs& args); + virtual void update(const AppUpdateArgs& args); void run(std::span args);