ULRE/inc/hgl/graph/RenderFramework.h

123 lines
3.3 KiB
C
Raw Normal View History

2024-10-19 13:08:05 +08:00
#pragma once
#include<hgl/graph/BlendMode.h>
2024-10-19 13:08:05 +08:00
#include<hgl/type/List.h>
#include<hgl/graph/ViewportInfo.h>
2024-11-05 23:12:35 +08:00
#include<hgl/graph/module/GraphModule.h>
#include<hgl/io/event/WindowEvent.h>
2024-10-19 13:08:05 +08:00
VK_NAMESPACE_BEGIN
2024-11-05 23:12:35 +08:00
class GPUDevice;
2024-11-05 00:04:36 +08:00
class TileData;
class TileFont;
class FontSource;
class VulkanInstance;
class RenderPassManager;
class TextureManager;
2024-10-29 00:50:15 +08:00
class SwapchainModule;
2024-10-19 13:08:05 +08:00
/**
*
*/
class RenderFramework:public io::WindowEvent
2024-10-19 13:08:05 +08:00
{
protected:
2024-10-29 00:50:15 +08:00
Window * win =nullptr;
VulkanInstance * inst =nullptr;
2024-10-19 13:08:05 +08:00
2024-10-29 00:50:15 +08:00
GPUDevice * device =nullptr;
2024-10-19 13:08:05 +08:00
protected:
GraphModuleManager *graph_module_manager=nullptr;
ObjectList<GraphModule> module_list;
protected:
2024-10-29 00:50:15 +08:00
SwapchainModule * swapchain_module =nullptr;
2024-10-19 13:08:05 +08:00
2024-11-05 23:12:35 +08:00
protected:
RenderPassManager * render_pass_manager =nullptr;
2024-11-05 23:12:35 +08:00
TextureManager * texture_manager =nullptr;
2024-10-29 00:50:15 +08:00
protected:
2024-10-19 13:08:05 +08:00
2024-10-29 00:50:15 +08:00
ViewportInfo viewport_info;
2024-10-19 13:08:05 +08:00
private:
double last_time =0;
double cur_time =0;
2024-10-19 13:08:05 +08:00
uint64 frame_count =0;
public:
const uint64 GetFrameCount ()const noexcept{return frame_count;} ///<取得当前帧数
void RestartFrameCount ()noexcept{frame_count=0;} ///<重新开始统计帧数
2024-11-05 23:12:35 +08:00
public: //module
template<typename T> T *GetModule(){return graph_module_manager->GetModule<T>(false);} ///<获取指定类型的模块
template<typename T> T *AddModule()
{
T *tm=new T(graph_module_manager);
module_list.Add(tm);
return tm;
}
2024-11-05 23:12:35 +08:00
SwapchainModule *GetSwapchain(){return swapchain_module;} ///<取得Swapchain模块
public: //manager
RenderPassManager * GetRenderPassManager(){return render_pass_manager;} ///<取得渲染通道管理器
TextureManager * GetTextureManager (){return texture_manager;} ///<取得纹理管理器
public: //event
virtual void OnResize(uint,uint)override;
virtual void OnActive(bool)override;
virtual void OnClose ()override;
2024-11-05 23:12:35 +08:00
2024-10-19 13:08:05 +08:00
public:
NO_COPY_NO_MOVE(RenderFramework)
2024-10-29 02:25:45 +08:00
RenderFramework();
virtual ~RenderFramework();
2024-11-12 01:51:14 +08:00
virtual bool Init(uint w,uint h,const OSString &app_name); ///<初始化
2024-10-19 13:08:05 +08:00
virtual void StartTime();
2024-10-19 13:08:05 +08:00
/**
* @pragma delta_time
*/
virtual void Update(const double delta_time){}
virtual void BeginFrame(); ///<开始当前帧
virtual void EndFrame(); ///<当前帧结束
2024-10-19 13:08:05 +08:00
virtual void MainLoop(); ///<主循环
2024-11-05 00:04:36 +08:00
virtual void Run();
2024-11-05 00:04:36 +08:00
public: //TileData
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
2024-10-19 13:08:05 +08:00
};//class RenderFramework
VK_NAMESPACE_END