This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/renderer/renderer.hpp

66 lines
1.3 KiB
C++
Raw Normal View History

2019-03-21 20:18:31 +01:00
#pragma once
#include "common.hpp"
#include "font_mgr.hpp"
2019-03-21 20:18:31 +01:00
namespace big
{
using dx_callback = std::function<void()>;
using wndproc_callback = std::function<void(HWND, UINT, WPARAM, LPARAM)>;
class renderer final
2019-03-21 20:18:31 +01:00
{
public:
explicit renderer();
~renderer() = default;
font_mgr& get_font_mgr()
{
return m_font_mgr;
}
bool init();
void destroy();
2019-03-21 20:18:31 +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
*/
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);
2019-03-21 20:18:31 +01:00
void on_present();
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:
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;
2019-03-21 20:18:31 +01:00
};
inline auto g_renderer = renderer();
2019-03-21 20:18:31 +01:00
}