Question about using OpenGL in Cocoa
Hi friends,
I`m new programming with Cocoa. I want to make an application using OpenGL.
I searched in the web for examples and found that a lot of examples use the method drawFrame: instead of drawRect:. The thing is that the method drawFrame: is not referenced in the NSView class or in the NSOpenGLView class. So, the question is: What is the difference between drawFrame and drawRect and how they work in cocoa?
Thanks
I don't know anything about OpenGL - however the drawRect method is the usual place in which to draw your own stuff in a custom view. So if you have you create your own class from NSView, your drawRect method will be called to paint when necessary. By coincidence someone asked today about custom views. I wrote a tutorial about this, and the details are here: http://www.cocoaforum.com/2010/08/17/looking-for-documentationhelp-to-make-new-views/#post1
I found a sample sample application on Apple's web site: http://developer.apple.com/mac/library/samplecode/GLSLBasicsCocoaDL/Introduction/Intro.html
For sure that code is calling drawRect. A quick glance at the code, I think it's an animation which uses a timer to call drawRect at even time intervals.
I googled around and also found some code which calls drawFrame. Perhaps drawFrame is called to redraw the total contents of a window (or frame) and doesn't have a clipping rectangle. The only place where I can find drawFrame is NSQuickDrawView - so maybe your sample code dates to an earlier implementation of OpenGL which might have been layer on QuickDraw. However I don't know.