NL3D::ITexture Class Reference

#include <texture.h>

Inheritance diagram for NL3D::ITexture:

NLMISC::CBitmap NLMISC::CRefCount NLMISC::IStreamable NLMISC::IClassable NL3D::CTextureBlank NL3D::CTextureBlend NL3D::CTextureBump NL3D::CTextureCross NL3D::CTextureCube NL3D::CTextureDLM NL3D::CTextureEmboss NL3D::CTextureFar NL3D::CTextureFile NL3D::CTextureFont NL3D::CTextureGrouped NL3D::CTextureMem NL3D::CTextureMultiFile NL3D::CTextureNear

Detailed Description

Interface for textures

Sharing System note: The deriver may implement sharing system by implement supportSharing() and getShareName(). Such a texture may return a Unique Name for sharing. If the driver already has this texture, it will reuse it. As a direct impact, you cannot invalidate part of the textures with shared texture. This is logic, since the Unique sharname of the texture must represent all of it.

Definition at line 106 of file texture.h.

Public Types

enum  TMagFilter { Nearest = 0, Linear, MagFilterCount }
enum  TMinFilter {
  NearestMipMapOff = 0, NearestMipMapNearest, NearestMipMapLinear, LinearMipMapOff,
  LinearMipMapNearest, LinearMipMapLinear, MinFilterCount
}
enum  TType {
  RGBA = 0, Luminance, Alpha, AlphaLuminance,
  DXTC1, DXTC1Alpha, DXTC3, DXTC5,
  DsDt, ModeCount, DonTKnow = 0xffffffff
}
enum  TUploadFormat {
  Auto = 0, RGBA8888, RGBA4444, RGBA5551,
  RGB888, RGB565, DXTC1, DXTC1Alpha,
  DXTC3, DXTC5, Luminance, Alpha,
  AlphaLuminance, DsDt, UploadFormatCount
}
enum  TWrapMode { Repeat = 0, Clamp, WrapModeCount }

Public Member Functions

virtual bool allowDegradation () const
 Does this texture allow the driver to degrade.

void blend (CBitmap &Bm0, CBitmap &Bm1, uint16 factor, bool inputBitmapIsMutable=false)
bool blit (const CBitmap *src, sint32 x, sint32 y)
void buildMipMaps ()
virtual ITexturebuildNonSelectableVersion (uint index)
void clearTouched (void)
bool convertToType (TType type)
void flipH ()
void flipV ()
void generate (bool async=false)
virtual std::string getClassName ()=0
CRGBAF getColor (float x, float y) const
virtual uint32 getHeight (uint32 numMipMap=0) const
uint32 getMipMapCount () const
CRGBA getPixelColor (sint x, sint y, uint32 numMipMap=0) const
TType getPixelFormat () const
const sintgetRefCount () const
bool getReleasable () const
virtual std::string getShareName () const
uint32 getSize (uint32 numMipMap=0) const
virtual uint32 getWidth (uint32 numMipMap=0) const
bool isAllInvalidated () const
virtual bool isBumpMap () const
bool isGrayscaleAsAlpha () const
virtual bool isSelectable () const
 Test wether this texture is selectable.

uint8 load (NLMISC::IStream &f, uint mipMapSkip=0)
void loadGrayscaleAsAlpha (bool loadAsAlpha)
void makeDummy ()
virtual void release ()
void releaseDriverSetup ()
 Release the Driver info for this texture (if any). Call it with care.

void releaseMipMaps ()
void resample (sint32 nNewWidth, sint32 nNewHeight)
void reset (TType type=RGBA)
void resize (sint32 nNewWidth, sint32 nNewHeight, TType newType=DonTKnow, bool resetTo0=true)
void resizeMipMap (uint32 numMipMap, sint32 nNewWidth, sint32 nNewHeight, bool resetTo0=true)
void rot90CCW ()
void rot90CW ()
void rotateCCW ()
virtual void selectTexture (uint index)
virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serial ITexture basic infos (clamp ...).

void setMipMapCount (uint32 mmc)
void setReleasable (bool r)
bool setupedIntoDriver () const
virtual bool supportSharing () const
void touch ()
bool touched (void)
void touchRect (const NLMISC::CRect &rect)
void validateGenerateFlag ()
bool writeJPG (NLMISC::IStream &f, uint8 quality=80)
bool writeTGA (NLMISC::IStream &f, uint32 d, bool upsideDown=false)
 ITexture (const ITexture &tex)
 see operator=.

 ITexture ()
 By default, a texture is releasable.

ITextureoperator= (const ITexture &tex)
 The operator= do not copy drv info, and set touched=true. _Releasable, WrapMode and UploadFormat are copied.

virtual ~ITexture ()
 Need a virtual dtor.


Static Public Member Functions

void loadSize (const std::string &path, uint32 &retWidth, uint32 &retHeight)
void loadSize (NLMISC::IStream &f, uint32 &width, uint32 &height)

Data Fields

std::list< NLMISC::CRect_ListInvalidRect
sint crefs
CPtrInfo * pinfo
enum NLMISC::CBitmap::TType PixelFormat
NLMISC::CRefPtr< CTextureDrvShareTextureDrvShare

Static Public Attributes

const uint32 bitPerPixels [ModeCount]
const uint32 DXTC1HEADER = NL_MAKEFOURCC('D','X', 'T', '1')
const uint32 DXTC3HEADER = NL_MAKEFOURCC('D','X', 'T', '3')
const uint32 DXTC5HEADER = NL_MAKEFOURCC('D','X', 'T', '5')
CPtrInfo NullPtrInfo

Protected Member Functions

virtual void doGenerate (bool async=false)=0

Protected Attributes

CObjectVector< uint8_Data [MAX_MIPMAP]
uint32 _Height
bool _LoadGrayscaleAsAlpha
uint8 _MipMapCount
bool _Touched
uint32 _Width

Private Attributes

bool _GoodGenerate
TMagFilter _MagFilter
TMinFilter _MinFilter
bool _Releasable
TUploadFormat _UploadFormat
TWrapMode _WrapS
TWrapMode _WrapT

Friends

struct CPtrInfo


Member Enumeration Documentation

enum NL3D::ITexture::TMagFilter
 

Magnification mode. Same behavior as OpenGL.

Enumeration values:
Nearest 
Linear 
MagFilterCount 

Definition at line 148 of file texture.h.

Referenced by getMagFilter().

00149         {
00150                 Nearest=0,
00151                 Linear,
00152 
00153                 MagFilterCount
00154         };

enum NL3D::ITexture::TMinFilter
 

Minifying mode. Same behavior as OpenGL. If the bitmap has no mipmap, and mipmap is required, then mipmaps are computed.

Enumeration values:
NearestMipMapOff 
NearestMipMapNearest 
NearestMipMapLinear 
LinearMipMapOff 
LinearMipMapNearest 
LinearMipMapLinear 
MinFilterCount 

Definition at line 159 of file texture.h.

Referenced by getMinFilter().

enum NLMISC::CBitmap::TType [inherited]
 

Enumeration values:
RGBA 
Luminance 
Alpha 
AlphaLuminance 
DXTC1 
DXTC1Alpha 
DXTC3 
DXTC5 
DsDt 
ModeCount 
DonTKnow 

Definition at line 234 of file bitmap.h.

00235         { 
00236                 RGBA=0,
00237                 Luminance,
00238                 Alpha,
00239                 AlphaLuminance,
00240                 DXTC1,
00241                 DXTC1Alpha,
00242                 DXTC3,
00243                 DXTC5,
00244                 DsDt,
00245                 ModeCount,
00246                 DonTKnow=0xffffffff
00247         } PixelFormat;

enum NL3D::ITexture::TUploadFormat
 

Enumeration values:
Auto 
RGBA8888 
RGBA4444 
RGBA5551 
RGB888 
RGB565 
DXTC1 
DXTC1Alpha 
DXTC3 
DXTC5 
Luminance 
Alpha 
AlphaLuminance 
DsDt 
UploadFormatCount 

Definition at line 125 of file texture.h.

Referenced by getUploadFormat().

00126         {
00127                 Auto= 0,
00128                 RGBA8888,
00129                 RGBA4444,
00130                 RGBA5551,
00131                 RGB888,
00132                 RGB565,
00133                 DXTC1,
00134                 DXTC1Alpha,
00135                 DXTC3,
00136                 DXTC5,
00137                 Luminance,
00138                 Alpha,
00139                 AlphaLuminance,
00140                 DsDt,
00141                 UploadFormatCount
00142         };

enum NL3D::ITexture::TWrapMode
 

Enumeration values:
Repeat 
Clamp 
WrapModeCount 

Definition at line 117 of file texture.h.

00118         {
00119                 Repeat= 0,
00120                 Clamp,
00121 
00122                 WrapModeCount
00123         };


Constructor & Destructor Documentation

NL3D::ITexture::ITexture  ) 
 

By default, a texture is releasable.

Definition at line 43 of file texture.cpp.

References _GoodGenerate, _MagFilter, _MinFilter, _Releasable, _UploadFormat, _WrapS, _WrapT, Auto, and LinearMipMapLinear.

00044 {
00045         _Touched= false;
00046         _GoodGenerate= false;
00047         _Releasable= true;
00048         _WrapS= _WrapT= Repeat;
00049         _UploadFormat= Auto;
00050         _MagFilter= Linear;
00051         _MinFilter= LinearMipMapLinear;
00052 }

NL3D::ITexture::ITexture const ITexture tex  )  [inline]
 

see operator=.

Definition at line 179 of file texture.h.

References operator=().

00179 {operator=(tex);}

NL3D::ITexture::~ITexture  )  [virtual]
 

Need a virtual dtor.

Definition at line 56 of file texture.cpp.

References releaseDriverSetup().

00057 {
00058         // Must kill the drv mirror of this texture.
00059         releaseDriverSetup();
00060 }


Member Function Documentation

virtual bool NL3D::ITexture::allowDegradation  )  const [inline, virtual]
 

Does this texture allow the driver to degrade.

Reimplemented in NL3D::CTextureFile, and NL3D::CTextureMem.

Definition at line 352 of file texture.h.

