I've built the opencv with cmake -DWITH_OPENGL=ON ..
, but the output of the cmake tell me the OpenGL supported is NO.
And I've checked the cmake cache to assure the WITH_OPENGL
is ON
.
The GUI used is GTK+ 3.0, and the libgtkglext1-dev is installed.
After reading the cmake script cmake/OpenCVFindLibsGUI.cmake
, I've found the related cmake codes:
# --- GTK ---
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
# ...
if(WITH_OPENGL AND NOT HAVE_GTK3)
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT) # MARK1
endif()
endif()
# --- OpenGl ---
ocv_clear_vars(HAVE_OPENGL HAVE_QT_OPENGL)
if(WITH_OPENGL)
if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTKGLEXT) # MARK2
find_package (OpenGL QUIET)
# ...
endif ()
endif(WITH_OPENGL)
For I use the GTK+ 3.0, so the statement marked with MARK1
will not be executed, then the condition marked with MARK2
will be false. So the OpenGL package will not be loaded.
I've also tried to force to call CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
even when HAVE_GTK3
is true, but I found compiling compiling error at last.
So I update my building command as below
cmake -DWITH_OPENGL=ON -DWITH_GTK_2_X=ON ..
With WITH_GTK_2_X
to be set on, the gtk2 is force to be used instead of gtk3.