[vtkusers] tutorial, step1, Cone runs like a snail on OSX 10.5

Darren Weber darren.weber.lists at gmail.com
Fri Mar 13 14:09:10 EDT 2009


Right on, guys!

In lines 580 -- 606 of vtk 5.2.1 :: vtkCocoaRenderWindow.mm, we have

//----------------------------------------------------------------------------
void vtkCocoaRenderWindow::CreateGLContext()
{
 NSOpenGLPixelFormatAttribute attribs[] =
   {
     NSOpenGLPFAAccelerated,
     NSOpenGLPFADepthSize,
     (NSOpenGLPixelFormatAttribute)32,
     (this->DoubleBuffer != 0) ?
       (NSOpenGLPixelFormatAttribute)NSOpenGLPFADoubleBuffer :
       (NSOpenGLPixelFormatAttribute)nil,
     (NSOpenGLPixelFormatAttribute)nil
   };

 NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc]
                                     initWithAttributes:attribs]
autorelease];
 NSOpenGLContext* context = [[[NSOpenGLContext alloc]
                             initWithFormat:pixelFormat
                             shareContext:nil] autorelease];

 // This syncs the OpenGL context to the VBL to prevent tearing
 //GLint one = 1;
 GLint one = 0;
 [context setValues:&one forParameter:NSOpenGLCPSwapInterval];

 this->SetPixelFormat((void*)pixelFormat);
 this->SetContextId((void*)context);
}


SO I switched to: GLint one = 0; and these are the results:

[ dweber at XXX ~/src/kitware/VTK_build ]$ time ./bin/Cone
real 0m0.432s
user 0m0.191s
sys 0m0.076s
[ dweber at XXX ~/src/kitware/VTK_build ]$ time ./bin/Cone
real 0m0.408s
user 0m0.191s
sys 0m0.077s
[ dweber at XXX ~/src/kitware/VTK_build ]$ time ./bin/Cone
real 0m0.405s
user 0m0.196s
sys 0m0.077s


Mucho gracias, amigos!


PS, Note the comment in the code about tearing, may be important for some
apps to switch over to sync mode.



On Thu, Mar 12, 2009 at 5:02 PM, Sean McBride <sean at rogue-research.com>
wrote:
> On 3/12/09 7:50 PM, Francois Bertel said:
>
>>Hello,
>>
>>If your display has a vertical refresh rate of 60Hz and the vertical
>>blank sync is set on your system,
>>each rendering of a frame waits for the next vertical blank to swap
>>the  front and back buffer.
>>
>>360 frames/60Hz=6s.
>>
>>I don't know how you can switch that off as a end-user on Mac.
>
> François,
>
> Good thinking.  VBL sync is always on in vtkCocoaRenderWindow.  This is
> the responsible snippit:
>
>  [context setValues:&one forParameter:NSOpenGLCPSwapInterval];
>
> Darren, try commenting that line out and rebuilding VTK.  See if
> François' theory is correct.
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 sean at rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090313/99455abb/attachment.htm>


More information about the vtkusers mailing list