MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / initFromResource

Method initFromResource

src/resources/TextureResource.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void TextureResource::initFromResource(const ResourceData data)
32{
33 //make sure we aren't going to leak an old texture
34 deinit();
35
36 size_t width, height;
37 std::vector<unsigned char> imageRGBA = ImageIO::loadFromMemoryRGBA32(const_cast<unsigned char*>(data.ptr.get()), data.length, width, height);
38
39 if(imageRGBA.size() == 0)
40 {
41 LOG(LogError) << "Could not initialize texture (invalid resource data)!";
42 return;
43 }
44
45 //now for the openGL texture stuff
46 glGenTextures(1, &mTextureID);
47 glBindTexture(GL_TEXTURE_2D, mTextureID);
48
49 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageRGBA.data());
50
51 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
52 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
53
54 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
55 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
56
57 mTextureSize << width, height;
58}
59
60void TextureResource::initFromScreen()
61{

Callers

nothing calls this directly

Calls 4

dataMethod · 0.80
deinitFunction · 0.50
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected