MCPcopy Create free account
hub / github.com/Hopson97/HopsonCraft / loadFromFile

Method loadFromFile

Source/Texture/Texture.cpp:7–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace 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 {

Callers 5

loadMethod · 0.45
addMethod · 0.45
ComponentMethod · 0.45
Imaged_ButtonMethod · 0.45
ImageMethod · 0.45

Calls 2

clearFunction · 0.85
getSizeMethod · 0.45

Tested by

no test coverage detected