Simulant  21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
wal_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 WAL_LOADER_H
20 #define WAL_LOADER_H
21 
22 /*
23  * Texture loader for Quake 2 WAL textures
24  */
25 
26 #include "../loader.h"
27 
28 namespace smlt {
29 namespace loaders {
30 
31 class WALLoader : public BaseTextureLoader {
32 public:
33  WALLoader(const Path& filename, std::shared_ptr<std::istream> data):
34  BaseTextureLoader(filename, data) {}
35 
36 private:
37  bool format_stored_upside_down() const override { return false; }
38  TextureLoadResult do_load(std::shared_ptr<FileIfstream> stream) override;
39 };
40 
41 class WALLoaderType : public LoaderType {
42 public:
43  WALLoaderType() {
44  // Always add the texture hint
45  add_hint(LOADER_HINT_TEXTURE);
46  }
47 
48  virtual ~WALLoaderType() {}
49 
50  const char* name() override { return "wal_texture"; }
51  bool supports(const Path& filename) const override {
52  return filename.ext() == ".wal";
53  }
54 
55  Loader::ptr loader_for(const Path& filename, std::shared_ptr<std::istream> data) const override {
56  return Loader::ptr(new WALLoader(filename, data));
57  }
58 };
59 
60 }
61 }
62 
63 #endif // WAL_LOADER_H
smlt::TextureLoadResult
Definition: loader.h:133
smlt
Definition: animation.cpp:25
smlt::LoaderType
Definition: loader.h:111
smlt::loaders::WALLoaderType
Definition: wal_loader.h:41
smlt::loaders::BaseTextureLoader
Definition: loader.h:143
smlt::Path
Definition: path.h:7
smlt::loaders::WALLoader
Definition: wal_loader.h:31