[vtk-developers] Volume won't show on Win7/Intel HD4600 with QVTKOpenGLWidget in 8.0.0.rc1

Elvis Stansvik elvis.stansvik at orexplore.com
Tue May 23 06:50:20 EDT 2017


Hi all,

In porting to QVTKOpenGLWidget, I can't get volumes rendered using
vtkGPUVolumeRayCastMapper to show up on Windows 7, Intel graphics (HD
4600). They show up fine on Linux. They also show up fine on Windows 7
if using a plain VTK render window. I've tried turning off
multisampling with setSamples(0) on the default QSurfaceFormat.

The below test case illustrates the issue. See the attached
screenshots from running "TestCase" (left) and "TestCase 1" (right).
The former uses a plain render window while the latter uses the new
QVTKOpenGLWidget. Notice how in the Windows 7 screenshot, the plain
VTK rendering works fine, but the QVTKOpenGLWidget one is not showing
the volume.

Versions used:

Kubuntu Linux 16.04
VTK 8.0.0.rc1, OpenGL2
Qt 5.5.1

Windows 7
VTK 8.0.0.rc1, OpenGL2
Qt 5.6.2

Any ideas what the problem might be?

I can provide a standalone .zip distribution of my build of the test
case if you want.

Note that this issue is orthogonal to the alpha issue I reported and
got solved in my other thread.

Many thanks in advance,
Elvis


main.cpp:

#include <algorithm>

#include <vtkColorTransferFunction.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkGPUVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include <vtkNew.h>
#include <vtkPiecewiseFunction.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkVolume.h>
#include <vtkVolumeProperty.h>

#include <QVTKOpenGLWidget.h>

#include <QApplication>

int main(int argc, char *argv[])
{
    auto defaultFormat = QVTKOpenGLWidget::defaultFormat();
    defaultFormat.setSamples(0);
    QSurfaceFormat::setDefaultFormat(defaultFormat);

    QApplication app(argc, argv);

    // Set up volume rendering
    vtkNew<vtkColorTransferFunction> colorFunction;
    colorFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
    colorFunction->AddRGBPoint(1.0, 0.0, 0.0, 0.0);

    vtkNew<vtkPiecewiseFunction> opacityFunction;
    opacityFunction->AddPoint(0.0, 0.0);
    opacityFunction->AddPoint(1.0, 1.0);

    vtkNew<vtkImageData> imageData;
    imageData->SetExtent(0, 200, 0, 200, 0, 200);
    imageData->AllocateScalars(VTK_FLOAT, 1);
    std::fill_n(static_cast<float *>(imageData->GetScalarPointer()),
8000000, 0.01);

    vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
    volumeMapper->SetInputData(imageData.Get());

    vtkNew<vtkVolumeProperty> volumeProperty;
    volumeProperty->SetScalarOpacity(opacityFunction.Get());
    volumeProperty->SetColor(colorFunction.Get());
    volumeProperty->ShadeOff();

    vtkNew<vtkVolume> volume;
    volume->SetMapper(volumeMapper.Get());
    volume->SetProperty(volumeProperty.Get());

    vtkNew<vtkRenderer> renderer;
    renderer->AddVolume(volume.Get());
    renderer->SetBackground(1.0, 1.0, 1.0);

    if (argc > 1) {
        // Render with QVTKOpenGLWidget
        vtkNew<vtkGenericOpenGLRenderWindow> window;
        window->AddRenderer(renderer.Get());

        auto widget = new QVTKOpenGLWidget();
        widget->SetRenderWindow(window.Get());
        widget->show();

        return app.exec();
    } else {
        // Render with "plain" render window / interactor
        vtkNew<vtkRenderWindow> window;
        window->AddRenderer(renderer.Get());

        vtkNew<vtkRenderWindowInteractor> interactor;
        interactor->SetRenderWindow(window.Get());
        interactor->Start();

        return 0;
    }
}


CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)

project(TestCase)

find_package(VTK 8.0 COMPONENTS
    vtkCommonCore
    vtkCommonDataModel
    vtkCommonExecutionModel
    vtkCommonMath
    vtkFiltersSources
    vtkGUISupportQt
    vtkInteractionStyle
    vtkRenderingCore
    vtkRenderingOpenGL2
    vtkRenderingVolume
    vtkRenderingVolumeOpenGL2
    REQUIRED
)

find_package(Qt5Widgets REQUIRED)

add_executable(TestCase main.cpp)

target_link_libraries(TestCase PUBLIC
    vtkCommonCore
    vtkCommonDataModel
    vtkCommonExecutionModel
    vtkCommonMath
    vtkFiltersSources
    vtkGUISupportQt
    vtkInteractionStyle
    vtkRenderingCore
    vtkRenderingOpenGL2
    vtkRenderingVolume
    vtkRenderingVolumeOpenGL2
    Qt5::Widgets
)

target_include_directories(TestCase PUBLIC
    ${VTK_INCLUDE_DIRS}
)

target_compile_definitions(TestCase PUBLIC
    ${VTK_DEFINITIONS}
)

set_target_properties(TestCase PROPERTIES
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED ON
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: voltestcase-linux-vtk8rc1-qt55.png
Type: image/png
Size: 346918 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170523/8e59f860/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: voltestcase-win7-vtk8rc1-qt56.png
Type: image/png
Size: 167329 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170523/8e59f860/attachment-0003.png>


More information about the vtk-developers mailing list