TmpMenu/src/renderer/renderer.hpp
Andreas Maerten 1064077b9c feat(renderer): added dynamic font loading based on lang requirements (#2738)
Related YimMenu/Translations#117
Closes #2723

Changes made:
 - Renderer class was changed to a static instance
 - Some throw code was removed because of change of instantiation of the renderer
 - Fonts are dynamically loaded based on the language requirements
 - renderer files have been moved to make the root directory less messy
 - Added a font mgr to improve the ease of adding more language support
2024-02-21 21:26:29 +01:00

66 lines
1.3 KiB
C++

#pragma once
#include "common.hpp"
#include "font_mgr.hpp"
namespace big
{
using dx_callback = std::function<void()>;
using wndproc_callback = std::function<void(HWND, UINT, WPARAM, LPARAM)>;
class renderer final
{
public:
explicit renderer();
~renderer() = default;
font_mgr& get_font_mgr()
{
return m_font_mgr;
}
bool init();
void destroy();
/**
* @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
*/
bool add_dx_callback(dx_callback callback, uint32_t priority);
/**
* @brief Add a callback function on wndproc
*
* @param callback Function
*/
void add_wndproc_callback(wndproc_callback callback);
void on_present();
void rescale(float rel_size);
void pre_reset();
void post_reset();
void wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
private:
static void new_frame();
static void end_frame();
private:
IDXGISwapChain* m_dxgi_swapchain;
ID3D11Device* m_d3d_device;
ID3D11DeviceContext* m_d3d_device_context;
std::map<uint32_t, dx_callback> m_dx_callbacks;
std::vector<wndproc_callback> m_wndproc_callbacks;
font_mgr m_font_mgr;
};
inline auto g_renderer = renderer();
}