Re: subclassed NSOpenGLView won't draw in subclassed NSView
Re: subclassed NSOpenGLView won't draw in subclassed NSView
- Subject: Re: subclassed NSOpenGLView won't draw in subclassed NSView
- From: Shaun Wexler <email@hidden>
- Date: Mon, 7 Feb 2005 08:40:27 -0800
On Feb 7, 2005, at 8:33 AM, Carl Gieringer wrote:
I am having problems subclassing NSView with a subclassed OpenGlView
inside. I apologize, because this seems like a simple problem, but I
haven't found anything that helps in the archives (cocoa-dev's or
mac-opengl's) or in the AppKit documentation.
I am subclassing NSView to make a graph with labeled axes. The NSView
subclass, HistoryView, is in my nib file, and during its awakeFromNib
it creates NSTextFields to label the axes and also creates a subclass
of NSOpenGLView, HistoryGraphView. HistoryView is responsible for
laying out its subviews, making them draw in -drawRect: and resizing
the subviews. I do call -lockFocus and -unlockFocus before drawing
every subview of HistoryView. I do also add the subviews to my
History view via [aHistoryView addSubview:subview];
The problem I am having is that the OpenGLView subclass
HistoryGraphView does not draw except for when it is first placed on
the screen. The only exception is as I resize HistoryView's window.
Then HistoryGraphView draws correctly. The most correct way to draw
the subview (I think) would be to do [aHistoryGraphView
setNeedsDisplay:YES] when -updateHistory is called (that is, when the
data that aHistoryGraph represents changes.) Unfortunately, this
method does not cause aHistoryGraphView's frame to refresh on my
screen.
The Cocoa way:
[[aHistoryGraphView openGLContext] flushBuffer];
Instead, if you're double-buffered, call glSwapAPPLE() after drawRect:
returns, or if single-buffered call glFlush().
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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