Simulant  21.12-246
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
texture_loader.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef SIMULANT_TGA_LOADER_H
20 #define SIMULANT_TGA_LOADER_H
21 
22 #include "../threads/mutex.h"
23 #include "../loader.h"
24 
25 namespace smlt {
26 namespace loaders {
27 
29 public:
30  TextureLoader(const Path& filename, std::shared_ptr<std::istream> data):
31  BaseTextureLoader(filename, data) {}
32 
33 private:
34  TextureLoadResult do_load(std::shared_ptr<FileIfstream> stream) override;
35 
36  thread::Mutex lock_;
37 };
38 
39 class TextureLoaderType : public LoaderType {
40 public:
42  // Always add the texture hint
43  add_hint(LOADER_HINT_TEXTURE);
44  }
45 
46  virtual ~TextureLoaderType() {}
47 
48  const char* name() override { return "texture"; }
49  bool supports(const Path& filename) const override {
50  return filename.ext() == ".tga" || filename.ext() == ".png" || filename.ext() == ".jpg";
51  }
52 
53  Loader::ptr loader_for(const Path& filename, std::shared_ptr<std::istream> data) const override {
54  return Loader::ptr(new TextureLoader(filename, data));
55  }
56 };
57 
58 }
59 }
60 
61 #endif
smlt::loaders::TextureLoaderType
Definition: texture_loader.h:39
smlt::TextureLoadResult
Definition: loader.h:133
smlt
Definition: animation.cpp:25
smlt::LoaderType
Definition: loader.h:111
smlt::loaders::BaseTextureLoader
Definition: loader.h:143
smlt::Path
Definition: path.h:7
smlt::thread::Mutex
Definition: mutex.h:25
smlt::loaders::TextureLoader
Definition: texture_loader.h:28