support C++20
This commit is contained in:
parent
fdf073376c
commit
416b7bfcb3
@ -7,7 +7,7 @@ namespace hgl
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
* 2Dλͼ¼ÓÔØ
|
||||
* 2D位图加载类
|
||||
*/
|
||||
class Bitmap2DLoader:public Texture2DLoader
|
||||
{
|
||||
@ -20,7 +20,7 @@ namespace hgl
|
||||
Bitmap2DLoader():Texture2DLoader(){}
|
||||
~Bitmap2DLoader();
|
||||
|
||||
void *OnBegin(uint32 total_bytes) override;
|
||||
void *OnBegin(uint32 total_bytes,const VkFormat &) override;
|
||||
bool OnEnd() override {return(false);}
|
||||
|
||||
BitmapData *GetBitmap();
|
||||
|
@ -85,10 +85,16 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
virtual void *OnBegin(uint32)=0;
|
||||
virtual void *OnBegin(uint32,const VkFormat &)=0;
|
||||
virtual bool OnEnd()=0;
|
||||
virtual void OnError(){}
|
||||
|
||||
public:
|
||||
|
||||
const TextureFileHeader & GetFileHeader ()const{return file_header;}
|
||||
const VkFormat & GetTextureFormat()const{return format;}
|
||||
const uint32 GetZeroMipmapBytes()const{return mipmap_zero_total_bytes;}
|
||||
|
||||
public:
|
||||
|
||||
TextureLoader()
|
||||
|
@ -9,7 +9,7 @@ namespace hgl
|
||||
SAFE_CLEAR(bmp);
|
||||
}
|
||||
|
||||
void *Bitmap2DLoader::OnBegin(uint32 total_bytes)
|
||||
void *Bitmap2DLoader::OnBegin(uint32 total_bytes,const VkFormat &)
|
||||
{
|
||||
SAFE_CLEAR(bmp);
|
||||
|
||||
|
@ -194,7 +194,7 @@ namespace hgl
|
||||
{
|
||||
if(file_header.pixel_format.compress_format<0
|
||||
||file_header.pixel_format.compress_format>=CompressFormatCount)
|
||||
return(nullptr);
|
||||
return(false);
|
||||
|
||||
format=CompressFormatList[file_header.pixel_format.compress_format];
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace hgl
|
||||
if(file_left_bytes<total_bytes)
|
||||
return(false);
|
||||
|
||||
void *ptr=OnBegin(total_bytes);
|
||||
void *ptr=OnBegin(total_bytes,format);
|
||||
|
||||
if(!ptr)
|
||||
return(false);
|
||||
|
@ -22,6 +22,6 @@ Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename,bo
|
||||
if(!loader.Load(filename))
|
||||
return(nullptr);
|
||||
|
||||
return loader.CreateTexture();
|
||||
return loader.CreateTexture(loader.GetFileHeader(),loader.GetTextureFormat(),loader.GetZeroMipmapBytes());
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -22,6 +22,6 @@ TextureCube *CreateTextureCubeFromFile(GPUDevice *device,const OSString &filenam
|
||||
if(!loader.Load(filename))
|
||||
return(nullptr);
|
||||
|
||||
return loader.CreateTexture();
|
||||
return loader.CreateTexture(loader.GetFileHeader(),loader.GetTextureFormat(),loader.GetZeroMipmapBytes());
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -32,11 +32,11 @@ public:
|
||||
SAFE_CLEAR(buf);
|
||||
}
|
||||
|
||||
void *OnBegin(uint32 total_bytes) override
|
||||
void *OnBegin(uint32 total_bytes,const VkFormat &tex_format) override
|
||||
{
|
||||
SAFE_CLEAR(buf);
|
||||
|
||||
if(!CheckVulkanFormat(format))
|
||||
if(!CheckVulkanFormat(tex_format))
|
||||
return(nullptr);
|
||||
|
||||
buf=device->CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,total_bytes);
|
||||
@ -61,9 +61,9 @@ public:
|
||||
|
||||
DeviceBuffer *GetBuffer(){return buf;}
|
||||
|
||||
T *CreateTexture()
|
||||
T *CreateTexture(const TextureFileHeader &tex_file_header,const VkFormat &tex_format,const uint32 top_mipmap_bytes)
|
||||
{
|
||||
TextureCreateInfo *tci=new TextureCreateInfo(format);
|
||||
TextureCreateInfo *tci=new TextureCreateInfo(tex_format);
|
||||
|
||||
VkExtent3D extent;
|
||||
|
||||
@ -71,11 +71,11 @@ public:
|
||||
|
||||
tci->SetData(buf,extent);
|
||||
|
||||
tci->origin_mipmaps=file_header.mipmaps;
|
||||
tci->origin_mipmaps=tex_file_header.mipmaps;
|
||||
|
||||
if(auto_mipmaps&&file_header.mipmaps<=1)
|
||||
if(auto_mipmaps&&tex_file_header.mipmaps<=1)
|
||||
{
|
||||
if(device->CheckFormatSupport(format,VK_FORMAT_FEATURE_BLIT_DST_BIT))
|
||||
if(device->CheckFormatSupport(tex_format,VK_FORMAT_FEATURE_BLIT_DST_BIT))
|
||||
{
|
||||
tci->usage|=VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
tci->SetAutoMipmaps();
|
||||
@ -83,10 +83,10 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
tci->target_mipmaps=file_header.mipmaps;
|
||||
tci->target_mipmaps=tex_file_header.mipmaps;
|
||||
}
|
||||
|
||||
tci->mipmap_zero_total_bytes=mipmap_zero_total_bytes;
|
||||
tci->mipmap_zero_total_bytes=top_mipmap_bytes;
|
||||
|
||||
SAFE_CLEAR(tex);
|
||||
tex=OnCreateTexture(tci);
|
||||
|
Loading…
x
Reference in New Issue
Block a user