OpenGL ES 3D + 2D text.

Nibbie
Posts: 2
Joined: 2009.01
Post: #1
Ok. I'm now able to display and rotate a 3D object using OpenGL ES.
Now I want to display 2D text on top of it. How do I proceed?
I've read about texture2D included in the crashlanding sample, but this sample is not available anymore, so I don't have the code.
Any ideas?
Thanks.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #2
It sounds like a two part question, both parts which are not a simple answer. Which part do you need an answer to or both?

1) 2D drawing on top of 3D drawing

a) Setup your 3D Projection
b) Draw your 3D stuff
c) Reset your matrices
d) Setup your 2D projection
e) Draw your 2D stuff (in this case font).


2) Font drawing?

I never figured out how the crash landing example works. What I did was, created a class that will draw sections of a loaded texture by changing the UV coordinates to select rectangles on the textures. Then go to LMNOPC.com and using their wonderful tool for creating font sheets, create a font sheet from any loaded system font. Now, taking that font sheet and a string, you can algorithmically select the letters using an array of rectangles. It's disadvantage is, it's a true bitmap font system so the letters are blocky and kerning can be a headache but it's a solution.
I couldn't find the Crash Landing example either. If this doesn't help you at all, I'll try to get you a copy of that example code if that's not against some terms of service or something. Annoyed

@end
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #3
CrashLanding uses the popular Texture2D class to use Quartz to render a string into a texture. It's not like the good ol' bitmap font on quads technique that you're talking about. Both techniques have advantages and disadvantages. One major bonus to the Quartz rendered text is that it has full kerning applied to it, and another is that it only uses one quad for the whole string.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #4
Hmm, how's the quality of the Quartz version vs. the BMF? What advantage does the BMF have?
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #5
A couple advantages to the BitMappedFont approach I can think of at the moment:

- you can use whatever fancy pre-rendered font plus effects you want (i.e. whatever you can come up with in Photoshop, you can use in your game). Want drop shadows or embossing? Can't do that without BMF, practically speaking. This is arguably the biggest advantage.
- if you only need a few characters updated frequently, it's fastest. Lots of characters needing to be drawn every frame is slower though.

Use either technique as the situation warrants, or whichever happens to be more convenient. Personally, I can't say I use one or the other more often as both of them have their place.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #6
Sounds like I should put some Quartz into my font system. Thanks again for your input Jake. One last question though, I get the impression that the quality of the Quartz fonts is a lot better, is that generally the case? By quality, I mean sharpness of the fonts.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #7
Apple has particularly excellent (and proprietary) font anti-aliasing algorithms that Quartz uses, so yes, you get very nice-looking text from it.
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #8
Yeah, Quartz has sweet font rendering. The only thing that comes close is FreeType (which is actually really good, but not needed if you're Mac/iPhone only). Of course, you could just as well render your BitMapFonts using Quartz in another program and achieve the same quality end result -- minus the automatic kerning of course.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES : Drawing Text... savage 8 9,742 Jan 4, 2010 08:59 PM
Last Post: alerus
  Drawing Text With OpenGL ES? Nick 6 5,331 Jan 27, 2009 09:22 AM
Last Post: spjwebster
  Drawing Text with OpenGL ES bronxbomber92 19 17,798 Jan 2, 2009 12:11 AM
Last Post: codetiger
  Opengl ES: drawing text papillon68 0 1,951 Dec 20, 2008 03:52 PM
Last Post: papillon68