From 135c19b4337e1ab45cff40a306eadc52a061ddef Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 13 Aug 2012 22:18:03 +0300 Subject: add atlas textures support. --- src/resources/resourcemanager.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/resources/resourcemanager.cpp') 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(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(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; -- cgit v1.2.3-60-g2f50