Re: Displaying text in an OpenGLView?
On Tuesday, October 1, 2002, at 09:39 AM, David Remahl wrote:
>> I want to display some text in an OpenGLView. Since I didn't come
>> across an OpenGL way (an easy one anyway), I first tried just using
>> NSAttributedString drawAtPoint:, which didn't work. This failure to
>> allow mixing of quartz and opengl wasn't surprising.
>>
>> The next thing I tried was to just put a NSTextField into the view.
>> This didn't work either, and that is more surprising, since it seems
>> to say that an OpenGLView is not a normal view that can display
>> subviews. Can someone confirm that this is the case? If so, is that
>> necessarily the case, or just the way things stand now?
>
> In Mac OS X 10.2 Jaguar, there are features which enable exactly the
> kind of
> things you like to see. Underlay surfaces allow you to mix OpenGL and
> Cocoa
> controls.
>
> There is an example project here:
>
> /Developer/Examples/OpenGL/Cocoa/UnderlaySurface/
This shows how to configure the OpenGL view, but it doesn't help you
draw the text with line breaks, etc. If you want to format text, then
you need to use the NSTextStorage/NSLayoutManager/NSTextContainer
combination. The "Assembling the Text System by Hand" topic in the docs
goes into this. For all of this to work, you will need to flip the
coordinates in your view, by overriding isFlipped to return YES.
(Continue reading)