NL3D::CTextureDLM Class Reference

#include <texture_dlm.h>

Inheritance diagram for NL3D::CTextureDLM:

NL3D::ITexture NLMISC::CBitmap NLMISC::CRefCount NLMISC::IStreamable NLMISC::IClassable

Detailed Description

This texture is used by landscape to perform Dynamic LightMap (DLM). Actually a CTextureDLM handle many block of lightmap in one single big texture. If NL_DLM_TILE_RES, then Block can be of size of 2,3,5 or 9 * 2,3,5 or 9 (eg 2x9, or 5x5 texture). else Block can be of size of 3,5,9 or 17 * 3,5,9 or 17 (eg 3x17, or 9x9 texture).

Implementation note (NL_DLM_TILE_RES not defined): To make this possible easily, blocks of 10x10 are created and placed in the texture. Hence a 9x9 texture lies in a single block, 3 textures of 3x9 lies in a block etc... In worst case, lost space is 19% (1 - 9*9 / 10*10).

If NL_DLM_TILE_RES is defined, then, same reasoning, with blocks of 18x18. In worst case, space lost is 70%: (1 - 15*15 / 18*18). But others cases are pretty good (90% to 100%)

NB: TextureDLM ensure that point (MaxX,MaxY) of this texture is black. UseFull for patch who want default black color

Author:
Lionel Berenguier

Nevrax France

Date:
2002

Definition at line 77 of file texture_dlm.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)
 CTextureDLM ()
 TextureDLM are system. Do not need to serialize them...

 CTextureDLM (uint width, uint height)
 Constructor.

void doGenerate (bool async=false)
 Since texture is always in memory...

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 ()
 NLMISC_DECLARE_CLASS (CTextureDLM)
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)
Lightmap mgt.
bool canCreateLightMap (uint w, uint h)
 return true if can create a texture of this size.

void copyRect (uint x, uint y, uint w, uint h, CRGBA *textMap)
bool createLightMap (uint w, uint h, uint &x, uint &y)
void fillRect (uint x, uint y, uint w, uint h, uint8 value)
void modulateAndfillRect565 (uint x, uint y, uint w, uint h, CRGBA *textMap, uint16 *modColor)
void modulateAndfillRect8888 (uint x, uint y, uint w, uint h, CRGBA *textMap, CRGBA *modColor)
void modulateConstantAndfillRect (uint x, uint y, uint w, uint h, CRGBA *textMap, CRGBA modColor)
void releaseLightMap (uint x, uint y)
 Set a lightmap as free for use. It is an error to free a not allocated lightmap. (nlassert!!).


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 Attributes

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

Private Member Functions

uint getTypeForSize (uint width, uint height)
 get the lightmap type id according to lightmap size.

void linkFreeBlock (uint lMapType, CBlock *block)
 FreeBlock list mgt.

void unlinkFreeBlock (uint lMapType, CBlock *block)

Private Attributes

std::vector< CBlock_Blocks
std::vector< uint_EmptyBlocks
 The list of available Blocks, ie Blocks with FreeSpace==0.

CBlock_FreeBlocks [16]
 For each type of lightmaps (2x2, 2x3 etc...), list of blocks which are not full.

uint _WBlock
 Number of block per line.


Friends

struct CPtrInfo


Member Enumeration Documentation

enum NL3D::ITexture::TMagFilter [inherited]
 

Magnification mode. Same behavior as OpenGL.

Enumeration values:
Nearest 
Linear 
MagFilterCount 

Definition at line 148 of file texture.h.

Referenced by NL3D::ITexture::getMagFilter().

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

enum NL3D::ITexture::TMinFilter [inherited]
 

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 NL3D::ITexture::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 [inherited]
 

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 NL3D::ITexture::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 [inherited]
 

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::CTextureDLM::CTextureDLM uint  width,
uint  height
 

Constructor.

Definition at line 42 of file texture_dlm.cpp.

