[vtkusers] Problem with vtkTkRenderWidget and CrystalEyes stereo

Jens Thomas j.m.h.thomas at dl.ac.uk
Tue Jul 11 05:14:27 EDT 2006


Hi Micheal,

Many thanks for getting back to me.

Michael Scarpa wrote:
> On Mon, Jul 10, 2006 at 05:33:25PM +0100, Jens Thomas wrote:
>   
>> Michael Scarpa wrote:
>>     
>>> Jens Thomas wrote:
>>>       
>>>> 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.
>>>>
>>>>         
>>> >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()
>>>>    
>>>>         
>>> Have you tried the same things with vtkTkRenderWindowInteractor instead
>>> of vtkTkRenderWidget? With the former, you can create your own
>>> vtkRenderWindow instance and provide it to the widget for use.  It
>>> would be interesting to see if you encounter the same problem in this
>>> case, since you can create your own render window and set its
>>> capabilities yourself before handing it over to Tk.
>>>
>>>       
>> I've been playing around with this a bit more and have got a little 
>> further, although I'm still stuck.
>>
>> You can actually create your own window with the vtkTkRenderWidget and 
>> pass it in too, so I tried this and still had the same problem. I've 
>> therefore tried to remove Python from the equation by writing a Tcl 
>> script that does exactly the same thing (well, I think it does - I've 
>> never used Tcl before) . It seems that the vtkTkRenderWidget doesn't 
>> accept a -stereo argument, so I have to create the render window myself 
>> and then pass it in.
>>
>> However, even doing this, the code demonstrates exactly the same 
>> problems as calling the routine from Python, so it seems that the 
>> problem resides in the Tcl/Tk side of things. I've pasted the code into 
>> the tail of this email in case anyone wants to try it.
>>
>> I've tried this with the VTK 5.0 on Windows, Mac OSX and Linux, and 
>> things seem to work fine on Windows and Mac OSX, but not under Linux - 
>> and unfortunately, it's Linux that I need this to work on.
>>     
>
> Just a crazy thought, but ... are you sure the graphics card of the
> Linux machine you are using is able to produce active stereo images?
> Because if not, vtk won't produce any error messages (at least in my
> experience) and simply not render in active stereo.
>   
The problem is that the render window is not stereo capable and that I'm 
getting an error messages when I try to set the stereo type to crystal 
eyes. The kit I've got is capable of working with active stereo, but 
until I can get a stereo capable window, there's not much I can do with it!
>   
>> I've tried this on Linux running Suse 9.3 on a Pentium with tcl 8.4.9-7 
>> and tk 8.4.9-9, as well as a RHEL 3 on a Intel Xeon with tcl 8.3.5-92.4 
>> and tk 8.3.5-92.4, so it doesn't appear to be specific to a brand of 
>> Linux/version of Tk/Tcl.
>>
>> If anyone can suggest where I go from here, I'd be most grateful to hear 
>> from you!
>>
>> package require vtk
>> package require vtkinteraction
>>
>> # Create the render window to pass to the vtkTkRenderWidget
>> vtkRenderWindow renWin1
>> renWin1 StereoCapableWindowOn
>> # At this point the window is stereo capable
>> puts stdout [renWin1 Print]
>>
>> set renderWidget [vtkTkRenderWidget .ren -width 400 -height 400 -r renWin1]
>> ::vtk::bind_tk_render_widget $renderWidget
>> wm protocol . WM_DELETE_WINDOW ::vtk::cb_exit
>> pack $renderWidget
>>
>> # Return the render window from the vtkTkRenderWidget
>> set renWin [$renderWidget GetRenderWindow]
>>
>> # This should be the same window as was created before, but it is not 
>> stereo capapble
>> puts stdout [$renWin Print]
>>
>> $renWin SetStereoTypeToCrystalEyes
>> $renWin StereoRenderOn
>>
>> vtkRenderer ren
>> $renWin AddRenderer ren
>> vtkConeSource cone
>> cone SetResolution 16
>> vtkPolyDataMapper coneMapper
>> coneMapper SetInput [cone GetOutput]
>> vtkActor coneActor
>> coneActor SetMapper coneMapper
>> ren AddActor coneActor
>>
>> $renderWidget Render
>> tkwait window .
>>     
>
> I have tried your code on a Linux machine here.  The script works fine
> and I get an active stereo image.
>
> Furthermore, you say in your Tcl/Tk code that $renWin should be the same
> window as $renWin1, but that it is not.  How did you conclude that?  In
> the output the script generated for me, the address of the two objects
> was the same, but some parameters did indeed change.  Nevertheless, it
> would seem to me that the two variables point to the same object in
> memory, even though it gets modified by the initialization.
>
> I hope this helps.
>
> Kind regards,
>
> Michael
>
>
>   

