GL fonts

blah.

Can someone give me a brief explanation of creating bitmapped fonts for use
in GL? I have a working version for vanilla SDL, but try as I might, I
can’t seem to come up with a decent one for GL that isn’t a complete pain to
use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely dependent on
how much work I want to do behind the scenes…but still. It can’t be as
ugly as examples I am seeing. The SDL version creates pixel data for each
letter of the font. Is it possible to use glCopyPixels() to grab individual
letters in order to do the blit? The red book says to use display lists,
and swap the list base number when using multiple fonts, but Lord…that
just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and wish for
a pony, too?

[;

-HaB_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

I use sfont, and it’s usually just that simple in my experience :slight_smile:

-EvilTypeGuyOn Wed, Apr 24, 2002 at 04:13:03PM -0400, HaB JacKaL wrote:

blah.

Can someone give me a brief explanation of creating bitmapped fonts for use
in GL? I have a working version for vanilla SDL, but try as I might, I
can’t seem to come up with a decent one for GL that isn’t a complete pain
to use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely dependent on
how much work I want to do behind the scenes…but still. It can’t be as
ugly as examples I am seeing. The SDL version creates pixel data for each
letter of the font. Is it possible to use glCopyPixels() to grab
individual letters in order to do the blit? The red book says to use
display lists, and swap the list base number when using multiple fonts, but
Lord…that just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and wish
for a pony, too?

[;

-HaB


Join the world?s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I’ve been experimenting with Texfont, but I’m having issues with it. The API
is as easy as you indicate, but I’m finding that it leaves OGL in some funky
state where I can’t render anything after rendering some text… There is
also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to tell me
that I’d have to release my stuff in a relinkable format if I were to use
it.

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

-Blake> ----- Original Message -----

From: feelthel0ve@hotmail.com (HaB JacKaL)
To:
Sent: Wednesday, April 24, 2002 1:13 PM
Subject: [SDL] GL fonts

blah.

Can someone give me a brief explanation of creating bitmapped fonts for
use
in GL? I have a working version for vanilla SDL, but try as I might, I
can’t seem to come up with a decent one for GL that isn’t a complete pain
to
use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely dependent on
how much work I want to do behind the scenes…but still. It can’t be as
ugly as examples I am seeing. The SDL version creates pixel data for each
letter of the font. Is it possible to use glCopyPixels() to grab
individual
letters in order to do the blit? The red book says to use display lists,
and swap the list base number when using multiple fonts, but Lord…that
just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and wish
for
a pony, too?

[;

-HaB


Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I’ve been experimenting with Texfont, but I’m having issues with it. The API
is as easy as you indicate, but I’m finding that it leaves OGL in some funky
state where I can’t render anything after rendering some text… There is
also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to tell me
that I’d have to release my stuff in a relinkable format if I were to use
it.

Considering that you’re using SDL, you’d have to do that anyway :wink:

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

http://www.linux-games.com/sfont/

From the sound of it though, you wouldn’t want to use it as it’s GPL, not
LGPL…

-Blake

-EvilTypeGuyOn Wed, Apr 24, 2002 at 02:50:05PM -0700, Blake Senftner wrote:

Well… “sfont” is not a OGL solution, so I would expect that it will stall
any OpenGL rendering, killing frame rates. Anyone else know of any OpenGL
bitmapped font systems?

Looks like fixing TexFont is the solution…

-Blake> ----- Original Message -----

From: @Blake_Senftner (Blake Senftner)
To:
Sent: Wednesday, April 24, 2002 2:50 PM
Subject: Re: [SDL] GL fonts

I’ve been experimenting with Texfont, but I’m having issues with it. The
API
is as easy as you indicate, but I’m finding that it leaves OGL in some
funky
state where I can’t render anything after rendering some text… There is
also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to tell
me
that I’d have to release my stuff in a relinkable format if I were to use
it.

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

-Blake

----- Original Message -----
From: “HaB JacKaL”
To:
Sent: Wednesday, April 24, 2002 1:13 PM
Subject: [SDL] GL fonts

blah.

Can someone give me a brief explanation of creating bitmapped fonts for
use
in GL? I have a working version for vanilla SDL, but try as I might, I
can’t seem to come up with a decent one for GL that isn’t a complete
pain
to

use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely dependent
on

how much work I want to do behind the scenes…but still. It can’t be
as

ugly as examples I am seeing. The SDL version creates pixel data for
each

letter of the font. Is it possible to use glCopyPixels() to grab
individual
letters in order to do the blit? The red book says to use display
lists,

and swap the list base number when using multiple fonts, but Lord…that
just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and wish
for
a pony, too?

[;

-HaB


Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Actually, with SDL I just redistribute the SDL ddls.

-Blake> ----- Original Message -----

From: eviltypeguy@qeradiant.com (EvilTypeGuy)
To:
Sent: Wednesday, April 24, 2002 3:10 PM
Subject: Re: [SDL] GL fonts

On Wed, Apr 24, 2002 at 02:50:05PM -0700, Blake Senftner wrote:

I’ve been experimenting with Texfont, but I’m having issues with it. The
API

is as easy as you indicate, but I’m finding that it leaves OGL in some
funky

state where I can’t render anything after rendering some text… There
is

also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to
tell me

that I’d have to release my stuff in a relinkable format if I were to
use

it.

Considering that you’re using SDL, you’d have to do that anyway :wink:

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

http://www.linux-games.com/sfont/

From the sound of it though, you wouldn’t want to use it as it’s GPL, not
LGPL…

-Blake

-EvilTypeGuy


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

How about the font library from PLIB? It works great for me in OpenGL.

http://plib.sourceforge.net/whats_inside.html

John> ----- Original Message -----

From: bsenftner@earthlink.net (Blake Senftner)
To:
Sent: Wednesday, April 24, 2002 6:11 PM
Subject: Re: [SDL] GL fonts

Well… “sfont” is not a OGL solution, so I would expect that it will
stall
any OpenGL rendering, killing frame rates. Anyone else know of any OpenGL
bitmapped font systems?

Looks like fixing TexFont is the solution…

-Blake

----- Original Message -----
From: “Blake Senftner”
To:
Sent: Wednesday, April 24, 2002 2:50 PM
Subject: Re: [SDL] GL fonts

I’ve been experimenting with Texfont, but I’m having issues with it. The
API
is as easy as you indicate, but I’m finding that it leaves OGL in some
funky
state where I can’t render anything after rendering some text… There
is

also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to
tell
me

that I’d have to release my stuff in a relinkable format if I were to
use

it.

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

-Blake

----- Original Message -----
From: “HaB JacKaL”
To:
Sent: Wednesday, April 24, 2002 1:13 PM
Subject: [SDL] GL fonts

blah.

Can someone give me a brief explanation of creating bitmapped fonts
for

use

in GL? I have a working version for vanilla SDL, but try as I might,
I

can’t seem to come up with a decent one for GL that isn’t a complete
pain
to

use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely
dependent
on

how much work I want to do behind the scenes…but still. It can’t
be
as

ugly as examples I am seeing. The SDL version creates pixel data for
each

letter of the font. Is it possible to use glCopyPixels() to grab
individual
letters in order to do the blit? The red book says to use display
lists,

and swap the list base number when using multiple fonts, but
Lord…that

just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and
wish

for

a pony, too?

[;

-HaB


Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

OK, I was able to get TexFont to work by ignoring the example logic from the author’s web page and just using my noggin to setup the OGL environment how I thought it should be… and it worked.

So, this site has the source files and the documentation:

http://www.opengl.org/developers/code/mjktips/TexFont/TexFont.html

The license is a “do whatever you want with this- but it is not in the public domain” strange type of license. I guess he just doesn’t want it showing up in someone’s book or technical paper without his permission. But it is free for use in commercial applications.

With the following wrapper logic you should be able to get it working with SDL. Note that if you support resizable windows or a toggle to and from full screen, you have to recall the txfEstablishTexture() routine on the font after the resize/toggle event. You can just call the “InitFont()” wrapper routine that I provide here and it should be cool. One may also want to consider deleting the texture objects and the TexFont structure before the resize/toggle event, since the destruction and recreation of an OpenGL context that occurs with an additional call to SDL_SetVideoMode() may end up leaving the texture object that is the bitmapped font dangling.

------------------------------------ code starts here -----------------------------------------
BOOL InitFont( VOID );
BOOL FontRender( CHAR *string );
TexFont *gCurrTexturedFont = NULL;
// ------------------------------------------------------------------------------------------------------
BOOL InitFont( VOID )
{
CHAR *fontStr = “C:\Blake\HGS\txf\times_medium.txf”;

if (!gCurrTexturedFont)
{
gCurrTexturedFont = txfLoadFont( fontStr );
if (!gCurrTexturedFont)
{
fprintf( stderr, “Problem loading %s, %s\n”, fontStr, txfErrorString() );
return FALSE;
}
}

txfEstablishTexture( gCurrTexturedFont, 0, GL_TRUE );

return TRUE;
}
// ------------------------------------------------------------------------------------------------------
BOOL FontRender( CHAR *string )
{
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

INT32 stringLen = strlen( string );
INT32 width, ascent, descent;
txfGetStringMetrics( gCurrTexturedFont, string, stringLen, &width, &ascent, &descent);

glPushMatrix();

INT32 x = (INT32)(-width * 0.5f), y = 0;
glTranslatef( (float)x, (float)y, 0.0f );

// note that I use a +z is “up” type of coordinate system,
// therefore I need to rotate by 90 in X before rendering any text…
glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );

glColor3f( 0.2f, 0.2f, 0.9f );

txfRenderString( gCurrTexturedFont, string, stringLen );

glPopMatrix();

glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);

return TRUE;
}

------------------------------------ code ends here -----------------------------------------

Slight side note: while looking up the address to the TexFont home page I can across this:

http://nate.scuzzy.net/programming/gltexfont/gltexfontdoc.html
http://nate.scuzzy.net/programming/gltexfont/

which is another OpenGL font library with a very similar name but different features. It allows meta characters within the string to turn on and off italics and possibly other neato stuff. But since I got TexFont to work, I did not really persue it.

Back on the TexFont topic, this site here:

http://plib.sourceforge.net/fnt/index.html

is a GLUT based OpenGL font library by Steve Baker that also reads the same “.fnt” files as TexFont, and that version distributes about a dozen example fonts that you can use with TexFont. So if you use TexFont you may want to grab those also. On the home page for TexFont there is an X based utility that generates new TexFonts, but since I’m developing on Win32 I can’t use it. If anyone working within an X environment does happen to start using the GenTexFont utility, I would appreciate them passing any useful fonts my way.

good luck,
-Blake

What I do is just put all the characters in one big texture, and then when
rendering text, select texture coordinates so the correct character covers
the quad. It’s not to hard, and it works good for me. Do you not want to
write your own font code to handle it all? If so, I can’t help you there,
since I always do it myself.> ----- Original Message -----

From: bsenftner@earthlink.net (Blake Senftner)
To:
Sent: Wednesday, April 24, 2002 6:11 PM
Subject: Re: [SDL] GL fonts

Well… “sfont” is not a OGL solution, so I would expect that it will
stall
any OpenGL rendering, killing frame rates. Anyone else know of any OpenGL
bitmapped font systems?

Looks like fixing TexFont is the solution…

-Blake

----- Original Message -----
From: “Blake Senftner”
To:
Sent: Wednesday, April 24, 2002 2:50 PM
Subject: Re: [SDL] GL fonts

I’ve been experimenting with Texfont, but I’m having issues with it. The
API
is as easy as you indicate, but I’m finding that it leaves OGL in some
funky
state where I can’t render anything after rendering some text… There
is

also the FNT library from Steven Baker’s Plib, which uses the same .fnt
files as TexFont. But FNT is LGPL released as a .lib, which seems to
tell
me

that I’d have to release my stuff in a relinkable format if I were to
use

it.

I think I’ll have a quick look at that “sfont” that "EvilTypeGuy"
suggested…

-Blake

----- Original Message -----
From: “HaB JacKaL”
To:
Sent: Wednesday, April 24, 2002 1:13 PM
Subject: [SDL] GL fonts

blah.

Can someone give me a brief explanation of creating bitmapped fonts
for

use

in GL? I have a working version for vanilla SDL, but try as I might,
I

can’t seem to come up with a decent one for GL that isn’t a complete
pain
to

use.

The SDL version is just like

font = initFont(srcBitmap, r, g, b, a);
font.writeLine(x, y, “writing this line”);

I’d LIKE it to be that simple in GL. I know this is solely
dependent
on

how much work I want to do behind the scenes…but still. It can’t
be
as

ugly as examples I am seeing. The SDL version creates pixel data for
each

letter of the font. Is it possible to use glCopyPixels() to grab
individual
letters in order to do the blit? The red book says to use display
lists,

and swap the list base number when using multiple fonts, but
Lord…that

just seems so ugly to me…

Is there a better way? Or while I’m wishing, should I go ahead and
wish

for

a pony, too?

[;

-HaB


Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl