Fonts with OpenGL & GLF

Jones
Unregistered
 
Post: #1
I've been researching ways to do fonts in OpenGL. So far I've read about bitmapped fonts, and pixmapped fonts. In my searches I found this thread:

http://www.idevgames.com/forum/showthrea...enGL+fonts

Which has several methods in it. However, several I could not find on google. Others apear to be Mac Specific. I want to keep my projects as cross platform as possible.

I'm about to try GLF, as it appears to be easy to include in a project, something I value tremendously. (sp?)

Aside from that one, I know about FreeType and SDL_font. Could I send fonts from SDL_Font to openGL textures? That would be really cool.

I've also looked at NeHe's tutorial:

http://nehe.gamedev.net/data/lessons/les...?lesson=13

But like all of them, it uses Windows Classes which I do not have readily available.

Anyway, in short, is GLF a good way to go? If not, what is better? Keep in mind that I am not using Cocoa. That is why I need a font system, to make my own OpenGL interface system.

Thanks!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
IIRC, GLF requires FreeType 1. You should try out FTGL, which uses FreeType 2. However, you should probably use my build here, which has FreeType 2 built in, so you don't have to worry about the extra library. It is already set up to be used as a Universal Binary, and I can assure you it works. It uses C++ for the interface, but if you use ObjectiveC++ (with a .mm file extension), you should have no problems using it.
Quote this message in a reply
Jones
Unregistered
 
Post: #3
Oh wow, thanks for those links! Is FTGL something that would work in a windows program, with a windows build of FreeType?

Also, if you could clarify something...

When I download FTGl or say GLF, do I need to build anything (other than FreeType), or can I just drop the headers in as indicated?

Thanks!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
If you build the a Windows version of FTGL with a Windows version of Freetype, then it shouldn't have any problems. In fact, the build that I have, if you set up the files similarly, should compile as well. The only thing is you would have to replace the UNIX-specific source file with the Windows specific source file.

If you already have a pre-compiled version of FTGL or GLF, you won't have to build anything. Otherwise, you will: the headers aren't enough, since they don't actually provide any of the code necessary to do the functions that are declared.
Quote this message in a reply
Jones
Unregistered
 
Post: #5
Ok then. I noticed on the GLF site they mentioned it was good because it only needed to headers to work. True... but two headers + FreeType. Does the FTGL.framework that I assume you compiled, from the link you gave me have FreeType built into it?

Thanks!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
Reading comprehension is clearly not your strong point.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
Jones Wrote:Ok then. I noticed on the GLF site they mentioned it was good because it only needed to headers to work. True... but two headers + FreeType. Does the FTGL.framework that I assume you compiled, from the link you gave me have FreeType built into it?

Thanks!
Yes, as I've said before. However, the only headers you need to include for FTGL are for the class you need. For example, if you only want polygon fonts, you can just include FTGLPolygonFont.h, and that's all you need.
Quote this message in a reply
Jones
Unregistered
 
Post: #8
OneSadCookie Wrote:Reading comprehension is clearly not your strong point.

Well, I am sorry, but I wasn't sure what he meant by "the extra library". I see now that it was probably the font lib. I am grateful for the explanations provided here.

Thanks.

EDIT:

That, and the fact that I only have experience with frameworks jam packed with headers. When I find one with a lack of those, I wonder if they are seperate, or something else is needed/must be compiled.

Please try to remember that I am a novice, with little experience in this sort of thing.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #9
You can create a folder in the framework called Headers and put the headers in there if you want them readily accessible. I'm not 100% sure what copy files phase you need to put them in there. (there's headers in the "Copy Headers" section, but they don't appear to actually be copied...)
Quote this message in a reply
Jones
Unregistered
 
Post: #10
Yeah, I tried that. But I don't I'm setting it up right... I've dropped the FTGL framework (universal) into my /Library/Frameworks folder. I then added it to my project, along with the "freetype include" and "include" headers. (Directly all into my project folder). But it would appear that FTGL can't find FreeType. Here are some sample errors:

