diff options
author | TravisBot <> | 2017-09-21 23:52:57 +0000 |
---|---|---|
committer | TravisBot <> | 2017-09-21 23:52:57 +0000 |
commit | 43d8d9b5de8f269643c380d8d6c6c65d9224ad4a (patch) | |
tree | b8a9546cb663081e4587f812fa49a228be9978e5 /yage/base/imageloader.cpp | |
parent | ad666428488d3c800ca18d877dad803bf18b8168 (diff) | |
download | YAGE-43d8d9b5de8f269643c380d8d6c6c65d9224ad4a.tar.gz YAGE-43d8d9b5de8f269643c380d8d6c6c65d9224ad4a.zip |
Rebuilding documentation
Diffstat (limited to 'yage/base/imageloader.cpp')
-rw-r--r-- | yage/base/imageloader.cpp | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/yage/base/imageloader.cpp b/yage/base/imageloader.cpp deleted file mode 100644 index 0d7d5df9..00000000 --- a/yage/base/imageloader.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* ---------------------------------------------------------------------------- - * imageloader.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#include <yage/base/imageloader.h> -#include <yage/base/iomanager.h> -#include <yage/base/picopng.h> - -#include <stdexcept> - -namespace yage -{ - -Texture ImageLoader::loadPng(const std::string &file_path) -{ - std::vector<unsigned char> in; - std::vector<unsigned char> out; - unsigned long width, height; - - if (!IoManager::readFileToBuffer(file_path, in)) { - throw std::runtime_error("Failed to load '" + file_path + - "' to buffer"); - } - - int error_code = decodePNG(out, width, height, &in[0], in.size()); - if (error_code != 0) { - throw std::runtime_error("Failed to load '" + file_path + - "' to png with error code" + - std::to_string(error_code)); - } - - Texture texture{0, (int)width, (int)height}; - - glGenTextures(1, &texture.id); - - glBindTexture(GL_TEXTURE_2D, texture.id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, - GL_UNSIGNED_BYTE, &out[0]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_LINEAR); - - glGenerateMipmap(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, 0); - - return texture; -} - -} // namespace yage |