Re: Problem with setNeedsDisplay: in derived NSOpenGLView
Re: Problem with setNeedsDisplay: in derived NSOpenGLView
- Subject: Re: Problem with setNeedsDisplay: in derived NSOpenGLView
- From: Shaun Wexler <email@hidden>
- Date: Thu, 1 Dec 2005 18:06:06 -0800
On Dec 1, 2005, at 9:13 AM, Brant Sears wrote:
I have a view that is derived from NSOpenGLView. It draws when it
is initially opened and redraws when it is resized. However, when I
call:
[glView setNeedsDisplay:YES];
the view is not redisplayed. I have verified that the value of the
view to which I am sending the message is correct and also that the
redraw is really not happening (using Quartz debug). When I resize
the window (which resizes the view), Quartz debug shows it
redrawing (and I see other consistant behavior), but not when I
explicitly call setNeedsDisplay: on the view from a button push.
It sounds like you forgot to explicitly flush your GL context in -
drawRect:
What things should I investigate that might cause this behavior?
Add an ivar to your GLView class, and some optimization code:
NSSize lastBoundsSize;
- (void)drawRect:(NSRect)rect
{
/* perform drawing here */
NSSize size;
if (!NSEqualSizes(lastBoundsSize, (size = [self bounds].size))) {
lastBoundsSize = size;
} else if (doubleBufferedAndPantherCompatible) {
glFlush();
} else { // singleBuffered, or doubleBufferedAndTigerOrGreater
glFlushRenderAPPLE();
}
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Efficiency is intelligent laziness.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden