noizex
Topic Author
Posts: 11
Joined: 15 Apr 2019, 00:43

Text rendering / OpenGL / glyph textures

08 Aug 2019, 19:26

Hi,
I think I need some help pushing me forward with this, after hours spent in RenderDoc, going through memory and trying to compare my implementation with provided GL renderer - I can't tell if I'm doing anything wrong. The result is - I see no fonts, just filled geometry - I disabled sampling of glyph texture now because that's the problem and I work entirely in RenderDoc to figure out what's wrong with my glyphs. I followed GL render device idea and I think I make same calls. This is dump from my UpdateTexture call:
Creating texture Noesis::Ramps 512x512, levels: 1
Creating texture Noesis::Glyphs_R8 1024x1024, levels: 1
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=0, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=256, y=0, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=512, y=0, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=768, y=0, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=256, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=256, y=256, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=512, y=256, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=768, y=256, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=512, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=256, y=512, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=512, y=512, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=768, y=512, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=768, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=256, y=768, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=512, y=768, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=768, y=768, width=256, height=256 dataPtr=000000ED86F3EFD0
Updating texture Noesis::Ramps (id= 1) for level 0 x=0, y=0, width=512, height=1 dataPtr=000000ED86F7DDD0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=0, width=23, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=24, y=0, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=43, y=0, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=63, y=0, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=83, y=0, width=16, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=100, y=0, width=16, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=117, y=0, width=20, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=138, y=0, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=158, y=0, width=5, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=164, y=0, width=16, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=181, y=0, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=201, y=0, width=15, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=217, y=0, width=23, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=10, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=20, y=10, width=20, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=41, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=60, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=79, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=98, y=10, width=19, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=118, y=10, width=21, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=241, y=0, width=10, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=140, y=10, width=17, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=158, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=177, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=196, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=215, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=234, y=10, width=18, height=9 dataPtr=000000ED86F72CA0
Updating texture Noesis::Glyphs_R8 (id= 2) for level 0 x=0, y=20, width=12, height=13 dataPtr=000000ED86F72CA0
And my glyph texture ends up as something like this:
texture.PNG
From what I see the data void* pointer when I check the memory has only 0s there for the first amount of calls (these that go with the 256x256 regions). Then there is another batch of updates that specify very small regions and they seem to produce that glitchy data in the left bottom corner of the 1024x1024 texture. This even resembles full letters sometimes but is obviously broken. I spent so much time I usually find a solution at this moment, but I can't really find what is wrong here. Is it font loading? I'm now returning a forced font Stream ("Gidole.tff") to make sure that it does that call and it's not my LocalFontProvider. But then it's black box - UpdateTexture call comes and I just have a void pointer to figure it out.

Does someone have a real-life example of glyph texture for, say, "Hello world" text that he could share? What the texture should contain? All I can achieve is various sort of distorted "font-like" mess in left bottom corner. Also why it updates texture twice in various ranges, from two different pointers?

Also, ramps texture is fine and renders gradients just fine. It's only the R8 glyph texture that's completely broken.

Any hints welcome, as I'm literally stuck - I can provide more info if you tell me what's needed. Thanks!
 
noizex
Topic Author
Posts: 11
Joined: 15 Apr 2019, 00:43

Re: Text rendering / OpenGL / glyph textures

08 Aug 2019, 19:54

This is what is displayed when I turn on "font rendering", and draw that glitched glyph texture:

Render:
badrender.PNG
Texture view in RenderDoc:
badtexture.PNG
So "something" is right there, the text from XAML is:
Hello world
The quick brown fox jumps over the lazy dog

so you can clearly see resemblence there, but it's not.. quite there. :/ I wonder if it maybe has something to do with unpacking the texture data? It ends up very distorted.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Text rendering / OpenGL / glyph textures

08 Aug 2019, 21:54

As explained in the other thread, you can use XamlPlayer with OpenGL and compare renderdoc frames but by the information you are giving it seems you are not uploading the R8 texture correctly. It seems you have an error in the pitch computation.
 
noizex
Topic Author
Posts: 11
Joined: 15 Apr 2019, 00:43

Re: Text rendering / OpenGL / glyph textures

08 Aug 2019, 21:57

Ok thanks for the support - I will investigate the states for working GL and how texture should look like. It almost works so I'm missing something small - at least I'm pretty sure the font loading is working :)

Who is online

Users browsing this forum: No registered users and 78 guests