References _EmptyBlocks, _FreeBlocks, _WBlock, height, NL_DLM_BLOCK_SIZE, NL_DLM_LIGHTMAP_TYPE_SIZE, nlassert, NL3D::ITexture::setFilterMode(), NL3D::ITexture::setReleasable(), NL3D::ITexture::setUploadFormat(), sint, uint, and width.

00043 {
00044         nlassert(width>=NL_DLM_BLOCK_SIZE);
00045         nlassert(height>=NL_DLM_BLOCK_SIZE);
00046         nlassert(NLMISC::isPowerOf2(width));
00047         nlassert(NLMISC::isPowerOf2(height));
00048 
00049         // verify there is sufficient blocks.
00050         _WBlock= width/NL_DLM_BLOCK_SIZE;
00051         uint    nBlocks= _WBlock * (height/NL_DLM_BLOCK_SIZE);
00052         nlassert(nBlocks>=NL_DLM_LIGHTMAP_TYPE_SIZE);
00053 
00054 
00055         // The DLM texture always reside in memory...
00056         // NB: this is simplier like that, and this is not a problem, since actually only 256Ko is allocated :o)
00057         setReleasable(false);
00058         // create the bitmap.
00059         CBitmap::resize(width, height, CBitmap::RGBA);
00060         // Format of texture, 32 bits and no mipmaps.
00061         // NB: 16 bits is not a good idea, because implies lot of flicking
00062         setUploadFormat(ITexture::RGBA8888);
00063         setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
00064 
00065         // Fill the array of blocks.
00066         _Blocks.resize(nBlocks);
00067         _EmptyBlocks.resize(nBlocks);
00068         sint i;
00069         for(i=0;i<(sint)_Blocks.size();i++)
00070         {
00071                 // compute position of the block in the texture
00072                 _Blocks[i].PosX= (i%_WBlock) * NL_DLM_BLOCK_SIZE;
00073                 _Blocks[i].PosY= (i/_WBlock) * NL_DLM_BLOCK_SIZE;
00074 
00075                 // This block is free!!
00076                 _EmptyBlocks[i]=i;
00077         }
00078 
00079         // init list to NULL.
00080         for(i=0;i<(sint)NL_DLM_LIGHTMAP_TYPE_SIZE;i++)
00081         {
00082                 _FreeBlocks[i]= NULL;
00083         }
00084 
00085         // Since NL_DLM_BLOCK_SIZE is 10 or 18 (a factor of prime number 5 or 3 respectively), we are sure there is 
00086         // at least one pixel which is not used by blcks. The last pixel is filled with black (see CTextureDLm doc)
00087         nlassert(NL_DLM_BLOCK_SIZE==10 || NL_DLM_BLOCK_SIZE==18);
00088         CRGBA   *ptr= (CRGBA*)(&CBitmap::getPixels(0)[0]);
00089         // fill last pixel with black.
00090         ptr[width*height-1]= CRGBA::Black;
00091         // Also, to ensure the texture do not wrap around, disable Tiling.
00092         ITexture::setWrapS(ITexture::Clamp);
00093         ITexture::setWrapT(ITexture::Clamp);
00094 }

NL3D::CTextureDLM::CTextureDLM  )  [inline]
 

TextureDLM are system. Do not need to serialize them...

Definition at line 92 of file texture_dlm.h.

References nlstop.

00092 {nlstop;}


Member Function Documentation

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

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, inherited]
 

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; }

bool NL3D::CTextureDLM::canCreateLightMap uint  w,
uint  h
 

return true if can create a texture of this size.

Definition at line 124 of file texture_dlm.cpp.

References _EmptyBlocks, _FreeBlocks, getTypeForSize(), uint, and w.

Referenced by createLightMap().

00125 {
00126         // First test if the list is not empty.
00127         if(_FreeBlocks[getTypeForSize(w,h)])
00128                 return true;
00129 
00130         // If empty, test if there is an empty block.
00131         return _EmptyBlocks.size()>0;
00132 }

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

