From 4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Thu, 18 May 2017 19:03:05 +0500 Subject: 2017-05-18 --- src/graphics/Texture.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/graphics/Texture.cpp (limited to 'src/graphics/Texture.cpp') diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp new file mode 100644 index 0000000..0104530 --- /dev/null +++ b/src/graphics/Texture.cpp @@ -0,0 +1,39 @@ +#include +#include +#include "Texture.hpp" + +Texture::Texture(std::string filename, GLenum textureWrapping, GLenum textureFiltering) { + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + + //Texture options + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapping); + + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,textureFiltering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + //Image load + sf::Image image; + if (!image.loadFromFile(filename)) { + std::cout << "Can't open image " << filename << std::endl; + throw 201; + } + if (image.getPixelsPtr()==nullptr){ + std::cout<<"Image data is corrupted!"<