summaryrefslogtreecommitdiff
path: root/src/resources/atlas/atlasmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/atlas/atlasmanager.cpp')
-rw-r--r--src/resources/atlas/atlasmanager.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp
index 4e1b0e96c..353818d68 100644
--- a/src/resources/atlas/atlasmanager.cpp
+++ b/src/resources/atlas/atlasmanager.cpp
@@ -103,6 +103,38 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name,
return resource;
}
+AtlasResource *AtlasManager::loadEmptyAtlas(const std::string &name,
+ const StringVect &files)
+{
+ std::vector<TextureAtlas*> atlases;
+ std::vector<Image*> images;
+ AtlasResource *resource = new AtlasResource;
+
+ loadEmptyImages(files, images);
+ int maxSize = OpenGLImageHelper::getTextureSize();
+
+ // sorting images on atlases.
+ simpleSort(name, atlases, images, maxSize);
+
+ FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
+ {
+ TextureAtlas *const atlas = *it;
+ if (!atlas)
+ continue;
+
+ atlas->atlasImage = new Image(0,
+ 8192, 8192,
+ 8192, 8192);
+ // convert SDL images to OpenGL
+ convertAtlas(atlas);
+
+ resource->atlases.push_back(atlas);
+ }
+
+ BLOCK_END("AtlasManager::loadTextureAtlas")
+ return resource;
+}
+
void AtlasManager::loadImages(const StringVect &files,
std::vector<Image*> &images)
{
@@ -151,6 +183,33 @@ void AtlasManager::loadImages(const StringVect &files,
BLOCK_END("AtlasManager::loadImages")
}
+void AtlasManager::loadEmptyImages(const StringVect &files,
+ std::vector<Image*> &images)
+{
+ BLOCK_START("AtlasManager::loadEmptyImages")
+
+ FOR_EACH (StringVectCIter, it, files)
+ {
+ const std::string str = *it;
+ // check is image with same name already in cache
+ // and if yes, move it to deleted set
+ Resource *const res = resourceManager->getTempResource(str);
+ if (res)
+ {
+ // increase counter because in moveToDeleted it will be decreased.
+ res->incRef();
+ resourceManager->moveToDeleted(res);
+ }
+
+ Image *const image = new Image(0,
+ 2048, 2048,
+ 2048, 2048);
+ image->mIdPath = str;
+ images.push_back(image);
+ }
+ BLOCK_END("AtlasManager::loadEmptyImages")
+}
+
void AtlasManager::simpleSort(const std::string &restrict name,
std::vector<TextureAtlas*> &restrict atlases,
const std::vector<Image*> &restrict images,