Exemple #1
0
	bool TextureAtlas::load()
	{
		if (mLoaded)
		{
			return true;
		}

		XML::Document xml(mPath);

		if (!xml.isValid())
		{
			return false;
		}

		XML::Element e = xml.getElement("atlas");
		std::string texturePath = e.attribute("texture");
		GL_TextureManager::get().loadTexture(texturePath);
		mTexture = GL_TextureManager::get().acquireTexture(texturePath);

		for (e = e.first(); e.isValid(); e = e.next())
		{
			std::string key = e.name();

			if (key.compare("image") == 0)
			{
				ImageRect imageRect;
				e.attribute("x", imageRect.x);
				e.attribute("y", imageRect.y);
				e.attribute("w", imageRect.w);
				e.attribute("h", imageRect.h);
				mImageMap[e.attribute("name")] = imageRect;
			}
		}

		mLoaded = true;
		return true;

	}
Exemple #2
0
// Read a hex + alpha colour from xml //
Colour Loader::readColour(const XML::Element& e) const {
	const char* s = e.attribute("colour", "ffffff");
	Colour c = Loader::parseHex(s);
	c.a = e.attribute("alpha", 1.0f);
	return c;
}