Commit adc03cb4 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED z-buffer/transparency problem in 3D viewer

parent 484a8638
......@@ -98,8 +98,25 @@
// On some OpenGL drivers (e.g. Mesa 13), the OpenGL context has to be requested before hand
static void initialize() {
CAMITK_TRACE_ALT("Initializing OpenGL Context...");
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
//QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
// recommended: disable multisampling for older version of OpenGL ES
// see for instance how mitk (thank guys!) solved the problem in BaseApplication::getQApplication()
// from Modules/AppUtil/src/mitkBaseApplication.cpp
vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(0);
auto defaultFormat = QVTKOpenGLWidget::defaultFormat();
defaultFormat.setSamples(0);
//defaultFormat.setDepthBufferSize(8);
QSurfaceFormat::setDefaultFormat(defaultFormat);
#ifdef Q_OS_OSX
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
}
Q_COREAPP_STARTUP_FUNCTION(initialize)
......@@ -378,6 +395,15 @@ RendererWidget::RendererWidget(QWidget * parent, ControlMode mode) : QVTKOpenGLW
//-- renderer
renderer = vtkSmartPointer<vtkRenderer>::New();
#if VTK_MAJOR_VERSION == 8
// depth peeling ensure that when slices are displayed properly independently to
// the order in which the slice actors were added
// This avoid a z-buffer problem resulting in strange transparency behaviour between slices
// (i.e., the last added actor is transparent to all other actors, the one added before last
// is transparent only to all but the last added actors, etc... the first added actor is
// transparent to none)
renderer->UseDepthPeelingOn();
#endif
renderWindow->AddRenderer(renderer);
//-- interactor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment