xoreos  0.0.5
texture.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_TEXTURE_H
26 #define GRAPHICS_AURORA_TEXTURE_H
27 
28 #include "src/common/scopedptr.h"
29 #include "src/common/ustring.h"
30 
31 #include "src/graphics/types.h"
32 #include "src/graphics/texture.h"
33 
34 #include "src/aurora/types.h"
35 
36 namespace Common {
37  class SeekableReadStream;
38 }
39 
40 namespace Graphics {
41 
42 class ImageDecoder;
43 class TXI;
44 
45 namespace Aurora {
46 
48 class Texture : public Graphics::Texture {
49 public:
50  virtual ~Texture();
51 
52  uint32 getWidth() const;
53  uint32 getHeight() const;
54 
55  bool hasAlpha() const;
56 
58  virtual bool isDynamic() const;
59 
61  const TXI &getTXI() const;
63  const ImageDecoder &getImage() const;
64 
66  virtual bool reload();
67 
69  bool dumpTGA(const Common::UString &fileName) const;
70 
71 
73  static ImageDecoder *loadImage(const Common::UString &name, bool deswizzle = false);
75  static ImageDecoder *loadImage(const Common::UString &name, ::Aurora::FileType &type,
76  bool deswizzle = false);
77 
79  static Texture *create(const Common::UString &name, bool deswizzle = false);
82  TXI *txi = 0, bool deswizzle = false);
83 
84 
85 protected:
88 
91 
94 
95  bool _deswizzle;
96 
97 
98  Texture();
99  Texture(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi = 0,
100  bool deswizzle = false);
101 
102  void set(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi,
103  bool deswizzle = false);
104 
105  void addToQueues();
106  void removeFromQueues();
107  void refresh();
108 
109 
110  // GLContainer
111  void doRebuild();
112  void doDestroy();
113 
114 
115  void create2DTexture();
116  void createCubeMapTexture();
117 
118  void setWrap(GLenum target, GLint wrapModeX, GLint wrapModeY);
119  void setAlign();
120  void setFilter(GLenum target);
121  void setMipMaps(GLenum target);
122  void setMipMapData(GLenum target, size_t layer, size_t mipMap);
123 
124  static TXI *loadTXI(const Common::UString &name);
126  TXI *txi = 0, bool deswizzle = false);
127 
128  static ImageDecoder *loadImage(const Common::UString &name, ::Aurora::FileType &type, TXI *txi,
129  bool deswizzle = false);
130 
131  static Texture *createPLT(const Common::UString &name, Common::SeekableReadStream *imageStream);
132 };
133 
134 } // End of namespace Aurora
135 
136 } // End of namespace Graphics
137 
138 #endif // GRAPHICS_AURORA_TEXTURE_H
bool hasAlpha() const
Definition: texture.cpp:84
const TXI & getTXI() const
Return the TXI.
Definition: texture.cpp:96
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
static Texture * createPLT(const Common::UString &name, Common::SeekableReadStream *imageStream)
Definition: texture.cpp:310
void setMipMapData(GLenum target, size_t layer, size_t mipMap)
Definition: texture.cpp:244
static Texture * create(const Common::UString &name, bool deswizzle=false)
Create a texture from this image resource.
Definition: texture.cpp:323
static TXI * loadTXI(const Common::UString &name)
Definition: texture.cpp:502
uint32 getHeight() const
Definition: texture.cpp:80
Basic graphics types.
A texture.
Definition: texture.h:34
Virtual base class of a texture.
A simple scoped smart pointer template.
const ImageDecoder & getImage() const
Return the image.
Definition: texture.cpp:106
Common::ScopedPtr< TXI > _txi
The TXI.
Definition: texture.h:90
static ImageDecoder * loadImage(const Common::UString &name, bool deswizzle=false)
Load an image in any of the common texture formats.
Definition: texture.cpp:401
void setFilter(GLenum target)
Definition: texture.cpp:216
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
Common::UString _name
The name of the texture&#39;s image&#39;s file.
Definition: texture.h:86
uint32 getWidth() const
Definition: texture.cpp:76
virtual bool isDynamic() const
Is this a dynamic texture, or a shared static one?
Definition: texture.cpp:91
Unicode string handling.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
bool dumpTGA(const Common::UString &fileName) const
Dump the texture into a TGA.
Definition: texture.cpp:139
uint32_t uint32
Definition: types.h:204
Texture information.
Definition: txi.h:40
FileType
Various file types used by the Aurora engine and found in archives.
Definition: types.h:56
A generic interface for image decoders.
Definition: decoder.h:48
virtual bool reload()
Try to reload the texture.
Definition: texture.cpp:112
void setMipMaps(GLenum target)
Definition: texture.cpp:228
::Aurora::FileType _type
The type of the texture&#39;s image&#39;s file.
Definition: texture.h:87
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void setWrap(GLenum target, GLint wrapModeX, GLint wrapModeY)
Definition: texture.cpp:172
Common::ScopedPtr< ImageDecoder > _image
The actual image.
Definition: texture.h:89