[vtk-developers] Sitching to offscreen rendering exits application.

Jenya Burstein taijinian at gmail.com
Wed Aug 17 20:10:23 EDT 2011


Hello,

I've ran into an issue of VTK exiting the application if an offscreen
rendering is requested for a large size render window. VTK has a very
unforgiving error handling. It displays a system message box (at least on
Windows) and then calls exit(1) if there are no vtkCommand::ExitEvent
observers. Even if I install my own ExitEvent observer, VTK will still
present a rather user-unfriendly "ChoosePixelFormat failed." message.
Ideally, clients of VTK would want to handle the error in their own way. Is
there a reason why VTK doesn't simply invoke vtkCommand::ErrorEvent?

Best Regards,
Jenya Burstein

void vtkWin32OpenGLRenderWindow::SetupPixelFormat(HDC hDC, DWORD dwFlags,
                                                  int debug, int bpp,
                                                  int zbpp)
{
....
    pixelFormat = ChoosePixelFormat(hDC, &pfd);
    if (pixelFormat == 0)
      {
#ifdef UNICODE
      MessageBox(WindowFromDC(hDC), L"ChoosePixelFormat failed.", L"Error",
                 MB_ICONERROR | MB_OK);
#else
      MessageBox(WindowFromDC(hDC), "ChoosePixelFormat failed.", "Error",
                 MB_ICONERROR | MB_OK);
#endif
      if (this->HasObserver(vtkCommand::ExitEvent))
        {
        this->InvokeEvent(vtkCommand::ExitEvent, NULL);
        return;
        }
      else
        {
        exit(1);
        }
      }
....
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110817/c3c11e71/attachment.html>


More information about the vtk-developers mailing list