Missing freetype classes...
Code:
FTFace.h:103: error: 'FT_GlyphSlot' does not name a type
FTFace.h:115: error: 'FT_Error' does not name a type
FTFace.h:121: error: ISO C++ forbids declaration of 'FT_Face' with no type
FTFace.h:121: error: expected %<;%> before '*' token
FTFace.h:133: error: ISO C++ forbids declaration of 'FT_Encoding' with no type
FTFace.h:133: error: expected %<;%> before '*' token
FTFace.h:143: error: 'FT_Error' does not name a type
FTFont.h:87: error: `FT_Encoding' has not been declared
FTFont.h:101: error: ISO C++ forbids declaration of 'FT_Encoding' with no type
FTFont.h:101: error: expected %<;%> before '*' token
FTFont.h:217: error: 'FT_Error' does not name a type
FTFont.h:251: error: 'FT_Error' does not name a type

Not understanding that stuff...
Code:
FTPoint.h:5:10: error: #include expects "FILENAME" or <FILENAME>
FTPoint.h:6:10: error: #include expects "FILENAME" or <FILENAME>

This appears to be missing...
Code:
/Users/gareth/Desktop/sdlContext/ft2build.h:34:38: error: freetype/config/ftheader.h: No such file or directory

And yet, there it is, in that folder. (It's placed so that all the paths would work.)

I'm sorry for needing so much help with this, but it is much appreciated.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #11
No, not to your project, to the framework. Have a Headers folder in the framework, and just dump the contents of the two header folders into there.
Quote this message in a reply
Jones
Unregistered
 
Post: #12
akb825 Wrote:No, not to your project, to the framework. Have a Headers folder in the framework, and just dump the contents of the two header folders into there.


Did that, at first it didn't work. Then I added the FTGL framework headers folder to my search directories, and it compiles! Huzzah!

Thanks a ton for this!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #13
No problem. Actually, looking at the structures, it looks like the correct way to do it (without having to add the headers to the search path) is to put the Headers folder under FTGL.framework/Versions/A, then put an alias under the root directory of the framework. I thought it would just look at that alias for the headers, but I guess it looks at the version rather than what's currently being used as the alias. Regardless of where you put the headers, if you add the folders to your search path, you can use the <> notation of include rather than "".
Quote this message in a reply
Jones
Unregistered
 
Post: #14
Yeah, thanks. That'll be useful if I ever distribute the game.

I think I'm doing something wrong though, the FAQ and the readme both say this is how to do it:

Code:
FTGLPixmapFont font;
font.Open( "Fonts:Arial");
font.FaceSize( 72);
font.render( "Hello World!");

And I am doing so, except that .render must actually be .Render. But anyway, it says that FTGLPixmapFont, or BitmapFont for that matter has no Open class. I've never done anything with oop classes, but I do now how to make one, and what a class would look like. And it's true (I checked), neither class has a .Open function. Nor a .open or .load or related commands.

Am I missing a piece of the puzzle? Huh

(Note: I have all the FTGL stuff included, every single header.)
Quote this message in a reply
Jones
Unregistered
 
Post: #15
Ok, after a quick analysis of how the classes work, and classes in general. I realized the docs are a bit outdated. You actually load them up like this:

FTGLBitmapFont font("your-font-here");

There is no "open" function. Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How do I flip upside down fonts in FTGL mr5z 4 1,502 Mar 3, 2014 03:36 PM
Last Post: JustinFic
  Bitmap fonts markhula 6 8,450 Feb 27, 2011 12:55 PM
Last Post: markhula
  Anti-aliased bitmapped fonts Jake 12 7,071 Nov 19, 2007 05:02 PM
Last Post: Jake
  shared context breaking FTGL texture fonts akb825 12 6,677 Sep 7, 2006 08:56 PM
Last Post: akb825
  Bitmap Fonts in GL Joseph Duchesne 18 9,799 Feb 3, 2006 09:25 AM
Last Post: ThemsAllTook