Memo‎ > ‎

Offscreen Rendering in VTK 5.0

posted May 6, 2013, 11:41 AM by Teng-Yok Lee   [ updated May 6, 2013, 12:30 PM ]
On remote servers without graphics display, it will be desired to do offscreen rendering. Although it is supported in VTK, I cannot find documents or examples about how to do it. Nevertheless, the information can be found in its CMakeLists.txt.

Prerequisites

Mesa is for software-based OpenGL rendering. It can be installed as follows. Besides Mesa, VTK also needs OSMESA.

On Ubuntu, they can be installed via apt-get as follows:

sudo apt-get install libgl1-mesa-dev -y
sudo apt-get install libosmesa6-dev -y


For python binding, we need to install python-dev too
sudo apt-get install python-dev -y


We can also install other dependent software packages by install the pre-packaged VTK. On Ubuntu, it can be installed as follows:

sudo apt-get install python-vtk -y

Configure via CMake

First, set VTK_USE_OFFSCREEN
VTK_USE_OFFSCREEN = ON.

Then according to Rendering/CMakeListst.txt, the following options should be specified:
VTK_USE_X = OFF
VTK_OPENGL_HAS_OSMESA = ON
OPENLGL_gl_LIBRARY = /usr/lib/libGL.so
OSMESA_LIBRARY = /usr/lib/libOSMesa.so
OSMESA_INCLUDE_DIR = /usr/include/GL

For python binding:
BUILD_SHARED_LIBS = ON
VTK_WRAP_PYTHON = ON

There are more variables to configure:
CMAKE_BUILD_TYPE = Release
VTK_USE_TK = OFF
CMAKE_INSTALL_PREFIX = /usr/bin/vtk


Configure Environment Variables

Once the program is configured and build, we need tosetup the environment variables PYTHONPATH and LD_LIBRARY_PATH. Assume that the built VTK is installed to /usr/local/vtk, the two variables should be configured as follows (PS. Modify the python version and VTK version for your cases).

export PYTHONPATH=$PYTHONPATH:/usr/bin/vtk/lib:/usr/bin/vtk/lib/python2.7/site-packages
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/bin/vtk/lib/vtk-5.1

Comments