renamed to CreateTexture from GetTexture in TextureLoader<>

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-09-25 19:49:06 +08:00
parent 7d9192051a
commit 65c3d5cad1
6 changed files with 17 additions and 11 deletions

View File

@ -21,7 +21,7 @@ namespace hgl
~Bitmap2DLoader(); ~Bitmap2DLoader();
void *OnBegin(uint32 total_bytes) override; void *OnBegin(uint32 total_bytes) override;
void OnEnd() override {} bool OnEnd() override {return(false);}
BitmapData *GetBitmap(); BitmapData *GetBitmap();
};//class Bitmap2DLoader };//class Bitmap2DLoader

View File

@ -86,7 +86,7 @@ namespace hgl
protected: protected:
virtual void *OnBegin(uint32)=0; virtual void *OnBegin(uint32)=0;
virtual void OnEnd()=0; virtual bool OnEnd()=0;
virtual void OnError(){} virtual void OnError(){}
public: public:

View File

@ -22,6 +22,6 @@ Texture2DArray *CreateTexture2DArrayFromFile(GPUDevice *device,const OSString &f
if(!loader.Load(filename)) if(!loader.Load(filename))
return(nullptr); return(nullptr);
return loader.GetTexture(); return loader.CreateTexture();
} }
VK_NAMESPACE_END VK_NAMESPACE_END

View File

@ -22,6 +22,6 @@ Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename,bo
if(!loader.Load(filename)) if(!loader.Load(filename))
return(nullptr); return(nullptr);
return loader.GetTexture(); return loader.CreateTexture();
} }
VK_NAMESPACE_END VK_NAMESPACE_END

View File

@ -22,6 +22,6 @@ TextureCube *CreateTextureCubeFromFile(GPUDevice *device,const OSString &filenam
if(!loader.Load(filename)) if(!loader.Load(filename))
return(nullptr); return(nullptr);
return loader.GetTexture(); return loader.CreateTexture();
} }
VK_NAMESPACE_END VK_NAMESPACE_END

View File

@ -48,12 +48,19 @@ public:
} }
void OnExtent(VkExtent3D &extent); void OnExtent(VkExtent3D &extent);
T *OnCreateTexture(TextureCreateInfo *); T *OnCreateTexture(TextureCreateInfo *);
void OnEnd() override bool OnEnd() override
{ {
if(!buf)return(false);
buf->Unmap(); buf->Unmap();
return(true);
}
T *CreateTexture()
{
TextureCreateInfo *tci=new TextureCreateInfo(format); TextureCreateInfo *tci=new TextureCreateInfo(format);
VkExtent3D extent; VkExtent3D extent;
@ -82,12 +89,11 @@ public:
SAFE_CLEAR(tex); SAFE_CLEAR(tex);
tex=OnCreateTexture(tci); tex=OnCreateTexture(tci);
if(tex) if(!tex)
buf=nullptr; return nullptr;
}
buf=nullptr;
T *GetTexture()
{
T *result=tex; T *result=tex;
tex=nullptr; tex=nullptr;
return result; return result;