View Full Version : initializing opengl in cocoa
FreeKQuency23
2006.04.01, 08:27 PM
hello
When initializing an subclass of an NSOpenGLView in Cocoa, why would you use the initwithcoder method over the initwithframe method which is the default method for initializing any NSView derivitive. The Green triangle tutorial on apple's website does it this way and Im really not sure why they dont use initwithframe like the deep cocoa tutorials do. Any insight?
cheers
OneSadCookie
2006.04.02, 12:07 AM
if you drag an NSOpenGLView in IB, -initWithFrame: is not called. If you drag a custom view, and set its subclass to a subclass of NSOpenGLView, -initWithFrame: is called. I always do things the second way, personally.
FreeKQuency23
2006.04.02, 12:24 AM
So why does the green apple tutorial use initWithCoder?
What does this get us?
OneSadCookie
2006.04.02, 12:46 AM
the ability to drag an NSOpenGLView in IB, rather than a custom view.
FreeKQuency23
2006.04.02, 04:34 AM
So it makes no difference? You get the same functionality either way you do it?
What about specifying a pixel format? When building a NSOpenGLView in IB, you can specify depth buffers and such.
I guess the real question is, what's the best method (easiest and most hassle free)?
thanks for your help
OneSadCookie
2006.04.02, 04:54 AM
when dragging an NSOpenGLView in IB, you don't get the option to specify double buffering, which you always want. So whichever you use, you have to create your own pixel format. That's why I use the custom view + initWithFrame: route.
I don't really think there's anything to choose between them though. Pick whichever seems right to you and go with it.
arekkusu
2006.04.02, 04:10 PM
Q&A1167: Using Interface Builder's NSOpenGLView or Custom View objects for an OpenGL application (http://developer.apple.com/qa/qa2004/qa1167.html)
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.