makotok / Hanappe

Hanappe is a game framework for MOAI SDK.
Other
107 stars 41 forks source link

Possible Improvement: lazy init for button labels #73

Closed Vavius closed 11 years ago

Vavius commented 11 years ago

Currently, every button even without text contains empty textBox object. This breaks dynamic batching when drawing a big bunch of simple buttons.

makotok commented 11 years ago

If there is no text, is it a demand that do not want to create a Label? At the moment, I want to create a MOAITextBox empty.

It does not look like there is a problem with the performance. I only consume slightly more memory if there is no string.

Vavius commented 11 years ago

This empty labels break draw call batching - when they are rendered GL state is changing.

In my app there is a widget similar to apple's springboard - a bunch of icons that are buttons without labels. I have 20 or 30 icons on one screen and noticed that buttons do not batch - i've got something like 40 draw calls. When I remove text labels draw calls count drops to 7-8.

My proposal is to make labels created lazilly. Create label only when we fisrt time set non-empty text to button. But maybe this issue is too specific to my app. I'm now setting different priorities to button images and labels so that all textures are drawn first and only then all text boxes are drawn.

2013/5/26 makoto notifications@github.com

If there is no text, is it a demand that do not want to create a Label? At the moment, I want to create a MOAITextBox empty.

It does not look like there is a problem with the performance. I only consume slightly more memory if there is no string.

Reply to this email directly or view it on GitHubhttps://github.com/makotok/Hanappe/issues/73#issuecomment-18458493 .

÷ÁÓÉÌÉÊ ñÎÕÛÅ×ÉÞ

makotok commented 11 years ago

Thank you. I understood.

Blank label can affect performance indeed.

If it is empty, the text is to false Visible. In this way, drawing less often in the case of the same texture.

I would fix.

makotok commented 11 years ago

How to fix

It should not affect the performance in this. When delay the generation of Label, modification becomes a little cumbersome.

Is there a difference in my perception?

Vavius commented 11 years ago

Setting visible false is OK

2013/5/26 makoto notifications@github.com

How to fix

  • If empty, the text is to hide Label.

It should not affect the performance in this. When delay the generation of Label, modification becomes a little cumbersome.

Is there a difference in my perception?

Reply to this email directly or view it on GitHubhttps://github.com/makotok/Hanappe/issues/73#issuecomment-18460460 .

÷ÁÓÉÌÉÊ ñÎÕÛÅ×ÉÞ

makotok commented 11 years ago

First, I tried to control in the Visible. However, I do not know why but it did not work.

Was modified to control the properties of the different. In this way, the state does not change if there is no string.