diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-13 22:18:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-30 02:57:13 +0300 |
commit | 135c19b4337e1ab45cff40a306eadc52a061ddef (patch) | |
tree | 0a163ca1edd542aec5570b7e451034aafb4089dd /src/resources/resourcemanager.cpp | |
parent | 3a2bab265768c219b0c077eef10b69dfe8158131 (diff) | |
download | manaplus-135c19b4337e1ab45cff40a306eadc52a061ddef.tar.gz manaplus-135c19b4337e1ab45cff40a306eadc52a061ddef.tar.bz2 manaplus-135c19b4337e1ab45cff40a306eadc52a061ddef.tar.xz manaplus-135c19b4337e1ab45cff40a306eadc52a061ddef.zip |
add atlas textures support.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 9f2947dfc..5270e6f60 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -27,11 +27,13 @@ #include "configuration.h" #include "logger.h" +#include "resources/atlasmanager.h" #include "resources/dye.h" #include "resources/image.h" #include "resources/imagehelper.h" #include "resources/imageset.h" #include "resources/music.h" +#include "resources/openglimagehelper.h" #include "resources/soundeffect.h" #include "resources/spritedef.h" @@ -652,6 +654,32 @@ Image *ResourceManager::getSubImage(Image *const parent, return static_cast<Image*>(get(ss.str(), SubImageLoader::load, &rl)); } +struct AtlasLoader +{ + const std::string name; + const StringVect *files; + + static Resource *load(const void *const v) + { + if (!v) + return nullptr; + + const AtlasLoader *const rl = static_cast<const AtlasLoader *const>(v); + AtlasResource *const resource = AtlasManager::loadTextureAtlas( + rl->name, *rl->files); + AtlasManager::injectToResources(resource); + return resource; + } +}; + +Resource *ResourceManager::getAtlas(const std::string &name, + const StringVect &files) +{ + AtlasLoader rl = { name, &files }; + + return get("atlas_" + name, AtlasLoader::load, &rl); +} + struct SpriteDefLoader { std::string path; |