Help for drawing text with Quartz
I don't see whats wrong with my code. Must be something really dumb I'm missing. I'm trying to draw text with Quartz from the drawRect method of a subclassed NSOpenGLView.
When drawRect is called all the rest of my drawing displays fine but the text doesn't show up at all. Does it matter that I'm using OpenGL?
Code:
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSelectFont (myContext, "Times", 14, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (myContext, kCGTextFillStroke);
CGContextSetRGBFillColor (myContext, 0, 1, 0, 1);
CGContextSetRGBStrokeColor (myContext, 0, 1, 0, 1);
CGContextSetTextPosition (myContext, 50.0, 50.0);
CGContextShowText (myContext, "New Game", 8);When drawRect is called all the rest of my drawing displays fine but the text doesn't show up at all. Does it matter that I'm using OpenGL?
Any OpenGL drawing will obscure any Quartz drawing. There are ways around it, but easiest is to use a CGBitmapContext or NSView to create an OpenGL texture. http://onesadcookie.com/svn/repos/NSViewTexture shows how to do the latter.
Thanks a bunch
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Getting text from a window text field | mars | 7 | 4,358 |
Mar 26, 2005 06:06 PM Last Post: OneSadCookie |
|
| Quartz and Animation | Cloke | 4 | 4,179 |
May 9, 2002 04:22 PM Last Post: Pazolli |
|

