| 5 | namespace Texture |
| 6 | { |
| 7 | bool Basic_Texture::loadFromFile(const std::string& fileName) |
| 8 | { |
| 9 | clear(); |
| 10 | std::string filePath = "Data/Textures/" + fileName + ".png"; |
| 11 | |
| 12 | sf::Image image; |
| 13 | if (!image.loadFromFile(filePath)) |
| 14 | { |
| 15 | return false; |
| 16 | } |
| 17 | |
| 18 | glGenTextures(1, &m_textureID); |
| 19 | glBindTexture(GL_TEXTURE_2D, m_textureID); |
| 20 | |
| 21 | //glGenerateMipmap(GL_TEXTURE_2D); |
| 22 | glTexImage2D(GL_TEXTURE_2D, |
| 23 | 0, |
| 24 | GL_RGBA, |
| 25 | image.getSize().x, |
| 26 | image.getSize().y, |
| 27 | 0, |
| 28 | GL_RGBA, |
| 29 | GL_UNSIGNED_BYTE, |
| 30 | image.getPixelsPtr()); |
| 31 | |
| 32 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 33 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 34 | |
| 35 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 36 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | Basic_Texture::~Basic_Texture() |
| 42 | { |