[vtkusers] Problem with vtkTkRenderWidget and CrystalEyes stereo

Jens Thomas j.m.h.thomas at dl.ac.uk
Fri Jun 30 07:13:30 EDT 2006


Hi,

I'm trying to get vtk to use CrystalEyes stereo with a 
vtkTkRenderWidget, but am hitting a problem in that the render window I 
create is not stereo capapble, and I therefore get the error message:

vtkXOpenGLRenderWindow (0x8351740): Adjusting stereo mode on a window 
that does not support stereo type CrystalEyes is not possible.

I call vtkTkRenderWidget with the "stereo=1" flag to generate a widget 
with a renderwindow that is stereo capable, and then call the 
GetRenderWindow method on the widget to get the RenderWindow. However, 
the RenderWindow I get back is not stereo capable, as illustrated by the 
error message above. This is despite the fact that the window that is 
initially created within vtkTkRenderWidget is stereo capable.

I checked this with a print statement in the file:

VTK/Wrapping/Python/vtk/tk/vtkTkRenderWidget.py

at line 89, where it checks the keyword dictionary as shown below:

try:  # was a stereo rendering context requested?
            if kw['stereo']:
               print "Setting stereo"
               renderWindow.StereoCapableWindowOn()
               print renderWindow
               del kw['stereo']
        except KeyError:
            pass

At the point of the print statement, the window is stereo capapble.

It therefore seems that the window returned by the GetRenderWindow is 
not the same one as was first created.

If I create the render window directly, and avoid the vtkTkRenderWidget 
side of things, it appears to work o.k.

I've pasted in an example below that demonstrates the problem - setting 
the tk variable to 0 or 1 turns off the Tk code and shows that it 
appears to work if you don't use the  vtkTkRenderWidget code.

Any suggestions/help would be greatly appreciated.

Best wishes,

Jens


from Tkinter import *
from vtk import *
from vtk.tk.vtkTkRenderWidget import *

# Set the tk variable to 0 to eschew the Tk code
tk=1
if tk:
    # Make a root window
    root = Tk()
    # Add a vtkTkRenderWidget
    renderWidget = vtkTkRenderWidget(root,stereo=1)
    renderWidget.pack()
    # Get the render window from the widget
    renWin = renderWidget.GetRenderWindow()
    print "renWin is"
    print renWin
else:
    renWin = vtk.vtkRenderWindow()
    renWin.StereoCapableWindowOn()
    print "renWin is"
    print renWin
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)   

renWin.SetStereoTypeToCrystalEyes()
#renWin.SetStereoTypeToRedBlue()
renWin.StereoRenderOn()

# Next, do the VTK stuff
ren = vtkRenderer()
renWin.AddRenderer(ren)
cone = vtkConeSource()
cone.SetResolution(16)
coneMapper = vtkPolyDataMapper()
coneMapper.SetInput(cone.GetOutput())
coneActor = vtkActor()
coneActor.SetMapper(coneMapper)
ren.AddActor(coneActor)


# start up the event loop
if tk:
    root.mainloop()
else:
    iren.Initialize()
    renWin.Render()
    iren.Start()




More information about the vtkusers mailing list