Referenced by NL3D::CDriverGL::getGlTextureFormat(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

00352 { return false; }

void NLMISC::CBitmap::blend CBitmap Bm0,
CBitmap Bm1,
uint16  factor,
bool  inputBitmapIsMutable = false
[inherited]
 

Set this bitmap as the result of the blend bewteen 2 bitmap REQUIRE : - Bm0 and Bm1 should have the same size.

  • Both bitmap should be convertible to RGBA pixel format. The result is a RGBA bitmap. NB: this just works with the first mipmaps
    Parameters:
    factor The blend factor. 0 means the result is equal to Bm0, 256 means the result is equal to Bm1
    inputBitmapIsMutable when true, bitmap can be converted in place when needed (no copy done)

Definition at line 2817 of file bitmap.cpp.

References NLMISC::CBitmap::_Data, NLMISC::CBitmap::_Height, NLMISC::CBitmap::_Width, NLMISC::CBitmap::convertToRGBA(), nlassert, NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::resize(), NLMISC::CBitmap::RGBA, uint, uint16, uint64, and uint8.

02818 {
02819         nlassert(factor <= 256);
02820 
02821         nlassert(Bm0._Width != 0 && Bm0._Height != 0
02822                          && Bm1._Width != 0 && Bm1._Height != 0);
02823 
02824         nlassert(Bm0._Width  == Bm1._Width);    // the bitmap should have the same size
02825         nlassert(Bm0._Height == Bm1._Height);
02826 
02827         const CBitmap *nBm0, *nBm1; // pointer to the bitmap that is used for blending, or to a copy is a conversion wa required
02828 
02829         CBitmap cp0, cp1; // these bitmap are copies of Bm1 and Bm0 if a conversion was needed
02830 
02831         if (Bm0.PixelFormat != RGBA)
02832         {
02833                 if (inputBitmapIsMutable)
02834                 {
02835                         Bm0.convertToRGBA();
02836                         nBm0 = &Bm0;
02837                 }
02838                 else
02839                 {               
02840                         cp0 = Bm0;
02841                         cp0.convertToRGBA();
02842                         nBm0 = &cp0;
02843                 }
02844         }
02845         else
02846         {
02847                 nBm0 = &Bm0;
02848         }
02849 
02850 
02851         if (Bm1.PixelFormat != RGBA)
02852         {
02853                 if (inputBitmapIsMutable)
02854                 {
02855                         Bm1.convertToRGBA();
02856                         nBm1 = &Bm1;
02857                 }
02858                 else
02859                 {
02860                         cp1 = Bm1;
02861                         cp1.convertToRGBA();
02862                         nBm1 = &cp1;
02863                 }
02864         }
02865         else
02866         {
02867                 nBm1 = &Bm1;
02868         }
02869 
02870         this->resize(Bm0._Width, Bm0._Height, RGBA);
02871 
02872         uint numPix = _Width * _Height; // 4 component per pixels
02873 
02874 
02875         const uint8 *src0               = &(nBm0->_Data[0][0]);
02876         const uint8 *src1               = &(nBm1->_Data[0][0]);
02877         uint8 *dest                             = &(this->_Data[0][0]);
02878         
02879 
02880         #ifdef NL_OS_WINDOWS                    
02881         if (CSystemInfo::hasMMX())              
02882         {
02883                 // On a P4 2GHz, with a 256x256 texture, I got the following results :
02884                 // without mmx : 5.2 ms
02885         // with mmx    : 1.7 ms
02886                 // I'm sure this can be further optimized..
02887 
02888                 uint numPixLeft = numPix & 1; // process 2 pixels at once, so special case for odd number
02889                 numPix = numPix & ~1;
02890                 // do fast blend with mmx
02891                 uint64 blendFactor0;
02892                 uint64 blendFactor1;
02893                 uint16 *bf0 = (uint16 *) &blendFactor0;
02894                 uint16 *bf1 = (uint16 *) &blendFactor1;
02895                 bf0[0] = bf0[1] = bf0[2] = bf0[3] = factor;
02896                 bf1[0] = bf1[1] = bf1[2] = bf1[3] = 256 - factor;
02897                 __asm
02898                 {                       
02899                         mov esi, src0
02900                         mov eax, src1
02901                         mov edi, dest
02902                         mov ebx, -8
02903                         mov ecx, numPix
02904                         shr ecx, 1 // process pixels 2 by 2
02905                         movq mm1, blendFactor0
02906                         movq mm0, blendFactor1 
02907                                 
02908                 myLoop:
02909                         pxor mm6, mm6
02910                         lea  ebx, [ebx + 8] // points next location
02911                         pxor mm7, mm7                   
02912                         movq mm2, [esi + ebx]
02913                         movq mm3, [eax + ebx]                   
02914                         // do blend 
02915                         punpckhbw mm7, mm2  // mm7 contains src0 color 0 in high bytes
02916                         punpckhbw mm6, mm3  // mm6 contains src1 color 0 in high bytes
02917                         psrl      mm7, 1
02918                         pxor mm4, mm4       // mm4 = 0                  
02919                         psrl      mm6, 1
02920                         pmulhw mm7, mm0     // src0 = src0 * blendFactor
02921                         pxor mm5, mm5       // mm5 = 0
02922                         pmulhw mm6, mm1     // src1 = src1 * (1 - blendfactor)
02923                         punpcklbw mm4, mm2  // mm4 contains src0 color 1 in high bytes
02924                         paddusw mm6, mm7    // mm6 = src0[0] blended with src1[0]
02925                         psrl      mm4, 1
02926                         punpcklbw mm5, mm3  // mm4 contains src1 color 1 in high bytes
02927                         psll      mm6, 1
02928                         psrl      mm5, 1
02929                         pmulhw    mm4, mm0     // src0 = src0 * blendFactor
02930                         pmulhw    mm5, mm1     // src1 = src1 * (1 - blendfactor)
02931                         paddusw   mm4, mm5    // mm6 = src0[1] blended with src1[1]
02932                         psll      mm4, 1
02933                         // pack result
02934                         packuswb  mm4, mm6
02935                         dec               ecx
02936                         movq      [edi + ebx], mm4  // store result
02937                         jne myLoop
02938                         emms
02939                 }
02940                 if (numPixLeft)
02941                 {
02942                         // case of odd number of pixels
02943                         src0 += 4 * numPix;
02944                         src1 += 4 * numPix;
02945                         dest += 4 * numPix;
02946                         uint blendFact    = (uint) factor;
02947                         uint invblendFact = 256 - blendFact;                    
02948                         *dest = (uint8) (((blendFact * *src1)           + (invblendFact * *src0)) >> 8);
02949                         *(dest + 1) = (uint8) (((blendFact * *(src1 + 1)) + (invblendFact * *(src0 + 1))) >> 8);
02950                         *(dest + 2) = (uint8) (((blendFact * *(src1 + 2)) + (invblendFact * *(src0 + 2))) >> 8);
02951                         *(dest + 3)  = (uint8) (((blendFact * *(src1 + 3)) + (invblendFact * *(src0 + 3))) >> 8);
02952                 }
02953         }       
02954         else    
02955         #endif //#ifdef NL_OS_WINDOWS   
02956         {       
02957                 uint8 *endPix                   = dest + (numPix << 2);
02958                 // no mmx version
02959                 uint blendFact    = (uint) factor;
02960                 uint invblendFact = 256 - blendFact;
02961                 do
02962                 {
02964                         *dest = (uint8) (((blendFact * *src1)           + (invblendFact * *src0)) >> 8);
02965                         *(dest + 1) = (uint8) (((blendFact * *(src1 + 1)) + (invblendFact * *(src0 + 1))) >> 8);
02966                         *(dest + 2) = (uint8) (((blendFact * *(src1 + 2)) + (invblendFact * *(src0 + 2))) >> 8);
02967                         *(dest + 3)  = (uint8) (((blendFact * *(src1 + 3)) + (invblendFact * *(src0 + 3))) >> 8);
02968 
02969                         src0 = src0 + 4;
02970                         src1 = src1 + 4;
02971                         dest = dest + 4;        
02972                 }
02973                 while (dest != endPix);
02974         }
02975 }

bool NLMISC::CBitmap::blit const CBitmap src,
sint32  x,
sint32  y
[inherited]
 

Perform a simple blit from the source to this bitmap at the (x, y) pos The dimension of the original bitmap are preserved For now, this texture and the source must have the same format With DXTC format, the dest coordinates must be a multiple of 4 mipmap are not rebuild when present

Returns:
true if the params were corrects and if the blit occures. In debug build there's an assertion

Definition at line 2332 of file bitmap.cpp.

References NLMISC::CBitmap::bitPerPixels, NLMISC::CBitmap::DonTKnow, height, nlassert, NLMISC::CBitmap::PixelFormat, sint, sint32, src, uint, uint8, width, x, and y.

Referenced by NL3D::CTextureGrouped::doGenerate(), and NL3D::CCoarseMeshBuild::expand().

02333 {
02334         
02335         nlassert(this->PixelFormat == src->PixelFormat);
02336         if (this->PixelFormat != src->PixelFormat)
02337         {
02338                 return false;
02339         }
02340 
02341 
02342         // check for dxtc use
02343 
02344         const bool useDXTC   =  PixelFormat == DXTC1 || PixelFormat == DXTC1Alpha || PixelFormat == DXTC3 || PixelFormat ==     DXTC5;
02345 
02346         // number of bits for a 4x4 pix block
02347         const uint dxtcNumBits  =  PixelFormat == DXTC1 || PixelFormat == DXTC1Alpha ? 64 : 128;
02348         
02349 
02350         if (useDXTC)
02351         {
02352                 // blit pos must be multiple of 4
02353 
02354                 nlassert(! (x & 3 || y & 3) );
02355                 if (x & 3 || y & 3) return false;
02356 
02357         }
02358 
02359         nlassert(PixelFormat != DonTKnow);
02360 
02361         // the width to copy
02362         sint width = src->_Width;
02363         // the height to copy
02364         sint height = src->_Height;
02365 
02366         uint destStartX, destStartY;
02367         uint srcStartX, srcStartY;
02368 
02369 
02370         // clip against left
02371         if (x < 0)
02372         {
02373                 width += x;
02374                 if (width <= 0) return true;
02375                 destStartX = 0;
02376                 srcStartX = -x;
02377         }
02378         else
02379         {
02380                 destStartX = x;
02381                 srcStartX = 0;
02382         }
02383 
02384         // clip against top
02385         if (y < 0)
02386         {
02387                 height += y;
02388                 if (height <= 0) return true;
02389                 srcStartY = -y;
02390                 destStartY = 0;
02391         }
02392         else
02393         {
02394                 destStartY = y;
02395                 srcStartY = 0;
02396         }
02397 
02398         // clip against right
02399         if ((destStartX + width - 1) >= _Width)
02400         {
02401                 width = _Width - destStartX;
02402                 if (width <= 0) return true;
02403         }
02404 
02405         // clip against bottom
02406         if ((destStartY + height - 1) >= _Height)
02407         {
02408                 height = _Height - destStartY;
02409                 if (width <= 0) return true;
02410         }
02411 
02412 
02413         // divide all distance by 4 when using DXTC
02414         if (useDXTC)
02415         {
02416                 destStartX >>= 2;
02417                 destStartY >>= 2;
02418                 srcStartX >>= 2;
02419                 srcStartY >>= 2;
02420                 width >>= 2;
02421                 height >>= 2;
02422         }
02423         
02424 
02425         // bytes per pixs is for either one pixel or 16 (a 4x4 block in DXTC)
02426         const uint bytePerPixs = ( useDXTC ? dxtcNumBits : bitPerPixels[PixelFormat] ) >> 3 /* divide by 8 to get the number of bytes */;
02427 
02428 
02429         const uint destRealWidth = useDXTC ? (_Width >> 2) : _Width;
02430         const uint srcRealWidth = useDXTC ? (src->_Width >> 2) : src->_Width;
02431         
02432 
02433         // size to go to the next line in the destination
02434         const uint destStride = destRealWidth * bytePerPixs;
02435 
02436         // size to go to the next line in the source
02437         const uint srcStride = srcRealWidth * bytePerPixs;
02438         
02439         // length in bytes of a line to copy
02440         const uint lineLength = width * bytePerPixs;
02441 
02442 
02443         uint8  *destPos = &(_Data[0][0]) + destStride * destStartY + bytePerPixs * destStartX;
02444         const uint8 *srcPos = &(src->_Data[0][0]) + srcStride * srcStartY + bytePerPixs * srcStartX;
02445 
02446         // copy each hline
02447         for (sint k = 0; k < height; ++k)
02448         {
02449                 ::memcpy(destPos, srcPos, lineLength);
02450                 destPos += destStride;
02451                 srcPos += srcStride;
02452         }
02453 
02454         
02455         return true;
02456 }

void NLMISC::CBitmap::buildMipMaps  )  [inherited]
 

Build the mipmaps of the bitmap if they don't exist. Work only in RGBA mode...

See also:
releaseMipMaps().

Definition at line 1422 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::isPowerOf2(), NLMISC::CBitmap::PixelFormat, NLMISC::CRGBA::R, NLMISC::CObjectVector< uint8 >::resize(), NLMISC::CBitmap::RGBA, sint, uint32, and w.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CTextureMem::doGenerate(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NLMISC::CBitmap::resample(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), and NL3D::CDriverGL::setupTextureEx().

01423 {
01424         uint32 i,j;
01425 
01426         if(PixelFormat!=RGBA) return;
01427         if(_MipMapCount!=1) return;
01428         if(!NLMISC::isPowerOf2(_Width)) return;
01429         if(!NLMISC::isPowerOf2(_Height)) return;
01430         
01431         uint32 w = _Width;
01432         uint32 h = _Height;
01433 
01434         while(w>1 || h>1)
01435         {
01436                 uint32 precw = w;
01437                 uint32 prech = h;
01438                 w = (w+1)/2;
01439                 h = (h+1)/2;
01440                 uint32  mulw= precw/w;
01441                 uint32  mulh= prech/h;
01442 
01443                 _Data[_MipMapCount].resize(w*h*4);
01444                 
01445         
01446                 NLMISC::CRGBA *pRgba = (NLMISC::CRGBA*)&_Data[_MipMapCount][0];
01447                 NLMISC::CRGBA *pRgbaPrev = (NLMISC::CRGBA*)&_Data[_MipMapCount-1][0];
01448                 for(i=0; i<h; i++)
01449                 {
01450                         sint    i0= mulh*i;
01451                         sint    i1= mulh*i+1;
01452                         if(mulh==1)
01453                                 i1=i0;
01454                         i0*=precw;
01455                         i1*=precw;
01456                         for(j=0; j<w; j++)
01457                         {
01458                                 sint    j0= mulw*j;
01459                                 sint    j1= mulw*j+1;
01460                                 if(mulh==1)
01461                                         j1=j0;
01462                                 CRGBA   &c0= pRgbaPrev[i0+j0];
01463                                 CRGBA   &c1= pRgbaPrev[i0+j1];
01464                                 CRGBA   &c2= pRgbaPrev[i1+j0];
01465                                 CRGBA   &c3= pRgbaPrev[i1+j1];
01466                                 pRgba[i*w + j].R = (c0.R +
01467                                                                         c1.R +
01468                                                                         c2.R +
01469                                                                         c3.R + 2 ) /4;
01470                                 pRgba[i*w + j].G = (c0.G +
01471                                                                         c1.G +
01472                                                                         c2.G +
01473                                                                         c3.G + 2 ) /4;
01474                                 pRgba[i*w + j].B = (c0.B +
01475                                                                         c1.B +
01476                                                                         c2.B +
01477                                                                         c3.B + 2 ) /4;
01478                                 pRgba[i*w + j].A = (c0.A +
01479                                                                         c1.A +
01480                                                                         c2.A +
01481                                                                         c3.A + 2 ) /4;
01482                         }
01483                 }
01484 
01485                 _MipMapCount++;
01486         }
01487 }

virtual ITexture* NL3D::ITexture::buildNonSelectableVersion uint  index  )  [inline, virtual]
 

If this texture is selectable, build a non selectable version of this texture that is setupped with the given slot. NB : If this texture is selectable, you are ensured that the return pointer is not 'this'

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 368 of file texture.h.

References index, and uint.

Referenced by NL3D::CMeshBaseInstance::selectTextureSet().

00368 { return this; }

void NL3D::ITexture::clearTouched void   )  [inline]
 

Definition at line 448 of file texture.h.

References _ListInvalidRect.

Referenced by NL3D::CDriverGL::setupTextureEx().

00449         { 
00450                 _Touched=false; 
00451                 _ListInvalidRect.clear();
00452         }

bool NLMISC::CBitmap::convertToType TType  type  )  [inherited]
 

Convert bitmap to another type conversion to rgba always work. No-op if already rgba.

Parameters:
type new type for the bitmap
Returns:
true if conversion succeeded, false else

Definition at line 926 of file bitmap.cpp.

References NLMISC::CBitmap::convertToAlpha(), NLMISC::CBitmap::convertToAlphaLuminance(), NLMISC::CBitmap::convertToDXTC5(), NLMISC::CBitmap::convertToLuminance(), NLMISC::CBitmap::convertToRGBA(), NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::RGBA, and type.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHeightMap::buildFromBitmap(), NL3D::CAsyncTextureManager::CTextureEntry::createCoarseBitmap(), NL3D::CZoneLighter::getTexture(), NL3D::CTileBank::getTileNoiseMap(), and NL3D::CDriverGL::setupTextureEx().

00927 {
00928         if(PixelFormat==type) return true;
00929 
00930         switch(type)
00931         {
00932                 case RGBA :
00933                         return convertToRGBA();
00934                         break;
00935 
00936                 case DXTC5 :
00937                         return convertToDXTC5();                
00938                         break;
00939 
00940                 case Luminance :
00941                         return convertToLuminance();
00942                         break;
00943 
00944                 case Alpha :
00945                         return convertToAlpha();
00946                         break;
00947 
00948                 case AlphaLuminance :
00949                         return convertToAlphaLuminance();
00950                         break;
00951 
00952                 default:
00953                         break;
00954         }
00955         
00956         return false;
00957 }

virtual void NL3D::ITexture::doGenerate bool  async = false  )  [protected, pure virtual]
 

Generate the texture pixels.

If the invalidate rect list is empty, generate() must rebuild all the texture. If the invalidate rect list is not empty, generate() rebuilds only the invalidate rectangles in the list.

See also:
isAllInvalidated(), touch(), touched(), touchRect(), clearTouched(), _ListInvalidRect, generate()

getReleasable(), setReleasable()

Implemented in NL3D::CTextureCross, NL3D::CTextureBlank, NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureDLM, NL3D::CTextureEmboss, NL3D::CTextureFar, NL3D::CTextureFile, NL3D::CTextureFont, NL3D::CTextureGrouped, NL3D::CTextureMem, NL3D::CTextureMultiFile, and NL3D::CTextureNear.

Referenced by generate().

void NLMISC::CBitmap::flipH  )  [inherited]
 

Horizontal flip (all the columns are flipped)

Definition at line 2682 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CBitmap::buildMipMaps(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getWidth(), NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::RGBA, and sint32.

02683 {
02684         if (PixelFormat != RGBA)
02685                 return;
02686 
02687         sint32 nWidth = getWidth(0);
02688         sint32 nHeight = getHeight(0);
02689         sint32 i, j;
02690         NLMISC::CRGBA *pBitmap = (NLMISC::CRGBA*)&_Data[0][0];
02691         bool needRebuild = false;
02692         CRGBA temp;
02693 
02694         if(_MipMapCount>1)
02695                 needRebuild = true;
02696         releaseMipMaps();
02697 
02698         for( i = 0; i < nHeight; ++i )
02699                 for( j = 0; j < nWidth/2; ++j )
02700                 {
02701                         temp = pBitmap[i*nWidth+j];
02702                         pBitmap[i*nWidth+j] = pBitmap[i*nWidth+nWidth-j-1];
02703                         pBitmap[i*nWidth+nWidth-j-1] = temp;
02704                 }
02705 
02706         // Rebuilding mipmaps
02707         if(needRebuild)
02708         {
02709                 buildMipMaps();
02710         }
02711 }

void NLMISC::CBitmap::flipV  )  [inherited]
 

Vertical flip (all the rows are flipped)

Definition at line 2714 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CBitmap::buildMipMaps(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getWidth(), NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::RGBA, and sint32.

02715 {
02716         if (PixelFormat != RGBA)
02717                 return;
02718 
02719         sint32 nWidth = getWidth(0);
02720         sint32 nHeight = getHeight(0);
02721         sint32 i, j;
02722         NLMISC::CRGBA *pBitmap = (NLMISC::CRGBA*)&_Data[0][0];
02723         bool needRebuild = false;
02724         CRGBA temp;
02725 
02726         if(_MipMapCount>1)
02727                 needRebuild = true;
02728         releaseMipMaps();
02729 
02730         for( j = 0; j < nHeight/2; ++j )
02731                 for( i = 0; i < nWidth; ++i )
02732                 {
02733                         temp = pBitmap[j*nWidth+i];
02734                         pBitmap[j*nWidth+i] = pBitmap[(nHeight-j-1)*nWidth+i];
02735                         pBitmap[(nHeight-j-1)*nWidth+i] = temp;
02736                 }
02737 
02738         // Rebuilding mipmaps
02739         if(needRebuild)
02740         {
02741                 buildMipMaps();
02742         }
02743 }

void NL3D::ITexture::generate bool  async = false  )  [inline]
 

Generate the texture pixels.

This method is called by the driver when it needs to generate pixels of the texture. If the texture is used for the first time or if it is touched, the driver will call this method. For exemple, a texture file will load the bitmap in this method.

If the invalidate rect list is empty, generate() rebuild all the texture. If the invalidate rect list is not empty, generate() rebuilds only the invalidate rectangles in the list.

Don't clear the touch flag or the invalid rectangle list until updating the texture in generate(). It's the generate()'s caller jobs.

After generation, if the texture is releasable, the driver will release the texture by calling release().

NB: a flag is maintained to see if the generated bitmap is coherent with texture description (see touch*()). So if you do {generate(); generate();}, you only get 1 real bitmap generation...

If, after the doGenerate, the bitmap format is compressed (DXTC) and no mipmaps have been generated, the mipmap are disabled beacause the user probably don't want the driver to unpacks the texture, generates the mipmaps and repacks the dxtc texture (that takes a lot of CPU time).

Parameters:
async tells the texture if the call is made asynchronously or not.
See also:
isAllInvalidated(), touch(), touched(), touchRect(), clearTouched(), _ListInvalidRect

getReleasable(), setReleasable()

Definition at line 309 of file texture.h.

References _GoodGenerate, and doGenerate().

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureCube::doGenerate(), NL3D::CZoneLighter::getTexture(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CAsyncFileManager3D::CTextureLoad::run(), NL3D::CAsyncFileManager3D::CMeshLoad::run(), NL3D::CPSMultiTexturedParticle::setupMaterial(), and NL3D::CDriverGL::setupTextureEx().

00310         {
00311                 if(!_GoodGenerate)
00312                 {
00313                         doGenerate(async);
00314                         _GoodGenerate=true;
00315                 }
00316         }

virtual std::string NLMISC::IClassable::getClassName  )  [pure virtual, inherited]
 

Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc.

Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize().

CRGBAF NLMISC::CBitmap::getColor float  x,
float  y
const [inherited]
 

Get the color in the bitmap given a pixel size The mipmaps must be built. If not just return the bilinear at the given point. The input x and y must be clamped between 0 and 1

Definition at line 2470 of file bitmap.cpp.

References NLMISC::CRGBAF::A, NLMISC::CRGBAF::B, NLMISC::CRGBAF::G, NLMISC::CBitmap::getColorInterp(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getPixelColor(), NLMISC::CBitmap::getPixels(), NLMISC::CBitmap::getWidth(), nlassert, NLMISC::CBitmap::PixelFormat, NLMISC::CRGBAF::R, NLMISC::CBitmap::RGBA, sint32, uint32, x, and y.

02471 {
02472         if (x < 0.0f) x = 0.0f;
02473         if (x > 1.0f) x = 1.0f;
02474         if (y < 0.0f) y = 0.0f;
02475         if (y > 1.0f) y = 1.0f;
02476 
02477         sint32 nWidth = getWidth(0);
02478         sint32 nHeight = getHeight(0);
02479 
02480         if (nWidth == 0 || nHeight == 0) return CRGBAF(0, 0, 0, 0);
02481 
02482         const CObjectVector<uint8> &rBitmap = getPixels(0);
02483         sint32 nX[4], nY[4];
02484 
02485         x *= nWidth-1;
02486         y *= nHeight-1;
02487 
02488         // Integer part of (x,y)
02489         //nX[0] = ((sint32)floor(x-0.5f));
02490         //nY[0] = ((sint32)floor(y-0.5f));
02491         nX[0] = ((sint32)floor(x));
02492         nY[0] = ((sint32)floor(y));
02493 
02494         nX[1] = (nX[0] < (nWidth-1) ? nX[0]+1 : nX[0]);
02495         nY[1] = nY[0];
02496 
02497         nX[2] = nX[0];
02498         nY[2] = (nY[0] < (nHeight-1) ? nY[0]+1 : nY[0]);
02499 
02500         nX[3] = nX[1];
02501         nY[3] = nY[2];
02502 
02503         uint32 i;
02504 
02505         for (i = 0; i < 4; ++i)
02506         {
02507                 nlassert (nX[i] >= 0);
02508                 nlassert (nY[i] >= 0 );
02509                 nlassert (nX[i] < nWidth);
02510                 nlassert (nY[i] < nHeight);
02511         }
02512 
02513         // Decimal part of (x,y)
02514         x = x - (float)nX[0]; 
02515         y = y - (float)nY[0];
02516 
02517         switch (this->PixelFormat)
02518         {
02519                 case RGBA:
02520                 case DXTC1:
02521                 case DXTC1Alpha:
02522                 case DXTC3:
02523                 case DXTC5:
02524                 {                                                                       
02525                         CRGBAF finalVal;
02526                         CRGBA val[4];
02527 
02528                         if (this->PixelFormat == RGBA)
02529                         {
02530                                 for (i = 0; i < 4; ++i)
02531                                 {
02532                                         val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
02533                                                                         rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
02534                                                                         rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
02535                                                                         rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
02536                                 }
02537                         }
02538                         else
02539                         {
02540                                 // slower version : get from DXT
02541                                 for (i = 0; i < 4; ++i)
02542                                 {
02543                                         val[i] = getPixelColor(nX[i], nY[i]);
02544                                 }
02545                         }
02546 
02547                         finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R);
02548                         finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G);
02549                         finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B);
02550                         finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A);
02551                         finalVal /= 255.f;
02552 
02553                         return finalVal;                        
02554                 }
02555                 break;
02556                 case Alpha:
02557                 case Luminance:
02558                 {
02559                         
02560                         float finalVal;
02561                         float val[4];
02562 
02563                         for (i = 0; i < 4; ++i)
02564                                 val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
02565 
02566                         finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]);
02567                         finalVal /= 255.f;
02568 
02569                         if (this->PixelFormat == Alpha)
02570                                 return CRGBAF (1.f, 1.f, 1.f, finalVal);
02571                         else // Luminance
02572                                 return CRGBAF (finalVal, finalVal, finalVal, 1.f);
02573                 }
02574                 break;
02575                 default: break;
02576         }
02577 
02578         return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f);
02579 }

