# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

texture_mem.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_TEXTURE_MEM_H
00027 #define NL_TEXTURE_MEM_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/texture.h"
00031 #include <string>
00032 
00033 
00034 namespace NL3D 
00035 {
00036 
00037 
00038 //****************************************************************************
00042 class CTextureMem : public ITexture
00043 {
00044         uint8                                   *_Data;
00045         uint32                                  _Length;
00046         bool                                    _Delete;
00047         bool                                    _IsFile;
00048         bool                                    _AllowDegradation; // the default is false
00049         std::string                             _ShareName;
00050         NLMISC::CBitmap::TType  _TexType;
00051 
00053         uint            _TexWidth, _TexHeight;
00054 public:
00055 
00059         CTextureMem() : _Data(NULL),
00060                                         _Delete(false),
00061                                         _AllowDegradation(false),
00062                                         _TexType(CBitmap::RGBA)
00063         {               
00064         }
00065 
00066 
00070         virtual ~CTextureMem() 
00071         { 
00072                 if (_Data && _Delete)
00073                         delete [] _Data;
00074         }
00075 
00076 
00089         CTextureMem(uint8 *data, uint32 length, bool _delete, bool isFile = true, uint width = 0, uint height = 0, CBitmap::TType texType = CBitmap::RGBA) 
00090         { 
00091                 _AllowDegradation=false;
00092                 _Data=NULL;
00093                 _Delete=false;          
00094                 setPointer(data, length, _delete, isFile, width, height, texType);              
00095         }
00096 
00097 
00108         void setPointer(uint8 *data, uint32 length, bool _delete, bool isFile = true, uint width = 0, uint height = 0, CBitmap::TType texType = CBitmap::RGBA) 
00109         { 
00110                 if (_Data&&_Delete)
00111                         delete [] _Data;
00112                 _Touched=true;
00113                 _Data=data;
00114                 _Length=length;
00115                 _Delete=_delete;
00116                 _IsFile = isFile;
00117                 _TexWidth = width;
00118                 _TexHeight = height;
00119                 _TexType = texType;
00120         }
00121 
00122 
00123 
00127         uint8* getPointer() const { return _Data; } 
00128 
00129 
00133         uint32 getLength() const { return _Length; } 
00134 
00135 
00139         bool isDeletable() const { return _Delete; } 
00140 
00141 
00145         void doGenerate();
00146 
00148         virtual bool                    supportSharing() const 
00149         {
00150                 return !_ShareName.empty();
00151         }
00152 
00154         virtual std::string             getShareName() const 
00155         {
00156                 nlassert(!_ShareName.empty());
00157                 return _ShareName;
00158         }
00159 
00161         void setShareName(const std::string &shareName) 
00162         { 
00163                 _ShareName = shareName;
00164         }
00165 
00167         virtual bool    allowDegradation() const { return _AllowDegradation; }
00169         void                    setAllowDegradation(bool allow);
00170 
00172         virtual void    serial(NLMISC::IStream &f) throw(NLMISC::EStream) {nlstop;}
00173         NLMISC_DECLARE_CLASS(CTextureMem);
00174 
00178         static ITexture *Create1x1WhiteTex();   
00179 
00180 };
00181 
00182 
00183 } // NL3D
00184 
00185 
00186 #endif // NL_TEXTURE_MEM_H
00187 
00188 /* End of texture_mem.h */