2019-03-21 20:18:31 +01:00
|
|
|
#pragma once
|
|
|
|
#include "common.hpp"
|
2024-02-21 21:26:29 +01:00
|
|
|
#include "font_mgr.hpp"
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
using dx_callback = std::function<void()>;
|
2022-12-16 18:55:55 +01:00
|
|
|
using wndproc_callback = std::function<void(HWND, UINT, WPARAM, LPARAM)>;
|
|
|
|
|
|
|
|
class renderer final
|
2019-03-21 20:18:31 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit renderer();
|
2024-02-21 21:26:29 +01:00
|
|
|
~renderer() = default;
|
|
|
|
|
|
|
|
font_mgr& get_font_mgr()
|
|
|
|
{
|
|
|
|
return m_font_mgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
void destroy();
|
2019-03-21 20:18:31 +01:00
|
|
|
|
2022-12-16 18:55:55 +01:00
|
|
|
/**
|
|
|
|
* @brief Add a callback function to draw your ImGui content in
|
|
|
|
*
|
|
|
|
* @param callback Function
|
|
|
|
* @param priority The higher the priority the value the later it gets drawn on top
|
|
|
|
* @return true
|
|
|
|
* @return false
|
|
|
|
*/
|
2023-07-20 22:46:32 +02:00
|
|
|
bool add_dx_callback(dx_callback callback, uint32_t priority);
|
2022-12-16 18:55:55 +01:00
|
|
|
/**
|
|
|
|
* @brief Add a callback function on wndproc
|
|
|
|
*
|
|
|
|
* @param callback Function
|
|
|
|
*/
|
|
|
|
void add_wndproc_callback(wndproc_callback callback);
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
void on_present();
|
|
|
|
|
2022-12-09 20:43:01 +01:00
|
|
|
void rescale(float rel_size);
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
void pre_reset();
|
|
|
|
void post_reset();
|
|
|
|
|
|
|
|
void wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
2022-08-10 08:42:34 +08:00
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
private:
|
2023-03-01 21:27:15 +00:00
|
|
|
static void new_frame();
|
|
|
|
static void end_frame();
|
2022-12-16 18:55:55 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
IDXGISwapChain* m_dxgi_swapchain;
|
|
|
|
ID3D11Device* m_d3d_device;
|
|
|
|
ID3D11DeviceContext* m_d3d_device_context;
|
|
|
|
|
2023-07-20 22:46:32 +02:00
|
|
|
std::map<uint32_t, dx_callback> m_dx_callbacks;
|
2022-12-16 18:55:55 +01:00
|
|
|
std::vector<wndproc_callback> m_wndproc_callbacks;
|
2024-02-21 21:26:29 +01:00
|
|
|
|
|
|
|
font_mgr m_font_mgr;
|
2019-03-21 20:18:31 +01:00
|
|
|
};
|
|
|
|
|
2024-02-21 21:26:29 +01:00
|
|
|
inline auto g_renderer = renderer();
|
2019-03-21 20:18:31 +01:00
|
|
|
}
|