Definition at line 448 of file texture.h.

References NL3D::ITexture::_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 }

void NL3D::CTextureDLM::copyRect uint  x,
uint  y,
uint  w,
uint  h,
CRGBA textMap
 

refill the texture with raw data. NB: no check is made on x,y,w,h lightmap validity. CRGBA are transformed to texture format (16 bits or better) The texture is invalidate (on this part only...)

Parameters:
map is the raw array of RGBA colors to fills. must be of w*h size

Definition at line 241 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::getWidth(), sint, src, uint, w, x, and y.

Referenced by NL3D::CPatchDLMContext::compileLighting().

00242 {
00243         // copy image.
00244         CRGBA   *src= textMap;
00245         CRGBA   *dst= (CRGBA*)getPixels().getPtr();
00246         dst+= y*getWidth()+x;
00247         for(sint n= h;n>0;n--, src+= w, dst+= getWidth())
00248         {
00249                 memcpy(dst, src, w*sizeof(CRGBA));
00250         }
00251 
00252         // Invalidate the rectangle.
00253         ITexture::touchRect(CRect(x, y, w, h));
00254 }

bool NL3D::CTextureDLM::createLightMap uint  w,
uint  h,
uint x,
uint y
 

create a space for a lightmap. NB: texture space is not filled with black. return false if cannot, else return true, and return in x/y the position in the texture.

Definition at line 164 of file texture_dlm.cpp.

References _EmptyBlocks, _FreeBlocks, canCreateLightMap(), NL3D::CTextureDLM::CBlock::FreeSpace, getTypeForSize(), NL3D::CTextureDLM::CBlock::Height, linkFreeBlock(), NL_DLM_BLOCK_SIZE, nlassert, NL3D::CTextureDLM::CBlock::PosX, NL3D::CTextureDLM::CBlock::PosY, uint, unlinkFreeBlock(), w, NL3D::CTextureDLM::CBlock::Width, x, and y.

Referenced by NL3D::CPatchDLMContext::generate().

00165 {
00166         // at least cna create it??
00167         if(!canCreateLightMap(w, h))
00168                 return false;
00169 
00170         // the type of lightmap.
00171         uint    lMapType= getTypeForSize(w,h);
00172 
00173         // First manage case list is empty.
00174         //===================
00175         if(_FreeBlocks[lMapType]==NULL)
00176         {
00177                 // list is empty => allocate a block from _EmptyBlocks.
00178                 nlassert(_EmptyBlocks.size()>0);
00179 
00180                 // pop a block from empty list
00181                 CBlock  *block= &_Blocks[_EmptyBlocks.back()];
00182                 _EmptyBlocks.pop_back();
00183 
00184                 // init this block.
00185                 nlassert(block->FreeSpace==0);
00186                 // set size of lightmaps for this blocks.
00187                 block->Width= w;
00188                 block->Height= h;
00189 
00190                 // Link this block to the list.
00191                 linkFreeBlock(lMapType, block);
00192         }
00193 
00194         // Get the block from the list.
00195         CBlock  *block= _FreeBlocks[lMapType];
00196 
00197         // Allocate block lightmap.
00198         //===================
00199 
00200         // compute block info.
00201         uint    nLMapOnX= NL_DLM_BLOCK_SIZE / block->Width;
00202         uint    nLMapOnY= NL_DLM_BLOCK_SIZE / block->Height;
00203         uint    nLMapPerBlock= nLMapOnX * nLMapOnY;
00204         // bit must fit in a uint64
00205         nlassert(nLMapPerBlock<=64);
00206 
00207         // get an id in the FreeSpace bitField.
00208         uint    i;
00209         for(i= 0;i<nLMapPerBlock; i++)
00210         {
00211                 uint    mask= 1<<i;
00212                 // If the bit is not set, then this id is free.
00213                 if( (block->FreeSpace & mask)==0 )
00214                 {
00215                         // take this id, hence set this bit
00216                         block->FreeSpace|= mask;
00217                         // stop, found.
00218                         break;
00219                 }
00220         }
00221         nlassert(i<nLMapPerBlock);
00222 
00223         // compute x/y texture pos for this id.
00224         x= block->PosX + (i%nLMapOnX) * w;
00225         y= block->PosY + (i/nLMapOnX) * h;
00226 
00227 
00228         // if lightmap full
00229         //===================
00230         // if bitfield is full
00231         if( block->FreeSpace == (uint)(1<<nLMapPerBlock)-1 )
00232         {
00233                 // Must remove it from free list.
00234                 unlinkFreeBlock(lMapType, block);
00235         }
00236 
00237         return true;
00238 }

