Show bonus/malus timer text if available
[ryzomcore.git] / nel / src / 3d / texture.cpp
blobc31fecdea81571d63ce7ef8f198673902f0c6de9
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
19 #include "nel/3d/texture.h"
20 #include "nel/3d/driver.h"
21 #include <vector>
23 #ifdef DEBUG_NEW
24 #define new DEBUG_NEW
25 #endif
27 namespace NL3D
31 /*==================================================================*\
32 ITEXTURE
33 \*==================================================================*/
36 // ***************************************************************************
37 ITexture::ITexture()
39 _Touched= false;
40 _FilterOrWrapModeTouched = false;
41 _GoodGenerate= false;
42 _Releasable= true;
43 _RenderTarget= false;
44 _WrapS= _WrapT= Repeat;
45 _UploadFormat= Auto;
46 _MagFilter= Linear;
47 _MinFilter= LinearMipMapLinear;
51 // ***************************************************************************
52 ITexture::~ITexture()
54 // Must kill the drv mirror of this texture.
55 releaseDriverSetup();
59 // ***************************************************************************
60 void ITexture::releaseDriverSetup()
62 // Must kill the drv mirror of this texture.
63 if (TextureDrvShare) TextureDrvShare.kill();
67 // ***************************************************************************
68 ITexture &ITexture::operator=(const ITexture &tex)
70 // The operator= do not copy drv info
71 // set touched=true. _Releasable is copied.
72 _UploadFormat= tex._UploadFormat;
73 _Releasable= tex._Releasable;
74 _WrapS= tex._WrapS;
75 _WrapT= tex._WrapT;
76 _MagFilter= tex._MagFilter;
77 _MinFilter= tex._MinFilter;
78 _RenderTarget= tex._RenderTarget;
79 _FilterOrWrapModeTouched = tex._FilterOrWrapModeTouched;
80 touch();
81 return *this;
85 // ***************************************************************************
86 void ITexture::setUploadFormat(TUploadFormat pf)
88 if(pf!=_UploadFormat)
90 _UploadFormat= pf;
91 // All the texture may be reloaded...
92 touch();
97 // ***************************************************************************
98 void ITexture::setFilterMode(TMagFilter magf, TMinFilter minf)
100 if (_MagFilter != magf)
102 _MagFilter= magf;
103 _FilterOrWrapModeTouched = true;
105 // If the MipMap mode has switched Off/On, then must recompute...
106 bool precOff= mipMapOff();
107 if (_MinFilter != minf)
109 _MinFilter= minf;
110 _FilterOrWrapModeTouched = true;
112 bool nowOff= mipMapOff();
114 if(precOff!=nowOff)
116 // Must recompute mipmaps!!
117 touch();
123 // ***************************************************************************
124 CTextureDrvShare::~CTextureDrvShare()
126 _Driver->removeTextureDrvSharePtr(_DriverIterator);
128 // ***************************************************************************
129 ITextureDrvInfos::~ITextureDrvInfos()
131 // NB: _Driver may be NULL because texture may not be stored in the share texture map.
132 // so there is no need to remove it from this map!!
133 if(_Driver)
134 _Driver->removeTextureDrvInfoPtr(_DriverIterator);
138 // ***************************************************************************
139 void ITexture::serial(NLMISC::IStream &f)
142 Version 1:
143 - _LoadGrayscaleAsAlpha
144 Version 0:
145 - base version.
148 sint ver= f.serialVersion(1);
150 f.serialEnum(_UploadFormat);
151 f.serialEnum(_WrapS);
152 f.serialEnum(_WrapT);
153 f.serialEnum(_MinFilter);
154 f.serialEnum(_MagFilter);
155 if(ver>=1)
156 f.serial(_LoadGrayscaleAsAlpha);
159 // ***************************************************************************
161 void ITexture::setRenderTarget (bool enable)
163 _RenderTarget = enable;
164 touch ();
167 // ***************************************************************************
170 } // NL3D