uint32 NLMISC::CBitmap::getHeight uint32  numMipMap = 0  )  const [virtual, inherited]
 

Return the image height, or a mipmap height.

Parameters:
mipMap mipmap level
Returns:
image height (0 if mipmap not found)

Definition at line 1388 of file bitmap.cpp.

References uint32, and w.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CFontManager::computeString(), NL3D::CFastHLSModifier::convertDDSBitmap(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NL3D::CPatchDLMContext::generate(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), NLMISC::CBitmap::getSize(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CShapeBank::processWSUploadTexture(), RenderTriangle(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().

01389 {
01390         if(mipMap==0) return _Height;
01391         
01392         uint32 w = _Width;
01393         uint32 h = _Height;
01394         uint32 m = 0;
01395 
01396         do
01397         {
01398                 m++;
01399                 w = (w+1)/2;
01400                 h = (h+1)/2;
01401                 if(m==mipMap) return h;
01402         }
01403         while(w!=1 || h!=1);
01404 
01405         return 0;
01406 }

TMagFilter NL3D::ITexture::getMagFilter  )  const [inline]
 

Definition at line 214 of file texture.h.

References _MagFilter, and TMagFilter.

Referenced by NL3D::CDriverGL::activateTexture(), and NL3D::CDriverGL::setupTextureEx().

00214 {return _MagFilter;}

TMinFilter NL3D::ITexture::getMinFilter  )  const [inline]
 

Definition at line 215 of file texture.h.

References _MinFilter, and TMinFilter.

Referenced by NL3D::CDriverGL::activateTexture(), and NL3D::CDriverGL::setupTextureEx().

00215 {return _MinFilter;}

uint32 NLMISC::CBitmap::getMipMapCount  )  const [inline, inherited]
 

Return the number of mipmaps. Level0 is a mipmap...

Returns:
number of mipmaps. 0 if no image at all. 1 if no mipmaping (for the base level).

Definition at line 369 of file bitmap.h.

References NLMISC::CBitmap::_MipMapCount, and uint32.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), NL3D::CAsyncTextureManager::uploadTexturePart(), and NL3D::CAsyncTextureManager::validDXTCMipMap().

00370         {
00371                 return _MipMapCount; 
00372         }

CRGBA NLMISC::CBitmap::getPixelColor sint  x,
sint  y,
uint32  numMipMap = 0
const [inherited]
 

Get the pixel at the given coorrdinate. Works in RGBA and DXTC modes. Outside of the bitmap it returns Black (or if mipmap is not found)

Definition at line 3134 of file bitmap.cpp.

References NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), nlstop, NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::RGBA, sint, uint32, x, and y.

Referenced by NLMISC::CBitmap::getColor().

03135 {
03136         
03137         switch (PixelFormat)
03138         {
03139                 case RGBA:      
03140                         return getRGBAPixel(x, y, numMipMap);           
03141                 case DXTC1:
03142                 case DXTC1Alpha: 
03143                         return getDXTC1Texel(x, y, numMipMap);
03144                 case DXTC3:
03145                         return getDXTC3Texel(x, y, numMipMap);
03146                 case DXTC5:
03147                         return getDXTC5Texel(x, y, numMipMap);
03148                 default:
03149                         nlstop;
03150                 break;
03151         }
03152         return CRGBA::Black;
03153 }

TType NLMISC::CBitmap::getPixelFormat  )  const [inline, inherited]
 

Return the format of pixels stored at the present time in the object buffer.

Returns:
Pixel format (rgba luminance alpha alphaLuminance dxtc1 dxtc1Alpha dxtc3 dxtc5)

Definition at line 335 of file bitmap.h.

References NLMISC::CBitmap::PixelFormat.

Referenced by NL3D::CFastHLSModifier::convertDDSBitmap(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureGrouped::doGenerate(), NL3D::CDriverGL::fillBuffer(), NL3D::getGlSrcTextureFormat(), NL3D::CDriverGL::getGlTextureFormat(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CTextureFar::rebuildPatch(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CAsyncTextureManager::update(), NL3D::CDriverGL::uploadTexture(), NL3D::CAsyncTextureManager::uploadTexturePart(), and NL3D::CAsyncTextureManager::validDXTCMipMap().

00336         {
00337                 return PixelFormat; 
00338         }

const CObjectVector<uint8>& NLMISC::CBitmap::getPixels uint32  numMipMap = 0  )  const [inline, inherited]
 

Definition at line 313 of file bitmap.h.

References uint32.

00314         {
00315                 //nlassert (numMipMap<=_MipMapCount);
00316                 return _Data[numMipMap]; 
00317         }

CObjectVector<uint8>& NLMISC::CBitmap::getPixels uint32  numMipMap = 0  )  [inline, inherited]
 

Return the pixels buffer of the image, or of one of its mipmap. Return a reference of an array in pixel format get with getPixelFormat().

Returns:
CObjectVector<uint8>& RGBA pixels

Definition at line 308 of file bitmap.h.

References uint32.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC1Or1A(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC3Or5(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureDLM::copyRect(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), draw2dLine(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CTextureDLM::fillRect(), NL3D::CDriverGL::getBufferPart(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CTextureFar::rebuildPatch(), RenderTriangle(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

00309         { 
00310                 //nlassert (numMipMap<=_MipMapCount);
00311                 return _Data[numMipMap];
00312         }

const sint& NLMISC::CRefCount::getRefCount  )  const [inline, inherited]
 

Definition at line 70 of file smart_ptr.h.

References NLMISC::CRefCount::crefs, and sint.

00071         {
00072                 return  crefs;
00073         }

bool NL3D::ITexture::getReleasable  )  const [inline]
 

Return whether texture can be released. If it returns true, the driver will release the texture after generate it and upload it into the videomemory by calling release(). If it returns false, the driver won't release the texture.

Returns:
true if texture can be released, false else
See also:
setReleasable(), generate()

Definition at line 267 of file texture.h.

References _Releasable.

Referenced by NL3D::CTextureBump::getNormalizationFactor(), NL3D::GetTextureSize(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CAsyncTextureManager::uploadTexturePart().

00267 { return _Releasable; }

virtual std::string NL3D::ITexture::getShareName  )  const [inline, virtual]
 

Return the Unique ident/name of the texture, used for Driver sharing caps. Deriver should add a prefix for their texture type. eg "file::pipoland", "noise::4-4-2" etc....

Reimplemented in NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureEmboss, NL3D::CTextureFile, NL3D::CTextureGrouped, NL3D::CTextureMem, and NL3D::CTextureMultiFile.

Definition at line 338 of file texture.h.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CZoneLighter::getTexture(), NL3D::IDriver::getTextureShareName(), NL3D::CCoarseMeshBuild::remapCoordinates(), and NL3D::CAsyncFileManager3D::CMeshLoad::run().

00338 {return std::string();}

uint32 NLMISC::CBitmap::getSize uint32  numMipMap = 0  )  const [inherited]
 

Return the size (in pixels) of the image: <=> getHeight()*getWidth().

Parameters:
mipMap mipmap level
Returns:
image size (0 if mipmap not found)

Definition at line 1412 of file bitmap.cpp.

References NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getWidth(), and uint32.

Referenced by NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setupTextureEx(), NL3D::CAsyncTextureManager::update(), and NL3D::CAsyncTextureManager::uploadTexturePart().

01413 {
01414         return getHeight(numMipMap)*getWidth(numMipMap);
01415 }

TUploadFormat NL3D::ITexture::getUploadFormat  )  const [inline]
 

Definition at line 212 of file texture.h.

References _UploadFormat, and TUploadFormat.

Referenced by NL3D::CTextureBump::doGenerate(), NL3D::CDriverGL::getGlTextureFormat(), and NL3D::IDriver::getTextureShareName().

00212 {return _UploadFormat;}

uint32 NLMISC::CBitmap::getWidth uint32  numMipMap = 0  )  const [virtual, inherited]
 

Return the image width, or a mipmap width.

Parameters:
mipMap mipmap level
Returns:
image width (0 if mipmap not found)

Definition at line 1363 of file bitmap.cpp.

References uint32, and w.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CShadowMapManager::allocateTexture(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CFontManager::computeString(), NL3D::CFastHLSModifier::convertDDSBitmap(), NL3D::CTextureDLM::copyRect(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CTextureDLM::fillRect(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NL3D::CPatchDLMContext::generate(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), NLMISC::CBitmap::getSize(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CShapeBank::processWSUploadTexture(), RenderTriangle(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().

01364 {
01365         if(mipMap==0) return _Width;
01366         
01367         uint32 w = _Width;
01368         uint32 h = _Height;
01369         uint32 m = 0;
01370         
01371         do
01372         {
01373                 m++;
01374                 w = (w+1)/2;
01375                 h = (h+1)/2;
01376                 if(m==mipMap) return w;
01377         }
01378         while(w!=1 || h!=1);
01379 
01380         return 0;
01381 }

TWrapMode NL3D::ITexture::getWrapS  )  const [inline]
 

Definition at line 204 of file texture.h.

References _WrapS.

Referenced by NL3D::CDriverGL::activateTexture(), NL3D::CZoneLighter::getTexture(), and NL3D::CDriverGL::setupTextureEx().

00204 {return _WrapS;}

TWrapMode NL3D::ITexture::getWrapT  )  const [inline]
 

Definition at line 205 of file texture.h.

References _WrapT.

Referenced by NL3D::CDriverGL::activateTexture(), NL3D::CZoneLighter::getTexture(), and NL3D::CDriverGL::setupTextureEx().

00205 {return _WrapT;}

bool NL3D::ITexture::isAllInvalidated  )  const [inline]
 

Return true if ALL the texture is invalidate, else return false.

Definition at line 428 of file texture.h.

References _ListInvalidRect.

Referenced by NL3D::CDriverGL::setupTextureEx(), and touchRect().

00429         {
00430                 return  _Touched&&(_ListInvalidRect.begin()==_ListInvalidRect.end());
00431         }

virtual bool NL3D::ITexture::isBumpMap  )  const [inline, virtual]
 

Reimplemented in NL3D::CTextureBump.

Definition at line 380 of file texture.h.

Referenced by NL3D::CDriverGL::setupWaterPassARB(), NL3D::CDriverGL::setupWaterPassNV20(), and NL3D::CDriverGL::setupWaterPassR200().

00380 { return false; }

bool NLMISC::CBitmap::isGrayscaleAsAlpha  )  const [inline, inherited]
 

Tell if the bitmap loads grayscale bitmap as alpha or luminance format.

Returns:
true if the bitmap loads grayscale bitmaps as alpha, false if it loads grayscale bitmaps as luminance.

Definition at line 483 of file bitmap.h.

References NLMISC::CBitmap::_LoadGrayscaleAsAlpha.

00484         {
00485                 return _LoadGrayscaleAsAlpha;
00486         }

virtual bool NL3D::ITexture::isSelectable  )  const [inline, virtual]
 

