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

Method read

Engine/source/gfx/bitmap/ddsFile.cpp:369–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369bool 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.

Callers 14

_handleIncludesMethod · 0.45
_compileShaderMethod · 0.45
_loadCompiledOutputMethod · 0.45
readHeaderMethod · 0.45
readNextMipMethod · 0.45
createMethod · 0.45
tga_get_pixelFunction · 0.45
sReadTGAFunction · 0.45
pngReadDataFnFunction · 0.45
sReadPNGFunction · 0.45
sReadBMPFunction · 0.45
jpegReadDataFnFunction · 0.45

Calls 9

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

Tested by

no test coverage detected