ULRE/inc/hgl/graph/RenderList.h

83 lines
2.0 KiB
C
Raw Normal View History

2019-05-25 00:50:04 +08:00
#ifndef HGL_GRAPH_RENDER_LIST_INCLUDE
#define HGL_GRAPH_RENDER_LIST_INCLUDE
#include<hgl/graph/vulkan/VK.h>
#include<hgl/graph/Camera.h>
#include<hgl/graph/SceneNode.h>
2019-05-25 01:06:33 +08:00
#include<hgl/type/Color4f.h>
2019-05-25 00:50:04 +08:00
namespace hgl
{
namespace graph
{
class RenderableInstance;
2019-05-25 00:50:04 +08:00
struct UBOMatrixData
{
Matrix4f projection;
Matrix4f modelview;
Matrix4f mvp;
2019-05-25 01:06:33 +08:00
Matrix3f normal;
2019-05-25 00:50:04 +08:00
};//
struct UBOSkyLight
2019-05-25 01:06:33 +08:00
{
Color4f sun_color;
Vector4f sun_direction;
2019-05-25 00:50:04 +08:00
};//
class RenderList
{
vulkan::CommandBuffer *cmd_buf;
2019-05-25 01:06:33 +08:00
private:
2019-05-25 00:50:04 +08:00
2019-05-25 01:06:33 +08:00
Camera camera;
2019-05-25 00:50:04 +08:00
Frustum frustum;
2019-05-25 01:06:33 +08:00
private:
UBOMatrixData ubo_matrix;
UBOSkyLight ubo_skylight;
2019-05-25 00:50:04 +08:00
private:
List<SceneNode *> scene_node_list;
2019-05-25 00:50:04 +08:00
vulkan::Pipeline * last_pipeline;
vulkan::DescriptorSets *last_desc_sets;
vulkan::Renderable * last_renderable;
void Render(RenderableInstance *);
void Render(List<RenderableInstance *> &);
2019-05-25 00:50:04 +08:00
public:
RenderList()
{
cmd_buf=nullptr;
last_pipeline=nullptr;
last_desc_sets=nullptr;
last_renderable=nullptr;
}
~RenderList()=default;
void Add (SceneNode *node) {if(node)scene_node_list.Add(node);}
void Clear () {scene_node_list.ClearData();}
2019-05-25 00:50:04 +08:00
void SetCamera(const Camera &);
void SetMVP(const Matrix4f &proj,const Matrix4f &mv);
void SetSkyLightColor(const Color4f &c,const Vector4f &d)
2019-05-25 01:06:33 +08:00
{
ubo_skylight.sun_color=c;
ubo_skylight.sun_direction=d;
}
2019-05-25 00:50:04 +08:00
bool Render(vulkan::CommandBuffer *);
2019-05-25 00:50:04 +08:00
};//class RenderList
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_RENDER_LIST_INCLUDE