(TextSprite) Added atlas storage check

Former-commit-id: f9d222e196a0ef1aebcfd2baf8b425f55f852a9a
This commit is contained in:
Lynix 2015-01-17 23:00:56 +01:00
parent 9662f4167d
commit f9345dc5fe
1 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/TextSprite.hpp> #include <Nazara/Graphics/TextSprite.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/SparsePtr.hpp> #include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Graphics/AbstractViewer.hpp> #include <Nazara/Graphics/AbstractViewer.hpp>
#include <memory> #include <memory>
@ -129,10 +130,26 @@ void NzTextSprite::SetText(const NzAbstractTextDrawer& drawer)
{ {
ClearAtlases(); ClearAtlases();
NzCallOnExit clearOnFail([this]()
{
Clear();
});
unsigned int fontCount = drawer.GetFontCount(); unsigned int fontCount = drawer.GetFontCount();
for (unsigned int i = 0; i < fontCount; ++i) for (unsigned int i = 0; i < fontCount; ++i)
{ {
const NzAbstractAtlas* atlas = drawer.GetFont(i)->GetAtlas().get(); NzFont* font = drawer.GetFont(i);
const NzAbstractAtlas* atlas = font->GetAtlas().get();
#if NAZARA_GRAPHICS_SAFE
if ((atlas->GetStorage() & nzDataStorage_Hardware) == 0)
{
// Cet atlas ne nous donnera pas de texture, nous ne pouvons pas l'utiliser
NazaraError("Font " + NzString::Pointer(font) + " uses a non-hardware atlas which cannot be used by text sprites");
return;
}
#endif
if (m_atlases.insert(atlas).second) if (m_atlases.insert(atlas).second)
atlas->AddListener(this); atlas->AddListener(this);
} }
@ -233,6 +250,8 @@ void NzTextSprite::SetText(const NzAbstractTextDrawer& drawer)
m_boundingVolume.MakeNull(); m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = false; m_boundingVolumeUpdated = false;
m_verticesUpdated = false; m_verticesUpdated = false;
clearOnFail.Reset();
} }
NzTextSprite& NzTextSprite::operator=(const NzTextSprite& text) NzTextSprite& NzTextSprite::operator=(const NzTextSprite& text)