00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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;
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 }
00184
00185
00186 #endif // NL_TEXTURE_MEM_H
00187
00188