#include <texture_multi_file.h>
Inheritance diagram for NL3D::CTextureMultiFile:
Nevrax France
Definition at line 48 of file texture_multi_file.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 ITexture * | buildNonSelectableVersion (uint index) |
=========================================================== | |
void | clearTouched (void) |
bool | convertToType (TType type) |
CTextureMultiFile (uint numTexs=0) | |
=========================================================== | |
virtual void | doGenerate (bool async=false) |
=========================================================== | |
void | flipH () |
void | flipV () |
void | generate (bool async=false) |
virtual std::string | getClassName ()=0 |
CRGBAF | getColor (float x, float y) const |
const std::string & | getFileName (uint index) const |
virtual uint32 | getHeight (uint32 numMipMap=0) const |
uint32 | getMipMapCount () const |
uint | getNumFileName () const |
CRGBA | getPixelColor (sint x, sint y, uint32 numMipMap=0) const |
TType | getPixelFormat () const |
const sint & | getRefCount () 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 (CTextureMultiFile) | |
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) |
=========================================================== | |
void | setFileName (uint index, const char *) |
=========================================================== | |
void | setMipMapCount (uint32 mmc) |
void | setNumTextures (uint numTexs) |
=========================================================== | |
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) |
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< CTextureDrvShare > | TextureDrvShare |
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 | |
sint | getTexIndex (uint index) const |
=========================================================== | |
const std::string & | getTexNameByIndex (uint index) const |
=========================================================== | |
Private Attributes | |
uint32 | _CurrSelectedTexture |
std::vector< std::string > | _FileNames |
Friends | |
struct | CPtrInfo |
|
Magnification mode. Same behavior as OpenGL. Definition at line 148 of file texture.h. Referenced by NL3D::ITexture::getMagFilter().
00149 { 00150 Nearest=0, 00151 Linear, 00152 00153 MagFilterCount 00154 }; |
|
Minifying mode. Same behavior as OpenGL. If the bitmap has no mipmap, and mipmap is required, then mipmaps are computed.
Definition at line 159 of file texture.h. Referenced by NL3D::ITexture::getMinFilter().
00160 { 00161 NearestMipMapOff=0, 00162 NearestMipMapNearest, 00163 NearestMipMapLinear, 00164 LinearMipMapOff, 00165 LinearMipMapNearest, 00166 LinearMipMapLinear, 00167 00168 MinFilterCount 00169 }; |
|
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; |
|
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 }; |
|
Definition at line 117 of file texture.h.
00118 { 00119 Repeat= 0, 00120 Clamp, 00121 00122 WrapModeCount 00123 }; |
|
===========================================================
Definition at line 38 of file texture_multi_file.cpp. References uint.
00038 : _CurrSelectedTexture(0), _FileNames(numTexs) 00039 { 00040 } |
|
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; } |
|
Set this bitmap as the result of the blend bewteen 2 bitmap REQUIRE : - Bm0 and Bm1 should have the same size.
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 } |
|
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
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 } |
|
Build the mipmaps of the bitmap if they don't exist. Work only in RGBA mode...
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 } |
|
===========================================================
Reimplemented from NL3D::ITexture. Definition at line 132 of file texture_multi_file.cpp. References getTexNameByIndex(), index, and uint.
00133 { 00134 CTextureFile *tf = new CTextureFile(getTexNameByIndex(index)); 00135 // copy tex parameters 00136 (ITexture &) *tf = (ITexture &) *this; // invoke ITexture = op for basics parameters 00137 // 00138 return tf; 00139 } |
|
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 } |
|
|
===========================================================
Implements NL3D::ITexture. Definition at line 77 of file texture_multi_file.cpp. References _CurrSelectedTexture, _FileNames, getTexIndex(), NLMISC::CBitmap::makeDummy(), and sint.
00078 { 00079 sint usedTexture = getTexIndex(_CurrSelectedTexture); 00080 if (usedTexture == -1) 00081 { 00082 makeDummy(); 00083 } 00084 else 00085 { 00086 CTextureFile::buildBitmapFromFile(*this, _FileNames[usedTexture], async); 00087 } 00088 } |
|
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 } |
|
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 } |
|
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).
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 } |
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
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 } |
|
get the name of the file containing the texture for the given index
Definition at line 68 of file texture_multi_file.h. References _FileNames, index, and uint.
00068 { return _FileNames[index]; } |
|
Return the image height, or a mipmap height.
Definition at line 1388 of file bitmap.cpp. 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().
|
|
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;}
|
|
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;}
|
|
Return the number of mipmaps. Level0 is a mipmap...
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 } |
|
Definition at line 63 of file texture_multi_file.h. References _FileNames, and uint.
00063 { return _FileNames.size(); } |
|
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 } |
|
Return the format of pixels stored at the present time in the object buffer.
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 } |
|
Definition at line 313 of file bitmap.h. References uint32.
00314 { 00315 //nlassert (numMipMap<=_MipMapCount); 00316 return _Data[numMipMap]; 00317 } |
|
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().
Definition at line 308 of file bitmap.h. References uint32. Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC1Or1A(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC3Or5(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureDLM::copyRect(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), draw2dLine(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CTextureDLM::fillRect(), NL3D::CDriverGL::getBufferPart(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CTextureFar::rebuildPatch(), RenderTriangle(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().
00309 { 00310 //nlassert (numMipMap<=_MipMapCount); 00311 return _Data[numMipMap]; 00312 } |
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 { 00072 return crefs; 00073 } |
|
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.
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; }
|
|
===========================================================
Reimplemented from NL3D::ITexture. Definition at line 115 of file texture_multi_file.cpp. References _CurrSelectedTexture, and getTexNameByIndex().
00116 { 00117 return getTexNameByIndex(_CurrSelectedTexture); 00118 } |
|
Return the size (in pixels) of the image: <=> getHeight()*getWidth().
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().
|
|
===========================================================
Definition at line 61 of file texture_multi_file.cpp. References _FileNames, index, sint, and uint. Referenced by doGenerate(), and getTexNameByIndex().
00062 { 00063 if (_FileNames.empty()) 00064 { 00065 return -1; 00066 } 00067 sint usedTexture = index >= _FileNames.size() ? 0 : index; 00068 if (_FileNames[usedTexture].empty()) 00069 { 00070 return (usedTexture != 0 && !_FileNames[0].empty()) ? 0 : -1; 00071 } 00072 return usedTexture; 00073 } |
|
===========================================================
Definition at line 107 of file texture_multi_file.cpp. References _FileNames, NL3D::DummyTexName(), getTexIndex(), index, sint, and uint. Referenced by buildNonSelectableVersion(), and getShareName().
00108 { 00109 sint usedTexture = getTexIndex(index); 00110 return usedTexture == -1 ? DummyTexName : _FileNames[usedTexture]; 00111 } |
|
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;}
|
|
Return the image width, or a mipmap width.
Definition at line 1363 of file bitmap.cpp. Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CShadowMapManager::allocateTexture(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CFontManager::computeString(), NL3D::CFastHLSModifier::convertDDSBitmap(), NL3D::CTextureDLM::copyRect(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CTextureDLM::fillRect(), NLMISC::CBitmap::flipH(), NLMISC::CBitmap::flipV(), NL3D::CPatchDLMContext::generate(), NLMISC::CBitmap::getColor(), NLMISC::CBitmap::getDXTC1Texel(), NLMISC::CBitmap::getDXTC3Texel(), NLMISC::CBitmap::getDXTC5Texel(), NLMISC::CBitmap::getRGBAPixel(), NLMISC::CBitmap::getSize(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CShapeBank::processWSUploadTexture(), RenderTriangle(), NLMISC::CBitmap::rot90CCW(), NLMISC::CBitmap::rot90CW(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().
|
|
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;}
|
|
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;}
|
|
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 } |
|
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; } |
|
Tell if the bitmap loads grayscale bitmap as alpha or luminance format.
Definition at line 483 of file bitmap.h. References NLMISC::CBitmap::_LoadGrayscaleAsAlpha.
00484 { 00485 return _LoadGrayscaleAsAlpha; 00486 } |
|
Test wether this texture is selectable.
Reimplemented from NL3D::ITexture. Definition at line 75 of file texture_multi_file.h.
00075 { return true; } |
|
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; } |
|
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).
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 } |
|
Tell the bitmap to load grayscale bitmap as alpha or luminance format.
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 } |
|
same than other loadSize(), but with a pathName.
Definition at line 2671 of file bitmap.cpp. References NLMISC::CBitmap::loadSize(), NLMISC::CIFile::open(), and uint32.
|
|
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.
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 } |
|
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(), 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 } |
|
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;} |
|
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();} |
|
|
|
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; } |
|
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 } |
|
Release the mipmaps of the bitmap if they exist. Work for any mode.
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 } |
|
Resample the bitmap. If mipmaps exist they are deleted, then rebuilt after resampling.
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 } |
|
Reset the buffer. Mipmaps are deleted and bitmap is not valid anymore.
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 } |
|
Resize the bitmap. If mipmaps exist they are deleted and not rebuilt. This is not a crop. Pixels are lost after resize.
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 } |
|
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.
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 } |
|
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 } |
|
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 } |
|
Rotate a bitmap in CCW mode.
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], ©[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 } |
|
===========================================================
Reimplemented from NL3D::ITexture. Definition at line 121 of file texture_multi_file.cpp. References _CurrSelectedTexture, index, NL3D::ITexture::touch(), and uint.
00122 { 00123 if (index != _CurrSelectedTexture) 00124 { 00125 _CurrSelectedTexture = index; 00126 touch(); 00127 } 00128 } |
|
===========================================================
Reimplemented from NL3D::ITexture. Definition at line 91 of file texture_multi_file.cpp.
00092 { 00093 (void)f.serialVersion(0); 00094 00095 // serial the base part of ITexture. 00096 ITexture::serial(f); 00097 00098 f.serialCont(_FileNames); 00099 f.serial(_CurrSelectedTexture); 00100 00101 if(f.isReading()) 00102 touch(); 00103 } |
|
=========================================================== Set the name of the file containing the i-th texture
Definition at line 52 of file texture_multi_file.cpp. References _CurrSelectedTexture, _FileNames, index, NL3D::ITexture::touch(), and uint.
00053 { 00054 _FileNames[index] = fileName; 00055 if (index == _CurrSelectedTexture) touch(); 00056 00057 } |
|
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(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureGrouped::CTextureGrouped(), NL3D::CTextureNear::CTextureNear(), and NL3D::CVegetableManager::loadTexture().
|
|
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 } |
|
===========================================================
Definition at line 44 of file texture_multi_file.cpp. References _CurrSelectedTexture, _FileNames, min, sint, and uint.
00045 { 00046 _FileNames.resize(numTexs); 00047 _CurrSelectedTexture = (uint) std::min((sint) _CurrSelectedTexture, std::min((sint) 0, (sint) (numTexs - 1))); 00048 } |
|
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.
Definition at line 278 of file texture.h. References NL3D::ITexture::_Releasable, and r. Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CWaterPoolManager::releaseBlendTextures(), NL3D::CWaterPoolManager::setBlendFactor(), and NL3D::CAsyncTextureManager::uploadTexturePart().
00278 { _Releasable = r; } |
|
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 } |
|
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 NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CDriverGL::getSpecularCubeMap(), and NL3D::CDriverGL::setupWaterPassARB().
00089 { 00090 if(pf!=_UploadFormat) 00091 { 00092 _UploadFormat= pf; 00093 // All the texture may be reloaded... 00094 touch(); 00095 } 00096 } |
|
By default, parameters are:
NB: if multiple ITexture acces the same data via the sharing system (such as a CTextureFile), then:
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;} |
|
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;} |
|
Does this texture support sharing system. Reimplemented from NL3D::ITexture. Definition at line 72 of file texture_multi_file.h.
00072 { return true; } |
|
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.
Definition at line 227 of file texture.h. References NL3D::ITexture::_GoodGenerate, and NL3D::ITexture::_ListInvalidRect. Referenced by NL3D::CTextureFile::CTextureFile(), NL3D::ITexture::operator=(), selectTexture(), NL3D::CTextureCube::selectTexture(), NL3D::CTextureEmboss::setAmbient(), NL3D::CTextureBlend::setBlendFactor(), NL3D::CTextureBlend::setBlendTexture(), NL3D::CTextureEmboss::setDiffuse(), 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 } |
|
This method return the touched flag. If it is true, the driver will call generate to rebuild the texture.
Definition at line 438 of file texture.h. Referenced by NL3D::CDriverGL::setupTextureEx().
00439 { 00440 return _Touched; 00441 } |
|
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).
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 } |
|
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;}
|
|
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
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 } |
|
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
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 } |
|
Definition at line 67 of file smart_ptr.h. |
|
Definition at line 86 of file texture_multi_file.h. Referenced by doGenerate(), getShareName(), selectTexture(), setFileName(), and setNumTextures(). |
|
Reimplemented in NL3D::CTextureMem. Definition at line 90 of file bitmap.h. Referenced by NLMISC::CBitmap::blend(). |
|
Definition at line 87 of file texture_multi_file.h. Referenced by doGenerate(), getFileName(), getNumFileName(), getTexIndex(), getTexNameByIndex(), setFileName(), and setNumTextures(). |
|
Definition at line 96 of file bitmap.h. Referenced by NLMISC::CBitmap::blend(). |
|
List of invalided rectangle. If the list is empty, generate() will rebuild all the texture.
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(). |
|
Definition at line 94 of file bitmap.h. Referenced by NLMISC::CBitmap::CBitmap(), NLMISC::CBitmap::isGrayscaleAsAlpha(), NLMISC::CBitmap::loadGrayscaleAsAlpha(), and NLMISC::CBitmap::readTGA(). |
|
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(). |
|
|
|
Definition at line 95 of file bitmap.h. Referenced by NLMISC::CBitmap::blend(). |
|
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(). |
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
Definition at line 83 of file bitmap.cpp. Referenced by NLMISC::CBitmap::readDDS(). |
|
Definition at line 84 of file bitmap.cpp. Referenced by NLMISC::CBitmap::readDDS(). |
|
Definition at line 85 of file bitmap.cpp. Referenced by NLMISC::CBitmap::readDDS(). |
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
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(). |
|
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(). |