GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/loaders/atlasloader.cpp Lines: 0 11 0.0 %
Date: 2017-11-29 Branches: 0 10 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#ifdef USE_OPENGL
22
23
#include "resources/atlas/atlasmanager.h"
24
#include "resources/atlas/atlasresource.h"
25
26
#include "resources/loaders/atlasloader.h"
27
28
#include "resources/resourcemanager/resourcemanager.h"
29
30
#include "utils/checkutils.h"
31
32
#include "debug.h"
33
34
struct AtlasLoader final
35
{
36
    A_DEFAULT_COPY(AtlasLoader)
37
38
    const std::string name;
39
    const StringVect *const files;
40
41
    static Resource *load(const void *const v)
42
    {
43
        if (v == nullptr)
44
            return nullptr;
45
46
        const AtlasLoader *const rl = static_cast<const AtlasLoader *>(v);
47
        AtlasResource *const resource = AtlasManager::loadTextureAtlas(
48
            rl->name, *rl->files);
49
        if (resource == nullptr)
50
            reportAlways("Atlas creation error: %s", rl->name.c_str());
51
        return resource;
52
    }
53
};
54
55
Resource *Loader::getAtlas(const std::string &name,
56
                           const StringVect &files)
57
{
58
    AtlasLoader rl = { name, &files };
59
    return ResourceManager::get("atlas_" + name, AtlasLoader::load, &rl);
60
}
61
62
#endif  // USE_OPENGL