How do I draw normal flat text on top of an OpenGL scene using Quartz? I'm looking for the Mac equivalent of glXUseXFont() or wglUseFontBitmaps(): I just want to blast some text on the screen on top of the GL scene; I'm not interested in getting an image of the font into a texture, or scaling, rotating, occluding, spindling or mutilating it in any way.
Google has turned up a few things, but they all look insanely complicated (people giving the answer of "use the over-engineered library I wrote for that!" instead of just explaining it).
Update: Ok, it looks like aglUseFont() is what I want, but I don't get how to initialize AGL so that it can draw on my NSOpenGLView: if I ever call aglSetCurrentContext(), then regular GL activity stops showing up on the window at all (even if I never do any other AGL things). Are AGL and OpenGL fighting with each other? Do I have to synchronize aglChoosePixelFormat() with NSOpenGLPixelFormat somehow?
Update 2: I finally figured it out -- the answer is "you can't use NSOpenGLView when doing things that require an AGLContext, because NSOpenGLContext and AGLContext are orthogonal". But that's ok, because it turns out that NSOpenGLView doesn't really do much for you anyway: it just makes a context and keeps it current, and if you do that manually with the AGLContext, you can render GL onto any old NSWindow.
Are you rewriting your caller ID Script ? :)
...but I've used OGLFT in the past, and it's actually a rather simple c++ interface to freetype and OpenGL.
I suspect that what you really want to look at, though, is either:
http://developer.apple.com/samplecode/Cocoa_OpenGL/Cocoa_OpenGL.html
or:
http://developer.apple.com/samplecode/GLChildWindowDemo/GLChildWindowDemo.html
(probably the latter)
Is aglUseFont() what you're looking for?
AGL is, in general, what he's looking for.
I finally stumbled across that, yeah... Still trying to make it work...
I don't think the two are particularly compatible. You might be able to convince things to work properly by using CGLGet/SetCurrentContext() instead since both AGL and NSOpenGL are built on the CGL library, but who the hell knows? Alternatively you can render an NSString into an image and then create a texture from that to display--there's sample code from Apple here (StringTexture in particular).
I don't get it. What in the world are these AGL functions for if you can't use them in an OpenGL environment?
You can use them in an OpenGL environment as long as its a Carbon OpenGL environment and not a Cocoa one. This happens to be one of the areas where you can't switch between the two for whatever reason (from Apple's documentation it may have something to do with the fact that Cocoa windows do not necessarily have an associated Carbon window reference. Using the windowRef message might get things working, but then again it might not. Its probably easier to just crib Apple's StringTexture code).
FYI -- you could always use glDrawPixels. It isn't accelerated and you would still need a way to render the font (but with bitmap fonts it isn't too complicated).
A number of vector graphics libraries are available and capable of excellent text rendering, while leaving the details of font handling behind the scenes. Those libraries be easily used to generate input for glDrawPixels. This is what I do, anyway.