ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

material.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_MATERIAL_H
00024 #define GRIM_MATERIAL_H
00025 
00026 #include "engines/grim/object.h"
00027 
00028 namespace Grim {
00029 
00030 class CMap;
00031 
00032 class Texture {
00033 public:
00034     Texture() :
00035         _width(0), _height(0), _colorFormat(0), _bpp(0), _hasAlpha(false), _texture(nullptr), _data(nullptr), _isShared(false) {};
00036     int _width;
00037     int _height;
00038     int _colorFormat;
00039     int _bpp;
00040     bool _hasAlpha;
00041     void *_texture;
00042     uint8 *_data;
00043     bool _isShared;
00044 };
00045 
00046 class MaterialData {
00047 public:
00048     MaterialData(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap);
00049     ~MaterialData();
00050 
00051     static MaterialData *getMaterialData(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap);
00052     static Common::List<MaterialData *> *_materials;
00053 
00054     Common::String _fname;
00055     const ObjectPtr<CMap> _cmap;
00056     int _numImages;
00057     Texture **_textures;
00058     int _refCount;
00059 
00060 private:
00061     void initGrim(Common::SeekableReadStream *data);
00062     void initEMI(Common::SeekableReadStream *data);
00063 };
00064 
00065 class Material : public Object {
00066 public:
00067     // Load a texture from the given data.
00068     Material(const Common::String &filename, Common::SeekableReadStream *data, CMap *cmap, bool clamp);
00069 
00070     void reload(CMap *cmap);
00071     // Load this texture into the GL context
00072     virtual void select() const;
00073 
00074     // Set which image in an animated texture to use
00075     void setActiveTexture(int n);
00076 
00077     int getNumTextures() const;
00078     int getActiveTexture() const;
00079 
00080     const Common::String &getFilename() const;
00081     MaterialData *getData() const;
00082 
00083     virtual ~Material();
00084 
00085 protected:
00086     Material();
00087 
00088 private:
00089     MaterialData *_data;
00090     int _currImage;
00091     bool _clampTexture;
00092 };
00093 
00094 } // end of namespace Grim
00095 
00096 #endif


Generated on Sat Dec 7 2019 05:00:33 for ResidualVM by doxygen 1.7.1
curved edge   curved edge