Using Carbon API in Cocoa Apps

Member
Posts: 201
Joined: 2002.06
Post: #1
I'm pretty new to the whole Cocoa thing. I want to use Quickdraw in my Cocoa application. How do I do this? From what I've read, Quickdraw is the only graphics API on Mac OS X with decent speeds.
Quote this message in a reply
Member
Posts: 116
Joined: 2002.04
Post: #2
Link in the Carbon framework and call the Carbon functions. Carbon is fully-available to Cocoa apps.

Wade
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #3
That's it? Just link it? Man, and here I was thinking that I had to do some other special modification in Project Builder or something. Thanks!
Quote this message in a reply
jefftkd
Unregistered
 
Post: #4
If you want to use Interface Builder and Quickdraw, just use the NSQuickdrawView (icon like the Finder) control.

Just overwrite drawRect and do all your drawing in there. There is a nice method (qdPort) so you can do:

Code:
- (void)drawRect: (NSRect)rect {
    GrafPort *g = [self qdPort];

    /* Use g just like normal */
}

HTH,
Jeff Cool
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #5
Ah, thank you thank you thank you! That's what I was looking for! I just didn't know how to word it.
Quote this message in a reply
Jeff Binder
Unregistered
 
Post: #6
Quote:Originally posted by geezusfreeek
From what I've read, Quickdraw is the only graphics API on Mac OS X with decent speeds.

Don't forget OpenGL :-) .
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #7
Oh ya. But I don't have any OpenGL experience anyway. I'll learn it eventually.
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #8
I just stumbled across some CoreGraphics stuff. How does this compare to QuickDraw and OpenGL, as far as speed goes? It looks easy. Is it related to Quartz in some way?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
CoreGraphics is Quartz.
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #10
Okay. There's the sign of a beginner for you. Wink
Quote this message in a reply
Member
Posts: 75
Joined: 2002.04
Post: #11
Isn't CoreGraphics a lower level API that Quartz is based on (Quartz calls CG functions)?

Chris Burkhardt
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #12
That's what I was thinking (and hoping).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #13
I imagine that the Cocoa drawing routines may well call the CoreGraphics functions, in which case calling the CG stuff directly may be slightly faster.

Anyone care to benchmark?
Quote this message in a reply
Feanor
Unregistered
 
Post: #14
CoreGraphics and Quartz are exactly alike. There are no "Quartz" functions, that's just the marketing name Steve came up with. Uh, not me, but I'm sure you're right -- you call the method, the AppKit calls the CGfunction equivalent.

The idea that QuickDraw is faster than Quartz seems absurd, but I guess its possible. I was under the impression that QuickDraw just called CoreGraphics equivalents. Now, stuff like bezier paths and all that fancy PDF stuff is going to be slow, sure, but the usual bit copy stuff should be faster in OS X. But I'm not much for 2D. You all may as well learn OpenGL because that's the future on OS X starting with Jaguar. EVERYTHING you see on screen ends up as OpenGL from now on. You may as well cut to the chase.

For those who like to troll around Apple's documentation pages online, there has recently appeared a programming topic entitled "Drawing Directly to the Screen" -- description forthcoming (of course!). Hopefully a new API in Jaguar?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #15
You can already get direct access to the screen buffer memory using CGDirectDisplay...

I wonder whether any of the blitting routines on OS X < 10.2 are hardware accelerated at all... given that they must all composite from in-memory buffers to in-memory buffers, I'd guess the CPU is the fastest way.

QuickDraw doesn't call into Quartz in any way AFAIK... I'm pretty sure all the Quartz stuff does anti-aliasing and deals with fractional coordinates and things, none of which QuickDraw has to deal with. I suspect most of QuickDraw is still the same code that ran on your Mac 128K Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa or Carbon? Leroy 5 3,630 May 17, 2007 06:54 PM
Last Post: SethWillits
  Newbie question: Cocoa and Carbon - which for what and how to get started? BliTz 3 3,113 Jul 27, 2006 10:07 PM
Last Post: OneSadCookie
  Carbon C/ Cocoa API Questions Stalin55 3 3,179 Jul 3, 2006 02:07 PM
Last Post: OneSadCookie
  Noob Cocoa and Carbon Questions MonitorFlickers 15 6,072 Feb 23, 2006 06:01 PM
Last Post: Tesselate
  Carbon or Cocoa for Games Nick 26 13,157 Mar 11, 2005 12:59 PM
Last Post: Duane