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

Method _createTexture

Engine/source/gfx/gfxTextureManager.cpp:301–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301GFXTextureObject *GFXTextureManager::_createTexture( GBitmap *bmp,
302 const String &resourceName,
303 GFXTextureProfile *profile,
304 bool deleteBmp,
305 GFXTextureObject *inObj )
306{
307 PROFILE_SCOPE( GFXTextureManager_CreateTexture_Bitmap );
308
309 #ifdef DEBUG_SPEW
310 Platform::outputDebugString( "[GFXTextureManager] _createTexture (GBitmap) '%s'",
311 resourceName.c_str()
312 );
313 #endif
314
315 // Massage the bitmap based on any resize rules.
316 U32 scalePower = getTextureDownscalePower( profile );
317
318 GBitmap *realBmp = bmp;
319 U32 realWidth = bmp->getWidth();
320 U32 realHeight = bmp->getHeight();
321
322 if ( scalePower &&
323 isPow2(bmp->getWidth()) &&
324 isPow2(bmp->getHeight()) &&
325 profile->canDownscale() )
326 {
327 // We only work with power of 2 textures for now, so we
328 // don't have to worry about padding.
329
330 // We downscale the bitmap on the CPU... this is the reason
331 // you should be using DDS which already has good looking mips.
332 GBitmap *padBmp = bmp;
333 padBmp->extrudeMipLevels();
334 scalePower = getMin( scalePower, padBmp->getNumMipLevels() - 1 );
335
336 realWidth = getMax( (U32)1, padBmp->getWidth() >> scalePower );
337 realHeight = getMax( (U32)1, padBmp->getHeight() >> scalePower );
338 realBmp = new GBitmap( realWidth, realHeight, false, bmp->getFormat() );
339
340 // Copy to the new bitmap...
341 dMemcpy( realBmp->getWritableBits(),
342 padBmp->getBits(scalePower),
343 padBmp->getBytesPerPixel() * realWidth * realHeight );
344
345 // This line is commented out because createPaddedBitmap is commented out.
346 // If that line is added back in, this line should be added back in.
347 // delete padBmp;
348 }
349
350 // Call the internal create... (use the real* variables now, as they
351 // reflect the reality of the texture we are creating.)
352 U32 numMips = 0;
353 GFXFormat realFmt = realBmp->getFormat();
354 _validateTexParams( realWidth, realHeight, profile, numMips, realFmt );
355
356 GFXTextureObject *ret;
357 if ( inObj )
358 {

Callers

nothing calls this directly

Calls 15

isPow2Function · 0.85
getMaxFunction · 0.85
swizzleDDSFunction · 0.85
ddsCompressFunction · 0.85
canDownscaleMethod · 0.80
extrudeMipLevelsMethod · 0.80
getNumMipLevelsMethod · 0.80
getWritableBitsMethod · 0.80
noMipMethod · 0.80
isSRGBMethod · 0.80
doStoreBitmapMethod · 0.80
dMemcpyFunction · 0.50

Tested by

no test coverage detected