scrawl
30-04-2012 20:17:50
I'm doing tooltips that show info about selected items in the game with MyGUI. Because the tooltips can contain a variety of information (with different types and counts of sub-widgets, depending on the item) I have to update these widgets (create and destroy) every frame. Basically, I was doing it like this:
However, I noticed that after looking at an object and displaying it's tooltip, the framerate drops quite rapidly. After a few seconds I'm down to 10 fps from the initial 200 fps. So, I played around a little and now use this instead:
With the second solution I have no FPS drop at all. Is there any reason why the first solution apparently causes MyGUI to leak resources, and the second one not?
void ToolTips::onFrame(float frameDuration)
{
for (size_t i=0; i<mDynamicToolTipBox->getChildCount(); ++i)
{
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(i));
}
/* Create new widgets as children of mDynamicToolTipBox*/
.....
}
However, I noticed that after looking at an object and displaying it's tooltip, the framerate drops quite rapidly. After a few seconds I'm down to 10 fps from the initial 200 fps. So, I played around a little and now use this instead:
void ToolTips::onFrame(float frameDuration)
{
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox);
mDynamicToolTipBox = mMainWidget->createWidget<Widget>("HUD_Box",
IntCoord(0, 0, mMainWidget->getCoord().width, mMainWidget->getCoord().height),
Align::Stretch, "DynamicToolTipBox");
/* Create new widgets as children of mDynamicToolTipBox */
}
With the second solution I have no FPS drop at all. Is there any reason why the first solution apparently causes MyGUI to leak resources, and the second one not?