messed up text

Help with integrating libRocket into your engine and game

messed up text

Postby cppanda on Mon Mar 05, 2012 5:39 am

hi,

i recently stumbled across librocket and tried implpementing in my engine which seemed pretty straightforward up to now, but i'm having an issue and i can't find the answer myself.

i'm just rendering a simple window and i'm not getting any errors from the librocket log, but the text rendering is messed up:
Image

i can't figure out what causes the text to be this way, i'm thought it might be one of the following:
- i build with freetype 2.4.5 (although i read that someone did this successfully in this forum)
- my render states are bad, maybe wrong blending (but there isn't anything in the scene but the librocket rendering)

is there anything else i could check?

thanks
cppanda
 
Posts: 3
Joined: Mon Mar 05, 2012 5:30 am

Re: messed up text

Postby cppanda on Thu Mar 08, 2012 10:59 am

i've pulled the newest source from github and tried recompiling with the freetype version from the support package, as well as the newest 2.4.8 Version, but i get the same result wit both freetype versions. and due to the newest pull from github it all seems even more messed up:

Image


am i the only one getting this?
cppanda
 
Posts: 3
Joined: Mon Mar 05, 2012 5:30 am

Re: messed up text

Postby halsafar on Thu Mar 08, 2012 6:01 pm

Same setup as you, messed up text. My OpenGL ES Renderer thread might be related as I'm having trouble getting it to render properly so I can't say for sure what might be the cause. When I do see text it looks identical to yours.
halsafar
 
Posts: 9
Joined: Thu Mar 08, 2012 3:20 am

Re: messed up text

Postby cppanda on Mon Apr 09, 2012 10:30 pm

haven't had time in a while, but this weekend i sat down and investigated a little. just posting this in case anyone else is having the same problem (did the same dumb mistake i did :D ). Instead of directly creating the font texture i was generating a texture, and then calling one of my engines update methods. that method was expecting stuff a little different then the stream which came from librocket, so that was my bad. hope this helps
cppanda
 
Posts: 3
Joined: Mon Mar 05, 2012 5:30 am

Re: messed up text

Postby Dex on Sun Aug 12, 2012 1:42 pm

I think this problem is due to some mismatch between sprintf and sscanf implementations in the particular cstdio you are using.

I got the same problem with messed up text using some ancient mingw gcc installation.

I tracked the problem down to the file Core\TextureResource.cpp line 138

Code: Select all
if (sscanf(source.CString(), "?font::%p/%p/%d", &handle, &layer_id, &texture_id) == 3)
{
   handle->GenerateLayerTexture(data,
                         dimensions,
                         layer_id,
                         texture_id);
}

For some unknown reason sscanf would return 1 - and not 3 as expected!

The problem (my theory, at least) is that sscanf did not correctly parse out the pointer data from the source string - which I assume was written by sprintf using the exact same format specifier "?font::%p/%p/%d" so it should work.


The solution in my case was to upgrade my build environment to a newer version of mingw gcc (4.6.1).
Above sscanf call now returns 3, font textures are now generated and the text is longer messed up.
Dex
 
Posts: 2
Joined: Sun Aug 12, 2012 1:12 pm

Re: messed up text

Postby yaxinhoo on Thu Jan 24, 2013 6:19 am

i got the same problem on ogreiphone render . but sscanf is right , it return 3. i think it is another problem lead to this .
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: messed up text

Postby gabomdq on Thu Jan 24, 2013 12:28 pm

I saw that sort of effect (fonts rendered as squares) on two situations: The texture that holds the pre rendered fonts is not valid, or it was not properly binded to the OpenGL state. The first thing would be to dig in and see what textures Rocket is creating, and verify that they have the right content in them. Then check every step of the renderer for functions returning OpenGL errors (or Direct3D errors).
gabomdq
 
Posts: 3
Joined: Wed Aug 29, 2012 12:07 pm

Re: messed up text

Postby yaxinhoo on Thu Jan 24, 2013 9:43 pm

i think it is
Code: Select all
bool FontFaceLayer::GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id)


but i don't understand the code, why copy bitmap to texture do like this . alough it had worked right on window(opengl/direct) , but it can't worked on ogre iphone gles1/gles2, it massed up.

Code: Select all
         // Copy the glyph's bitmap data into its allocated texture.
         if (glyph.bitmap_data != NULL)
         {
            byte* destination = rectangle.GetTextureData();
            byte* source = glyph.bitmap_data;
                for (int j = 0; j < glyph.bitmap_dimensions.y; ++j)
            {
               for (int k = 0; k < glyph.bitmap_dimensions.x; ++k)
                  destination[k * 4 + 3] = source[k];

               destination += rectangle.GetTextureStride();
                    len += rectangle.GetTextureStride();
                    source += glyph.bitmap_dimensions.x;
            }
               
                //memcpy(destination, glyph.bitmap_data, glyph.bitmap_dimensions.x*glyph.bitmap_dimensions.y);
         }


i had debuged to save the bitmap_data to file , it show right. but i don't know how to show the texturedata.
Last edited by yaxinhoo on Fri Jan 25, 2013 8:28 am, edited 2 times in total.
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: messed up text

Postby yaxinhoo on Thu Jan 24, 2013 9:46 pm

the bitmap like this , it seems right of the ascii letter bitmap. do you know how to show the content of texture or save the content of texture to a file ?
Attachments
35_origin.jpg
35_origin.jpg (688 Bytes) Viewed 8758 times
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: messed up text

Postby lloydw on Thu Feb 07, 2013 1:44 am

On IOS you can use the Xcode frame capture button to look at the bound OpenGL textures.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Next

Return to Engine Integration


cron