ULRE/inc/hgl/graph/PrimitiveCreater.h

82 lines
3.1 KiB
C
Raw Normal View History

2024-05-05 04:37:04 +08:00
#pragma once
2024-06-01 12:08:49 +08:00
#include<hgl/graph/VKBufferMap.h>
#include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
#include<hgl/graph/VKIndexBuffer.h>
2024-05-05 04:37:04 +08:00
VK_NAMESPACE_BEGIN
/**
*
2024-05-05 04:37:04 +08:00
*/
class PrimitiveCreater
{
protected:
GPUDevice * device;
VertexDataManager * vdm;
2024-04-17 20:22:31 +08:00
const VIL * vil;
protected:
AnsiString prim_name;
PrimitiveData * prim_data;
uint32_t vertices_number; ///<顶点数量
2024-04-02 22:15:44 +08:00
2024-08-30 01:28:20 +08:00
bool has_index; ///<是否有索引
uint32_t index_number; ///<索引数量
IndexType index_type; ///<索引类型
2024-05-28 02:21:33 +08:00
IndexBuffer * ibo; ///<索引缓冲区
2024-04-02 22:15:44 +08:00
protected:
const int InitVAB(const AnsiString &name,const VkFormat format,const void *data); ///<取得顶点属性索引
2024-05-05 04:37:04 +08:00
public:
PrimitiveCreater(GPUDevice *,const VIL *);
PrimitiveCreater(VertexDataManager *);
virtual ~PrimitiveCreater();
/**
*
* @parama name
* @parama vertices_count
* @parama index_count
* @parama it (使VDM时)
*/
bool Init(const AnsiString &name,
const uint32_t vertices_count,
const uint32_t index_count=0,IndexType it=IndexType::AUTO);
void Clear(); ///<清除创建器数据
public: //顶点缓冲区
const uint32_t GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
VABMap * GetVABMap (const AnsiString &name,const VkFormat format=VK_FORMAT_UNDEFINED);
2024-05-28 02:21:33 +08:00
bool WriteVAB (const AnsiString &name,const VkFormat format,const void *data); ///<直接写入顶点属性数据
public: //索引缓冲区
2024-08-30 01:28:20 +08:00
const bool hasIndex()const{return vdm?has_index:index_number>0;} ///<是否有索引缓冲区
const IndexType GetIndexType()const{return index_type;} ///<取得索引类型
const uint32_t GetIndexCount()const{return index_number;} ///<取得索引数量
IBMap * GetIBMap();
bool WriteIBO(const void *data,const uint32_t count);
template<typename T>
bool WriteIBO(const T *data){return WriteIBO(data,index_number);}
public: //创建可渲染对象
Primitive * Create(); ///<创建一个可渲染对象,并清除创建器数据
2024-05-05 04:37:04 +08:00
};//class PrimitiveCreater
2024-06-01 12:08:49 +08:00
VK_NAMESPACE_END