From 60072c1d8089ffd3294e76636198d14710be95b8 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 9 Sep 2017 07:55:22 +0100 Subject: Restructuring --- src/imageloader.cpp | 60 ----------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/imageloader.cpp (limited to 'src/imageloader.cpp') diff --git a/src/imageloader.cpp b/src/imageloader.cpp deleted file mode 100644 index 812110d8..00000000 --- a/src/imageloader.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* ---------------------------------------------------------------------------- - * imageloader.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#include -#include -#include - -#include - -namespace yage -{ - -Texture ImageLoader::loadPng(const std::string &file_path) -{ - Texture texture = {}; - - std::vector in; - std::vector 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)); - } - - 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); - - texture.width = (int)width; - texture.height = (int)height; - - return texture; -} - -} // namespace yage -- cgit