Test wether this texture is selectable.

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 363 of file texture.h.

Referenced by NL3D::CMeshBaseInstance::selectTextureSet().

00363 { return false; }

virtual bool NL3D::ITexture::isTextureCube  )  const [inline, virtual]
 

Does this texture is a cube texture.

Reimplemented in NL3D::CTextureCube.

Definition at line 376 of file texture.h.

Referenced by NL3D::CDriverGL::activateTexture(), NL3D::convTexAddr(), NL3D::CDriverGL::copyFrameBufferToTexture(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setTextureEnvFunction(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CDriverGL::uploadTextureCube().

00376 { return false; }       

uint8 NLMISC::CBitmap::load NLMISC::IStream f,
uint  mipMapSkip = 0
[inherited]
 

Read a bitmap(TGA or DDS) from an IStream. Bitmap supported are DDS (DXTC1, DXTC1 with Alpha, DXTC3, DXTC5, and uncompressed TGA (24 and 32 bits).

Parameters:
IStream The stream must be in reading mode.
mipMapSkip if the file is a DDS with mipMap. N=mipMapSkip mipmaps are skipped.
Returns:
image depth (24 or 32), or 0 if load failed
Exceptions:
ESeekFailed : seek has failed

Definition at line 109 of file bitmap.cpp.

References NLMISC::IStream::begin, NLMISC::DDS, depth, height, NLMISC::IStream::isReading(), nlassert, NLMISC::CBitmap::readDDS(), NLMISC::CBitmap::readTGA(), NLMISC::IStream::seek(), NLMISC::IStream::serial(), uint, uint16, uint32, uint8, and width.

Referenced by NL3D::CTextureFile::buildBitmapFromFile(), and NL3D::CTextureMem::doGenerate().

00110 {
00111         nlassert(f.isReading()); 
00112         
00113         // testing if DDS
00114         uint32 fileType = 0;;
00115         f.serial(fileType);
00116         if(fileType == DDS)
00117         {
00118 #ifdef NEL_ALL_BITMAP_WHITE
00119                 uint8 result = readDDS(f, mipMapSkip);
00120                 MakeWhite (*this);
00121                 return result;
00122 #else // NEL_ALL_BITMAP_WHITE
00123                 return readDDS(f, mipMapSkip);
00124 #endif // NEL_ALL_BITMAP_WHITE
00125         }
00126         // assuming it's TGA
00127         else 
00128         {
00129                 NLMISC::IStream::TSeekOrigin origin= f.begin;
00130                 if(!f.seek (0, origin))
00131                 {
00132                         throw ESeekFailed();
00133                 }
00134 
00135                 // Reading header, 
00136                 // To make sure that the bitmap is TGA, we check imageType and imageDepth.
00137                 uint8   lengthID;
00138                 uint8   cMapType;
00139                 uint8   imageType;
00140                 uint16  tgaOrigin;
00141                 uint16  length;
00142                 uint8   depth;
00143                 uint16  xOrg;
00144                 uint16  yOrg;
00145                 uint16  width;
00146                 uint16  height;
00147                 uint8   imageDepth;
00148                 uint8   desc;
00149                 
00150                 f.serial(lengthID);
00151                 f.serial(cMapType);
00152                 f.serial(imageType);
00153                 if(imageType!=2 && imageType!=3 && imageType!=10 && imageType!=11) return 0;
00154                 f.serial(tgaOrigin);
00155                 f.serial(length);
00156                 f.serial(depth);
00157                 f.serial(xOrg);
00158                 f.serial(yOrg);
00159                 f.serial(width);
00160                 f.serial(height);
00161                 f.serial(imageDepth);
00162                 if(imageDepth!=8 && imageDepth!=16 && imageDepth!=24 && imageDepth!=32) return 0;
00163                 f.serial(desc);
00164 
00165                 if(!f.seek (0, origin))
00166                 {
00167                         throw ESeekFailed();
00168                 }
00169 #ifdef NEL_ALL_BITMAP_WHITE
00170                 uint8 result = readTGA(f);
00171                 MakeWhite (*this);
00172                 return result;
00173 #else // NEL_ALL_BITMAP_WHITE
00174                 return readTGA(f);
00175 #endif // NEL_ALL_BITMAP_WHITE
00176                 
00177         }       
00178 }

void NLMISC::CBitmap::loadGrayscaleAsAlpha bool  loadAsAlpha  )  [inline, inherited]
 

Tell the bitmap to load grayscale bitmap as alpha or luminance format.

Parameters:
loadAsAlpha is true to load grayscale bitmaps as alpha. false to load grayscale bitmaps as luminance. default value is true.

Definition at line 472 of file bitmap.h.

References NLMISC::CBitmap::_LoadGrayscaleAsAlpha.

Referenced by NL3D::CTextureFile::buildBitmapFromFile(), and NL3D::CTileBank::getTileNoiseMap().

00473         {
00474                 _LoadGrayscaleAsAlpha=loadAsAlpha;
00475         }

void NLMISC::CBitmap::loadSize const std::string &  path,
uint32 retWidth,
uint32 retHeight
[static, inherited]
 

same than other loadSize(), but with a pathName.

See also:
loadSize()

Definition at line 2671 of file bitmap.cpp.

References NLMISC::CBitmap::loadSize(), NLMISC::CIFile::open(), and uint32.

02672 {
02673         retWidth= 0;
02674         retHeight= 0;
02675 
02676         CIFile          f(path);
02677         if(f.open(path))
02678                 loadSize(f, retWidth, retHeight);
02679 }

void NLMISC::CBitmap::loadSize NLMISC::IStream f,
uint32 width,
uint32 height
[static, inherited]
 

Determinate the bitmap size from a bitmap(TGA or DDS) from an IStream. load just header of the file. Bitmap supported are DDS (DXTC1, DXTC1 with Alpha, DXTC3, DXTC5, and uncompressed TGA (24 and 32 bits). NB: at the end, f is seeked to begin.

Parameters:
IStream The stream must be in reading mode.
width the width of the image. 0 if fails.
height the height of the image. 0 if fails.
Exceptions:
ESeekFailed : seek has failed

Definition at line 2582 of file bitmap.cpp.

References NLMISC::DDS, DDSD_LINEARSIZE, depth, height, NLMISC::IStream::isReading(), nlassert, NLMISC::IStream::seek(), NLMISC::IStream::serial(), size, uint, uint16, uint32, uint8, and width.

Referenced by NLMISC::CBitmap::loadSize().

02583 {
02584         retWidth= 0;
02585         retHeight= 0;
02586 
02587 
02588         nlassert(f.isReading()); 
02589         
02590         // testing if DDS
02591         uint32 fileType = 0;
02592         f.serial(fileType);
02593         if(fileType == DDS)
02594         {
02595                 // read entire DDS header.
02596                 uint32 size = 0;
02597                 f.serial(size); // size in Bytes of header(without "DDS")
02598                 uint32 * _DDSSurfaceDesc = new uint32[size]; 
02599                 std::auto_ptr<uint32> _DDSSurfaceDescAuto(_DDSSurfaceDesc);
02600                 _DDSSurfaceDesc[0]= size;
02601 
02602                 for(uint i= 0; i<size/4 - 1; i++)
02603                 {
02604                         f.serial(_DDSSurfaceDesc[i+1]);
02605                 }
02606                 
02607                 // flags determines which members of the header structure contain valid data
02608                 uint32 flags = _DDSSurfaceDesc[1];
02609 
02610                 //verify if file have linearsize set
02611                 if(!(flags & DDSD_LINEARSIZE)) 
02612                 {
02613                         throw EDDSBadHeader();
02614                 }
02615                 
02616                 //-------------- extracting and testing useful info
02617                 retHeight  = _DDSSurfaceDesc[2];
02618                 retWidth = _DDSSurfaceDesc[3];
02619         }
02620         // assuming it's TGA
02621         else 
02622         {
02623                 if(!f.seek (0, NLMISC::IStream::begin))
02624                 {
02625                         throw ESeekFailed();
02626                 }
02627 
02628                 // Reading header, 
02629                 // To make sure that the bitmap is TGA, we check imageType and imageDepth.
02630                 uint8   lengthID;
02631                 uint8   cMapType;
02632                 uint8   imageType;
02633                 uint16  tgaOrigin;
02634                 uint16  length;
02635                 uint8   depth;
02636                 uint16  xOrg;
02637                 uint16  yOrg;
02638                 uint16  width;
02639                 uint16  height;
02640                 uint8   imageDepth;
02641                 uint8   desc;
02642                 
02643                 f.serial(lengthID);
02644                 f.serial(cMapType);
02645                 f.serial(imageType);
02646                 if(imageType!=2 && imageType!=3 && imageType!=10 && imageType!=11) return;
02647                 f.serial(tgaOrigin);
02648                 f.serial(length);
02649                 f.serial(depth);
02650                 f.serial(xOrg);
02651                 f.serial(yOrg);
02652                 f.serial(width);
02653                 f.serial(height);
02654                 f.serial(imageDepth);
02655                 if(imageDepth!=8 && imageDepth!=24 && imageDepth!=32) return;
02656                 f.serial(desc);
02657 
02658                 // Ok, we have width and height.
02659                 retWidth= width;
02660                 retHeight= height;
02661         }
02662 
02663         // reset stream.
02664         if(!f.seek (0, NLMISC::IStream::begin))
02665         {
02666                 throw ESeekFailed();
02667         }
02668 }

void NLMISC::CBitmap::makeDummy  )  [inherited]
 

Make a dummy "?" texture. Usefull for file not found. Mode is rgba.

Definition at line 184 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::PixelFormat, NLMISC::CObjectVector< uint8 >::resize(), NLMISC::CBitmap::RGBA, NLMISC::CRGBA::set(), sint, and uint8.

Referenced by NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CreateDummyMesh(), NL3D::CTextureMultiFile::doGenerate(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), and NL3D::CTextureBlend::doGenerate().

00185 {
00186         static  const uint8     bitmap[1024]= {  
00187                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00188                 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
00189                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00190                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00191                 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00192                 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00193                 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00194                 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00195                 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
00196                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00197                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00198                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00199                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00200                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00201                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00202                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00203                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00204                 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
00205                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00206                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00207                 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00208                 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00209                 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00210                 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00211                 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
00212                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00213                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00214                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00215                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00216                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00217                 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00218                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00219         }; 
00220 
00221         PixelFormat = RGBA;
00222         _MipMapCount = 1;
00223         _Width= 32;
00224         _Height= 32;
00225         _Data[0].resize(_Width*_Height*sizeof(NLMISC::CRGBA));
00226         NLMISC::CRGBA   *pix= (NLMISC::CRGBA*)(_Data[0].getPtr());
00227 
00228         for(sint i=0;i<(sint)(_Width*_Height);i++)
00229         {
00230                 if(bitmap[i])
00231                         pix[i].set(255,255,255,255);
00232                 else
00233                         pix[i].set(0x80,0x80,0x80,0x40);
00234         }
00235 
00236 }

bool NL3D::ITexture::mipMapOff  )  const [inline]
 

Definition at line 216 of file texture.h.

References _MinFilter, LinearMipMapOff, and NearestMipMapOff.

Referenced by mipMapOn(), and setFilterMode().

bool NL3D::ITexture::mipMapOn  )  const [inline]
 

Definition at line 217 of file texture.h.

References mipMapOff().

Referenced by NL3D::IDriver::getTextureShareName(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

00217 {return !mipMapOff();}

ITexture & NL3D::ITexture::operator= const ITexture tex  ) 
 

