| 8 | std::set<TextureResource*> TextureResource::sAllTextures; |
| 9 | |
| 10 | TextureResource::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 | |
| 45 | TextureResource::~TextureResource() |
| 46 | { |
nothing calls this directly
no test coverage detected