Skip to content

Instantly share code, notes, and snippets.

@glass5er
Last active August 29, 2015 14:13
Show Gist options
  • Save glass5er/dfe3bfe7ff992a20db9b to your computer and use it in GitHub Desktop.
Save glass5er/dfe3bfe7ff992a20db9b to your computer and use it in GitHub Desktop.
wxPython + vtk renderer problems

wxPython + vtk renderer problems

Preliminaries

  • Ubuntu 14.04 LTS
  • Anaconda 3.7.4 with python 2.7
  • wxpython 3.0.0
  • vtk 5.10.1

Problems

1. Error termination problem

Traceback (most recent call last):
  File "sample.py", line 44, in __init__
    wxVTKRenderWindow.\_\_init\_\_(self, parent, ID, *args, **kw)
  File "$HOME/anaconda/lib/python2.7/site-packages/vtk/wx/wxVTKRenderWindow.py", line 194, in __init__
    attribList=[wx.glcanvas.WX_GL_DOUBLEBUFFER])
  File "$HOME/anaconda/lib/python2.7/site-packages/wx-3.0-gtk2/wx/glcanvas.py", line 106, in __init__
    _glcanvas.GLCanvas_swiginit(self,_glcanvas.new_GLCanvas(*args, **kwargs))
TypeError: Argument given by name ('attribList') and position (3)

This is because of the version of wxPython.
vtk supposes wxPython's version to be >= 2.9.
see :
https://groups.google.com/forum/#!topic/wxpython-users/MxJPxlOS05A

2. Depth test (culling) problem

Mesh collapse and object disorder occur.
This is because of depth buffer bit size of wxpython.glcanvas.
see :
https://groups.google.com/forum/#!topic/wxpython-users/lbzhzaBNkxQ

Solution

edit $HOME/anaconda/lib/python2.7/site-packages/vtk/wx/wxVTKRenderWindow.py :: line 193:

  1. change the order of arguments (attribList)
  2. add "wx.glcanvas.WX_GL_DEPTH_SIZE,16" to attribList
- baseClass.__init__(self, parent, ID, position, size, style, attribList=[wx.glcanvas.WX_GL_DOUBLEBUFFER])
+ baseClass.__init__(self, parent, ID, [wx.glcanvas.WX_GL_DOUBLEBUFFER, wx.glcanvas.WX_GL_DEPTH_SIZE, 16], position, size, style)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment