1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * This program 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 2
10  * of the License, or (at your option) 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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef STARK_FORMATS_TM_H
24 #define STARK_FORMATS_TM_H
25 
26 #include "engines/stark/formats/biff.h"
27 
28 #include "common/str.h"
29 #include "graphics/surface.h"
30 
31 namespace Stark {
32 
33 class ArchiveReadStream;
34 
35 namespace Gfx {
36 class TextureSet;
37 class Texture;
38 }
39 
40 namespace Formats {
41 
42 /**
43  * A texture set loader able to read '.tm' files
44  */
45 class TextureSetReader {
46 public:
47 	/**
48 	 * Load a texture set from the provided stream.
49 	 *
50 	 * The caller is responsible for freeing the texture set.
51 	 */
52 	static Gfx::TextureSet *read(ArchiveReadStream *stream);
53 
54 	/** Read the texture set archive from the provided stream */
55 	static BiffArchive *readArchive(ArchiveReadStream *stream);
56 
57 private:
58 	static BiffObject *biffObjectBuilder(uint32 type);
59 
60 };
61 
62 enum TextureSetType {
63 	kTextureSetGroup   = 0x02faf082,
64 	kTextureSetTexture = 0x02faf080
65 };
66 
67 /**
68  * A texture contained in a '.tm' texture set archive
69  *
70  * Textures have mipmaps.
71  */
72 class Texture : public BiffObject {
73 public:
74 	static const uint32 TYPE = kTextureSetTexture;
75 
76 	Texture();
77 	~Texture() override;
78 
getName()79 	Common::String getName() const {
80 		return _name;
81 	}
82 
83 	/**
84 	 * Return a pointer to a texture ready for rendering
85 	 *
86 	 * The caller takes ownership of the texture.
87 	 * This method can only be called successfully once
88 	 * per texture. Subsequent calls return a null pointer.
89 	 */
90 	Gfx::Texture *acquireTexturePointer();
91 
92 	/** Return a RGBA copy of the pixel data */
93 	Graphics::Surface *getSurface() const;
94 
95 	// BiffObject API
96 	void readData(ArchiveReadStream *stream, uint32 dataLength) override;
97 
98 private:
99 	Common::String _name;
100 	Gfx::Texture *_texture;
101 	Graphics::Surface _surface;
102 	byte _u;
103 };
104 
105 } // End of namespace Formats
106 } // End of namespace Stark
107 
108 #endif // STARK_FORMATS_TM_H
109