AronaCore/core/application/application.h

69 lines
1.9 KiB
C++

#pragma once
#include <string>
#include "SDL.h"
#include "imgui.h"
#include "slang-com-ptr.h"
#include "slang.h"
class pixel_shader_drawer;
class render_target;
class renderer;
class texture;
class application;
extern bool g_is_running;
extern bool g_exit_requested;
extern Slang::ComPtr<slang::IGlobalSession>g_slang_global_session;
extern application* g_app_instance;
struct window_params
{
std::string title;
int width;
int height;
bool fullscreen;
bool borderless;
bool resizable;
bool minimized;
bool maximized;
bool hi_dpi;
bool always_on_top;
};
class CORE_API application
{
public:
application()
{
g_app_instance = this;
}
virtual ~application() = default;
application(const application&) = delete;
application(application&&) = delete;
static application* get()
{
return g_app_instance;
}
virtual void init(window_params in_window_params, int argc, char** argv);
virtual int run();
virtual void shutdown();
virtual void draw_gui() = 0;
virtual const char* get_shader_path() = 0;
virtual void init_imgui(ImGuiContext* in_context) = 0;
std::shared_ptr<texture> load_texture(const std::string& path) const;
std::shared_ptr<texture> create_texture(const unsigned char* data, const int width, const int height) const;
std::shared_ptr<render_target> create_render_target(const int width, const int height, texture_format format) const;
std::shared_ptr<pixel_shader_drawer> create_pixel_shader_drawer() const;
virtual const char* get_entry_model() const = 0;
virtual const char* get_draw_ps_vertex_shader_entry() const = 0; // Vertex Shader used for drawing ps
renderer* get_renderer() const { return renderer_; }
SDL_Window* get_window() const { return window_; }
protected:
renderer* renderer_ = nullptr;
SDL_Window* window_ = nullptr;
std::shared_ptr<spdlog::logger> async_spdlog_;
};