NSOpenGLView's init not being called... why? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: NSOpenGLView's init not being called... why? (/thread-7621.html)
NSOpenGLView's init not being called... why? - codemattic - Aug 11, 2002 11:10 AM
I have a subclass of an NSOpenGLView - which I placed in a window in IB. Now there is some member variables I need to initialize when the view is created. Ive tried alternately the methods listed below. None seems to get called. My workaround is to have a method called -setup, and every other method (-drawRect, -reshape, etc) first checks if the view has been initialized, and if not calls setup first before doing anything. It works - but its inelegant - and Id like to know why I cant initialize properly. help.
NSOpenGLView's init not being called... why? - kainsin - Aug 12, 2002 08:05 AM
Have you tried awakeFromNib? I don't believe that objects will have their init* methods called if they are stored in nib files since they are "freeze-dried" objects, not just placeholders.
NSOpenGLView's init not being called... why? - GoodDoug - Aug 12, 2002 01:42 PM
Kainsin is exactly right. objects created from Interface Builder nibs are intited with - (id) initWithCoder: and so bypasess all of your init routines. That's what awakeFromNib does. Now, be aware that in most cases, the OpenGL context is not fully available until after awakeFromNib. The context isn't really created until it is first drawn, so any OpenGL initialization calls need to be done in the views, - (void) drawRect: method
NSOpenGLView's init not being called... why? - codemattic - Aug 12, 2002 10:59 PM
Thanks guys. awakeFromNib it is... along with an extra sanity check or two. However:
Quote:Originally posted by kainsin
Quote:Originally posted by GoodDoug
okay smarty-guys, why when I create a subclass of NSView and attach it up in IB does its -(id)initWithFrame:(NSRect)frame method get called? Everything is the same as before - except its a nsview subclass instead of an nsopenglview.