MyGUI font texture problem on Android

lindenrty

26-11-2014 14:20:28

Ogre 1.9 + MyGUI3.20 + NDK-r9d + Android 4.0(OpenGLES1.0 ,TrueTypeFont )

hi,any body find this problem?
1.launch the application( Android NativeActivity).
=> has some button (attachment before.png)
2.touch mobile's [home] button.
3.resume application.
=>it looks perfect except text (attachment after.png)

i'm sorry ,my english is very bed.
could you give me some advise?

thank you for read this.

G3D

20-03-2015 13:02:11

Hello! Have same problem.. :(
Who knows a simple way how to fix it? :)

G3D

20-03-2015 14:35:13

In fact, in my case the font textures destroyed after app hide to tray and resume again:
[attachment=0]p8PH3NArpew.jpg[/attachment]

In Android cmd_handle I just notify Ogre window about native android app window terminating and recreating :
APP_CMD_TERM_WINDOW:
static_cast<Ogre::AndroidEGLWindow*>(getWindow())->_destroyInternalResources();

APP_CMD_INIT_WINDOW:
static_cast<Ogre::AndroidEGLWindow*>(getWindow())->_createInternalResources(app->window, config);

P.S. Ogre 1.9(OpenGLES2.0) + MyGUI3.20 + NDK + Android 4.4.4

G3D

20-03-2015 17:06:05

Found some fast solution in this way: :D
Index: thirdParty/MyGUI/MyGUIEngine/include/MyGUI_ResourceTrueTypeFont.h
===================================================================
--- thirdParty/MyGUI/MyGUIEngine/include/MyGUI_ResourceTrueTypeFont.h (revision 306)
+++ thirdParty/MyGUI/MyGUIEngine/include/MyGUI_ResourceTrueTypeFont.h (working copy)
@@ -35,7 +35,7 @@
{

class MYGUI_EXPORT ResourceTrueTypeFont :
- public IFont
+ public IFont, public ITextureInvalidateListener
{
MYGUI_RTTI_DERIVED( ResourceTrueTypeFont )

@@ -62,6 +62,8 @@
// code point is FontCodeType::NotDefined, but it can be customized in the font definition file.
Char getSubstituteCodePoint() const;

+ virtual void textureInvalidate(ITexture* _texture);
+
private:
void addCodePoint(Char _codePoint);
void removeCodePoint(Char _codePoint);
Index: thirdParty/MyGUI/MyGUIEngine/src/MyGUI_ResourceTrueTypeFont.cpp
===================================================================
--- thirdParty/MyGUI/MyGUIEngine/src/MyGUI_ResourceTrueTypeFont.cpp (revision 306)
+++ thirdParty/MyGUI/MyGUIEngine/src/MyGUI_ResourceTrueTypeFont.cpp (working copy)
@@ -655,9 +655,18 @@
// Create the texture and render the glyphs onto it.
//-------------------------------------------------------------------//

- mTexture = RenderManager::getInstance().createTexture(MyGUI::utility::toString((size_t)this, "_TrueTypeFont"));
-
- mTexture->createManual(texWidth, texHeight, TextureUsage::Static | TextureUsage::Write, Pixel<LAMode>::getFormat());
+ if( !mTexture )
+ {
+ mTexture = RenderManager::getInstance().createTexture(MyGUI::utility::toString((size_t)this, "_TrueTypeFont"));
+ }
+ else
+ {
+ mTexture->destroy();
+ }
+
+ mTexture->setInvalidateListener(nullptr);
+ mTexture->createManual(texWidth, texHeight, TextureUsage::Static | TextureUsage::Write, Pixel<LAMode>::getFormat());
+ mTexture->setInvalidateListener(this);

uint8* texBuffer = static_cast<uint8*>(mTexture->lock(TextureUsage::Write));

@@ -958,6 +967,12 @@
if (width > 0)
_texX += mGlyphSpacing + width;
}
+
+ void ResourceTrueTypeFont::textureInvalidate(ITexture* _texture)
+ {
+ mGlyphMap.clear();
+ initialise();
+ }

#endif // MYGUI_USE_FREETYPE

Altren

20-03-2015 23:58:17

Looks correct. Could you create pull request at github please.

G3D

21-03-2015 19:33:07

Looks correct. Could you create pull request at github please.

Ooh... :shock: Sorry, ashamed to admit my incompetence, but I never used Git... Only SVN.. :(

Altren

21-03-2015 22:51:12

Ok, I'll apply patch myself. Thank you for contribution.

Altren

22-03-2015 14:47:52

Done.