Game Development Community

GuiBitmapCtrl - "wrapping" small bitmaps is extremely slow

by Orion Elenzil · in Torque Game Engine · 05/13/2008 (9:49 am) · 4 replies

This is with a TGE 1.3-based codebase.

i decided that in a particular situation it would be nice to overlay our entire game window with fine horizontal lines. so i made a 16x16 bitmap of a few fine horizontal lines, made a GuiBitmapCtrl with "wrap" set to true, and voila! a thing of beauty!
except later i noticed that the framerate dropped a bit when this GuiControl was visible, so i did some tests.

testing with a window approximately 1000 x 600,
the baseline framerate was about 330 FPS.
when overlayed with a fullscreen GuiBitmapCtrl using a "wrapped" 8x8 image, the framerate dives to about 80 FPS.
using the exact same GuiBitmapCtrl but changing the image to 512x512, the framerate holds at about 300 FPS.

since onRender() implements repeated bitmaps by doing one draw per tile,
the 8x8 case means approximately 9,375 calls to dglDrawBitmapStretchSR(),
which certainly explains the framerate hit.

i don't have time this morning,
but i think this would be easy enough to do differently,
by reworking GuiBitmapCtrl::onRender() to make one call to dglDrawBitmapRepeating() instead of many to dglDrawBitmapStretchSR().

#1
05/13/2008 (10:00 am)
An interesting side note, and how this actually caught my eye,
is that when rendering the small images, a faint high-pitched squeal is audible in my headphones, which isn't present when rendering the larger images.
#2
05/13/2008 (11:01 am)
Actually dglDrawBitmapRepeating() just does the exact same thing,
so the proposed fix above wouldn't help. working on a better fix.
#3
05/13/2008 (11:53 am)
Did it still squeal? ;)
#4
05/13/2008 (12:25 pm)
Submitted a resource which fixes this issue, here.

i think the reason it was implemented the way it was was to account for textures which are not a power of two, in which case, yes, you need to manually draw each little tile. so the above resource detects when the texture is a power of two, and in that case uses a new dglDraw function to draw it in one swell foop.

i'm not sure how TGB goes about drawing repeating textures, but someone in that project might want to take a gander..

unfortunately the above fix also gets rid of the squealing..