OpenGL, text, Cocoa

Oldtimer
Posts: 834
Joined: 2002.09
Post: #1
These font issues seem to never halt. (...quoth the Raven...)

I think I have FTGL working somewhat reliably in my C++ engine, but now I'm writing a medium-sized app using Cocoa, and FTGL isn't Obj-C. (I really can't be bothered to mix the languages if it can be avoided.)

What are my choices? The text output is fairly simple - colored output of single sentences that do not change a lot. Should I render the string to a texture? Is there any usable source code or tutorials lying around?

Thanks,
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
http://onesadcookie.com/svn/repos/NSViewTexture ( 10.4+, if you figure out how to make it go on 10.3, let me know Smile )
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
It's not too difficult to add C++ code... All you do is use .mm instead of .m, then include the headers and use the code as normal.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #4
@Keith: Thanks, I'll check it out right away. Smile
@akb825: Thanks to you too, but I knew that. I should've mentioned that this isn't really my project, I'm writing it professionally, and the guy at the other end wants Cocoa and clean code. I'll give OSC:s version a go, and if I can't figure it out, I'll go .mm and reuse my FTGL stuff. Smile Thanks, though!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #5
generating a texture from a font is probably the easiest and quickest way, Its also completly system independent,
Ive got Zapfino, Freak, Smash and some others in an OpenGL program, I just need to make it non computer dependent then Ill upload a build,
GlyphTool renders every letter from 32 - 127 (or a custom string) into a texture for use in opengl.
Ill upload a built example today,

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
How do you handle the fact that Zapfino is really, *really* non-monospaced? I mean, using a texture grid for fonts is a good thing, so long as your fonts are monospaced. But Zapfino isn't...
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #7
http://www.geocities.com/ed72678954/GlyphTool.zip
Finally ive got a non my-computer specific build of an example of it being used.
Hope you like this, its good IMO.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #8
TomorrowPlusX Wrote:How do you handle the fact that Zapfino is really, *really* non-monospaced? I mean, using a texture grid for fonts is a good thing, so long as your fonts are monospaced. But Zapfino isn't...
If you use Cocoa for laying out text in a NSTextView or similar, you dont have to worry about glyph spacing etc.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #9
Check the example out, theres nothing to worry about there. GlyphTool and the example handel it all for you.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #10
freetype isn't so hard to use, and it's cross-platform and very fast. You should probably load the renders into texures, though, because the freetype rasterizer grows blurry and messed up the further away it is from origin.

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
DoG Wrote:If you use Cocoa for laying out text in a NSTextView or similar, you dont have to worry about glyph spacing etc.

Yeah, but isn't he rendering into a glyph matrix? That obviates variable-width spacing, unless some sort of data is exported alongside the image with metrics for the per-char advance.

Nonetheless, I'm a lover of FTGL. So simple. So easy to use. of course, for long text runs, Nayr's right. You gotta do it yerself.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #12
TomorrowPlusX, please try the demo that comes with GlyphTool, please!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #13
Will do... tomorrow. Got to go to the gym now.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #14
Aha! MetricData.h... very nice output, unknown!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl/Cocoa text rendering tesil 15 17,147 Mar 20, 2012 11:16 AM
Last Post: OneSadCookie
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 6,451 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin
  OpenGL Text Rendering (in Cocoa) daveh84 5 7,806 Feb 19, 2009 12:44 PM
Last Post: TomorrowPlusX
  OpenGL & Cocoa - Improving frame rate daveh84 4 5,494 Feb 2, 2009 06:53 AM
Last Post: backslash
  bad depth sorting in Cocoa OpenGL aldermoore 2 4,598 Dec 30, 2008 03:07 PM
Last Post: ThemsAllTook