Rendering tubes and spheres and QVTKOpenGLNativeWidget

Hello,
We are rendering polylines and are using the technique described here to render points as spheres, pixels and wire vs tubes.

I found that when using a console application, points are rendered as ‘pixels’ (squares), by setting

 anActor->GetProperty()->SetRenderPointsAsSpheres(false);

However, the same code don’t do the same thing when rendered using a QVTKOpenGLNativeWidget. In this case, the points are always rendered as spheres (when doing SetRenderPointsAsSpheres(false)) and not rendered at all when SetRenderPointsAsSpheres(true)

Is there a way to enable the ‘console app behavior’ when using a QVTKOpenGLNativeWidget ?


In a console application: SetRenderPointsAsSpheres(false);

image
In a QT application, using QVTKOpenGLNativeWidget: SetRenderPointsAsSpheres(true);

image
In a QT application, using QVTKOpenGLNativeWidget: SetRenderPointsAsSpheres(false);

We are using VTK 9.1 and QT 6.5.

Regards
Totte K.

Hello @totte_karlsson!

When you execute the Qt application and request the actor to render points as spheres, do you observe any errors or shader warnings in the console? It’s worth noting that opengl errors are turned off by default in VTK release builds. If you encounter this issue, you might need to include these CMake arguments during the configuration of VTK.

-DVTK_REPORT_OPENGL_ERRORS=ON
-DVTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS=ON

If you’re on windows, console output is generally disabled for Qt gui apps, so run your app this way in powershell to view console output:

& "my.exe" 2>&1 | Out-String

Hello,

If you build your Qt application with qmake, then enable the console with a CONFIG += console in your .pro file. If you build with CMake, make sure the executable target (add_executable(...)) doesn’t have a WIN32 modifier in it and/or you don’t have a set_property(TARGET <your exe target> PROPERTY WIN32_EXECUTABLE true). By default, CMake builds “console applications” in Windows.

best,

PC

@Paulo_Carvalho

Do Qt console apps on windows get a limited subset of OpenGL?

Hello Jaswant,

Here is my configs related to CMake VTK and OpenGL

When running my QT application, I don’t see any OpenGL errors in the console, and behavior is described as in the question.

So, there seem to be something different using a renderwindow in the QT widget, than one spawned from a console application.

Weird?

Hello Paulo,

I get console output when I’m running my QT application. We turn on/off the console using CMake. This is the CMake file for the application

cmake_minimum_required(VERSION 3.16.0)
set(target arboreta)
project(${target} VERSION 1.0.0 LANGUAGES CXX)
OPTION(SHOW_ARBORETA_CONSOLE                  "Show Arboreta Console"	                OFF)

include_directories(
    ../../foundation
    ../../foundation/common
    ../../foundation/math
    ../../foundation/graphics
    ../../foundation/volume_manager
    ${CMAKE_INSTALL_PREFIX}/include
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Qt Generated")

#Find boost
find_package(Boost ${BOOST_VERSION} EXACT COMPONENTS system filesystem REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})

find_package(Qt6 COMPONENTS Widgets REQUIRED)

file(GLOB_RECURSE UI_FILES *.ui)
file(GLOB_RECURSE HPP_FILES *.h)
file(GLOB_RECURSE CPP_FILES *.cpp)
file(GLOB_RECURSE QRC_FILES *.qrc)

qt_add_executable(${target}
    ../app/main.cpp
)

target_sources(${target}     
PUBLIC
        ${UI_FILES}
        ${HPP_FILES}
        ${CPP_FILES}
        ${QRC_FILES}
        ../../resources/arboreta_rs.qrc
)

source_group("UI" REGULAR_EXPRESSION ".*\\.ui?")
source_group("QRC" REGULAR_EXPRESSION ".*\\.qrc?")
# source_group("QRC" REGULAR_EXPRESSION ".*\\.qrc?")  # *.qrc | *_rs.cpp 
# source_group("QRC" REGULAR_EXPRESSION ".*\(\.qrc?|_rs\.cpp?)")
#set_target_properties(${target} PROPERTIES VS_GLOBAL_KEYWORD "QtVS_v304")

target_link_libraries(${target} PRIVATE 
Qt6::Widgets 
arbFoundation
)

install(    
    TARGETS ${target} 
    RUNTIME DESTINATION bin COMPONENT core
    LIBRARY DESTINATION lib COMPONENT core
    ARCHIVE DESTINATION lib COMPONENT core
)       

if(NOT ${SHOW_ARBORETA_CONSOLE})
	set_property(TARGET ${target} PROPERTY WIN32_EXECUTABLE true)
endif()


None that I know of. The real difference between a “console app” and a “Win32 app” is that the former starts at the void main() and the latter, at the WinMain() function. If you app starts at the WinMain(), a console does not appear when the program loads. So, a “console app” can have graphics in it.

Please, try to link against Qt’s winmain static library when configuring the “Win32 app” mode. This enrures you’re using Qt’s WinMain(). Maybe your program is finding some one else or the compiler is making one for you.

if(NOT ${SHOW_ARBORETA_CONSOLE})
	set_property(TARGET ${target} PROPERTY WIN32_EXECUTABLE true)
    target_link_libraries(${target} PUBLIC Qt::WinMain)
endif()

take care,

PC

Hello Totte K, have you resolved the problem? I met with the same thing

Hello Liang,

Nope, we are still observing this issue for now.

Totte

@totte_karlsson In your application, do you ensure that the correct surface format is initialized for Qt? See VTK: QVTKOpenGLNativeWidget Class Reference

ParaView uses QVTKOpenGLNativeWidget and can render lines as tubes and points as spheres on Windows.