<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I just submitted this bug report with a fix for the bug. I'm posting
it here in case anyone else is having this problem and to ask that
it be incorporated into the upcoming VTK 6.2 release.<br>
<br>
Thanks!<br>
<br>
In VTK 6.1, vtkWin32OpenGLRenderWindow::ResumeScreenRendering()
doesn't properly restore the context, nor does it reconnect the
render window with the renderer for screen rendering after rendering
to the bitmap if it couldn't create a hardware offscreen window (as
is the case for Remote Desktop).<br>
<br>
This worked properly in VTK 5.10.1.<br>
<br>
Here is the code in VTK 6.1:<br>
<br>
<tt>void vtkWin32OpenGLRenderWindow::ResumeScreenRendering(void)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
// release OpenGL graphics resources before switch back to
on-screen.</tt><tt><br>
</tt><tt>
if(this->ContextId!=0)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
this->MakeCurrent();</tt><tt><br>
</tt><tt>
// Renderers will need to redraw anything cached in display
lists</tt><tt><br>
</tt><tt>
vtkRenderer *ren;</tt><tt><br>
</tt><tt>
vtkCollectionSimpleIterator rsit;</tt><tt><br>
</tt><tt>
for (this->Renderers->InitTraversal(rsit);</tt><tt><br>
</tt><tt>
(ren = this->Renderers->GetNextRenderer(rsit));)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
ren->SetRenderWindow(NULL);</tt><tt><br>
</tt><tt>
ren->SetRenderWindow(this);</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
</tt><tt><br>
</tt><tt>
this->Mapped = this->ScreenMapped;</tt><tt><br>
</tt><tt>
this->Size[0] = this->ScreenWindowSize[0];</tt><tt><br>
</tt><tt>
this->Size[1] = this->ScreenWindowSize[1];</tt><tt><br>
</tt><tt>
this->DeviceContext = this->ScreenDeviceContext;</tt><tt><br>
</tt><tt>
this->DoubleBuffer = this->ScreenDoubleBuffer;</tt><tt><br>
</tt><tt>
this->ContextId = this->ScreenContextId;</tt><tt><br>
</tt><tt>
this->MakeCurrent();</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
</tt><br>
The problem is that ContextId is 0 in Remote Desktop, so the
rendered are never reconnected to the render window, but the render
window is NULL because of a previous call to CleanUpRenderers(). So
it will crash when trying to access the NULL render window later.<br>
<br>
Here is a fixed version that works in the hardware offscreen
rendering case and the software offscreen rendering case.<br>
<br>
<tt>void vtkWin32OpenGLRenderWindow::ResumeScreenRendering(void)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
// Restore the context members to the screen one before
switching back to</tt><tt><br>
</tt><tt>
// on-screen because ContextId will be 0 in the case of Remote
Desktop.</tt><tt><br>
</tt><tt>
this->Mapped = this->ScreenMapped;</tt><tt><br>
</tt><tt>
this->Size[0] = this->ScreenWindowSize[0];</tt><tt><br>
</tt><tt>
this->Size[1] = this->ScreenWindowSize[1];</tt><tt><br>
</tt><tt>
this->DeviceContext = this->ScreenDeviceContext;</tt><tt><br>
</tt><tt>
this->DoubleBuffer = this->ScreenDoubleBuffer;</tt><tt><br>
</tt><tt>
this->ContextId = this->ScreenContextId;</tt><tt><br>
</tt><tt>
</tt><tt><br>
</tt><tt>
// The OpenGL graphics resources should have been already
released by a previous</tt><tt><br>
</tt><tt>
// to CleanUpRenderers(), and it may also have been switched
back to on-screen. If so,</tt><tt><br>
</tt><tt>
// do nothing. Otherwise, clear it (clearing twice is a no-op)
and switch back to on-screen.</tt><tt><br>
</tt><tt>
if(this->ContextId!=0)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
this->MakeCurrent();</tt><tt><br>
</tt><tt>
// Renderers will need to redraw anything cached in display
lists</tt><tt><br>
</tt><tt>
vtkRenderer *ren;</tt><tt><br>
</tt><tt>
vtkCollectionSimpleIterator rsit;</tt><tt><br>
</tt><tt>
for (this->Renderers->InitTraversal(rsit);</tt><tt><br>
</tt><tt>
(ren = this->Renderers->GetNextRenderer(rsit));)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
if(ren->GetRenderWindow()!=this)</tt><tt><br>
</tt><tt>
{</tt><tt><br>
</tt><tt>
ren->SetRenderWindow(NULL);</tt><tt><br>
</tt><tt>
ren->SetRenderWindow(this);</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
}</tt><tt><br>
</tt><tt>
}</tt><br>
<br>
It would be really cool if this fix were applied to the upcoming VTK
6.2 release.<br>
<br>
Note that Bug report 15286 mentions this bug indirectly by sayign
that he had to call ResumeScreenRendering() twice. This fix will
correct that problem also.<br>
<div class="moz-signature">-- <br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Signature</title>
<a href="http:://www.infolytica.com">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
(514) 849-8752 x236, Fax: (514) 849-4239
</div>
</body>
</html>