| View previous topic :: View next topic |
| Author |
Message |
uberjack

Joined: 17 Jul 2007 Posts: 34 Location: California, USA
|
Posted: Thu Jul 31, 2008 6:32 pm Post subject: Low-level font rendering |
|
|
Hi,
What's the best way to implement font rendering on PSP? I've seen programs write directly to uncached VRAM, as well as using swizzled textures. I personally prefer to use sceGuDrawArray(GU_POINTS), but I haven't seen anyone else do it this way.
If you've tested various different methods, it'd be great to get a pros/cons type of comparison. For example, I'm sure writing to VRAM directly is fast, but will it bring up uncached memory access issues, when mixed with other code?
Also, if textures are used, is it still possible to control the color of the font?
Thanks
P.S. I'm not really interested in existing libraries for font rendering, as I know there are several |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Thu Jul 31, 2008 7:30 pm Post subject: |
|
|
in my personal experience the best way to do so is to load an "alphabet texture" and then render chars as textured sprites. You could even create a list for each char. So it will be faster if you swizzle your texture once loaded and for all. Oh and if you do so you can invalidate cache only at the end of the entire rendering process. A different story has to be told if you would like to render trueType...
PS: my chars are grayscale+alpha. ....try playing with sceGuColor and similar functions |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jul 31, 2008 7:56 pm Post subject: |
|
|
| Right now, I like using the built-in fonts via intraFont. That works rather well. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Thu Jul 31, 2008 10:40 pm Post subject: |
|
|
There are several options available, you'll have to decide on the best method to suit your own needs.
In my pgeFont implementation I load a TTF font and generate a 4-bit swizzled texture from that, which can be stored in either VRAM or RAM.
As jean mentioned, these are displayed by using a list for the characters and their position on the texture - after that they're just drawn using modulate, sceGuColor() to set the color and render as GU_SPRITES.
The benefits of this are that the memory footprint is small, only ~32kb for a 256x256 texture and that it is very very fast.
The downside is that the size of the font is set at load/creation. However because the memory footprint is so small you can always load the font multiple times at multiple sizes.
Hope this helps. |
|
| Back to top |
|
 |
uberjack

Joined: 17 Jul 2007 Posts: 34 Location: California, USA
|
Posted: Fri Aug 01, 2008 7:26 am Post subject: |
|
|
Thanks for the responses, everyone.
Sounds like swizzled textures present the best approach. |
|
| Back to top |
|
 |
|