Thursday, June 18, 2009

qt opengl





A thread suggested that for Re: [CMake] cmake link against Qt4's OpenGL


PROJECT ( COMBINED )
FIND_PACKAGE (Qt4 REQUIRED)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE( ${QT_USE_FILE} )
ADD_EXECUTABLE(exe main.cpp glwidget.cpp window.cpp)
TARGET_LINK_LIBRARIES(exe ${QT_LIBRARIES})


What I found for Marsyas linking a Qt application that uses OpenGL, I first had to add the following lines to marsyas-detect.cmake:


if (WITH_OPENGL)
find_package(OpenGL REQUIRED)
set (MARSYAS_OPENGL 1)
SET(QT_USE_QTOPENGL TRUE)
endif (WITH_OPENGL)


With the important line being


SET(QT_USE_QTOPENGL TRUE)


To get the OpenGL header files to be included I also added the following lines to the CMakeLists.txt file in the directory of the application I was working on:


INCLUDE_DIRECTORIES(${QT_QTOPENGL_INCLUDE_DIR})


Very simple, but really hard to find out how to do.