OpenMiner/source/resource/TextureLoader.cpp
Quentin Bazin fb3f7f0501 Lot of changes. [...]
[Renderer] Deleted, code moved to Application.
[Transformable] Transformations are now applied to model matrix in applyTransform.
[ResourceHandler|TextureLoader|XMLFile] Added.
[Debug|Exception] Updated.
2018-06-21 05:45:17 +02:00

34 lines
985 B
C++

/*
* =====================================================================================
*
* Filename: TextureLoader.cpp
*
* Description:
*
* Created: 09/04/2018 01:38:03
*
* Author: Quentin Bazin, <quent42340@gmail.com>
*
* =====================================================================================
*/
#include "ResourceHandler.hpp"
#include "Texture.hpp"
#include "TextureLoader.hpp"
#include "XMLFile.hpp"
void TextureLoader::load(const char *xmlFilename, ResourceHandler &handler) {
XMLFile doc(xmlFilename);
tinyxml2::XMLElement *textureElement = doc.FirstChildElement("textures").FirstChildElement("texture").ToElement();
while (textureElement) {
std::string name = textureElement->Attribute("name");
std::string path = textureElement->Attribute("path");
auto &texture = handler.add<Texture>("texture-" + name);
texture.loadFromFile(path);
textureElement = textureElement->NextSiblingElement("texture");
}
}