[Patch] Single texture font
Moderator: Committer
[Patch] Single texture font
This code changes Font such that instead of an arbitrary number of
256x256 textures, it stores all its glyphs in a single texture that is as large as it needs to be.
I don't think there is much fear of running on a device where
the glyphs won't fit on a MAX_TEXTURE_SIZE x MAX_TEXTURE_SIZE.
(At least as long as we don't have localization in chinese or something.
But I doubt our support for such a thing anyway.)
This change removes the need for switching textures while rendering text with a single font.
This is preparatory work for seeking a way to achieve the performance gains of the reckless adventure
(viewtopic.php?f=9&t=8965)
reliably and without doing anything reckless.
This is also theoretically good for performance,
but the gain is buried deep beneath various inefficiencies
without other changes.
256x256 textures, it stores all its glyphs in a single texture that is as large as it needs to be.
I don't think there is much fear of running on a device where
the glyphs won't fit on a MAX_TEXTURE_SIZE x MAX_TEXTURE_SIZE.
(At least as long as we don't have localization in chinese or something.
But I doubt our support for such a thing anyway.)
This change removes the need for switching textures while rendering text with a single font.
This is preparatory work for seeking a way to achieve the performance gains of the reckless adventure
(viewtopic.php?f=9&t=8965)
reliably and without doing anything reckless.
This is also theoretically good for performance,
but the gain is buried deep beneath various inefficiencies
without other changes.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
Re: [Patch] Single texture font
Hmm, at first sight this doesn't seem to work too well for me, at least as some text is concerned:
I was in windowed mode, and without thinking I moved the main() window around; amazingly, it helped!The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0
Re: [Patch] Single texture font
In the latter screenshot the slanted text still looks wonky.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556
- adrian_broher
- Programmer
- Posts: 1156
- Joined: Fri Mar 01, 2013 9:52 am
- Location: Germany
Re: [Patch] Single texture font
My guess its that the GL_UNPACK_ALIGNMENT isn't set properly when transferring the glyphs to the texture atlas.Foocaux wrote:I was in windowed mode, and without thinking I moved the main() window around; amazingly, it helped!
http://www.opengl.org/wiki/Pixel_Transfer#Pixel_layout
This seems to be a general problem with our(?) font/rendering code. Almost every glyph I see has some artifacts on the edges.em3 wrote:In the latter screenshot the slanted text still looks wonky.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz
Re: [Patch] Single texture font
This seems unlikely. I didn't change the part of the code that sets these parameters and that code sets the alignment as 1, which should work, I think.My guess its that the GL_UNPACK_ALIGNMENT isn't set properly when transferring the glyphs to the texture atlas.
And if it didn't work, how could it work anywhere? And how could moving the window fix it?
I am not a master of alignment, so there could be answers to all these questions, but seems a bit unlikely.
I added one pixel margin between the glyphs in the atlas. Seems to remove the artefacts. This fix could of course be done also in the original scheme,This seems to be a general problem with our(?) font/rendering code. Almost every glyph I see has some artefacts on the edges.
if we choose to stay with it.
Foocaux, does the issue arise consistently?
Does this change affect it?
Does it appear with larger font sizes (seeing the strange artefacts in more detail may help in guessing what is going on)?
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
Re: [Patch] Single texture font
The good news: no more font artifacts (used to be very visible in the research screen when at max magnification).
The bad news: my hyeroglyphs are still there.
At first I thought it was a random thing, but I've just found a way to reliably get squiggles as a window title: I close all but the fleet window, click twice on the research icon to go to research & back, tah-dah: the title is messed up. I move the fleet window about, tah-dah, english again!
I found the options for font sizes & resized the font successfully, but trying to change the value inside the 'window titles' box with the up arrow caused a crash to desktop for me.
To allow my below par laptop to compile FO, I had to disable all debug features, so I'm slightly stumped here... wish I could help more
Edit: weird, without using the up/down arrows I managed to change the window title font size: changing the title size doesn't seem to trigger a recalculation of the bitmap, so I get hyeroglyphs at 11, 10, 18; changing it to 12 'Options' - the title of the options menu itself - is readable again.
It looks like my computer doesn't like 13 as 'window titles'. Doing just that caused a CTD.
It also looks like it saved the setting as 13 just before crashing, since I now CTD every time I try to restart my compiled FO. Where are those settings kept? I've already tried Roaming\FreeOrion\config.xml, but that seems to affect only the downloaded test release...
The bad news: my hyeroglyphs are still there.
At first I thought it was a random thing, but I've just found a way to reliably get squiggles as a window title: I close all but the fleet window, click twice on the research icon to go to research & back, tah-dah: the title is messed up. I move the fleet window about, tah-dah, english again!
I found the options for font sizes & resized the font successfully, but trying to change the value inside the 'window titles' box with the up arrow caused a crash to desktop for me.
To allow my below par laptop to compile FO, I had to disable all debug features, so I'm slightly stumped here... wish I could help more
Edit: weird, without using the up/down arrows I managed to change the window title font size: changing the title size doesn't seem to trigger a recalculation of the bitmap, so I get hyeroglyphs at 11, 10, 18; changing it to 12 'Options' - the title of the options menu itself - is readable again.
It looks like my computer doesn't like 13 as 'window titles'. Doing just that caused a CTD.
It also looks like it saved the setting as 13 just before crashing, since I now CTD every time I try to restart my compiled FO. Where are those settings kept? I've already tried Roaming\FreeOrion\config.xml, but that seems to affect only the downloaded test release...
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0
Re: [Patch] Single texture font
http://freeorion.org/index.php/Config.xml I think it should be the same location for all builds (certainly is for Linux)Foocaux wrote:Where are those settings kept? I've already tried Roaming\FreeOrion\config.xml, but that seems to affect only the downloaded test release...
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: [Patch] Single texture font
I had simply missed the fact that one of the three RenderText overrides is not just
a convenience for the largest one, but wholly independent,
thereby neglecting to make it bind its font texture.
It was using its own coordinates with the texture of a different font.
a convenience for the largest one, but wholly independent,
thereby neglecting to make it bind its font texture.
It was using its own coordinates with the texture of a different font.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
Re: [Patch] Single texture font
Yep, so it is.Dilvish wrote: it should be the same location for all builds
I had 2 instances of FreeOrion running at once, in order to compare the user interface behaviour. I guess that's not a particularly good idea!
Thanks Mitten.O, compiling this new patch right now, will let you know how it goes!
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0
Re: [Patch] Single texture font
That's more like it!
The hyeroglyphs are gone, and I couldn't figure out a way to get them back. Changing window title size works properly too. (well, with one teensy weensy exception)
My build, and that's really puzzling, still doesn't like window title 13. It crashes the second I enter that number in.
Setting <title-font-size>13</title-font-size> inside config.xml, then starting FreeOrion.exe results into a crash to desktop every time.
The last line inside freeorion.log always reads:
Mitten.O, does this happen to you, or is it just me?
The hyeroglyphs are gone, and I couldn't figure out a way to get them back. Changing window title size works properly too. (well, with one teensy weensy exception)
My build, and that's really puzzling, still doesn't like window title 13. It crashes the second I enter that number in.
Setting <title-font-size>13</title-font-size> inside config.xml, then starting FreeOrion.exe results into a crash to desktop every time.
The last line inside freeorion.log always reads:
Code: Select all
DEBUG Client : HumanClientApp::Enter2DMode()
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0
Re: [Patch] Single texture font
just one more datapoint -- doesn't cause any trouble for meFoocaux wrote:Setting <title-font-size>13</title-font-size> inside config.xml, then starting FreeOrion.exe results into a crash to desktop every time.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: [Patch] Single texture font
I couldn't replicate the problem by your exact procedure.
I needed to launch freeorion, open the load dialog, close it,
then open options and change the title font from 13 to 14.
But that did it.
It is a wonder there was no more trouble.
I had a zero indexing bug.
I did not take into account that the width you need to
fit coordinate x is in fact x + 1.
Such a rookie mistake.
Thanks for helping me pin it down.
I needed to launch freeorion, open the load dialog, close it,
then open options and change the title font from 13 to 14.
But that did it.
It is a wonder there was no more trouble.
I had a zero indexing bug.
I did not take into account that the width you need to
fit coordinate x is in fact x + 1.
Such a rookie mistake.
Thanks for helping me pin it down.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
Re: [Patch] Single texture font
Yep, with the latest patch everything seems fine here!
Glad I could help, I've got a keen interest in FreeOrion.exe's optimisation.
Glad I could help, I've got a keen interest in FreeOrion.exe's optimisation.
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: [Patch] Single texture font
Builds and runs OK for me... Except for one quirk: If I set the Window Title font size to 13, I get a massive drop in FPS, while on the options screen from the main splash screen. 12, 11, or 14 render normal speed, but just on 13, it drops to 2 or 3 FPS. Regular text font size doesn't seem to have any similar effect.
Re: [Patch] Single texture font
I wasn't taking the texture max size into account properly,
which forced the opengl driver to simulate wider textures than
the hardware supported for very specific font sizes.
which forced the opengl driver to simulate wider textures than
the hardware supported for very specific font sizes.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.