[vtk-developers] Drawing performance problems with Cocoa; what is Render() exactly?

Sean McBride sean at rogue-research.com
Thu Feb 1 12:28:16 EST 2007


Hi all,

We have discovered a performance problem and are looking for some help/advice.

(First a short explanation of the Cocoa graphics model.  There are 2
important classes: NSWindow and NSView.  A 'window' is not the same as
in MS-Windows.  A 'window' refers to what an end user would call a
window.  Views are not subclasses of windows.  An NSView lives in an
NSWindow, and occupies a rectangular area.  An NSView does all its
drawing from its drawRect: method.  drawRect: is never invoked directly,
but rather the OS decides when a view needs to draw itself by sending it
the drawRect: message, at which point a view _must_ draw itself.  If you
want your view to redraw, you mark it dirty my calling [myView
setNeedsDisplay:YES] and sometime later the OS will send the view a
drawRect: message.  One has no control over when the OS will require
one's view to draw, so drawRect: must be fast, and do the minimum needed
to get the pixels onscreen.)

In vtk there is an NSView subclass named vtkCocoaGLView.  Its drawRect:
method invokes vtkRenderWindow's Render() method.

So the questions are: what exactly does Render() do?  We know it draws
(via OpenGL), but does it also do other computations?  Is Render()
overkill when all we need is to draw?

The problem is that the OS often sends vtkCocoaGLView a drawRect:
message even though nothing (camera, scene, lights, etc.) has changed
since the last drawRect: message.  Since we have no control over when
the OS sends drawRect: we are looking to make it faster.

Thanks!

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada





More information about the vtk-developers mailing list