MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / read

Method read

Engine/source/gfx/bitmap/ddsLoader.cpp:547–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547bool DDSFile::read(Stream &s, U32 dropMipCount)
548{
549 if( !readHeader(s) || mMipMapCount == 0 )
550 {
551 Con::errorf("DDSFile::read - error reading header!");
552 return false;
553 }
554
555 // If we're droping mips then make sure we have enough.
556 dropMipCount = getMin( dropMipCount, mMipMapCount - 1 );
557
558 // At this point we know what sort of image we contain. So we should
559 // allocate some buffers, and read it in.
560
561 // How many surfaces are we talking about?
562 if(mFlags.test(CubeMapFlag))
563 {
564 mSurfaces.setSize( Cubemap_Surface_Count );
565
566 for ( U32 i=0; i < Cubemap_Surface_Count; i++ )
567 {
568 // Does the cubemap contain this surface?
569 if ( mFlags.test( CubeMap_PosX_Flag + ( i << 1 ) ) )
570 mSurfaces[i] = new SurfaceData();
571 else
572 {
573 mSurfaces[i] = NULL;
574 continue;
575 }
576
577 // Load all the mips.
578 for(S32 l=0; l<mMipMapCount; l++)
579 mSurfaces[i]->readNextMip(this, s, mHeight, mWidth, l, l < dropMipCount );
580 }
581
582 }
583 else if (mFlags.test(VolumeFlag))
584 {
585 // Do something with volume
586 }
587 else
588 {
589 // It's a plain old texture.
590
591 // First allocate a SurfaceData to stick this in.
592 mSurfaces.push_back(new SurfaceData());
593
594 // Load however many mips there are.
595 for(S32 i=0; i<mMipMapCount; i++)
596 mSurfaces.last()->readNextMip(this, s, mHeight, mWidth, i, i < dropMipCount);
597
598 // Ok, we're done.
599 }
600
601 // If we're dropping mips then fix up the stats.
602 if ( dropMipCount > 0 )
603 {
604 // Fix up the pitch and/or linear size.

Callers 3

readHeaderMethod · 0.45
readNextMipMethod · 0.45
createMethod · 0.45

Calls 9

errorfFunction · 0.85
getMaxFunction · 0.85
getWidthFunction · 0.85
readNextMipMethod · 0.80
lastMethod · 0.80
getHeightFunction · 0.50
testMethod · 0.45
setSizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected