27 lines
1.2 KiB
C++
27 lines
1.2 KiB
C++
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
/// @file Application.hpp
|
|
/// For complete documentation, see src/Application.cpp
|
|
namespace hdk::sdl {
|
|
/** SDL Requires this interface to be implemented by the application class. */
|
|
class AppInterface {
|
|
public:
|
|
virtual SDL_AppResult Event(SDL_Event* event) = 0;
|
|
virtual SDL_AppResult Init(int argc, char* argv[]) = 0;
|
|
virtual SDL_AppResult Iterate() = 0;
|
|
virtual void Quit(SDL_AppResult code) = 0;
|
|
};
|
|
/** I'm calling it a public application because the AppStatus member is publicly accessible and so can be
|
|
* modified directly by the rest of application logic that has access to this application instance via this subclass.
|
|
*/
|
|
class PublicApp : public AppInterface {
|
|
public:
|
|
SDL_AppResult AppStatus { SDL_APP_CONTINUE };
|
|
virtual SDL_AppResult Event(SDL_Event* event) override { return AppStatus; }
|
|
virtual SDL_AppResult Init(int argc, char* argv[]) override { return AppStatus; }
|
|
virtual SDL_AppResult Iterate() override { return AppStatus; }
|
|
virtual void Quit(SDL_AppResult code) override {
|
|
// Default quit behavior is to do nothing, allowing the app to control its own lifetime.
|
|
}
|
|
};
|
|
} // namespace hdk::sdl
|