ScummVM API documentation
material.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_MATERIAL_H
23 #define GRIM_MATERIAL_H
24 
25 #include "engines/grim/object.h"
26 
27 namespace Grim {
28 
29 class CMap;
30 
31 class Texture {
32 public:
33  Texture() :
34  _width(0), _height(0), _bpp(0), _hasAlpha(false), _texture(nullptr), _data(nullptr), _isShared(false) {};
35  int _width;
36  int _height;
37  int _bpp;
38  bool _hasAlpha;
39  void *_texture;
40  uint8 *_data;
41  bool _isShared;
42 };
43 
44 class MaterialData {
45 public:
46  MaterialData(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap);
47  ~MaterialData();
48 
49  static MaterialData *getMaterialData(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap);
50  static Common::List<MaterialData *> *_materials;
51 
52  Common::String _fname;
53  const ObjectPtr<CMap> _cmap;
54  int _numImages;
55  Texture **_textures;
56  int _refCount;
57 
58 private:
59  void initGrim(Common::SeekableReadStream *data);
60  void initEMI(Common::SeekableReadStream *data);
61 };
62 
63 class Material : public Object {
64 public:
65  // Load a texture from the given data.
66  Material(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap, bool clamp);
67 
68  void reload(CMap *cmap);
69  // Load this texture into the GL context
70  virtual void select() const;
71 
72  // Set which image in an animated texture to use
73  void setActiveTexture(int n);
74 
75  int getNumTextures() const;
76  int getActiveTexture() const;
77 
78  const Common::String &getFilename() const;
79  MaterialData *getData() const;
80 
81  virtual ~Material();
82 
83 protected:
84  Material();
85 
86 private:
87  MaterialData *_data;
88  int _currImage;
89  bool _clampTexture;
90 };
91 
92 } // end of namespace Grim
93 
94 #endif
Definition: str.h:59
Definition: material.h:44
Definition: list.h:44
Definition: stream.h:745
Definition: actor.h:33
Definition: material.h:63
Definition: colormap.h:35
Definition: object.h:69
Definition: material.h:31
Definition: object.h:32