ULRE/inc/hgl/graph/VKRenderable.h

89 lines
2.6 KiB
C
Raw Normal View History

#ifndef HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE
#define HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE
2021-02-10 18:53:39 +08:00
#include<hgl/graph/VKIndexBuffer.h>
#include<hgl/type/Map.h>
2020-09-05 17:54:21 +08:00
#include<hgl/type/String.h>
#include<hgl/math/Math.h>
VK_NAMESPACE_BEGIN
/**
2019-05-05 01:28:01 +08:00
* <br>
* Mesh信息API使用的VBO数据MESH数据的集合</p>
* 使mesh就可以合并到一个Renderable中VBO
2019-05-22 18:10:13 +08:00
*/
class Renderable
{
2020-11-30 15:40:26 +08:00
struct VABData
{
VAB *buf;
VkDeviceSize offset;
public:
2020-11-30 15:40:26 +08:00
CompOperatorMemcmp(const VABData &);
};
2020-11-30 15:40:26 +08:00
Map<UTF8String,VABData> buffer_list;
protected:
2019-05-23 19:23:49 +08:00
uint32_t draw_count;
2019-04-25 14:10:18 +08:00
IndexBuffer *indices_buffer=nullptr;
VkDeviceSize indices_offset=0;
protected:
AABB BoundingBox;
2019-05-23 19:23:49 +08:00
protected:
friend class RenderableNode;
2019-05-23 19:23:49 +08:00
uint ref_count=0;
uint RefInc(){return ++ref_count;}
uint RefDec(){return --ref_count;}
public:
Renderable(const uint32_t dc=0):draw_count(dc){}
virtual ~Renderable()=default;
const uint GetRefCount()const{return ref_count;}
2019-05-23 19:23:49 +08:00
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
const AABB &GetBoundingBox()const {return BoundingBox;}
bool Set(const UTF8String &name,VAB *vb,VkDeviceSize offset=0);
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
{
if(!ib)return(false);
2019-04-25 14:10:18 +08:00
indices_buffer=ib;
indices_offset=offset;
return(true);
}
public:
2021-05-31 17:53:16 +08:00
void SetDrawCount(const uint32_t dc){draw_count=dc;} ///<设置当前对象绘制需要多少个顶点
virtual const uint32_t GetDrawCount()const ///<取得当前对象绘制需要多少个顶点
2019-05-23 19:23:49 +08:00
{
if(indices_buffer)
return indices_buffer->GetCount();
return draw_count;
}
2021-05-31 17:53:16 +08:00
VAB * GetVAB (const UTF8String &,VkDeviceSize *);
VkBuffer GetBuffer (const UTF8String &,VkDeviceSize *);
const int GetBufferCount ()const {return buffer_list.GetCount();}
2021-05-31 17:53:16 +08:00
IndexBuffer * GetIndexBuffer () {return indices_buffer;}
const VkDeviceSize GetIndexBufferOffset()const {return indices_offset;}
};//class Renderable
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_RENDERABLE_INCLUDE