The operator= do not copy drv info, and set touched=true. _Releasable, WrapMode and UploadFormat are copied.

Definition at line 72 of file texture.cpp.

References _MagFilter, _MinFilter, _Releasable, _UploadFormat, _WrapS, _WrapT, and touch().

Referenced by ITexture().

00073 {
00074         // The operator= do not copy drv info
00075         // set touched=true. _Releasable is copied.
00076         _UploadFormat= tex._UploadFormat;
00077         _Releasable= tex._Releasable;
00078         _WrapS= tex._WrapS;
00079         _WrapT= tex._WrapT;
00080         _MagFilter= tex._MagFilter;
00081         _MinFilter= tex._MinFilter; 
00082         touch();
00083         return *this;
00084 }

virtual void NL3D::ITexture::release void   )  [inline, virtual]
 

Release the texure (free memory)

Reimplemented in NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureEmboss, and NL3D::CTextureGrouped.

Definition at line 327 of file texture.h.

References _GoodGenerate, and NLMISC::CBitmap::reset().

Referenced by NL3D::CZoneLighter::getTexture(), NL3D::GetTextureSize(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CAsyncTextureManager::update().

00327 { reset(); _GoodGenerate= false; }

void NL3D::ITexture::releaseDriverSetup  ) 
 

Release the Driver info for this texture (if any). Call it with care.

Definition at line 64 of file texture.cpp.

References NLMISC::CRefPtr< CTextureDrvShare >::kill(), and TextureDrvShare.

Referenced by NL3D::CMeshBaseInstance::isAsyncTextureReady(), and ~ITexture().

00065 {
00066         // Must kill the drv mirror of this texture.
00067         TextureDrvShare.kill();
00068 }

void NLMISC::CBitmap::releaseMipMaps  )  [inherited]
 

Release the mipmaps of the bitmap if they exist. Work for any mode.

See also:
buildMipMaps().

Definition at line 1493 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::contReset(), NLMISC::MAX_MIPMAP, and sint.

Referenced by NL3D::CAsyncTextureManager::CTextureEntry::createCoarseBitmap(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NLMISC::CBitmap::resample(), NLMISC::CBitmap::resize(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), and NL3D::CDriverGL::setupTextureEx().

01494 {
01495         if(_MipMapCount<=1) return;
01496 
01497         _MipMapCount=1;
01498         for(sint i=1;i<MAX_MIPMAP;i++)
01499         {
01500                 NLMISC::contReset(_Data[i]); 
01501         }
01502 }

void NLMISC::CBitmap::resample sint32  nNewWidth,
sint32  nNewHeight
[inherited]
 

Resample the bitmap. If mipmaps exist they are deleted, then rebuilt after resampling.

Parameters:
nNewWidth width after resample
nNewHeight height after resample

Definition at line 1508 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CBitmap::buildMipMaps(), NLMISC::contReset(), nlassert, NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::resamplePicture32(), NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), NLMISC::CBitmap::RGBA, and sint32.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), and NL3D::CDriverGL::setupTextureEx().

01509 {
01510         nlassert(PixelFormat == RGBA);
01511         bool needRebuild = false;
01512 
01513         // Deleting mipmaps
01514         if(_MipMapCount>1)
01515                 needRebuild = true;
01516         releaseMipMaps();
01517 
01518         if(nNewWidth==0 || nNewHeight==0)
01519         {
01520                 _Width = _Height = 0;
01521                 return;
01522         }
01523         
01524         CObjectVector<uint8> pDestui;
01525         pDestui.resize(nNewWidth*nNewHeight*4);
01526         NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0];
01527 
01528         resamplePicture32 ((NLMISC::CRGBA*)&_Data[0][0], pDestRgba, _Width, _Height, nNewWidth, nNewHeight);
01529         NLMISC::contReset(_Data[0]); // free memory
01530         _Data[0] =  pDestui;
01531         _Width= nNewWidth;
01532         _Height= nNewHeight;
01533 
01534         // Rebuilding mipmaps
01535         if(needRebuild)
01536         {
01537                 buildMipMaps();
01538         }
01539 }

void NLMISC::CBitmap::reset TType  type = RGBA  )  [inherited]
 

Reset the buffer. Mipmaps are deleted and bitmap is not valid anymore.

Parameters:
type is the new type used for this texture

Definition at line 1599 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::contReset(), NLMISC::CBitmap::PixelFormat, NLMISC::CObjectVector< uint8 >::resize(), type, and uint.

Referenced by NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CDriverGL::getBufferPart(), and release().

01600 {
01601         for(uint i=0; i<_MipMapCount; i++)
01602         {
01603                 NLMISC::contReset(_Data[i]);
01604                 _Data[i].resize(0);
01605         }
01606         _Width = _Height = 0;
01607         _MipMapCount= 1;
01608         
01609         // Change pixel format
01610         PixelFormat=type;
01611 }

void NLMISC::CBitmap::resize sint32  nNewWidth,
sint32  nNewHeight,
TType  newType = DonTKnow,
bool  resetTo0 = true
[inherited]
 

Resize the bitmap. If mipmaps exist they are deleted and not rebuilt. This is not a crop. Pixels are lost after resize.

Parameters:
nNewWidth width after resize
nNewHeight height after resize
newType is the new type of the bitmap. If don_t_know, keep the same pixel format that before.
resetTo0 by default the vector are filled by 0. set false to gain performances.

Definition at line 1545 of file bitmap.cpp.

References NLMISC::CBitmap::DonTKnow, NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::resizeMipMap(), and sint32.

Referenced by NLMISC::CBitmap::blend(), NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureCross::doGenerate(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), and NL3D::CDriverGL::getBufferPart().

01546 {
01547         // Deleting mipmaps
01548         releaseMipMaps();
01549 
01550         // Change type of bitmap ?
01551         if (newType!=DonTKnow)
01552                 PixelFormat=newType;
01553 
01554         _Width = nNewWidth;
01555         _Height = nNewHeight;
01556 
01557         // resize the level 0 only.
01558         resizeMipMap(0, nNewWidth, nNewHeight, resetTo0);
01559 }

void NLMISC::CBitmap::resizeMipMap uint32  numMipMap,
sint32  nNewWidth,
sint32  nNewHeight,
bool  resetTo0 = true
[inherited]
 

ADVANCED USE Resize a single mipmap level. resize() should have been called before. This is not a crop. Pixels are lost after resize. No validity check is made. It is the user responsabitility fo setup correct mipmap size.

Parameters:
numMipMap id of the mipmap
nNewWidth width after resize
nNewHeight height after resize
resetTo0 by default the vector are filled by 0. set false to gain performances.

Definition at line 1565 of file bitmap.cpp.

References NLMISC::CBitmap::bitPerPixels, NLMISC::contReset(), NLMISC::CObjectVector< uint8 >::fill(), NLMISC::MAX_MIPMAP, nlassert, NLMISC::CBitmap::PixelFormat, NLMISC::CObjectVector< uint8 >::resize(), sint32, and uint32.

Referenced by NL3D::CHLSColorTexture::buildColorVersion(), and NLMISC::CBitmap::resize().

01566 {
01567         nlassert(numMipMap<MAX_MIPMAP);
01568 
01569         // free memory
01570         NLMISC::contReset(_Data[numMipMap]);
01571 
01572         // DXTC compressed??
01573         //bool  isDXTC= PixelFormat==DXTC1 || PixelFormat==DXTC1Alpha || PixelFormat==DXTC3 || PixelFormat==DXTC5;
01574         // if yes, must round up width and height to 4, for allocation
01575         nNewWidth= 4*((nNewWidth+3)/4);
01576         nNewHeight= 4*((nNewHeight+3)/4);
01577 
01578         // resize the buffer
01579         _Data[numMipMap].resize (((uint32)(nNewWidth*nNewHeight)*bitPerPixels[PixelFormat])/8);
01580 
01581         // Fill 0?
01582         if( resetTo0 )
01583                 _Data[numMipMap].fill(0);
01584 }

void NLMISC::CBitmap::rot90CCW  )  [inherited]
 

Rotation of the bitmap of 90 degree in counter clockwise

Definition at line 2781 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CBitmap::buildMipMaps(), NLMISC::contReset(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getWidth(), NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), NLMISC::CBitmap::RGBA, sint32, and uint32.

02782 {
02783         if (PixelFormat != RGBA)
02784                 return;
02785         sint32 nWidth = getWidth(0);
02786         sint32 nHeight = getHeight(0);
02787         sint32 i, j;
02788         NLMISC::CRGBA *pSrcRgba = (NLMISC::CRGBA*)&_Data[0][0];
02789         bool needRebuild = false;
02790 
02791         if(_MipMapCount>1)
02792                 needRebuild = true;
02793         releaseMipMaps();
02794 
02795         CObjectVector<uint8> pDestui;
02796         pDestui.resize(nWidth*nHeight*4);
02797         NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0];
02798 
02799         for( j = 0; j < nHeight; ++j )
02800         for( i = 0; i < nWidth;  ++i )
02801                 pDestRgba[j+i*nHeight] = pSrcRgba[nWidth-1-i+j*nWidth];
02802 
02803         uint32 nTemp = _Width;
02804         _Width = _Height;
02805         _Height = nTemp;
02806 
02807         NLMISC::contReset(_Data[0]); // free memory
02808         _Data[0] =  pDestui;
02809         // Rebuilding mipmaps
02810         if(needRebuild)
02811         {
02812                 buildMipMaps();
02813         }
02814 }

void NLMISC::CBitmap::rot90CW  )  [inherited]
 

Rotation of the bitmap of 90 degree in clockwise

Definition at line 2746 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, NLMISC::CBitmap::buildMipMaps(), NLMISC::contReset(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getWidth(), NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::releaseMipMaps(), NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), NLMISC::CBitmap::RGBA, sint32, and uint32.

02747 {
02748         if (PixelFormat != RGBA)
02749                 return;
02750         sint32 nWidth = getWidth(0);
02751         sint32 nHeight = getHeight(0);
02752         sint32 i, j;
02753         NLMISC::CRGBA *pSrcRgba = (NLMISC::CRGBA*)&_Data[0][0];
02754         bool needRebuild = false;
02755 
02756         if(_MipMapCount>1)
02757                 needRebuild = true;
02758         releaseMipMaps();
02759 
02760         CObjectVector<uint8> pDestui;
02761         pDestui.resize(nWidth*nHeight*4);
02762         NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0];
02763 
02764         for( j = 0; j < nHeight; ++j )
02765         for( i = 0; i < nWidth;  ++i )
02766                 pDestRgba[j+i*nHeight] = pSrcRgba[i+(nHeight-1-j)*nWidth];
02767 
02768         uint32 nTemp = _Width;
02769         _Width = _Height;
02770         _Height = nTemp;
02771 
02772         NLMISC::contReset(_Data[0]); // free memory
02773         _Data[0] =  pDestui;
02774         // Rebuilding mipmaps
02775         if(needRebuild)
02776         {
02777                 buildMipMaps();
02778         }
02779 }

void NLMISC::CBitmap::rotateCCW  )  [inherited]
 

Rotate a bitmap in CCW mode.

See also:
releaseMipMaps().

Definition at line 2306 of file bitmap.cpp.

References NLMISC::CBitmap::PixelFormat, NLMISC::CBitmap::RGBA, NLMISC::rotateCCW(), uint16, and uint32.

02307 {
02308         // Copy the array
02309         CObjectVector<uint8> copy=_Data[0];
02310 
02311         switch (PixelFormat)
02312         {
02313         case RGBA:
02314                 NLMISC::rotateCCW ((uint32*)&(_Data[0][0]), (uint32*)&(copy[0]), _Width, _Height);
02315                 break;
02316         case Luminance:
02317         case Alpha:
02318                 NLMISC::rotateCCW (&_Data[0][0], &copy[0], _Width, _Height);
02319                 break;
02320         case AlphaLuminance:
02321                 NLMISC::rotateCCW ((uint16*)&(_Data[0][0]), (uint16*)&(copy[0]), _Width, _Height);;
02322                 break;
02323         default: break;
02324         }
02325 
02326         uint32 tmp=_Width;
02327         _Width=_Height;
02328         _Height=tmp;
02329         _Data[0]=copy;
02330 }

