To add newly texture to set/map in TextureManager
This commit is contained in:
parent
8ff954b5c2
commit
173d3e075a
@ -28,7 +28,7 @@ private:
|
|||||||
|
|
||||||
Map<TextureID,Texture *> texture_by_id;
|
Map<TextureID,Texture *> texture_by_id;
|
||||||
|
|
||||||
Map<OSString,Texture *> texture_by_name;
|
Map<OSString,Texture *> texture_by_filename;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -103,6 +103,13 @@ public: //Create/Chagne
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void Release(Texture *);
|
void Release(Texture *);
|
||||||
|
void Destory(Texture *tex)
|
||||||
|
{
|
||||||
|
if(!tex)return;
|
||||||
|
|
||||||
|
Release(tex);
|
||||||
|
delete tex;
|
||||||
|
}
|
||||||
|
|
||||||
public: // Load
|
public: // Load
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Texture2D *TextureManager::CreateTexture2D(TextureData *tex_data)
|
|||||||
|
|
||||||
Texture2D *tex=new Texture2D(this,AcquireID(),tex_data);
|
Texture2D *tex=new Texture2D(this,AcquireID(),tex_data);
|
||||||
|
|
||||||
texture_set.Add(tex);
|
Add(tex);
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,11 @@ Texture2DArray *TextureManager::CreateTexture2DArray(TextureData *tex_data)
|
|||||||
if(!tex_data)
|
if(!tex_data)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(new Texture2DArray(this,AcquireID(),tex_data));
|
Texture2DArray *tex=new Texture2DArray(this,AcquireID(),tex_data);
|
||||||
|
|
||||||
|
Add(tex);
|
||||||
|
|
||||||
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2DArray *TextureManager::CreateTexture2DArray(TextureCreateInfo *tci)
|
Texture2DArray *TextureManager::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||||
|
@ -12,7 +12,11 @@ TextureCube *TextureManager::CreateTextureCube(TextureData *tex_data)
|
|||||||
if(!tex_data)
|
if(!tex_data)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(new TextureCube(this,AcquireID(),tex_data));
|
TextureCube *tex=new TextureCube(this,AcquireID(),tex_data);
|
||||||
|
|
||||||
|
Add(tex);
|
||||||
|
|
||||||
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCube *TextureManager::CreateTextureCube(TextureCreateInfo *tci)
|
TextureCube *TextureManager::CreateTextureCube(TextureCreateInfo *tci)
|
||||||
|
@ -43,7 +43,7 @@ const TextureID TextureManager::Add(Texture *tex,const OSString &tn)
|
|||||||
return id;
|
return id;
|
||||||
|
|
||||||
if(!tn.IsEmpty())
|
if(!tn.IsEmpty())
|
||||||
texture_by_name.Add(tn,tex);
|
texture_by_filename.Add(tn,tex);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ void TextureManager::Release(Texture *tex)
|
|||||||
|
|
||||||
texture_set.Delete(tex);
|
texture_set.Delete(tex);
|
||||||
texture_by_id.DeleteByKey(tex->GetID());
|
texture_by_id.DeleteByKey(tex->GetID());
|
||||||
texture_by_name.DeleteByValue(tex);
|
texture_by_filename.DeleteByValue(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D *CreateTexture2DFromFile(TextureManager *tm,const OSString &filename,bool auto_mipmaps);
|
Texture2D *CreateTexture2DFromFile(TextureManager *tm,const OSString &filename,bool auto_mipmaps);
|
||||||
@ -67,7 +67,7 @@ Texture2D *TextureManager::LoadTexture2D(const OSString &filename,bool auto_mipm
|
|||||||
{
|
{
|
||||||
Texture2D *tex;
|
Texture2D *tex;
|
||||||
|
|
||||||
if(texture_by_name.Get(filename,(Texture *&)tex))
|
if(texture_by_filename.Get(filename,(Texture *&)tex))
|
||||||
return tex;
|
return tex;
|
||||||
|
|
||||||
tex=CreateTexture2DFromFile(this,filename,auto_mipmaps);
|
tex=CreateTexture2DFromFile(this,filename,auto_mipmaps);
|
||||||
@ -132,7 +132,7 @@ TextureCube *TextureManager::LoadTextureCube(const OSString &filename,bool auto_
|
|||||||
{
|
{
|
||||||
TextureCube *tex;
|
TextureCube *tex;
|
||||||
|
|
||||||
if(texture_by_name.Get(filename,(Texture *&)tex))
|
if(texture_by_filename.Get(filename,(Texture *&)tex))
|
||||||
return tex;
|
return tex;
|
||||||
|
|
||||||
tex=CreateTextureCubeFromFile(this,filename,auto_mipmaps);
|
tex=CreateTextureCubeFromFile(this,filename,auto_mipmaps);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user