void NL3D::CTextureDLM::doGenerate bool  async = false  )  [inline, virtual]
 

Since texture is always in memory...

Implements NL3D::ITexture.

Definition at line 85 of file texture_dlm.h.

00086         {
00087                 // Do nothing. texture still in memory... :o)
00088         }

void NL3D::CTextureDLM::fillRect uint  x,
uint  y,
uint  w,
uint  h,
uint8  value
 

same as copyRect(), but fill a RGBA(value, value, value, value)

Definition at line 257 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::getWidth(), sint, uint, uint8, value, w, x, and y.

Referenced by NL3D::CPatchDLMContext::compileLighting().

00258 {
00259         // copy image.
00260         CRGBA   *dst= (CRGBA*)getPixels().getPtr();
00261         dst+= y*getWidth()+x;
00262         for(sint n= h;n>0;n--, dst+= getWidth())
00263         {
00264                 memset(dst, value, w*sizeof(CRGBA));
00265         }
00266 
00267         // Invalidate the rectangle.
00268         ITexture::touchRect(CRect(x, y, w, h));
00269 }

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, inherited]
 

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 NL3D::ITexture::_GoodGenerate, and NL3D::ITexture::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, inherited]
 

Definition at line 214 of file texture.h.

References NL3D::ITexture::_MagFilter, and NL3D::ITexture::TMagFilter.

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

00214 {return _MagFilter;}

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

Definition at line 215 of file texture.h.

References NL3D::ITexture::_MinFilter, and NL3D::ITexture::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(), copyRect(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), draw2dLine(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), 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(), modulateAndfillRect565(), modulateAndfillRect8888(), 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, inherited]
 

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 NL3D::ITexture::_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, inherited]
 

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 }

uint NL3D::CTextureDLM::getTypeForSize uint  width,
uint  height
[private]
 

get the lightmap type id according to lightmap size.

Definition at line 98 of file texture_dlm.cpp.

References NLMISC::getPowerOf2(), height, NL_DLM_LIGHTMAP_TYPE_SIZE, nlassert, uint, and width.

Referenced by canCreateLightMap(), createLightMap(), and releaseLightMap().

00099 {
00100 #ifdef NL_DLM_TILE_RES
00101         nlassert(width==3 || width==5 || width==9 || width==17);
00102         nlassert(height==3 || height==5 || height==9 || height==17);
00103 #else
00104         nlassert(width==2 || width==3 || width==5 || width==9);
00105         nlassert(height==2 || height==3 || height==5 || height==9);
00106 #endif
00107 
00108         // 0 for 2, 1 for 3, 2 for 5, and 3 for 9, and 4 for 17
00109         width= getPowerOf2(width-1);
00110         height= getPowerOf2(height-1);
00111 #ifdef NL_DLM_TILE_RES
00112         // 0 for 3, 1 for 5, 2, for 9, and 3 for 17
00113         width--; height--;
00114 #endif
00115 
00116         uint id= width + height*4;
00117         nlassert(id<NL_DLM_LIGHTMAP_TYPE_SIZE);
00118 
00119         return id;
00120 }

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

