Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/application/StarApplication.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/application/StarApplication.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/application/StarApplication.hpp')
-rw-r--r--source/application/StarApplication.hpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/source/application/StarApplication.hpp b/source/application/StarApplication.hpp
new file mode 100644
index 0000000..9e10f58
--- /dev/null
+++ b/source/application/StarApplication.hpp
@@ -0,0 +1,76 @@
+#ifndef STAR_APPLICATION_HPP
+#define STAR_APPLICATION_HPP
+
+#include "StarInputEvent.hpp"
+
+namespace Star {
+
+STAR_CLASS(ApplicationController);
+STAR_CLASS(Renderer);
+STAR_CLASS(Application);
+
+STAR_EXCEPTION(ApplicationException, StarException);
+
+enum class WindowMode {
+ Normal,
+ Maximized,
+ Fullscreen,
+ Borderless
+};
+
+class Application {
+public:
+ virtual ~Application() = default;
+
+ // Called once on application startup, before any other methods.
+ virtual void startup(StringList const& cmdLineArgs);
+
+ // Called on application initialization, before rendering initialization. If
+ // overriden, must call base class instance.
+ virtual void applicationInit(ApplicationControllerPtr appController);
+
+ // Called immediately after application initialization on startup, and then
+ // also whenever the renderer invalidated and recreated. If overridden, must
+ // call base class instance.
+ virtual void renderInit(RendererPtr renderer);
+
+ // Called when the window mode or size is changed.
+ virtual void windowChanged(WindowMode windowMode, Vec2U screenSize);
+
+ // Called before update, once for every pending event.
+ virtual void processInput(InputEvent const& event);
+
+ // Will be called at updateRate hz, or as close as possible.
+ virtual void update();
+
+ // Will be called at updateRate hz, or more or less depending on settings and
+ // performance. update() is always prioritized over render().
+ virtual void render();
+
+ // Will be called *from a different thread* to retrieve audio data (if audio
+ // is playing). Default implementation simply fills the buffer with silence.
+ virtual void getAudioData(int16_t* sampleData, size_t frameCount);
+
+ // Will be called once on application shutdown, including when shutting down
+ // due to an Application exception.
+ virtual void shutdown();
+
+ ApplicationControllerPtr const& appController() const;
+ RendererPtr const& renderer() const;
+
+private:
+ ApplicationControllerPtr m_appController;
+ RendererPtr m_renderer;
+};
+
+inline ApplicationControllerPtr const& Application::appController() const {
+ return m_appController;
+}
+
+inline RendererPtr const& Application::renderer() const {
+ return m_renderer;
+}
+
+}
+
+#endif