Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411522 Posts in 69377 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 28, 2024, 07:10:02 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Easy-To-Use OpenGL bitmap font library that can cope with 3D?
Pages: [1]
Print
Author Topic: Easy-To-Use OpenGL bitmap font library that can cope with 3D?  (Read 1577 times)
LemonScented
Level 7
**



View Profile
« on: January 03, 2010, 12:33:02 PM »

Hey guys,

This is something I'd normally throw at the GameDev.net forums, but they appear to be down, and I've got an Assemblee entry to write in a hurry... I need a quick, easy-to-use OpenGL library in C/C++ that can render a bitmap font (i.e. like the ones submitted to Assemblee part 1, rather than .TTF files or whatever), and I need it to be able to work with scales and 3D world co-ordinates specified by me (rather than always just using orthographic projection to do stuff in 2D screen-space). I've been using Guichan for font rendering up until now, but it only works in screen space. I tried fudging the renderer so I can switch it into a mode which doesn't push/pop the modelview and projection matrices but it looks like I'd have to basically rewrite the whole library, since it's all built on the assumption that 1 unit = 1 pixel in screen space.

Anyone got any recommendations?
Logged

powly
Level 4
****



View Profile WWW
« Reply #1 on: January 03, 2010, 12:38:46 PM »

I have one (uses SDL for image loading) that could be easily modified to be this (removing the force-to-ortographic) The only restriction is that you'll have to convert the font to a 16x16 char table in the correct ASCII codes. I can modify it and post if you want to see it.

EDIT: Also, this is about as easy as it gets - a loadfont("filename.png") and then text(size, font, text, ...)
« Last Edit: January 03, 2010, 12:44:44 PM by msqrt » Logged
LemonScented
Level 7
**



View Profile
« Reply #2 on: January 03, 2010, 12:45:20 PM »

That would be excellent, if it's something you're happy to do. I'm fine with rearranging the font image to match whatever the renderer expects, just so long as I can get something that works properly (right now I'm trying to get Guichan to render a string to a texture, so that I can map the texture to an object in 3D, which is a FAR from ideal way of doing things!)
Logged

powly
Level 4
****



View Profile WWW
« Reply #3 on: January 03, 2010, 01:09:14 PM »

Here you go. (sorry it took a while)

So, I included an example font - the only thing you really have to do is the ascii ordering. 0, 255, 0 and 255, 0, 255 are mask colors.. I'd suggest making the font white in order to help changing its colour. A bit of usage example follows:

Code:
font* f = loadfont("path.png");
text(10, 10, 2.0, f, "normal printf stuff, so this %d works", integervalue);
text3D(f, "A quickly hacked 3D version of this");//doesn't do any nice centering :/
freefont(f);

Of course loadfont and freefont outside any loops (: Even so, this is not the fastest thing ever - best not render thousands of strings per frame.
Logged
LemonScented
Level 7
**



View Profile
« Reply #4 on: January 03, 2010, 02:49:43 PM »

Cheers msqr!  Gentleman
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic