Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

OpenGL textured Font

dev48dev48 Member Posts: 7
Hi !
I want to know how to display font thanks to a texure where there is the alphabet on it...
So if can anyonme tell how to do...

Comments

  • chick80chick80 Member Posts: 349
    [b][red]This message was edited by chick80 at 2003-7-4 4:9:21[/red][/b][hr]
    : Hi !
    : I want to know how to display font thanks to a texure where there is the alphabet on it...
    : So if can anyonme tell how to do...
    :
    Well, you should creat a quad for every letter in the text you want to write and texture it with your image assigning the UV coordinates to the vertices based on the letter. For example, if the texture is something like this:

    [code]
    a b c d e f g h i j
    k l m n o p q r s t
    u v w x y z A B C D
    E F G H I J K L M N
    O P Q R S T U V W X
    Y Z 1 2 3 4 5 6 7 8
    9 0
    [/code]
    If you want to write the letter 'p' you should first calculate where it is, doing 'p' - 'a' that gives you 15 and then just do
    floor(15/10) = 1 that is the row, and 15%10 = 5 that is the column.
    So, as there are 7 rows and 10 columns, the UV coordinates for each letter are offsetted from the previous one by 1/10=0.1 in u and 1/7=0.14 in v. So, to calculate the coordinates for 'p' just do 1*0.14 for v and 5*0.1 for the u.

    bye
    nICO


    [hr]
    [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    JOHN KEATS




  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    And if that wasn't enough, or over your head, NeHe has an awesome tutorial on using bitmap fonts.

    http://nehe.gamedev.net/

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.