| 367 | } |
| 368 | |
| 369 | bool DDSFile::read(Stream &s, U32 dropMipCount) |
| 370 | { |
| 371 | if( !readHeader(s) ) |
| 372 | { |
| 373 | Con::errorf("DDSFile::read - error reading header!"); |
| 374 | return false; |
| 375 | } |
| 376 | |
| 377 | // If we're droping mips then make sure we have enough. |
| 378 | dropMipCount = getMin( dropMipCount, mMipMapCount - 1 ); |
| 379 | |
| 380 | // At this point we know what sort of image we contain. So we should |
| 381 | // allocate some buffers, and read it in. |
| 382 | |
| 383 | // How many surfaces are we talking about? |
| 384 | if(mFlags.test(CubeMapFlag)) |
| 385 | { |
| 386 | mSurfaces.setSize( Cubemap_Surface_Count ); |
| 387 | |
| 388 | for ( U32 i=0; i < Cubemap_Surface_Count; i++ ) |
| 389 | { |
| 390 | // Does the cubemap contain this surface? |
| 391 | if ( mFlags.test( CubeMap_PosX_Flag + ( i << 1 ) ) ) |
| 392 | mSurfaces[i] = new SurfaceData(); |
| 393 | else |
| 394 | { |
| 395 | mSurfaces[i] = NULL; |
| 396 | continue; |
| 397 | } |
| 398 | |
| 399 | // Load all the mips. |
| 400 | for(S32 mip=0; mip<mMipMapCount; mip++) |
| 401 | mSurfaces[i]->readNextMip(this, s, mHeight, mWidth, mip, mip < dropMipCount ); |
| 402 | } |
| 403 | |
| 404 | } |
| 405 | else if (mFlags.test(VolumeFlag)) |
| 406 | { |
| 407 | // Do something with volume |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | // It's a plain old texture. |
| 412 | |
| 413 | // First allocate a SurfaceData to stick this in. |
| 414 | mSurfaces.push_back(new SurfaceData()); |
| 415 | |
| 416 | // Load however many mips there are. |
| 417 | for(S32 i=0; i<mMipMapCount; i++) |
| 418 | mSurfaces.last()->readNextMip(this, s, mHeight, mWidth, i, i < dropMipCount); |
| 419 | |
| 420 | // Ok, we're done. |
| 421 | } |
| 422 | |
| 423 | // If we're dropping mips then fix up the stats. |
| 424 | if ( dropMipCount > 0 ) |
| 425 | { |
| 426 | // Fix up the pitch and/or linear size. |
no test coverage detected