From 416b7bfcb39fedc64e5d2029d217286773efa512 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 26 Jul 2024 03:24:44 +0800 Subject: [PATCH] support C++20 --- inc/hgl/graph/Bitmap2DLoader.h | 4 ++-- inc/hgl/graph/TextureLoader.h | 8 +++++++- src/SceneGraph/Bitmap2DLoader.cpp | 2 +- src/SceneGraph/TextureLoader.cpp | 4 ++-- .../Vulkan/Texture/VKTexture2DLoader.cpp | 2 +- .../Vulkan/Texture/VKTextureCubeLoader.cpp | 2 +- .../Vulkan/Texture/VKTextureLoader.h | 18 +++++++++--------- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/inc/hgl/graph/Bitmap2DLoader.h b/inc/hgl/graph/Bitmap2DLoader.h index 9dc830b6..3484c3fc 100644 --- a/inc/hgl/graph/Bitmap2DLoader.h +++ b/inc/hgl/graph/Bitmap2DLoader.h @@ -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(); diff --git a/inc/hgl/graph/TextureLoader.h b/inc/hgl/graph/TextureLoader.h index efc6e61a..5840a10f 100644 --- a/inc/hgl/graph/TextureLoader.h +++ b/inc/hgl/graph/TextureLoader.h @@ -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() diff --git a/src/SceneGraph/Bitmap2DLoader.cpp b/src/SceneGraph/Bitmap2DLoader.cpp index d4f1046d..ca26f6ed 100644 --- a/src/SceneGraph/Bitmap2DLoader.cpp +++ b/src/SceneGraph/Bitmap2DLoader.cpp @@ -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); diff --git a/src/SceneGraph/TextureLoader.cpp b/src/SceneGraph/TextureLoader.cpp index 29e35875..11352cda 100644 --- a/src/SceneGraph/TextureLoader.cpp +++ b/src/SceneGraph/TextureLoader.cpp @@ -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_bytesCreateBuffer(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);