views:

702

answers:

1
+1  A: 

I guess you already know that you obtain the rectangle of the view using -[NSView bounds]. Therefore, you get the following correspondances:

  • startTime <-> bounds.origin.x
  • endTime <-> bounds.origin.x + bounds.size.width
  • (-2) <-> bounds.origin.y
  • (+2) <-> bounds.origin.y + bounds.size.height

If I am not mistaken, this method should convert an NSOpenGL point to a view point:

- (NSPoint) pointWithTime:(long)time value:(float)value
{
    NSPoint point;

    point.x = [self bounds].origin.x 
     + [self bounds].size.width * ((time - startTime) / (endTime - startTime));
    point.y = [self bounds].origin.y
     + [self bounds].size.height * ((value - minValue) / (maxValue - minValue));

    return point;
}

(with minValue = -2 and maxValue = 2.)

For the second part of your question: use the rect provided to the -[NSView drawRect:] method to know which part of the view is to be refreshed. Set details in the Cocoa Drawing Guide which is loquacious about this point. The method may be called several times to draw different parts of the view.

Renaud Pradenc
Thanks for the answer; unfortunately, according to this mailing list post: http://tinyurl.com/bttty7 , the bounds rectangle has no effect on NSOpenGLViews.
Dan