87 lines
2.2 KiB
C++
87 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <sophia/asset_registry.hpp>
|
|
#include <sophia/camera_2d.hpp>
|
|
#include <sophia/canvas.hpp>
|
|
#include <sophia/console/console_command_registry.hpp>
|
|
#include <sophia/frame_info.hpp>
|
|
#include <sophia/types.hpp>
|
|
#include <sophia/ui/debug_ui.hpp>
|
|
#include <sophia/ui/panel_registry.hpp>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#define GLM_FORCE_RADIANS
|
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
|
#include <glm/glm.hpp>
|
|
|
|
namespace sophia {
|
|
|
|
class Application {
|
|
public:
|
|
struct Config {
|
|
int width;
|
|
int height;
|
|
std::string name;
|
|
};
|
|
|
|
Application(const Application&) = delete;
|
|
Application& operator=(const Application&) = delete;
|
|
|
|
explicit Application(const Config& config);
|
|
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() {}
|
|
|
|
AssetRegistry& assets() { return this->assetRegistry; }
|
|
PanelRegistry& panels() { return this->panelRegistry; }
|
|
|
|
DebugUI& debugUI() { return this->_debugUI; }
|
|
|
|
Canvas canvas;
|
|
Camera2D camera;
|
|
std::vector<std::string> args;
|
|
|
|
ConsoleCommandRegistry consoleCommandRegistry;
|
|
|
|
void drawMesh(MeshHandle handle, const glm::mat4& transform);
|
|
|
|
private:
|
|
friend class Canvas;
|
|
|
|
void pushMesh(std::vector<CanvasVertex> vertices, std::vector<u32> indices);
|
|
void clearMeshes();
|
|
|
|
class Impl;
|
|
std::unique_ptr<Impl> impl;
|
|
|
|
AssetRegistry assetRegistry;
|
|
PanelRegistry panelRegistry;
|
|
|
|
DebugUI _debugUI;
|
|
};
|
|
|
|
} // 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; \
|
|
}
|