Big application changes
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sophia/camera_2d.hpp>
|
||||
#include <sophia/canvas.hpp>
|
||||
#include <sophia/frame_info.hpp>
|
||||
#include <sophia/types.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace sophia {
|
||||
|
||||
@@ -11,20 +18,47 @@ class Application {
|
||||
int width;
|
||||
int height;
|
||||
std::string name;
|
||||
bool headless = false;
|
||||
};
|
||||
|
||||
Application(const Application&) = delete;
|
||||
Application& operator=(const Application&) = delete;
|
||||
|
||||
Application(const Config& config);
|
||||
~Application();
|
||||
virtual ~Application();
|
||||
|
||||
void run();
|
||||
|
||||
static void setCommandLineArgs(int argc, const char* const* argv);
|
||||
|
||||
protected:
|
||||
virtual void onCreate() {}
|
||||
virtual void onUpdate(const FrameInfo& frameInfo) { (void)frameInfo; }
|
||||
virtual void onRender() {}
|
||||
virtual void onDestroy() {}
|
||||
|
||||
Canvas canvas;
|
||||
Camera2D camera;
|
||||
std::vector<std::string> args;
|
||||
|
||||
private:
|
||||
friend class Canvas;
|
||||
|
||||
void pushModel(std::vector<CanvasVertex> vertices, std::vector<u32> indices);
|
||||
void clearModels();
|
||||
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
|
||||
#define SOPHIA_MAIN(AppType) \
|
||||
int main(int argc, const char** argv) { \
|
||||
std::cout << __FILE__ << "::" << __LINE__ << '\n'; \
|
||||
\
|
||||
sophia::Application::setCommandLineArgs(argc, argv); \
|
||||
AppType app; \
|
||||
app.run(); \
|
||||
\
|
||||
return EXIT_SUCCESS; \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user