Skip to content

Commit

Permalink
fix: add workaround to avoid viewer crash on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
j8xixo12 committed Feb 11, 2023
1 parent ef2b92b commit 6a9888d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ endif()
option(USE_CLANG_TIDY "use clang-tidy" OFF)
option(LINT_AS_ERRORS "clang-tidy warnings as errors" OFF)

if(BUILD_QT)
option(QT3D_USE_RHI "Qt use RHI" OFF)
message(STATUS "QT3D_USE_RHI: ${QT3D_USE_RHI}")
endif()

find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
Expand Down Expand Up @@ -149,8 +154,6 @@ endif()
add_subdirectory(cpp/binary/pymod_modmesh)
if(BUILD_QT)
add_subdirectory(cpp/binary/viewer)
set(ENV{QT3D_RENDERER} ${QT3D_RENDERER})
message(STATUS "QT3D_RENDERER: " $ENV{QT3D_RENDERER})
endif()

add_custom_target(flake8)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CMAKE_PREFIX_PATH ?=
CMAKE_ARGS ?=
VERBOSE ?=
FORCE_CLANG_FORMAT ?=
QT3D_RENDERER ?=
QT3D_USE_RHI ?= OFF

# !!! NOTE: USING ANY VENV IS STRONGLY DISCOURAGED IN DEVELOPING MODMESH !!!
# This treatment is a "smarter" way to find python3-config executable.
Expand Down Expand Up @@ -92,7 +92,7 @@ CMAKE_CMD = cmake $(MODMESH_ROOT) \
-DUSE_CLANG_TIDY=$(USE_CLANG_TIDY) \
-DLINT_AS_ERRORS=ON \
-DMODMESH_PROFILE=$(MODMESH_PROFILE) \
-DQT3D_RENDERER=$(QT3D_RENDERER) \
-DQT3D_USE_RHI=$(QT3D_USE_RHI) \
$(CMAKE_ARGS)

$(BUILD_PATH)/Makefile: CMakeLists.txt Makefile
Expand Down
2 changes: 1 addition & 1 deletion cpp/binary/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ install(TARGETS viewer
RUNTIME DESTINATION "${INSTALL_VIEWERDIR}"
BUNDLE DESTINATION "${INSTALL_VIEWERDIR}"
LIBRARY DESTINATION "${INSTALL_VIEWERDIR}"
)
)
8 changes: 8 additions & 0 deletions cpp/modmesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,12 @@ else () # MSVC
)
endif () # MSVC

if(QT3D_USE_RHI)
target_compile_options(modmesh_primary PRIVATE
${COMMON_COMPILER_OPTIONS}
-DQT3D_USE_RHI
)
endif() # QT3D_USE_RHI


# vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4 sts=4:
6 changes: 6 additions & 0 deletions cpp/modmesh/view/wrap_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ OneTimeInitializer<view_pymod_tag> & OneTimeInitializer<view_pymod_tag>::me()

void initialize_view(pybind11::module & mod)
{
// TODO: There is some bug in QT RHI, this is a workaround to force QT use opengl directly
#if defined (QT3D_USE_RHI)
qputenv("QT3D_RENDERER", "rhi");
#else
qputenv("QT3D_RENDERER", "opengl");
#endif // QT3D_USE_RHI
auto initialize_impl = [](pybind11::module & mod)
{
wrap_view(mod);
Expand Down

0 comments on commit 6a9888d

Please sign in to comment.