I am getting the render window in both cases (i.e. the address is the 
same), but the problem is that the window I am returned from the 
GetRenderWindow call is not stereo capable, whereas the initial one is. 
I've pasted the output of running the script on my machine below so that 
you can see the differences.

However, if this is working on your machine then it suggests that the 
problem is just due to the configurations of the machines I'm using.

Could you possibly send me some details of the machine this is working 
on for you? It would particularly helpful to know the processor, Linux 
distribution you are running, Tk and Tcl versions, as well as the 
version of VTK you are using.

Thanks again for all your help.

Best wishes,

Jens


vtkXOpenGLRenderWindow (0x80f4bc0)
  Debug: Off
  Modified Time: 5
  Reference Count: 1
  Registered Events:
    Registered Observers:
      vtkObserver (0x80f4410)
        Event: 2
        EventName: DeleteEvent
        Command: 0x80738c0
        Priority: 0
        Tag: 1
  Erase: On
  Window Name: Visualization Toolkit - OpenGL
  Position: (0, 0)
  Size: (0, 0)
  Mapped: 0
  OffScreenRendering: 0
  Double Buffered: 1
  DPI: 120
  TileScale: (1, 1)
  TileViewport: (0, 0, 1, 1)
  Borders: On
  IsPicking: Off
  Double Buffer: On
  Full Screen: Off
  Renderers:
    Debug: Off
    Modified Time: 3
    Reference Count: 1
    Registered Events: (none)
    Number Of Items: 0
  Stereo Capable Window Requested: Yes
  Stereo Render: Off
  Point Smoothing: Off
  Line Smoothing: Off
  Polygon Smoothing: Off
  Anti Aliased Frames: 0
  Abort Render: 0
  Current Cursor: 0
  Desired Update Rate: 0.0001
  Focal Depth Frames: 0
  In Abort Check: 0
  NeverRendered: 1
  Interactor: 0
  Motion Blur Frames: 0
  Swap Buffers: On
  Stereo Type: RedBlue
  Number of Layers: 1
  AccumulationBuffer Size 0
  AlphaBitPlanes: Off
  AnaglyphColorSaturation: 0.65
  AnaglyphColorMask: 4 , 3
  MultiSamples: 8
  ContextId: 0
  Color Map: 0
  Display Id: 0x814dec0
  Next Window Id: 0
  Window Id: 0


vtkXOpenGLRenderWindow (0x80f4bc0)
  Debug: Off
  Modified Time: 6
  Reference Count: 3
  Registered Events:
    Registered Observers:
      vtkObserver (0x8160788)
        Event: 10
        EventName: AbortCheckEvent
        Command: 0x8160770
        Priority: 0
        Tag: 2
      vtkObserver (0x80f4410)
        Event: 2
        EventName: DeleteEvent
        Command: 0x80738c0
        Priority: 0
        Tag: 1
  Erase: On
  Window Name: Visualization Toolkit - OpenGL
  Position: (0, 0)
  Size: (400, 400)
  Mapped: 1
  OffScreenRendering: 0
  Double Buffered: 1
  DPI: 120
  TileScale: (1, 1)
  TileViewport: (0, 0, 1, 1)
  Borders: On
  IsPicking: Off
  Double Buffer: On
  Full Screen: Off
  Renderers:
    Debug: Off
    Modified Time: 3
    Reference Count: 1
    Registered Events: (none)
    Number Of Items: 0
  Stereo Capable Window Requested: No
  Stereo Render: Off
  Point Smoothing: Off
  Line Smoothing: Off
  Polygon Smoothing: Off
  Anti Aliased Frames: 0
  Abort Render: 0
  Current Cursor: 0
  Desired Update Rate: 0.0001
  Focal Depth Frames: 0
  In Abort Check: 0
  NeverRendered: 0
  Interactor: 0x8155c20
  Motion Blur Frames: 0
  Swap Buffers: On
  Stereo Type: RedBlue
  Number of Layers: 1
  AccumulationBuffer Size 0
  AlphaBitPlanes: Off
  AnaglyphColorSaturation: 0.65
  AnaglyphColorMask: 4 , 3
  MultiSamples: 8
  ContextId: 0x80f3618
  Color Map: 10485784
  Display Id: 0x80a96f8
  Next Window Id: 0
  Window Id: 10485786


Warning: In /home/jmht/VTK/VTK5.5/VTK/Rendering/vtkRenderWindow.cxx, 
line 196
vtkXOpenGLRenderWindow (0x80f4bc0): Adjusting stereo mode on a window 
that does not support stereo type CrystalEyes is not possible.




More information about the vtkusers mailing list