virtual void NL3D::ITexture::selectTexture uint  index  )  [inline, virtual]
 

Select a texture among several other (if this texture is a set of texture such as CTextureMultiFile) The default does nothing

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 360 of file texture.h.

References index, and uint.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CCoarseMeshBuild::remapCoordinates(), and NL3D::CAsyncFileManager3D::CMeshLoad::run().

00360 {}

void NL3D::ITexture::serial NLMISC::IStream f  )  throw (NLMISC::EStream) [virtual]
 

serial ITexture basic infos (clamp ...).

Implements NLMISC::IStreamable.

Reimplemented in NL3D::CTextureCross, NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureDLM, NL3D::CTextureEmboss, NL3D::CTextureFar, NL3D::CTextureFile, NL3D::CTextureFont, NL3D::CTextureGrouped, NL3D::CTextureMem, NL3D::CTextureMultiFile, and NL3D::CTextureNear.

Definition at line 133 of file texture.cpp.

References sint.

Referenced by NL3D::CPSRibbon::serial(), and NL3D::CFlareShape::serial().

00134 {
00135         /*
00136         Version 1:
00137                 - _LoadGrayscaleAsAlpha
00138         Version 0:
00139                 - base version.
00140         */
00141 
00142         sint    ver= f.serialVersion(1);
00143 
00144         f.serialEnum(_UploadFormat);
00145         f.serialEnum(_WrapS);
00146         f.serialEnum(_WrapT);
00147         f.serialEnum(_MinFilter);
00148         f.serialEnum(_MagFilter);
00149         if(ver>=1)
00150                 f.serial(_LoadGrayscaleAsAlpha);
00151 }

void NL3D::ITexture::setFilterMode TMagFilter  magf,
TMinFilter  minf
[virtual]
 

Reimplemented in NL3D::CTextureBump.

Definition at line 100 of file texture.cpp.

References _MagFilter, _MinFilter, mipMapOff(), and touch().

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureGrouped::CTextureGrouped(), NL3D::CTextureNear::CTextureNear(), and NL3D::CVegetableManager::loadTexture().

00101 {
00102         _MagFilter= magf;
00103         // If the MipMap mode has siwtched Off/On, then must recompute...
00104         bool    precOff= mipMapOff();
00105         _MinFilter= minf;
00106         bool    nowOff= mipMapOff();
00107 
00108         if(precOff!=nowOff)
00109         {
00110                 // Must recompute mipmaps!!
00111                 touch();
00112         }
00113 }

void NLMISC::CBitmap::setMipMapCount uint32  mmc  )  [inherited]
 

ADVANCED USE To use in conjunction with resizeMipMap. Setup the correct total number of mipmap No validity check is made. It is the user responsabitility fo setup correct mipmap count.

Definition at line 1590 of file bitmap.cpp.

References NLMISC::CBitmap::_MipMapCount, uint32, and uint8.

Referenced by NL3D::CHLSColorTexture::buildColorVersion().

01591 {
01592         _MipMapCount= uint8(mmc);
01593 }

void NL3D::ITexture::setReleasable bool  r  )  [inline]
 

Set if texture can be released If it is true, the driver will release the texture after generating it and upload it into the videomemory by calling release(). If it is false, the driver won't release the texture.

See also:
getReleasable(), generate()
Parameters:
true if texture can be released, false else

Definition at line 278 of file texture.h.

References _Releasable, and r.

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CWaterPoolManager::releaseBlendTextures(), NL3D::CWaterPoolManager::setBlendFactor(), and NL3D::CAsyncTextureManager::uploadTexturePart().

00278 { _Releasable = r; }

bool NL3D::ITexture::setupedIntoDriver  )  const [inline]
 

Tells if the texture has been setuped by the driver.

Definition at line 343 of file texture.h.

References TextureDrvShare.

00344         {
00345                 return TextureDrvShare!=NULL;
00346         }

void NL3D::ITexture::setUploadFormat TUploadFormat  pf  ) 
 

Replace the uploaded format of the texture. If "Auto", the driver use CBitmap::getPixelFormat() to find the best associated pixelFormat. When no alpha is wanted (RGB, Luminance....), texture default output is 1.0. For "Alpha" mode, RGB output is (0,0,0).

Definition at line 88 of file texture.cpp.

References _UploadFormat, and touch().

Referenced by NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CDriverGL::getSpecularCubeMap(), and NL3D::CDriverGL::setupWaterPassARB().

00089 {
00090         if(pf!=_UploadFormat)
00091         {
00092                 _UploadFormat= pf;
00093                 // All the texture may be reloaded...
00094                 touch();
00095         }
00096 }

void NL3D::ITexture::setWrapS TWrapMode  mode  )  [inline]
 

By default, parameters are:

  • WrapS==Repeat
  • WrapT==Repeat
  • UploadFormat== Auto
  • MagFilter== Linear.
  • MinFilter= LinearMipMapLinear.

NB: if multiple ITexture acces the same data via the sharing system (such as a CTextureFile), then:

  • WrapS/WrapT is LOCAL for each ITexture (ie each ITexture will have his own Wrap mode) => no duplication is made.
  • UploadFormat may duplicate the texture in video memory. There is one texture per different UploadFormat.
  • MinFilter may duplicate the texture in video memory in the same way, wether the texture has mipmap or not.

Definition at line 202 of file texture.h.

References _WrapS.

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CVegetableManager::loadTexture(), and NL3D::CSegRemanenceShape::setupMaterial().

00202 {_WrapS= mode;}

void NL3D::ITexture::setWrapT TWrapMode  mode  )  [inline]
 

Definition at line 203 of file texture.h.

References _WrapT.

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), and NL3D::CVegetableManager::loadTexture().

00203 {_WrapT= mode;}

virtual bool NL3D::ITexture::supportSharing  )  const [inline, virtual]
 

Does this texture support sharing system.

Reimplemented in NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureEmboss, NL3D::CTextureFile, NL3D::CTextureGrouped, NL3D::CTextureMem, and NL3D::CTextureMultiFile.

Definition at line 332 of file texture.h.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CZoneLighter::getTexture(), NL3D::CCoarseMeshBuild::remapCoordinates(), NL3D::CAsyncFileManager3D::CMeshLoad::run(), NL3D::CDriverGL::setupTextureEx(), and touchRect().

00332 {return false;}

void NL3D::ITexture::touch  )  [inline]
 

This method invalidates all the texture surface. When the driver calls generate, the texture will rebuild all the texture and the driver will update it.

See also:
isAllInvalidated(), generate(), touchRect(), touched(), _ListInvalidRect

Definition at line 227 of file texture.h.

References _GoodGenerate, and _ListInvalidRect.

Referenced by NL3D::CTextureFile::CTextureFile(), operator=(), NL3D::CTextureMultiFile::selectTexture(), NL3D::CTextureCube::selectTexture(), NL3D::CTextureEmboss::setAmbient(), NL3D::CTextureBlend::setBlendFactor(), NL3D::CTextureBlend::setBlendTexture(), NL3D::CTextureEmboss::setDiffuse(), NL3D::CTextureMultiFile::setFileName(), NL3D::CTextureFile::setFileName(), setFilterMode(), NL3D::CTextureEmboss::setHeightMap(), NL3D::CTextureBump::setHeightMap(), NL3D::CTextureEmboss::setLightDir(), NL3D::CTextureEmboss::setSlopeFactor(), NL3D::CTextureGrouped::setTextures(), and setUploadFormat().

00228         { 
00229                 _ListInvalidRect.clear (); 
00230                 _Touched=true; 
00231                 _GoodGenerate= false;
00232         }

bool NL3D::ITexture::touched void   )  [inline]
 

This method return the touched flag. If it is true, the driver will call generate to rebuild the texture.

See also:
isAllInvalidated(), generate(), touch(), touchRect(), _ListInvalidRect

Definition at line 438 of file texture.h.

Referenced by NL3D::CDriverGL::setupTextureEx().

00439         {
00440                 return _Touched;
00441         }

void NL3D::ITexture::touchRect const NLMISC::CRect rect  )  [inline]
 

This method invalidates a rectangle of the texture surface. When the driver calls generate, the texture could rebuild only this part of texture and the driver will update only those rectangles.

This method is incompatible with textures which support sharing (see class description).

See also:
isAllInvalidated(), generate(), touch(), touched(), _ListInvalidRect

Definition at line 242 of file texture.h.

References _GoodGenerate, _ListInvalidRect, isAllInvalidated(), nlassert, and supportSharing().

Referenced by NL3D::CTextureFont::getLetterInfo().

00243         { 
00244                 // The texture must not support sharing....
00245                 nlassert(!supportSharing());
00246                 // Don't invalidate the rectangle if the full texture is already invalidated.
00247                 if (!isAllInvalidated ())
00248                 {
00249                         // Add the region to invalidate list
00250                         _ListInvalidRect.push_back (rect); 
00251                         // Touch flag
00252                         _Touched=true; 
00253                 }
00254 
00255                 _GoodGenerate= false;
00256         }

void NL3D::ITexture::validateGenerateFlag  )  [inline]
 

Advanced. erase the _GoodGenerate=true. Special if you want to setup directly the bitmap without using generate(). USE IT WITH CARE!! (used by the CAsyncTextureManager)

Definition at line 322 of file texture.h.

References _GoodGenerate.

00322 {_GoodGenerate=true;}

bool NLMISC::CBitmap::writeJPG NLMISC::IStream f,
uint8  quality = 80
[inline, inherited]
 

Write a JPG from the object pixels buffer. If the current pixel format is not rgba then the method does nothing If the pixel format is Alpha then we save in 8 bpp

Parameters:
f IStream (must be a reading stream)
quality 0=very bad quality 100=best quality
Returns:
true if succeed, false else

Definition at line 620 of file bitmap.h.

References nlwarning, and uint8.

00621 {
00622         nlwarning ("You must put #define USE_JPEG before all include in the file where you call writeJPG() if you want jpeg support");
00623         return false;
00624 }

bool NLMISC::CBitmap::writeTGA NLMISC::IStream f,
uint32  d,
bool  upsideDown = false
[inherited]
 

Write a TGA (24 or 32 bits) from the object pixels buffer. If the current pixel format is not rgba then the method does nothing If the pixel format is Alpha then we save in 8 bpp

Parameters:
f IStream (must be a reading stream)
d depth : 8 or 16 or 24 or 32
upsideDown if true, the bitmap will be saved with the upside down
Returns:
true if succeed, false else

Definition at line 2139 of file bitmap.cpp.

References depth, height, NLMISC::IStream::isReading(), NLMISC::CBitmap::PixelFormat, r, NLMISC::CBitmap::RGBA, NLMISC::IStream::serial(), sint32, uint16, uint32, uint8, width, x, and y.

Referenced by NL3D::CTextureFont::dumpTextureFont(), NL3D::CZoneLighter::lightWater(), and NL3D::CNELU::screenshot().

