xoreos  0.0.5
textureman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_TEXTUREMAN_H
26 #define GRAPHICS_AURORA_TEXTUREMAN_H
27 
28 #include <set>
29 #include <list>
30 
31 #include "src/common/types.h"
32 #include "src/common/singleton.h"
33 #include "src/common/mutex.h"
34 #include "src/common/ustring.h"
35 
37 
38 namespace Graphics {
39 
40 namespace Aurora {
41 
43 class TextureManager : public Common::Singleton<TextureManager> {
44 public:
46  enum TextureMode {
49  };
50 
53 
54  // .--- Texture management
56  void clear();
57 
62  void addBogusTexture(const Common::UString &name);
63 
72  void setDeswizzleSBM(bool deswizzle);
73 
75  bool hasTexture(const Common::UString &name);
76 
78  TextureHandle add(Texture *texture, Common::UString name = "");
83 
87  void stopRecordNewTextures(std::list<Common::UString> &newTextures);
88 
90  void reloadAll();
91  // '---
92 
93  // .--- Texture rendering
95  void set(const TextureHandle &handle, TextureMode mode = kModeDiffuse);
97  void set();
99  void reset();
100 
102  void activeTexture(size_t n);
103  // '---
104 
105 private:
108 
109  std::set<Common::UString> _bogusTextures;
110 
112 
114  std::list<Common::UString> _newTextureNames;
115 
116  void assign(TextureHandle &texture, const TextureHandle &from);
117  void release(TextureHandle &texture);
118 
119  friend class TextureHandle;
120 };
121 
122 } // End of namespace Aurora
123 
124 } // End of namespace Graphics
125 
127 #define TextureMan Graphics::Aurora::TextureManager::instance()
128 
129 #endif // GRAPHICS_AURORA_TEXTUREMAN_H
TextureHandle getIfExist(const Common::UString &name)
Retrieve this named texture, returning an empty handle if it&#39;s not managed.
Definition: textureman.cpp:178
void assign(TextureHandle &texture, const TextureHandle &from)
Definition: textureman.cpp:207
Class and macro for implementing singletons.
bool hasTexture(const Common::UString &name)
Does this named managed texture exist?
Definition: textureman.cpp:115
A class holding an UTF-8 string.
Definition: ustring.h:48
std::map< Common::UString, ManagedTexture * > TextureMap
Definition: texturehandle.h:48
The global Aurora texture manager.
Definition: textureman.h:43
void release(TextureHandle &texture)
Definition: textureman.cpp:217
void startRecordNewTextures()
Start recording all names of newly created textures.
Definition: textureman.cpp:191
A handle to an Aurora texture.
void clear()
Remove and delete all managed textures.
Definition: textureman.cpp:90
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
A mutex.
Definition: mutex.h:40
std::set< Common::UString > _bogusTextures
Definition: textureman.h:109
void setDeswizzleSBM(bool deswizzle)
Do we need to deswizzle SBM images?
Definition: textureman.cpp:111
Low-level type definitions to handle fixed width types portably.
void reset()
Completely reset the texture rendering.
Definition: textureman.cpp:248
TextureMode
The mode/usage of a specific texture.
Definition: textureman.h:46
TextureHandle add(Texture *texture, Common::UString name="")
Add this texture to the TextureManager.
Definition: textureman.cpp:126
Unicode string handling.
Thread mutex classes.
void addBogusTexture(const Common::UString &name)
Add the name of a texture that doesn&#39;t really exist.
Definition: textureman.cpp:105
std::list< Common::UString > _newTextureNames
Definition: textureman.h:114
void activeTexture(size_t n)
Set this texture unit as the current one.
Definition: textureman.cpp:327
void stopRecordNewTextures(std::list< Common::UString > &newTextures)
Stop the recording of texture names, and return a list of previously recorded names.
Definition: textureman.cpp:198
A handle to a texture.
Definition: texturehandle.h:51
void reloadAll()
Reload and rebuild all managed textures, if possible.
Definition: textureman.cpp:231