2024-05-05 04:37:04 +08:00
|
|
|
|
#pragma once
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
2024-06-01 12:08:49 +08:00
|
|
|
|
#include<hgl/graph/VKBufferMap.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKShaderModule.h>
|
2024-05-22 01:21:05 +08:00
|
|
|
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
2024-06-12 00:23:09 +08:00
|
|
|
|
#include<hgl/graph/VKIndexBuffer.h>
|
2024-04-27 03:09:16 +08:00
|
|
|
|
|
2024-05-05 04:37:04 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
/**
|
2024-05-26 15:04:44 +08:00
|
|
|
|
* 可绘制原始图形创建器
|
2024-05-05 04:37:04 +08:00
|
|
|
|
*/
|
|
|
|
|
class PrimitiveCreater
|
|
|
|
|
{
|
|
|
|
|
protected:
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
2024-05-25 01:46:19 +08:00
|
|
|
|
GPUDevice * device;
|
2024-05-25 02:48:37 +08:00
|
|
|
|
VertexDataManager * vdm;
|
2024-04-17 20:22:31 +08:00
|
|
|
|
|
2024-05-22 01:21:05 +08:00
|
|
|
|
const VIL * vil;
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
2024-05-25 01:46:19 +08:00
|
|
|
|
protected:
|
2024-05-25 03:14:26 +08:00
|
|
|
|
|
|
|
|
|
AnsiString prim_name;
|
|
|
|
|
PrimitiveData * prim_data;
|
2024-05-28 23:10:50 +08:00
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
uint32_t vertices_number; ///<顶点数量
|
2024-04-02 22:15:44 +08:00
|
|
|
|
|
2024-08-30 01:28:20 +08:00
|
|
|
|
bool has_index; ///<是否有索引
|
2024-05-26 15:04:44 +08:00
|
|
|
|
uint32_t index_number; ///<索引数量
|
2024-05-25 03:14:26 +08:00
|
|
|
|
IndexType index_type; ///<索引类型
|
2024-05-28 02:21:33 +08:00
|
|
|
|
IndexBuffer * ibo; ///<索引缓冲区
|
2024-04-02 22:15:44 +08:00
|
|
|
|
|
2024-06-02 12:16:33 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2024-06-12 01:48:25 +08:00
|
|
|
|
const int InitVAB(const AnsiString &name,const VkFormat format,const void *data); ///<取得顶点属性索引
|
2024-06-02 12:16:33 +08:00
|
|
|
|
|
2024-05-05 04:37:04 +08:00
|
|
|
|
public:
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
2024-05-25 03:14:26 +08:00
|
|
|
|
PrimitiveCreater(GPUDevice *,const VIL *);
|
2024-05-25 04:11:38 +08:00
|
|
|
|
PrimitiveCreater(VertexDataManager *);
|
2024-05-25 01:46:19 +08:00
|
|
|
|
virtual ~PrimitiveCreater();
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
/**
|
|
|
|
|
* 初始化一个原始图形创建
|
|
|
|
|
* @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);
|
2024-05-25 03:14:26 +08:00
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
void Clear(); ///<清除创建器数据
|
2024-05-25 22:47:26 +08:00
|
|
|
|
|
2024-05-25 01:46:19 +08:00
|
|
|
|
public: //顶点缓冲区
|
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
const uint32_t GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
|
2020-07-20 17:33:57 +08:00
|
|
|
|
|
2024-06-12 02:07:54 +08:00
|
|
|
|
VABMap * GetVABMap (const AnsiString &name,const VkFormat format=VK_FORMAT_UNDEFINED);
|
2024-05-28 02:21:33 +08:00
|
|
|
|
|
2024-06-12 01:48:25 +08:00
|
|
|
|
bool WriteVAB (const AnsiString &name,const VkFormat format,const void *data); ///<直接写入顶点属性数据
|
2020-07-20 18:12:02 +08:00
|
|
|
|
|
2024-05-25 01:46:19 +08:00
|
|
|
|
public: //索引缓冲区
|
|
|
|
|
|
2024-08-30 01:28:20 +08:00
|
|
|
|
const bool hasIndex()const{return vdm?has_index:index_number>0;} ///<是否有索引缓冲区
|
2024-05-26 15:04:44 +08:00
|
|
|
|
const IndexType GetIndexType()const{return index_type;} ///<取得索引类型
|
|
|
|
|
const uint32_t GetIndexCount()const{return index_number;} ///<取得索引数量
|
2024-05-25 01:46:19 +08:00
|
|
|
|
|
2024-06-12 02:07:54 +08:00
|
|
|
|
IBMap * GetIBMap();
|
2020-07-20 18:12:02 +08:00
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
bool WriteIBO(const void *data,const uint32_t count);
|
2024-04-02 21:34:49 +08:00
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
template<typename T>
|
|
|
|
|
bool WriteIBO(const T *data){return WriteIBO(data,index_number);}
|
2024-04-02 21:34:49 +08:00
|
|
|
|
|
2024-05-25 01:46:19 +08:00
|
|
|
|
public: //创建可渲染对象
|
|
|
|
|
|
2024-05-26 15:04:44 +08:00
|
|
|
|
Primitive * Create(); ///<创建一个可渲染对象,并清除创建器数据
|
2024-05-05 04:37:04 +08:00
|
|
|
|
};//class PrimitiveCreater
|
2024-06-01 12:08:49 +08:00
|
|
|
|
VK_NAMESPACE_END
|