02140 {
02141         if(f.isReading()) return false;
02142         if(d!=24 && d!=32 && d!=16 && d!=8) return false;
02143         if ((PixelFormat != RGBA)&&(PixelFormat != Alpha)&&(PixelFormat != Luminance)) return false;
02144         if ((PixelFormat == Alpha) && (d != 8)) return false;
02145         if ((PixelFormat == Luminance) && (d != 8)) return false;
02146 
02147         sint32  i,j,x,y;
02148         uint8   * scanline;
02149         uint8   r,g,b,a;
02150 
02151         uint8   lengthID = 0;
02152         uint8   cMapType = 0;
02153         uint8   imageType = 2;
02154         uint16  origin = 0;
02155         uint16  length = 0;
02156         uint8   depth = 0;
02157         uint16  xOrg = 0;
02158         uint16  yOrg = 0;
02159         uint16  width = (uint16)_Width;
02160         uint16  height = (uint16)_Height;
02161         uint8   imageDepth = (uint8)d;
02162         uint8   desc = 0;
02163         if (upsideDown)
02164                 desc |= 1<<5;
02165 
02166         if ((PixelFormat == Alpha) || (PixelFormat == Luminance))
02167                 imageType = 3; // Uncompressed grayscale
02168 
02169         f.serial(lengthID);
02170         f.serial(cMapType);
02171         f.serial(imageType);
02172         f.serial(origin);
02173         f.serial(length);
02174         f.serial(depth);
02175         f.serial(xOrg);
02176         f.serial(yOrg);
02177         f.serial(width);
02178         f.serial(height);
02179         f.serial(imageDepth);
02180         f.serial(desc);
02181 
02182         if ((PixelFormat == Alpha)||(PixelFormat == Luminance))
02183                 scanline = new uint8[width];
02184         else
02185                 scanline = new uint8[width*4];
02186         if(!scanline)
02187         {
02188                 throw EAllocationFailure();
02189         }
02190 
02191         for(y=0; y<(sint32)height; y++)
02192         {
02193                 
02194                 uint32 k=0;
02195                 if (PixelFormat == Alpha)
02196                 {
02197                         for(i=0; i<width; ++i) // Alpha
02198                         {
02199                                 scanline[k++] = _Data[0][(height-y-1)*width + i];
02200                         }
02201                 }
02202                 else if (PixelFormat == Luminance)
02203                 {
02204                         for(i=0; i<width; ++i) // Luminance
02205                         {
02206                                 scanline[k++] = _Data[0][(height-y-1)*width + i];
02207                         }
02208                 }
02209                 else
02210                 {
02211                         for(i=0; i<width*4; i+=4) // 4:RGBA
02212                         {
02213                                 if(d==16)
02214                                 {
02215                                         for(j=0; j<(sint32)4; j++)
02216                                         {
02217                                                 scanline[k++] = _Data[0][(height-y-1)*width*4 + i + j];
02218                                         }
02219                                 }
02220                                 else
02221                                 {
02222                                         for(j=0; j<(sint32)d/8; j++)
02223                                         {
02224                                                 scanline[k++] = _Data[0][(height-y-1)*width*4 + i + j];
02225                                         }
02226                                 }
02227                         }
02228                 }
02229                 
02230                 if(d==16)
02231                 {
02232                         for(x=0; x<(sint32)width; x++)
02233                         {
02234                                 r = scanline[x*4+0];
02235                                 g = scanline[x*4+1];
02236                                 b = scanline[x*4+2];
02237                                 int rr = r >>3;
02238                                 int gg = g >>3;
02239                                 int bb = b >>3;
02240                                 uint16 c16 = (rr<<10) | (gg<<5) | bb;
02241                                 scanline[x*2+0] = c16&0xff;
02242                                 scanline[x*2+1] = c16>>8;
02243                         }
02244                 }
02245                 if(d==24)
02246                 {
02247                         for(x=0; x<(sint32)width; x++)
02248                         {
02249                                 r = scanline[x*3+0];
02250                                 g = scanline[x*3+1];
02251                                 b = scanline[x*3+2];
02252                                 scanline[x*3+0] = b;
02253                                 scanline[x*3+1] = g;
02254                                 scanline[x*3+2] = r;
02255                         }
02256                 }
02257                 if(d==32)
02258                 {
02259                         for(x=0; x<(sint32)width; x++)
02260                         {
02261                                 r = scanline[x*4+0];
02262                                 g = scanline[x*4+1];
02263                                 b = scanline[x*4+2];
02264                                 a= scanline[x*4+3];
02265                                 scanline[x*4+0] = b;
02266                                 scanline[x*4+1] = g;
02267                                 scanline[x*4+2] = r;                            
02268                                 scanline[x*4+3] = a;
02269                         }
02270                 }
02271                 
02272                 int finaleSize=width*d/8;
02273                 for(i=0; i<finaleSize; i++)
02274                 {
02275                         f.serial(scanline[i]);
02276                 }               
02277         }
02278         delete scanline;
02279         return true;
02280 }


Friends And Related Function Documentation

friend struct CPtrInfo [friend, inherited]
 

Definition at line 67 of file smart_ptr.h.


Field Documentation

CObjectVector<uint8> NLMISC::CBitmap::_Data[MAX_MIPMAP] [protected, inherited]
 

Reimplemented in NL3D::CTextureMem.

Definition at line 90 of file bitmap.h.

Referenced by NLMISC::CBitmap::blend().

bool NL3D::ITexture::_GoodGenerate [private]
 

Definition at line 404 of file texture.h.

Referenced by generate(), ITexture(), release(), touch(), touchRect(), and validateGenerateFlag().

uint32 NLMISC::CBitmap::_Height [protected, inherited]
 

Definition at line 96 of file bitmap.h.

Referenced by NLMISC::CBitmap::blend().

std::list<NLMISC::CRect> NL3D::ITexture::_ListInvalidRect
 

List of invalided rectangle. If the list is empty, generate() will rebuild all the texture.

See also:
isAllInvalidated(), generate(), touch(), touchRect(), touched()

Definition at line 422 of file texture.h.

Referenced by clearTouched(), isAllInvalidated(), NL3D::CDriverGL::setupTextureEx(), touch(), and touchRect().

bool NLMISC::CBitmap::_LoadGrayscaleAsAlpha [protected, inherited]
 

Definition at line 94 of file bitmap.h.

Referenced by NLMISC::CBitmap::CBitmap(), NLMISC::CBitmap::isGrayscaleAsAlpha(), NLMISC::CBitmap::loadGrayscaleAsAlpha(), and NLMISC::CBitmap::readTGA().

TMagFilter NL3D::ITexture::_MagFilter [private]
 

Definition at line 410 of file texture.h.

Referenced by getMagFilter(), ITexture(), operator=(), and setFilterMode().

TMinFilter NL3D::ITexture::_MinFilter [private]
 

Definition at line 409 of file texture.h.

Referenced by getMinFilter(), ITexture(), mipMapOff(), operator=(), and setFilterMode().

uint8 NLMISC::CBitmap::_MipMapCount [protected, inherited]
 

Definition at line 93 of file bitmap.h.

Referenced by NLMISC::CBitmap::alphaLuminanceToAlpha(), NLMISC::CBitmap::alphaLuminanceToLuminance(), NLMISC::CBitmap::alphaLuminanceToRGBA(), NLMISC::CBitmap::alphaToAlphaLuminance(), NLMISC::CBitmap::alphaToRGBA(), NLMISC::CBitmap::buildMipMaps(), NLMISC::CBitmap::CBitmap(), NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NLMISC::CBitmap::getMipMapCount(), NLMISC::CBitmap::luminanceToAlpha(), NLMISC::CBitmap::luminanceToAlphaLuminance(), NLMISC::CBitmap::luminanceToRGBA(), NLMISC::CBitmap::makeDummy(), NLMISC::CBitmap::readDDS(), NLMISC::CBitmap::readTGA(), NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::resample(), NLMISC::CBitmap::reset(), NLMISC::CBitmap::rgbaToAlpha(), NLMISC::CBitmap::rgbaToAlphaLuminance(), NLMISC::CBitmap::rgbaToLuminance(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), and NLMISC::CBitmap::setMipMapCount().

bool NL3D::ITexture::_Releasable [private]
 

Definition at line 405 of file texture.h.

Referenced by getReleasable(), ITexture(), operator=(), and setReleasable().

bool NL3D::ITexture::_Touched [protected]
 

Definition at line 387 of file texture.h.

TUploadFormat NL3D::ITexture::_UploadFormat [private]
 

Definition at line 406 of file texture.h.

Referenced by getUploadFormat(), ITexture(), operator=(), and setUploadFormat().

uint32 NLMISC::CBitmap::_Width [protected, inherited]
 

Definition at line 95 of file bitmap.h.

Referenced by NLMISC::CBitmap::blend().

TWrapMode NL3D::ITexture::_WrapS [private]
 

Definition at line 407 of file texture.h.

Referenced by getWrapS(), ITexture(), operator=(), and setWrapS().

TWrapMode NL3D::ITexture::_WrapT [private]
 

Definition at line 408 of file texture.h.

Referenced by getWrapT(), ITexture(), operator=(), and setWrapT().

const uint32 NLMISC::CBitmap::bitPerPixels [static, inherited]
 

Initial value:

{
        32,             
        8,              
        8,              
        16,             
        4,              
        4,              
        8,              
        8,              
        16              
}

Definition at line 70 of file bitmap.cpp.

Referenced by NLMISC::CBitmap::blit(), and NLMISC::CBitmap::resizeMipMap().

sint NLMISC::CRefCount::crefs [mutable, inherited]
 

Definition at line 79 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount().

const uint32 NLMISC::CBitmap::DXTC1HEADER = NL_MAKEFOURCC('D','X', 'T', '1') [static, inherited]
 

Definition at line 83 of file bitmap.cpp.

Referenced by NLMISC::CBitmap::readDDS().

const uint32 NLMISC::CBitmap::DXTC3HEADER = NL_MAKEFOURCC('D','X', 'T', '3') [static, inherited]
 

Definition at line 84 of file bitmap.cpp.

Referenced by NLMISC::CBitmap::readDDS().

const uint32 NLMISC::CBitmap::DXTC5HEADER = NL_MAKEFOURCC('D','X', 'T', '5') [static, inherited]
 

Definition at line 85 of file bitmap.cpp.

Referenced by NLMISC::CBitmap::readDDS().

CRefCount::CPtrInfo NLMISC::CRefCount::NullPtrInfo [static, inherited]
 

Referenced by NLMISC::CRefCount::CRefCount().

CPtrInfo* NLMISC::CRefCount::pinfo [mutable, inherited]
 

Definition at line 80 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount().

enum NLMISC::CBitmap::TType NLMISC::CBitmap::PixelFormat [inherited]
 

Referenced by NLMISC::CBitmap::alphaLuminanceToAlpha(), NLMISC::CBitmap::alphaLuminanceToLuminance(), NLMISC::CBitmap::alphaLuminanceToRGBA(), NLMISC::CBitmap::alphaToAlphaLuminance(), NLMISC::CBitmap::alphaToLuminance(), NLMISC::CBitmap::alphaToRGBA(), NLMISC::CBitmap::blend(), NLMISC::CBitmap::blit(), NL3D::CTextureFile::buildBitmapFromFile(), NLMISC::CBitmap::buildMipMaps(), NLMISC::CBitmap::CBitmap(), NLMISC::CBitmap::convertToAlpha(), NLMISC::CBitmap::convertToAlphaLuminance(), NLMISC::CBitmap::convertToLuminance(), NLMISC::CBitmap::convertToRGBA(), NLMISC::CBitmap::convertToType(), NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getPixelColor(), NLMISC::CBitmap::getPixelFormat(), NLMISC::CBitmap::luminanceToAlpha(), NLMISC::CBitmap::luminanceToAlphaLuminance(), NLMISC::CBitmap::luminanceToRGBA(), NLMISC::CBitmap::makeDummy(), NLMISC::CBitmap::readDDS(), NLMISC::CBitmap::readTGA(), NLMISC::CBitmap::resample(), NLMISC::CBitmap::reset(), NLMISC::CBitmap::resize(), NLMISC::CBitmap::resizeMipMap(), NLMISC::CBitmap::rgbaToAlpha(), NLMISC::CBitmap::rgbaToAlphaLuminance(), NLMISC::CBitmap::rgbaToLuminance(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), NLMISC::CBitmap::rotateCCW(), NL3D::sameDXTCFormat(), and NLMISC::CBitmap::writeTGA().

NLMISC::CRefPtr<CTextureDrvShare> NL3D::ITexture::TextureDrvShare
 

Definition at line 416 of file texture.h.

Referenced by NL3D::CDriverGL::copyFrameBufferToTexture(), NL3D::getTextureGl(), NL3D::CDriverGL::getTextureHandle(), releaseDriverSetup(), setupedIntoDriver(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CDriverGL::uploadTextureCube().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 08:40:20 2004 for NeL by doxygen 1.3.6