MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / TextureResource

Method TextureResource

src/server/gui/core/resources/TextureResource.cpp:10–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8std::set<TextureResource*> TextureResource::sAllTextures;
9
10TextureResource::TextureResource(const std::string& path, bool tile, bool dynamic) : mTextureData(nullptr), mSize(0.0f, 0.0f), mSourceSize(0.0f, 0.0f), mForceLoad(false)
11{
12 // Create a texture data object for this texture
13 if (!path.empty())
14 {
15 // If there is a path then the 'dynamic' flag tells us whether to use the texture
16 // data manager to manage loading/unloading of this texture
17 std::shared_ptr<TextureData> data;
18 if (dynamic)
19 {
20 data = sTextureDataManager.add(this, tile);
21 data->initFromPath(path);
22 // Force the texture manager to load it using a blocking load
23 sTextureDataManager.load(data, true);
24 }
25 else
26 {
27 mTextureData = std::shared_ptr<TextureData>(new TextureData(tile));
28 data = mTextureData;
29 data->initFromPath(path);
30 // Load it so we can read the width/height
31 data->load();
32 }
33
34 mSize = Vector2i((int)data->width(), (int)data->height());
35 mSourceSize = Vector2f(data->sourceWidth(), data->sourceHeight());
36 }
37 else
38 {
39 // Create a texture managed by this class because it cannot be dynamically loaded and unloaded
40 mTextureData = std::shared_ptr<TextureData>(new TextureData(tile));
41 }
42 sAllTextures.insert(this);
43}
44
45TextureResource::~TextureResource()
46{

Callers

nothing calls this directly

Calls 10

initFromPathMethod · 0.80
sourceWidthMethod · 0.80
sourceHeightMethod · 0.80
Vector2iClass · 0.50
Vector2fClass · 0.50
emptyMethod · 0.45
addMethod · 0.45
loadMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected