2020-08-26 15:38:01 +08:00
|
|
|
#pragma once
|
2021-01-01 05:43:23 +08:00
|
|
|
#include <memory>
|
2021-02-22 10:43:42 +08:00
|
|
|
#include <functional>
|
2021-03-21 08:33:04 +08:00
|
|
|
#include <blah/core/common.h>
|
2020-08-26 15:38:01 +08:00
|
|
|
|
|
|
|
namespace Blah
|
|
|
|
{
|
2021-02-22 10:43:42 +08:00
|
|
|
using AppEventFn = std::function<void()>;
|
|
|
|
using AppLogFn = std::function<void(const char* message, Log::Category category)>;
|
|
|
|
|
2020-08-26 15:38:01 +08:00
|
|
|
struct Config
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int max_updates;
|
|
|
|
int target_framerate;
|
|
|
|
|
2021-02-22 10:43:42 +08:00
|
|
|
AppEventFn on_startup;
|
|
|
|
AppEventFn on_shutdown;
|
|
|
|
AppEventFn on_update;
|
|
|
|
AppEventFn on_render;
|
|
|
|
AppEventFn on_exit_request;
|
|
|
|
AppLogFn on_log;
|
2020-08-26 15:38:01 +08:00
|
|
|
|
|
|
|
Config();
|
|
|
|
};
|
|
|
|
|
2020-12-27 06:44:48 +08:00
|
|
|
enum class Renderer
|
|
|
|
{
|
|
|
|
None = -1,
|
|
|
|
OpenGL,
|
|
|
|
D3D11,
|
|
|
|
Metal,
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RendererFeatures
|
|
|
|
{
|
|
|
|
bool instancing = false;
|
|
|
|
bool origin_bottom_left = false;
|
|
|
|
int max_texture_size = 0;
|
|
|
|
};
|
|
|
|
|
2021-01-01 05:43:23 +08:00
|
|
|
class FrameBuffer;
|
|
|
|
using FrameBufferRef = std::shared_ptr<FrameBuffer>;
|
|
|
|
|
2020-08-26 15:38:01 +08:00
|
|
|
namespace App
|
|
|
|
{
|
|
|
|
// Runs the application
|
|
|
|
bool run(const Config* config);
|
|
|
|
|
|
|
|
// Returns whether the application is running
|
|
|
|
bool is_running();
|
|
|
|
|
|
|
|
// Exits the application
|
|
|
|
void exit();
|
|
|
|
|
|
|
|
// Gets the config data used to run the application
|
|
|
|
const Config* config();
|
|
|
|
|
|
|
|
// Gets the working path
|
|
|
|
const char* path();
|
|
|
|
|
|
|
|
// Gets the user path
|
|
|
|
const char* user_path();
|
|
|
|
|
|
|
|
// Gets the width of the window
|
|
|
|
int width();
|
|
|
|
|
|
|
|
// Gets the height of the window
|
|
|
|
int height();
|
|
|
|
|
|
|
|
// Gets the drawable width of the window
|
|
|
|
int draw_width();
|
|
|
|
|
|
|
|
// Gets the drawable height of the window
|
|
|
|
int draw_height();
|
|
|
|
|
|
|
|
// Gets the content scale based on the OS
|
|
|
|
float content_scale();
|
|
|
|
|
|
|
|
// Toggles fullscreen
|
|
|
|
void fullscreen(bool enabled);
|
2020-12-27 06:44:48 +08:00
|
|
|
|
|
|
|
// Returns the Rendering API in use
|
|
|
|
Renderer renderer();
|
|
|
|
|
|
|
|
// Retrieves the Renderer Features
|
|
|
|
const RendererFeatures& renderer_features();
|
|
|
|
|
|
|
|
// Reference to the window's back buffer
|
|
|
|
extern const FrameBufferRef backbuffer;
|
2020-08-26 15:38:01 +08:00
|
|
|
}
|
|
|
|
}
|