2020-06-20 19:40:09 +08:00
|
|
|
|
#ifndef HGL_GRAPH_TILE_DATA_INCLUDE
|
2019-11-06 20:52:09 +08:00
|
|
|
|
#define HGL_GRAPH_TILE_DATA_INCLUDE
|
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKTexture.h>
|
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_USING
|
|
|
|
|
|
2019-11-06 20:52:09 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
/**
|
2020-06-20 19:40:09 +08:00
|
|
|
|
* TileData是一种处理大量等同尺寸及格式贴图的管理机制,程序会自动根据显卡最大贴图处理能力来创建尽可能符合需求的贴图。(注:Tile的大小不必符合2次幂)
|
|
|
|
|
* Tile的增加或删除,程序会自动排序,尽可能小的减少I/O消耗。
|
|
|
|
|
*/
|
|
|
|
|
class TileData ///Tile纹理管理
|
2019-11-06 20:52:09 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
struct Object
|
2019-11-06 20:52:09 +08:00
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
double fl,ft,fw,fh;
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
int width,height;
|
2020-06-20 19:40:09 +08:00
|
|
|
|
};//struct TileObject
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
Texture2D *tile_texture; ///<TileData所用的纹理对象
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
TileData::Object **tile_object; ///<所有的Tile对象
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
int tile_width,tile_height; ///<Tile的宽和高
|
|
|
|
|
int tile_count,tile_total; ///<当前Tile数量与最大数量
|
|
|
|
|
int tile_rows,tile_cols; ///<贴图中可用的Tile行数和列数
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
2020-06-20 19:40:09 +08:00
|
|
|
|
|
|
|
|
|
int FindSpace(); ///<寻找一个空位
|
|
|
|
|
void WriteTile(int,TileData::Object *,void *,uint,uint32,int,int); ///<写入一个Tile
|
|
|
|
|
|
|
|
|
|
public:
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
int GetWidth ()const{return tile_width;} ///<取得Tile宽
|
|
|
|
|
int GetHeight ()const{return tile_height;} ///<取得Tile高
|
|
|
|
|
int GetCount ()const{return tile_count;} ///<取得Tile数量
|
|
|
|
|
int GetMaxCount ()const{return tile_total;} ///<取得Tile最大数量
|
|
|
|
|
int GetFreeCount()const{return tile_total-tile_count;} ///<取得空余Tile数量
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
Texture2D * GetTexture ()const{return tile_texture;} ///<取得贴图
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
TileData(int,int,int,unsigned int);
|
|
|
|
|
virtual ~TileData();
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
TileData::Object *Add(void *,unsigned int,uint32,int=-1,int=-1); ///<增加一个Tile
|
|
|
|
|
// TileData::Object *Add(Bitmap2D *,int=-1,int=-1); ///<增加一个Tile
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-20 19:40:09 +08:00
|
|
|
|
bool Delete(TileData::Object *); ///<删除一个Tile
|
|
|
|
|
bool Change(TileData::Object *,void *,unsigned int,uint32,int=-1,int=-1); ///<更改一个Tile的数据内容
|
|
|
|
|
void Clear(); ///<清除Tile数据
|
2019-11-06 20:52:09 +08:00
|
|
|
|
};//class TileData
|
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_TILE_DATA_INCLUDE
|