Definition at line 212 of file texture.h.

References NL3D::ITexture::_UploadFormat, and NL3D::ITexture::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(), copyRect(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), 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(), modulateAndfillRect565(), modulateAndfillRect8888(), 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, inherited]
 

Definition at line 204 of file texture.h.

References NL3D::ITexture::_WrapS.

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

00204 {return _WrapS;}

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

Definition at line 205 of file texture.h.

References NL3D::ITexture::_WrapT.

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

00205 {return _WrapT;}

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

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

Definition at line 428 of file texture.h.

References NL3D::ITexture::_ListInvalidRect.

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

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

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

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, inherited]
 

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, inherited]
 

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; }       

void NL3D::CTextureDLM::linkFreeBlock uint  lMapType,
CBlock block
[private]
 

FreeBlock list mgt.

Definition at line 136 of file texture_dlm.cpp.

References _FreeBlocks, NL3D::CTextureDLM::CBlock::FreeNext, NL3D::CTextureDLM::CBlock::FreePrec, and uint.

Referenced by createLightMap(), and releaseLightMap().

00137 {
00138         // link me to others
00139         block->FreeNext= _FreeBlocks[lMapType];
00140         block->FreePrec= NULL;
00141         // link other to me
00142         if(_FreeBlocks[lMapType])
00143                 _FreeBlocks[lMapType]->FreePrec= block;
00144         _FreeBlocks[lMapType]= block;
00145 }

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, inherited]
 

Definition at line 216 of file texture.h.

References NL3D::ITexture::_MinFilter, NL3D::ITexture::LinearMipMapOff, and NL3D::ITexture::NearestMipMapOff.

Referenced by NL3D::ITexture::mipMapOn(), and NL3D::ITexture::setFilterMode().

00216 {return _MinFilter==NearestMipMapOff || _MinFilter==LinearMipMapOff;}

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

Definition at line 217 of file texture.h.

References NL3D::ITexture::mipMapOff().

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

00217 {return !mipMapOff();}

void NL3D::CTextureDLM::modulateAndfillRect565 uint  x,
uint  y,
uint  w,
uint  h,
CRGBA textMap,
uint16 modColor
 

same as copyRect(), but modulate textMap with an array of 565 color, before copying.

Definition at line 273 of file texture_dlm.cpp.

References NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::getWidth(), NLMISC::CRGBA::R, sint, uint, uint16, w, x, and y.

Referenced by NL3D::CPatchDLMContext::compileLighting().

00274 {
00275         // compute start dst to copy.
00276         CRGBA   *dst= (CRGBA*)getPixels().getPtr();
00277         dst+= y*getWidth()+x;
00278 
00279         // precahce Data in memory (best CPU support)
00280         CFastMem::precache(textMap, w*h*sizeof(CRGBA));
00281         CFastMem::precache(modColor, w*h*sizeof(uint16));
00282 
00283         // For all lines
00284         for(sint n= h;n>0;n--, dst+= (getWidth()-w) )
00285         {
00286                 // For all the line.
00287                 for(sint nc= w;nc>0;nc--, textMap++, modColor++, dst++)
00288                 {
00289                         uint16  tc= *modColor;
00290                         // modulate R.
00291                         dst->R= ( (tc>>11) * textMap->R)>>5;
00292                         // modulate G.
00293                         dst->G= (((tc>>5)&63) * textMap->G)>>6;
00294                         // modulate B.
00295                         dst->B= ( (tc&31) * textMap->B)>>5;
00296                 }
00297         }
00298 
00299         // Invalidate the rectangle.
00300         ITexture::touchRect(CRect(x, y, w, h));
00301 }

void NL3D::CTextureDLM::modulateAndfillRect8888 uint  x,
uint  y,
uint  w,
uint  h,
CRGBA textMap,
CRGBA modColor
 

same as copyRect(), but modulate textMap with an array of CRGBA color, before copying.

