2018-06-21 05:45:17 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* OpenMiner
|
|
|
|
* Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
2018-06-21 05:45:17 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2018-06-21 05:45:17 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2018-06-21 05:45:17 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2018-06-21 05:45:17 +02:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
2018-12-29 02:23:23 +01:00
|
|
|
#include <gk/core/XMLFile.hpp>
|
|
|
|
#include <gk/gl/OpenGL.hpp>
|
|
|
|
#include <gk/gl/Texture.hpp>
|
|
|
|
#include <gk/resource/ResourceHandler.hpp>
|
|
|
|
|
2018-06-21 05:45:17 +02:00
|
|
|
#include "TextureLoader.hpp"
|
|
|
|
|
2018-12-29 02:23:23 +01:00
|
|
|
void TextureLoader::load(const char *xmlFilename, gk::ResourceHandler &handler) {
|
2018-12-29 23:24:38 +01:00
|
|
|
gk::XMLFile doc(xmlFilename);
|
2018-06-21 05:45:17 +02:00
|
|
|
|
|
|
|
tinyxml2::XMLElement *textureElement = doc.FirstChildElement("textures").FirstChildElement("texture").ToElement();
|
|
|
|
while (textureElement) {
|
|
|
|
std::string name = textureElement->Attribute("name");
|
|
|
|
std::string path = textureElement->Attribute("path");
|
|
|
|
|
2018-12-29 02:23:23 +01:00
|
|
|
auto &texture = handler.add<gk::Texture>("texture-" + name);
|
2018-06-21 05:45:17 +02:00
|
|
|
texture.loadFromFile(path);
|
|
|
|
|
2019-01-05 19:42:18 +01:00
|
|
|
// gk::Texture::bind(&texture);
|
|
|
|
// glGenerateMipmap(GL_TEXTURE_2D);
|
2019-01-05 05:41:18 +01:00
|
|
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
|
2019-01-05 19:42:18 +01:00
|
|
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4);
|
|
|
|
// gk::Texture::bind(nullptr);
|
2019-01-05 05:41:18 +01:00
|
|
|
|
2018-06-21 05:45:17 +02:00
|
|
|
textureElement = textureElement->NextSiblingElement("texture");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|