NSOpenGLView flickering when adding/removing from superview
NSOpenGLView flickering when adding/removing from superview
- Subject: NSOpenGLView flickering when adding/removing from superview
- From: Dorian Johnson <email@hidden>
- Date: Sat, 23 Jun 2007 16:10:29 -0500
I have an NSOpenGLView subclass which is displayed in a custom tab
view-like class (I'm not using a real tab view for a variety of
reasons, but that's irrelevant: the real tab view does the same exact
thing).
Basically, any time I switch from tab to tab, the entire area taken
by the tab view briefly flickers to completely white. The tab view
itself draws an opaque gray background, and the NSOpenGLView draws a
black background (via glClear). This is really visually jarring so I
need a solution of some sort.
The code that causes the flicker (from tab view's selectItem: method,
with finalContentView as the new NSOpenGLView and initialContentView
as the old one):
[self addSubview:finalContentView];
[initialContentView removeFromSuperviewWithoutNeedingDisplay];
If I switch the order, it does nothing to fix the problem.
The NSOpenGLView just draws a bitmap buffer
- (void)drawRect:(NSRect)rect
{
[self generateTexture]; // initializes the texture from the bitmap
store
glClear(GL_COLOR_BUFFER_BIT);
GLfloat textureWidth = rdBufferWidth;
GLfloat textureHeight = rdBufferHeight;
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, rdBufferTexture);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, textureHeight);
glVertex2f(-1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glTexCoord2f(textureWidth, 0.0f);
glVertex2f(1.0f, -1.0f);
glTexCoord2f(textureWidth, textureHeight);
glVertex2f(1.0f, 1.0f);
glEnd();
[[self openGLContext] flushBuffer];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden