I already had QT 5.5.1 with GCC 4.7.3 (and probably some libraries, including libcurl4-gnutls-dev, libgdal-dev, glut, that are installed, but not built) on my machine, so I built OSG with the following commands (I am not sure that it makes a sense to clone recursively, but making with ‘CMAKE_BUILD_TYPE=Debug’ can be better than with ‘debug’ or ‘DEBUG’, because CMAKE does case-sensitive compare. Also I am not sure What version of OpenSceneGraph I should build OsgEarth with.):
cd ~ mkdir examples cd examples mkdir install git clone --recursive https://github.com/openscenegraph/OpenSceneGraph.git git tag git reset --hard OpenSceneGraph-3.5.6 mkdir -p build/osg cd build/osg cmake ../../OpenSceneGraph/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install make -j3 install export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dmitry/examples/install/lib64 ~/examples/install/bin ./osgversiond
The last command shows OSG version, that is 3.5.6. Then I easily built OsgEarth with the similar steps:
cd ~/examples git clone --recursive https://github.com/gwaldron/osgearth.git git tag git reset --hard osgearth-2.8 cd build mkdir osgearth cd osgearth cmake ../../osgearth/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install make -j3 make install
After that I built my application:
export PKG_CONFIG_PATH=/home/dmitry/examples/install/lib64/pkgconfig:$PKG_CONFIG_PATH cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/build
There are also the following environment variables in my ~./bashrc
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/opt/lib/pkgconfig:$HOME/lib_build/qwt/lib/pkgconfig:/home/user/opt/lib64/pkgconfig export LD_LIBRARY_PATH=$HOME/opt/lib/x86_64-linux-gnu:$HOME/lib_build/qwt/lib:$HOME/build/lib:$LD_LIBRARY_PATH:/home/user/opt/lib64/
It is interesting that the total size of the source code (*.h, *.cpp) in OSG and OsgEarth is 18981452 + 23346192 = 42327644 bytes = 40.366 MB. Before in some project we used OpenSceneGraph-3.3.9 with osgearth-2.7.
Other useful GIT commands for working with tags:
git describe --tags git reset --hard origin/master
Starting the sample with grid on the Earth:
There are some options to compile OSG with different versions of OpenGL in the CMakeFileLists.txt, for example there is a variable that defines whether OSG uses OpenGL display lists or not:
SET(OPENGL_PROFILE "GL2" CACHE STRING "OpenGL Profile to use, choose from GL1, GL2, GL3, GLES1, GLES2, GLES3") ... IF (OSG_GLES2_AVAILABLE OR OSG_GLES3_AVAILABLE OR OSG_GL3_AVAILABLE) OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." OFF) ...
I successfully tried to enable OpenGL3 with the following CMake parameters (by default, GL2 is set):
cmake ../../OpenSceneGraph/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install -DOPENGL_PROFILE=GL3 grep -ri OPENGL_PROFILE
It generates include file ‘/home/dmitry/examples/build/osg/include/osg/GL’ with the following content:
... #define OSG_GL3_AVAILABLE ... #include <GL3/gl3.h> ...
But, probably, on Ubuntu, for example, GL3/gl3.h should be replaced with GL/gl.h.