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>
|
2019-05-27 16:54:08 +08:00
|
|
|
|
#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
|
|
|
|
|
{
|
2019-05-27 16:54:08 +08:00
|
|
|
|
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;
|
2019-05-25 14:52:24 +08:00
|
|
|
|
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:
|
|
|
|
|
|
2019-05-27 16:54:08 +08:00
|
|
|
|
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;
|
|
|
|
|
|
2019-05-27 16:54:08 +08:00
|
|
|
|
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;
|
|
|
|
|
|
2019-05-27 16:54:08 +08:00
|
|
|
|
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 &);
|
2019-05-27 16:54:08 +08:00
|
|
|
|
void SetMVP(const Matrix4f &proj,const Matrix4f &mv);
|
|
|
|
|
|
2019-05-25 14:52:24 +08:00
|
|
|
|
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
|
|
|
|
|
2019-05-27 16:54:08 +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
|