2019-04-28 17:02:38 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VK.h>
|
2019-04-26 03:03:21 +08:00
|
|
|
|
#include<hgl/type/BaseString.h>
|
2019-04-16 02:23:03 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-04-25 16:02:13 +08:00
|
|
|
|
/**
|
2019-05-05 01:28:01 +08:00
|
|
|
|
* 可渲染数据对象<br>
|
|
|
|
|
* 本对象包含材质实例信息和Mesh信息,可渲染数据对象中包含供最终API使用的VBO数据,可能存在多个MESH数据的集合。</p>
|
|
|
|
|
* 比如有多种形状的石头,它们使用了同一种材质,这种情况下多个mesh就可以合并到一个Renderable中,渲染时不再切换VBO。
|
2019-04-28 17:02:38 +08:00
|
|
|
|
*/
|
|
|
|
|
class Renderable
|
2019-04-25 16:02:13 +08:00
|
|
|
|
{
|
2019-04-28 17:02:38 +08:00
|
|
|
|
const VertexShaderModule *vertex_sm;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
|
2019-04-28 17:02:38 +08:00
|
|
|
|
int buf_count;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
VkBuffer *buf_list=nullptr;
|
|
|
|
|
VkDeviceSize *buf_offset=nullptr;
|
2019-04-28 17:02:38 +08:00
|
|
|
|
|
2019-04-25 14:10:18 +08:00
|
|
|
|
IndexBuffer *indices_buffer=nullptr;
|
|
|
|
|
VkDeviceSize indices_offset=0;
|
|
|
|
|
|
2019-04-16 02:23:03 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2019-04-28 17:02:38 +08:00
|
|
|
|
Renderable(const VertexShaderModule *);
|
|
|
|
|
virtual ~Renderable();
|
2019-04-17 02:26:58 +08:00
|
|
|
|
|
2019-05-06 21:03:05 +08:00
|
|
|
|
bool Set(const int stage_input_binding, VertexBuffer *vb,VkDeviceSize offset=0);
|
|
|
|
|
bool Set(const UTF8String &name, VertexBuffer *vb,VkDeviceSize offset=0);
|
2019-04-26 03:03:21 +08:00
|
|
|
|
|
2019-04-25 16:02:13 +08:00
|
|
|
|
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
|
2019-04-25 14:10:18 +08:00
|
|
|
|
{
|
|
|
|
|
if(!ib)return(false);
|
|
|
|
|
|
|
|
|
|
indices_buffer=ib;
|
|
|
|
|
indices_offset=offset;
|
2019-04-25 16:02:13 +08:00
|
|
|
|
return(true);
|
2019-04-25 14:10:18 +08:00
|
|
|
|
}
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-04-28 17:02:38 +08:00
|
|
|
|
const int GetBufferCount ()const{return buf_count;}
|
|
|
|
|
const VkBuffer * GetBuffer ()const{return buf_list;}
|
|
|
|
|
const VkDeviceSize * GetOffset ()const{return buf_offset;}
|
2019-04-18 16:37:59 +08:00
|
|
|
|
|
2019-04-28 17:02:38 +08:00
|
|
|
|
IndexBuffer * GetIndexBuffer() {return indices_buffer;}
|
2019-04-25 14:10:18 +08:00
|
|
|
|
const VkDeviceSize GetIndexOffset()const{return indices_offset;}
|
2019-04-28 17:02:38 +08:00
|
|
|
|
};//class Renderable
|
2019-04-16 02:23:03 +08:00
|
|
|
|
VK_NAMESPACE_END
|
2019-04-28 17:02:38 +08:00
|
|
|
|
#endif//HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE
|