Definition at line 305 of file texture_dlm.cpp.

References NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::getWidth(), NLMISC::CRGBA::R, sint, uint, w, x, and y.

Referenced by NL3D::CPatchDLMContext::compileLighting().

00306 {
00307         // compute start dst to copy.
00308         CRGBA   *dst= (CRGBA*)getPixels().getPtr();
00309         dst+= y*getWidth()+x;
00310 
00311         // precahce Data in memory (best CPU support)
00312         CFastMem::precache(textMap, w*h*sizeof(CRGBA));
00313         CFastMem::precache(modColor, w*h*sizeof(CRGBA));
00314 
00315         // For all lines
00316         for(sint n= h;n>0;n--, dst+= (getWidth()-w) )
00317         {
00318                 // For all the line.
00319                 for(sint nc= w;nc>0;nc--, textMap++, modColor++, dst++)
00320                 {
00321                         CRGBA           mc= *modColor;
00322                         // modulate RGB only
00323                         dst->R= ( mc.R * textMap->R)>>8;
00324                         dst->G= ( mc.G * textMap->G)>>8;
00325                         dst->B= ( mc.B * textMap->B)>>8;
00326                 }
00327         }
00328 
00329         // Invalidate the rectangle.
00330         ITexture::touchRect(CRect(x, y, w, h));
00331 }

void NL3D::CTextureDLM::modulateConstantAndfillRect uint  x,
uint  y,
uint  w,
uint  h,
CRGBA textMap,
CRGBA  modColor
 

same as copyRect(), but modulate textMap with a cte color, before copying.

Definition at line 335 of file texture_dlm.cpp.

References NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CBitmap::getWidth(), NLMISC::CRGBA::R, sint, uint, w, x, and y.

Referenced by NL3D::CPatchDLMContext::compileLighting().

00336 {
00337         // compute start dst to copy.
00338         CRGBA   *dst= (CRGBA*)getPixels().getPtr();
00339         dst+= y*getWidth()+x;
00340 
00341         // precahce Data in memory (best CPU support)
00342         CFastMem::precache(textMap, w*h*sizeof(CRGBA));
00343 
00344         // For all lines
00345         for(sint n= h;n>0;n--, dst+= (getWidth()-w) )
00346         {
00347                 // For all the line.
00348                 for(sint nc= w;nc>0;nc--, textMap++, dst++)
00349                 {
00350                         // modulate RGB only
00351                         dst->R= ( mc.R * textMap->R)>>8;
00352                         dst->G= ( mc.G * textMap->G)>>8;
00353                         dst->B= ( mc.B * textMap->B)>>8;
00354                 }
00355         }
00356 
00357         // Invalidate the rectangle.
00358         ITexture::touchRect(CRect(x, y, w, h));
00359 }

NL3D::CTextureDLM::NLMISC_DECLARE_CLASS CTextureDLM   ) 
 

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

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 NL3D::ITexture::_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  )  [inherited]
 

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 NL3D::ITexture::TextureDrvShare.

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

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

void NL3D::CTextureDLM::releaseLightMap uint  x,
uint  y
 

Set a lightmap as free for use. It is an error to free a not allocated lightmap. (nlassert!!).

Definition at line 363 of file texture_dlm.cpp.

References _EmptyBlocks, _WBlock, NL3D::CTextureDLM::CBlock::FreeSpace, getTypeForSize(), NL3D::CTextureDLM::CBlock::Height, linkFreeBlock(), NL_DLM_BLOCK_SIZE, nlassert, NL3D::CTextureDLM::CBlock::PosX, NL3D::CTextureDLM::CBlock::PosY, uint, unlinkFreeBlock(), NL3D::CTextureDLM::CBlock::Width, x, and y.

Referenced by NL3D::CPatchDLMContext::~CPatchDLMContext().

