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

Method extrudeMipLevels

Engine/source/gfx/bitmap/gBitmap.cpp:430–497  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

428
429//--------------------------------------------------------------------------
430void GBitmap::extrudeMipLevels(bool clearBorders)
431{
432 if(mNumMipLevels == 1)
433 allocateBitmap(getWidth(), getHeight(), true, getFormat());
434
435 switch (getFormat())
436 {
437 case GFXFormatR5G5B5A1:
438 {
439 for(U32 i = 1; i < mNumMipLevels; i++)
440 bitmapExtrude5551(getBits(i - 1), getWritableBits(i), getHeight(i), getWidth(i));
441 break;
442 }
443
444 case GFXFormatR8G8B8:
445 {
446 for(U32 i = 1; i < mNumMipLevels; i++)
447 bitmapExtrudeRGB(getBits(i - 1), getWritableBits(i), getHeight(i-1), getWidth(i-1));
448 break;
449 }
450
451 case GFXFormatR8G8B8A8:
452 case GFXFormatR8G8B8X8:
453 {
454 for(U32 i = 1; i < mNumMipLevels; i++)
455 bitmapExtrudeRGBA(getBits(i - 1), getWritableBits(i), getHeight(i-1), getWidth(i-1));
456 break;
457 }
458
459 case GFXFormatR16G16B16A16F:
460 {
461 for (U32 i = 1; i < mNumMipLevels; i++)
462 bitmapExtrudeFPRGBA(getBits(i - 1), getWritableBits(i), getHeight(i - 1), getWidth(i - 1));
463 break;
464 }
465
466 default:
467 break;
468 }
469 if (clearBorders)
470 {
471 for (U32 i = 1; i<mNumMipLevels; i++)
472 {
473 U32 width = getWidth(i);
474 U32 height = getHeight(i);
475 if (height<3 || width<3)
476 // bmp is all borders at this mip level
477 dMemset(getWritableBits(i),0,width*height*mBytesPerPixel);
478 else
479 {
480 width *= mBytesPerPixel;
481 U8 * bytes = getWritableBits(i);
482 U8 * end = bytes + (height-1)*width - mBytesPerPixel; // end = last row, 2nd column
483 // clear first row sans the last pixel
484 dMemset(bytes,0,width-mBytesPerPixel);
485 bytes -= mBytesPerPixel;
486 while (bytes<end)
487 {

Callers 4

_updateBaseTextureMethod · 0.80
_createTextureMethod · 0.80
gBitmap.cppFile · 0.80

Calls 3

getWidthFunction · 0.85
getHeightFunction · 0.50
dMemsetFunction · 0.50

Tested by

no test coverage detected