Clear up function parameters
This commit is contained in:
parent
7496609bfa
commit
964bb95445
@ -1326,10 +1326,8 @@ void B3DMeshLoader::loadTextures(SB3dMaterial& material, scene::IMeshBuffer* mb)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
TexConfig mtc(i <= 1 ? true : false/*srgb*/, false/*premul_alpha*/,
|
||||
true/*mesh_tex*/, true/*set_material*/);
|
||||
video::ITexture* tex = STKTexManager::getInstance()->getTexture
|
||||
(full_path.c_str(), &mtc);
|
||||
(full_path.c_str());
|
||||
material.Material.setTexture(i, tex);
|
||||
}
|
||||
if (material.Textures[i]->Flags & 0x10) // Clamp U
|
||||
|
@ -1637,33 +1637,19 @@ void IrrDriver::removeCameraSceneNode(scene::ICameraSceneNode *camera)
|
||||
* getTexture() function.s
|
||||
* \param type The FileManager::AssetType of the texture.
|
||||
* \param filename File name of the texture to load.
|
||||
* \param is_premul If the alpha values needd to be multiplied for
|
||||
* all pixels.
|
||||
* \param is_prediv If the alpha value needs to be divided into
|
||||
* each pixel.
|
||||
*/
|
||||
video::ITexture *IrrDriver::getTexture(FileManager::AssetType type,
|
||||
const std::string &filename,
|
||||
bool is_premul,
|
||||
bool is_prediv,
|
||||
bool complain_if_not_found)
|
||||
const std::string &filename)
|
||||
{
|
||||
const std::string path = file_manager->getAsset(type, filename);
|
||||
return getTexture(path, is_premul, is_prediv, complain_if_not_found);
|
||||
return getTexture(path);
|
||||
} // getTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Loads a texture from a file and returns the texture object.
|
||||
* \param filename File name of the texture to load.
|
||||
* \param is_premul If the alpha values needd to be multiplied for
|
||||
* all pixels.
|
||||
* \param is_prediv If the alpha value needs to be divided into
|
||||
* each pixel.
|
||||
*/
|
||||
video::ITexture *IrrDriver::getTexture(const std::string &filename,
|
||||
bool is_premul,
|
||||
bool is_prediv,
|
||||
bool complain_if_not_found)
|
||||
video::ITexture *IrrDriver::getTexture(const std::string &filename)
|
||||
{
|
||||
return STKTexManager::getInstance()->getTexture(filename);
|
||||
} // getTexture
|
||||
|
@ -218,14 +218,8 @@ public:
|
||||
void setAmbientLight(const video::SColorf &light,
|
||||
bool force_SH_computation = true);
|
||||
video::ITexture *getTexture(FileManager::AssetType type,
|
||||
const std::string &filename,
|
||||
bool is_premul=false,
|
||||
bool is_prediv=false,
|
||||
bool complain_if_not_found=true);
|
||||
video::ITexture *getTexture(const std::string &filename,
|
||||
bool is_premul=false,
|
||||
bool is_prediv=false,
|
||||
bool complain_if_not_found=true);
|
||||
const std::string &filename);
|
||||
video::ITexture *getTexture(const std::string &filename);
|
||||
void grabAllTextures(const scene::IMesh *mesh);
|
||||
void dropAllTextures(const scene::IMesh *mesh);
|
||||
scene::IMesh *createQuadMesh(const video::SMaterial *material=NULL,
|
||||
|
@ -500,9 +500,7 @@ void Material::install(bool srgb, bool premul_alpha)
|
||||
}
|
||||
else
|
||||
{
|
||||
TexConfig tc(srgb, premul_alpha, srgb/*mesh_tex*/);
|
||||
m_texture = STKTexManager::getInstance()
|
||||
->getTexture(m_sampler_path[0], &tc);
|
||||
m_texture = STKTexManager::getInstance()->getTexture(m_sampler_path[0]);
|
||||
}
|
||||
|
||||
if (m_texture == NULL) return;
|
||||
|
@ -58,9 +58,7 @@ STKTexture* STKTexManager::findTextureInFileSystem(const std::string& filename,
|
||||
} // findTextureInFileSystem
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
video::ITexture* STKTexManager::getTexture(const std::string& path,
|
||||
TexConfig* tc, bool no_upload,
|
||||
bool create_if_unfound)
|
||||
video::ITexture* STKTexManager::getTexture(const std::string& path)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
@ -69,7 +67,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path,
|
||||
}
|
||||
|
||||
auto ret = m_all_textures.find(path);
|
||||
if (!no_upload && ret != m_all_textures.end())
|
||||
if (ret != m_all_textures.end())
|
||||
return ret->second;
|
||||
|
||||
STKTexture* new_texture = NULL;
|
||||
@ -79,15 +77,12 @@ video::ITexture* STKTexManager::getTexture(const std::string& path,
|
||||
new_texture = findTextureInFileSystem(path, &full_path);
|
||||
if (full_path.empty())
|
||||
return NULL;
|
||||
if (!no_upload && new_texture)
|
||||
if (new_texture)
|
||||
return new_texture;
|
||||
}
|
||||
|
||||
if (create_if_unfound)
|
||||
{
|
||||
new_texture = new STKTexture(full_path.empty() ? path : full_path,
|
||||
tc, no_upload);
|
||||
if (new_texture->getTextureHandler() == 0 && !no_upload)
|
||||
new_texture = new STKTexture(full_path.empty() ? path : full_path, NULL);
|
||||
if (new_texture->getTextureHandler() == 0)
|
||||
{
|
||||
const char* name = new_texture->getName().getPtr();
|
||||
if (!m_texture_error_message.empty())
|
||||
@ -101,9 +96,7 @@ video::ITexture* STKTexManager::getTexture(const std::string& path,
|
||||
delete new_texture;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (create_if_unfound && !no_upload)
|
||||
addTexture(new_texture);
|
||||
return new_texture;
|
||||
} // getTexture
|
||||
@ -183,3 +176,29 @@ int STKTexManager::dumpTextureUsage()
|
||||
Log::info("STKTexManager", "Total %dMB", size);
|
||||
return size;
|
||||
} // dumpTextureUsage
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool STKTexManager::hasTexture(const std::string& path)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
Log::error("STKTexManager", "Texture name is empty.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = m_all_textures.find(path);
|
||||
if (ret != m_all_textures.end())
|
||||
return true;
|
||||
|
||||
video::ITexture* new_texture = NULL;
|
||||
std::string full_path;
|
||||
if (path.find('/') == std::string::npos)
|
||||
{
|
||||
new_texture = findTextureInFileSystem(path, &full_path);
|
||||
if (full_path.empty())
|
||||
return false;
|
||||
if (new_texture)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // hasTexture
|
||||
|
@ -74,13 +74,12 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
~STKTexManager();
|
||||
// ------------------------------------------------------------------------
|
||||
irr::video::ITexture* getTexture(const std::string& path,
|
||||
TexConfig* tc = NULL,
|
||||
bool no_upload = false,
|
||||
bool create_if_unfound = true);
|
||||
irr::video::ITexture* getTexture(const std::string& path);
|
||||
// ------------------------------------------------------------------------
|
||||
irr::video::ITexture* addTexture(STKTexture* texture);
|
||||
// ------------------------------------------------------------------------
|
||||
bool hasTexture(const std::string& path);
|
||||
// ------------------------------------------------------------------------
|
||||
void removeTexture(STKTexture* texture, bool remove_all = false);
|
||||
// ------------------------------------------------------------------------
|
||||
int dumpTextureUsage();
|
||||
|
@ -374,9 +374,7 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
|
||||
std::string name = stk_tex->getName().getPtr();
|
||||
name += "_disabled";
|
||||
STKTexManager* stkm = STKTexManager::getInstance();
|
||||
STKTexture* disabled_stk_tex = static_cast<STKTexture*>(stkm->getTexture
|
||||
(name, NULL/*tc*/, false /*no_upload*/, false/*create_if_unfound*/));
|
||||
if (disabled_stk_tex == NULL)
|
||||
if (!stkm->hasTexture(name))
|
||||
{
|
||||
SColor c;
|
||||
u32 g;
|
||||
@ -400,7 +398,7 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
|
||||
}
|
||||
return stkm->addTexture(new STKTexture(image, name));
|
||||
}
|
||||
return disabled_stk_tex;
|
||||
return stkm->getTexture(name);
|
||||
#else
|
||||
return texture;
|
||||
#endif // !SERVER_ONLY
|
||||
|
Loading…
Reference in New Issue
Block a user