00364 {
00365         // Search what block is under this pos.
00366         uint    blockId= (y/NL_DLM_BLOCK_SIZE)*_WBlock + (x/NL_DLM_BLOCK_SIZE);
00367         nlassert(blockId<_Blocks.size());
00368         CBlock  *block= &_Blocks[blockId];
00369 
00370         // compute block info.
00371         uint    nLMapOnX= NL_DLM_BLOCK_SIZE / block->Width;
00372         uint    nLMapOnY= NL_DLM_BLOCK_SIZE / block->Height;
00373         uint    nLMapPerBlock= nLMapOnX * nLMapOnY;
00374         // was Full (ie all bits set) before this release
00375         bool    wasFull= (block->FreeSpace == (uint)(1<<nLMapPerBlock)-1);
00376         // the type of lightmap.
00377         uint    lMapType= getTypeForSize(block->Width, block->Height);
00378 
00379 
00380         // get relative pos to the block.
00381         x-= block->PosX;
00382         y-= block->PosY;
00383 
00384         // compute bit number.
00385         uint    bitX= x/block->Width;
00386         uint    bitY= y/block->Height;
00387         // assert good pos param.
00388         nlassert(x == bitX*block->Width);
00389         nlassert(y == bitY*block->Height);
00390 
00391         // compute bitId, as done in createLightMap()
00392         uint    bitId= bitY * nLMapOnX + bitX;
00393         uint    mask= 1<<bitId;
00394 
00395         // Free this bit in the block.
00396         nlassert(block->FreeSpace & mask);
00397         block->FreeSpace&= ~mask;
00398 
00399 
00400         // Free the block if necessary.
00401         //=======================
00402         bool    isEmpty= block->FreeSpace==0;
00403 
00404         // If wasFull and now it is empty (nLMapPerBlock==1 case), just append to EmptyBlocks.
00405         if(wasFull && isEmpty)
00406         {
00407                 // add the id to the empty list.
00408                 _EmptyBlocks.push_back(blockId);
00409         }
00410         // if wasFull, but still have some lightmap now, must insert into FreeList
00411         else if(wasFull && !isEmpty)
00412         {
00413                 linkFreeBlock(lMapType, block);
00414         }
00415         // if was not full but now it is empty, must remove from free list and insert into EmptyBlocks
00416         else if(!wasFull && isEmpty)
00417         {
00418                 // remove the block from Free List
00419                 unlinkFreeBlock(lMapType, block);
00420                 // add the id to the empty list.
00421                 _EmptyBlocks.push_back(blockId);
00422         }
00423         // else (!wasFull && !isEmpty) no-op, since must be kept in the FreeList.
00424 
00425 }

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 NL3D::ITexture::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, inherited]
 

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 {}

virtual void NL3D::CTextureDLM::serial NLMISC::IStream f  )  throw (NLMISC::EStream) [inline, virtual]
 

serial ITexture basic infos (clamp ...).

Reimplemented from NL3D::ITexture.

Definition at line 93 of file texture_dlm.h.

References nlstop.

00093 {nlstop;}

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

Reimplemented in NL3D::CTextureBump.

Definition at line 100 of file texture.cpp.

References NL3D::ITexture::_MagFilter, NL3D::ITexture::_MinFilter, NL3D::ITexture::mipMapOff(), and NL3D::ITexture::touch().

Referenced by NL3D::CShadowMapManager::allocateTexture(), 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, inherited]
 

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 NL3D::ITexture::_Releasable, and r.

Referenced by NL3D::CShadowMapManager::allocateTexture(), 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, inherited]
 

Tells if the texture has been setuped by the driver.

Definition at line 343 of file texture.h.

References NL3D::ITexture::TextureDrvShare.

00344         {
00345                 return TextureDrvShare!=NULL;
00346         }

void NL3D::ITexture::setUploadFormat TUploadFormat  pf  )  [inherited]
 

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 NL3D::ITexture::_UploadFormat, and NL3D::ITexture::touch().

