iDevGames Forums
Using Carbon API in Cocoa Apps - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Using Carbon API in Cocoa Apps (/thread-7710.html)

Pages: 1 2


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 08:37 AM

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.


Using Carbon API in Cocoa Apps - wadesworld - Jun 10, 2002 09:00 AM

Link in the Carbon framework and call the Carbon functions. Carbon is fully-available to Cocoa apps.

Wade


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 10:12 AM

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!


Using Carbon API in Cocoa Apps - jefftkd - Jun 10, 2002 10:32 AM

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


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 10:37 AM

Ah, thank you thank you thank you! That's what I was looking for! I just didn't know how to word it.


Using Carbon API in Cocoa Apps - Jeff Binder - Jun 10, 2002 02:15 PM

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 :-) .


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 02:31 PM

Oh ya. But I don't have any OpenGL experience anyway. I'll learn it eventually.


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 02:40 PM

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?


Using Carbon API in Cocoa Apps - OneSadCookie - Jun 10, 2002 04:07 PM

CoreGraphics is Quartz.


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 05:02 PM

Okay. There's the sign of a beginner for you. Wink


Using Carbon API in Cocoa Apps - Chris Burkhardt - Jun 10, 2002 05:17 PM

Isn't CoreGraphics a lower level API that Quartz is based on (Quartz calls CG functions)?


Using Carbon API in Cocoa Apps - geezusfreeek - Jun 10, 2002 05:24 PM

That's what I was thinking (and hoping).


Using Carbon API in Cocoa Apps - OneSadCookie - Jun 10, 2002 05:31 PM

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?


Using Carbon API in Cocoa Apps - Feanor - Jun 10, 2002 10:00 PM

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?


Using Carbon API in Cocoa Apps - OneSadCookie - Jun 10, 2002 11:21 PM

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