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_GFX_TEXTURE_H 24 #define STARK_GFX_TEXTURE_H 25 26 #include "common/hash-str.h" 27 28 namespace Graphics { 29 struct Surface; 30 } 31 32 namespace Stark { 33 namespace Gfx { 34 35 /** 36 * An abstract texture 37 */ 38 class Texture { 39 public: 40 Texture(); 41 virtual ~Texture(); 42 43 /** Make the texture active */ 44 virtual void bind() const = 0; 45 46 /** Define or update the texture pixel data */ 47 virtual void update(const Graphics::Surface *surface, const byte *palette = nullptr) = 0; 48 49 /** 50 * Define the total number of levels of details 51 * 52 * Must be called before adding levels 53 */ 54 virtual void setLevelCount(uint32 count) = 0; 55 56 /** 57 * Add a detail level to the texture 58 */ 59 virtual void addLevel(uint32 level, const Graphics::Surface *surface, const byte *palette = nullptr) = 0; 60 61 /** Get the texture width */ width()62 uint32 width() const { return _width; } 63 64 /** Get teh texture height */ height()65 uint32 height() const { return _height; } 66 67 protected: 68 uint32 _width; 69 uint32 _height; 70 }; 71 72 /** 73 * A collection of textures referenced by their names 74 */ 75 class TextureSet { 76 public: 77 TextureSet(); 78 ~TextureSet(); 79 80 /** 81 * Add a texture to the set 82 */ 83 void addTexture(const Common::String &name, Texture *texture); 84 85 /** 86 * Retrieve a texture from the set 87 */ 88 const Texture *getTexture(const Common::String &name) const; 89 90 private: 91 typedef Common::HashMap<Common::String, Texture *> TextureMap; 92 93 TextureMap _texMap; 94 }; 95 96 } // End of namespace Gfx 97 } // End of namespace Stark 98 99 #endif // STARK_GFX_TEXTURE_H 100