Referenced by 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, inherited]
 

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 NL3D::ITexture::_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, inherited]
 

Definition at line 203 of file texture.h.

References NL3D::ITexture::_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, inherited]
 

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 NL3D::ITexture::touchRect().

00332 {return false;}

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

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 NL3D::ITexture::_GoodGenerate, and NL3D::ITexture::_ListInvalidRect.

Referenced by NL3D::CTextureFile::CTextureFile(), NL3D::ITexture::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(), NL3D::ITexture::setFilterMode(), NL3D::CTextureEmboss::setHeightMap(), NL3D::CTextureBump::setHeightMap(), NL3D::CTextureEmboss::setLightDir(), NL3D::CTextureEmboss::setSlopeFactor(), NL3D::CTextureGrouped::setTextures(), and NL3D::ITexture::setUploadFormat().

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

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

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, inherited]
 

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 NL3D::ITexture::_GoodGenerate, NL3D::ITexture::_ListInvalidRect, NL3D::ITexture::isAllInvalidated(), nlassert, and NL3D::ITexture::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::CTextureDLM::unlinkFreeBlock uint  lMapType,
CBlock block
[private]
 

Definition at line 148 of file texture_dlm.cpp.

References _FreeBlocks, NL3D::CTextureDLM::CBlock::FreeNext, NL3D::CTextureDLM::CBlock::FreePrec, and uint.

Referenced by createLightMap(), and releaseLightMap().

00149 {
00150         // unlink other from me
00151         if(block->FreeNext)
00152                 block->FreeNext->FreePrec= block->FreePrec;
00153         if(block->FreePrec)
00154                 block->FreePrec->FreeNext= block->FreeNext;
00155         else
00156                 _FreeBlocks[lMapType]= block->FreeNext;
00157         // reset me
00158         block->FreePrec= NULL;
00159         block->FreeNext= NULL;
00160 }

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

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 NL3D::ITexture::_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

std::vector<CBlock> NL3D::CTextureDLM::_Blocks [private]
 

The list of blocks. There is TextureWidth/NL_DLM_BLOCK_SIZE * TextureHeight/NL_DLM_BLOCK_SIZE blocks, ranged from left to right then top to bottom.

Definition at line 178 of file texture_dlm.h.

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().

std::vector<uint> NL3D::CTextureDLM::_EmptyBlocks [private]
 

The list of available Blocks, ie Blocks with FreeSpace==0.

Definition at line 182 of file texture_dlm.h.

Referenced by canCreateLightMap(), createLightMap(), CTextureDLM(), and releaseLightMap().

CBlock* NL3D::CTextureDLM::_FreeBlocks[ 16 ] [private]
 

For each type of lightmaps (2x2, 2x3 etc...), list of blocks which are not full.

Definition at line 186 of file texture_dlm.h.

Referenced by canCreateLightMap(), createLightMap(), CTextureDLM(), linkFreeBlock(), and unlinkFreeBlock().

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 [inherited]
 

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 NL3D::ITexture::clearTouched(), NL3D::ITexture::isAllInvalidated(), NL3D::CDriverGL::setupTextureEx(), NL3D::ITexture::touch(), and NL3D::ITexture::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().

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::_Touched [protected, inherited]
 

Definition at line 387 of file texture.h.

uint NL3D::CTextureDLM::_WBlock [private]
 

Number of block per line.

Definition at line 173 of file texture_dlm.h.

Referenced by CTextureDLM(), and releaseLightMap().

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

Definition at line 95 of file bitmap.h.

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

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 [inherited]
 

Definition at line 416 of file texture.h.

Referenced by NL3D::CDriverGL::copyFrameBufferToTexture(), NL3D::getTextureGl(), NL3D::CDriverGL::getTextureHandle(), NL3D::ITexture::releaseDriverSetup(), NL3D::ITexture::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 07:54:48 2004 for NeL by doxygen 1.3.6