Added argument structs to make extending arguments easier in the future.
This commit is contained in:
parent
4768f0a6a0
commit
853e55322c
@ -12,7 +12,7 @@ struct Vertex
|
||||
glm::vec2 texCoord;
|
||||
};
|
||||
|
||||
void TriangleWithTexcoordsApp::init(std::span<const char*> args)
|
||||
void TriangleWithTexcoordsApp::init(const AppInitArgs& args)
|
||||
{
|
||||
Application::init(args);
|
||||
|
||||
@ -88,9 +88,9 @@ void TriangleWithTexcoordsApp::init(std::span<const char*> 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;
|
||||
|
@ -14,8 +14,8 @@ private:
|
||||
sdlpp::GPUBuffer mVertexBuffer;
|
||||
sdlpp::GPUGraphicsPipeline mPipeline;
|
||||
public:
|
||||
void init(std::span<const char*> args) override;
|
||||
void update() override;
|
||||
void init(const AppInitArgs& args) override;
|
||||
void update(const AppUpdateArgs& args) override;
|
||||
};
|
||||
} // namespace sdl_gpu_test
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace sdl_gpu_test
|
||||
{
|
||||
void Application::init(std::span<const char*> args)
|
||||
void Application::init(const AppInitArgs& args)
|
||||
{
|
||||
mWindow.create({
|
||||
.title = "SDL_gpu Test",
|
||||
@ -19,22 +19,24 @@ void Application::init(std::span<const char*> 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<mijin::RelativeFileSystemAdapter<mijin::OSFileSystemAdapter>>(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<const char*> args)
|
||||
{
|
||||
init(args);
|
||||
init({
|
||||
.programArgs = args
|
||||
});
|
||||
while (mRunning)
|
||||
{
|
||||
std::optional<sdlpp::sdl_event_t> event;
|
||||
@ -45,9 +47,9 @@ void Application::run(std::span<const char*> args)
|
||||
[](const auto&) {} // default handler
|
||||
}, *event);
|
||||
}
|
||||
update();
|
||||
update({});
|
||||
}
|
||||
cleanup();
|
||||
cleanup({});
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,21 @@
|
||||
|
||||
namespace sdl_gpu_test
|
||||
{
|
||||
struct AppInitArgs
|
||||
{
|
||||
std::span<const char*> programArgs;
|
||||
};
|
||||
|
||||
struct AppCleanupArgs
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
struct AppUpdateArgs
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class Application
|
||||
{
|
||||
protected:
|
||||
@ -24,9 +39,9 @@ protected:
|
||||
public:
|
||||
virtual ~Application() noexcept = default;
|
||||
|
||||
virtual void init(std::span<const char*> 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<const char*> args);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user