ULRE/inc/hgl/graph/VKRenderable.h

90 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>
2021-09-24 01:53:44 +08:00
#include<hgl/graph/AABB.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
{
struct VBOData
{
2021-11-29 15:58:48 +08:00
VBO *buf;
VkDeviceSize offset;
public:
CompOperatorMemcmp(const VBOData &);
};
Map<AnsiString,VBOData> buffer_list;
2021-09-24 01:53:44 +08:00
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;
2022-06-20 21:39:04 +08:00
const uint GetRefCount()const{return ref_count;}
2019-05-23 19:23:49 +08:00
2022-06-20 21:39:04 +08:00
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
const AABB & GetBoundingBox()const {return BoundingBox;}
bool Set(const AnsiString &name,VBO *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;
}
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
2021-05-31 17:53:16 +08:00
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