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

Method addBitmap

Engine/source/gfx/gFont.cpp:301–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301void GFont::addBitmap(PlatformFont::CharInfo &charInfo)
302{
303 U32 nextCurX = U32(mCurX + charInfo.width ); /*7) & ~0x3;*/
304 U32 nextCurY = U32(mCurY + mPlatformFont->getFontHeight()); // + 7) & ~0x3;
305
306 // These are here for postmortem debugging.
307 bool routeA = false, routeB = false;
308
309 if(mCurSheet == -1 || nextCurY >= TextureSheetSize)
310 {
311 routeA = true;
312 addSheet();
313
314 // Recalc our nexts.
315 nextCurX = U32(mCurX + charInfo.width); // + 7) & ~0x3;
316 nextCurY = U32(mCurY + mPlatformFont->getFontHeight()); // + 7) & ~0x3;
317 }
318
319 if( nextCurX >= TextureSheetSize)
320 {
321 routeB = true;
322 mCurX = 0;
323 mCurY = nextCurY;
324
325 // Recalc our nexts.
326 nextCurX = U32(mCurX + charInfo.width); // + 7) & ~0x3;
327 nextCurY = U32(mCurY + mPlatformFont->getFontHeight()); // + 7) & ~0x3;
328 }
329
330 // Check the Y once more - sometimes we advance to a new row and run off
331 // the end.
332 if(nextCurY >= TextureSheetSize)
333 {
334 routeA = true;
335 addSheet();
336
337 // Recalc our nexts.
338 nextCurX = U32(mCurX + charInfo.width); // + 7) & ~0x3;
339 nextCurY = U32(mCurY + mPlatformFont->getFontHeight()); // + 7) & ~0x3;
340 }
341
342 charInfo.bitmapIndex = mCurSheet;
343 charInfo.xOffset = mCurX;
344 charInfo.yOffset = mCurY;
345
346 mCurX = nextCurX;
347
348 S32 x, y;
349 GBitmap *bmp = mTextureSheets[mCurSheet].getBitmap();
350
351 AssertFatal(bmp->getFormat() == GFXFormatA8, "GFont::addBitmap - cannot added characters to non-greyscale textures!");
352
353 for(y = 0;y < charInfo.height;y++)
354 for(x = 0;x < charInfo.width;x++)
355 *bmp->getAddress(x + charInfo.xOffset, y + charInfo.yOffset) = charInfo.bitmapData[y * charInfo.width + x];
356
357 mTextureSheets[mCurSheet].refresh();
358}

Callers

nothing calls this directly

Calls 6

getAddressMethod · 0.80
U32Enum · 0.50
getFontHeightMethod · 0.45
getBitmapMethod · 0.45
getFormatMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected