ULRE/inc/hgl/graph/VKPrimitive.h

79 lines
1.9 KiB
C
Raw Normal View History

2022-06-24 17:51:39 +08:00
#ifndef HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
#define HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
#include<hgl/graph/VKIndexBuffer.h>
#include<hgl/type/Map.h>
#include<hgl/type/String.h>
#include<hgl/math/Math.h>
#include<hgl/graph/AABB.h>
VK_NAMESPACE_BEGIN
/**
*
*/
class Primitive
{
struct VBOData
{
VBO *buf;
VkDeviceSize offset;
public:
CompOperatorMemcmp(const VBOData &);
};
Map<AnsiString,VBOData> buffer_list;
protected:
uint32_t vertex_count;
2022-06-24 17:51:39 +08:00
IndexBufferData index_buffer_data;
2022-06-24 17:51:39 +08:00
protected:
AABB BoundingBox;
protected:
friend class RenderableNode;
uint ref_count=0;
uint RefInc(){return ++ref_count;}
uint RefDec(){return --ref_count;}
public:
Primitive(const uint32_t vc=0):vertex_count(vc){}
2022-06-24 17:51:39 +08:00
virtual ~Primitive()=default;
const uint GetRefCount()const{return ref_count;}
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
2022-06-24 17:51:39 +08:00
const AABB & GetBoundingBox()const {return BoundingBox;}
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
2022-06-24 17:51:39 +08:00
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
2022-06-24 17:51:39 +08:00
{
if(!ib)return(false);
index_buffer_data.buffer=ib;
index_buffer_data.offset=offset;
2022-06-24 17:51:39 +08:00
return(true);
}
public:
const uint32_t GetVertexCount ()const {return vertex_count;}
2022-06-24 17:51:39 +08:00
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
const int GetBufferCount ()const {return buffer_list.GetCount();}
2022-06-24 17:51:39 +08:00
const IndexBufferData * GetIndexBufferData ()const {return &index_buffer_data;}
2022-06-24 17:51:39 +08:00
};//class Primitive
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE