Esempio n. 1
0
bool RenderObject::setTexture(const std::string &n)
{
	std::string name = n;
	stringToLowerUserData(name);

	if (name.empty())
		return false;

	if(texture && name == texture->name)
		return true; // no texture change

	TextureLoadResult res = TEX_FAILED;
	CountedPtr<Texture> tex = core->addTexture(name, &res);
	setTexturePointer(tex);
	return !!tex && res != TEX_FAILED;
}
void RenderObject::setTexture(const std::string &n)
{
	std::string name = n;
	stringToLowerUserData(name);

	if (name.empty())
        return;

    if(texture && texture->name == core->getInternalTextureName(name))
        return; // no texture change

    Texture *oldtex = texture;
	Texture *t = core->addTexture(name);
	setTexturePointer(t, NO_ADD_REF);

    if (oldtex)
        oldtex->removeRef();
}