improved TextureLoader and VKTexture2DLoader
This commit is contained in:
parent
3d9c229a20
commit
80bacd2b44
@ -93,7 +93,15 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextureLoader(const VkImageViewType &ivt){type=ivt;}
|
TextureLoader(const VkImageViewType &ivt)
|
||||||
|
{
|
||||||
|
type=ivt;
|
||||||
|
format=VK_FORMAT_UNDEFINED;
|
||||||
|
mipmap_zero_total_bytes=0;
|
||||||
|
total_bytes=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~TextureLoader()=default;
|
||||||
|
|
||||||
virtual bool Load(io::InputStream *);
|
virtual bool Load(io::InputStream *);
|
||||||
bool Load(const OSString &filename);
|
bool Load(const OSString &filename);
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
struct TextureCreateInfo
|
struct TextureCreateInfo
|
||||||
{
|
{
|
||||||
VkExtent3D extent;
|
VkImageViewType type;
|
||||||
|
|
||||||
|
VkExtent3D extent; //如为arrays,depth等同于layers
|
||||||
|
|
||||||
VkFormat format;
|
VkFormat format;
|
||||||
uint32_t usage;
|
uint32_t usage;
|
||||||
uint32_t mipmap_zero_total_bytes;
|
uint32_t mipmap_zero_total_bytes;
|
||||||
@ -149,15 +152,14 @@ public:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetData(GPUBuffer *buf,const uint32_t w,const uint32_t h)
|
bool SetData(GPUBuffer *buf,const VkExtent3D &ext)
|
||||||
{
|
{
|
||||||
if(!buf||w<=0||h<=0)return(false);
|
if(!buf)return(false);
|
||||||
|
if(ext.width<=0||ext.height<=0||ext.depth<=0)return(false);
|
||||||
|
|
||||||
buffer=buf;
|
buffer=buf;
|
||||||
|
|
||||||
extent.width=w;
|
extent=ext;
|
||||||
extent.height=h;
|
|
||||||
extent.depth=1;
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
class VkTextureLoader
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
class VkTexture2DLoader:public Texture2DLoader
|
class VkTexture2DLoader:public Texture2DLoader
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -24,7 +28,6 @@ namespace
|
|||||||
VkTexture2DLoader(GPUDevice *dev,const bool am):device(dev)
|
VkTexture2DLoader(GPUDevice *dev,const bool am):device(dev)
|
||||||
{
|
{
|
||||||
buf=nullptr;
|
buf=nullptr;
|
||||||
format=VK_FORMAT_UNDEFINED;
|
|
||||||
tex=nullptr;
|
tex=nullptr;
|
||||||
auto_mipmaps=am;
|
auto_mipmaps=am;
|
||||||
}
|
}
|
||||||
@ -56,8 +59,14 @@ namespace
|
|||||||
buf->Unmap();
|
buf->Unmap();
|
||||||
|
|
||||||
TextureCreateInfo *tci=new TextureCreateInfo(format);
|
TextureCreateInfo *tci=new TextureCreateInfo(format);
|
||||||
|
|
||||||
tci->SetData(buf,file_header.width,file_header.height);
|
VkExtent3D extent;
|
||||||
|
|
||||||
|
extent.width =file_header.width;
|
||||||
|
extent.height =file_header.height;
|
||||||
|
extent.depth =1;
|
||||||
|
|
||||||
|
tci->SetData(buf,extent);
|
||||||
|
|
||||||
if(auto_mipmaps&&file_header.mipmaps<=1)
|
if(auto_mipmaps&&file_header.mipmaps<=1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user