This topic is now archived and is closed to further replies.

JDS Games

Hardware Fonts

Recommended Posts

Hi !!

Hey, this is a very old AMIGA-Demo technic. I used that extensivly for my demos.

Ok, it depends, if you are using multitexturing. If not (or if you want the fonts texture to be in the first stage) just change the uv's of the faces structure. Check out prtypes.h for details. If you are using multitexturing and you want for example stage 1, then you have to change the uv's in the vertex structure.

The uv's are from 0 to 1, right. Now, in order to get your u or v, just check out this example.

Your texture with the font is 256x256 and the letter "i" is at 64,16 !! Then calculate u (this is the x-axis):

u = (float)x / (float)texture_width;
v = (float)y / (float)texture_height;

(It's important to type cast to float, because normally both (x and width) are longs, and the u is just 0 or 1, but nothing in between !!!!!)

So, in our example that would be:

u = 64 / 256 = 0.25
v = 16 / 256 = 0.0625

So, this is your u and your v coordinate which you know set either in the face structure (for stage 0) or in the vertex-structure for stages > 0 !!

Hope this helps.


Share this post

Link to post
Share on other sites

I am working on creating hardware accelerated fonts...

The way that I create my fonts now is that I create a TrueType font and a surface (320x200) and print all the chars to this surface and record the rects and use a bltfast to display them.

I was thinking, would it be possible to say.. create a 256x256 texture and put all the fonts to this texture like before, create an entity for each character and use the 256x256 texture, but change the UV coords to match the rects like in the first example so that I only use the one texture, but just position the UV to match the next char.

Is this possible to do in PR, if so, how/where would I change the UV coords of the entity. Looking at the examples, I notice the UV are from 0.0 to 1.0 and the rects would be absolute positions so how would I translate this.

Any help appreciated.


Jarrod Davis

Share this post

Link to post
Share on other sites