Help for drawing text with Quartz

Member
Posts: 53
Joined: 2007.08
Post: #1
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.

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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
Member
Posts: 53
Joined: 2007.08
Post: #3
Thanks a bunch
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Getting text from a window text field mars 7 4,901 Mar 26, 2005 06:06 PM
Last Post: OneSadCookie
  Quartz and Animation Cloke 4 4,838 May 9, 2002 04:22 PM
Last Post: Pazolli