Game Development Community

Lagging in GuiAnimatedBitmapCtrl

by Bullitt Sesariza · in Torque Game Engine · 07/07/2008 (7:25 pm) · 1 replies

Hi, sorry to trouble you guys again. I'm using the GuiAnimatedBitmapCtrl resource from this link . I use it to a lot of places in my game, especially in playGui. But the one in playGui makes the game lags. FYI, the one in playGui is taking space of almost all of the screen. My game is set at 1280 x 720 (widescreen) and the gui is at 1024 x 600. The gui itself is used to display the "you win" or "you lose" bitmap animation. If I use the original code of the gui, it would freeze for a few seconds (like loading the assets or so) and then played it normally. I believe it's caused by this lines of code:

bool GuiAnimatedBitmapCtrl::onWake()
{   
	if (! Parent::onWake())
		return false;
	setActive(true);


	if (dStrlen(mDmlFilename))
		loadDml();
	
	mIndex = 0;
	GuiBitmapCtrl::setBitmap(mTextureHandles[mIndex]);
	mLastTime = Sim::getCurrentTime();
	
	return true;
}

So I changed it that the gui will only load the dml if it was first created in GuiAnimatedBitmapCtrl::onAdd and disabled the one in onWake like so:

bool GuiAnimatedBitmapCtrl::onAdd()
{   
	if (!Parent::onAdd())
		return false;

	[b]if (dStrlen(mDmlFilename))
		loadDml();[/b]

	return true;
}

bool GuiAnimatedBitmapCtrl::onWake()
{   
	if (! Parent::onWake())
		return false;
	setActive(true);


	[b]/*if (dStrlen(mDmlFilename))
		loadDml();*/[/b]
	
	mIndex = 0;
	GuiBitmapCtrl::setBitmap(mTextureHandles[mIndex]);
	mLastTime = Sim::getCurrentTime();
	
	return true;
}

Now the lagging changes. Instead of freezing for a few seconds before it shows up, now it doesn't freeze but it makes the whole rendering process lags. It drops from 40-60 fps to 10 or below when the playGui plays the bitmap animation. Why is this happening? Can anybody help me to solve this issue? Thanks.

#1
07/08/2008 (7:58 pm)
Bump anyone? BTW, I've noticed that all the GUI is redrawn at every frame. Is it really necessary? Can it just be redrawn if it was flagged 'dirty' only? Then again AFAIK maybe it couldn't be applied at playGui because the buffer was swapped at every frame. CMIIW.