Re: Initializing NSOpenGLViews
Re: Initializing NSOpenGLViews
- Subject: Re: Initializing NSOpenGLViews
- From: Jeff Disher <email@hidden>
- Date: Tue, 10 Dec 2002 18:21:48 -0500
This has to do with the way that your control the current
OpenGLContext. Since you could have an arbitrary number of
OpenGLViews, each one with its own context, you need some way to
specify where the "pen" is in your thread. In drawRect:, this is done
for you since the NSOpenGLView sets itself as the current context
before it calls its drawRect: implementation (which you are overriding).
To resolve this (and other issues like shared texture memory), Apple
created the NSOpenGLContext class. In the init method of your
NSOpenGLView, you could do something like this:
[[self openGLContext] makeCurrentContext];
//OpenGL code here
I haven't actually tried this (I got around this problem by just
checking a flag in drawRect: to see if this was the first time, and
then initializing things... then someone told me about this facility)
but it should _work_.
Hope that helps,
Jeff.
On Tuesday, December 10, 2002, at 04:49 PM, Hussein Yahia wrote:
Hello,
I'm initializing an NSOpenGLView by creating a context in
initWithCoder. No problem so far, but if I set up the observer's
position there (with gluLookAt and gluPerspective), very hazardous
things happen. On another hand, if I set up the observer in drawRect,
no problem. Why is it so ? I wouldn't want to initialize the observer
everytime I call drawRect.
Any idea ?
hussein
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Jeff Disher
President and Lead Developer of Spectral Class
Spectral Class: Shedding Light on Innovation
http://www.spectralclass.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.