OpenGLCppWrapper is mainly made for Linux but it also works for OS X (while I can hardly test on it because I have to borrow a MacBook). OpenGLCppWrapper is yet working for Windows because I do not have windows to develop with.
Note: In this doc the -j8
with the make
command is the number of your CPU
cores. Please adapt this number to your case.
This project depends on:
- MyMakefile my GitHub Makefile
project used for compiling all my GitHub projects. It's automatically cloned
as a git submodule. You have nothing to do except not to forget to add the
option
--recurse-submodules
when you git clone the project. - OpenGLCppWrapper-data this repo contains all textures needed for examples. This repo is automatically downloaded the Makefile. You have nothing to do.
- SOIL this
library is used for loading picture files (jpeg, png ...). This library is
downloaded by the Makefile rule
download-external-libs
. - Dear IMgui this library is used for adding
widgets to your applications. This library is downloaded by the Makefile rule
download-external-libs
. - backward-cpp, this library is used
for displaying the stack when a crash occured. It is used on debug mode. This
library is downloaded by the Makefile rule
download-external-libs
. - glfw glew libraries for OpenGL.
sudo apt-get update && apt-get install libglew-dev libglfw3-dev libbz2-dev
brew install glfw glew
Optionally, if you want to help developing, want to write/launch unit tests, install googletest
wget https://github.com/google/googletest/archive/release-1.11.0.tar.gz
tar xf release-1.11.0.tar.gz
cd googletest-release-1.11.0
cmake .
sudo make install -j8
To download the project, its external libraries and compile the API with its examples:
git clone --recurse-submodules https://github.com/Lecrapouille/OpenGLCppWrapper.git --depth=1
cd OpenGLCppWrapper
make download-external-libs
make compile-external-libs
make -j8
If you are a developper make download-external-libs
and make compile-external-libs
has to be called once or when you want to upgrade the
libraries (they follow the master branch). These commands play the same role
than a recursive git clone: they will download, compile (but not install) GitHub
libraries: Backward, SOIL and Dear IMgui. You have to do it once (or for
updating). Why? I hate git submodules: it always make things painful. repo
with its manifests is a bit overkill, so I prefer Makefile rules or script
shell and this gave me good result with Travis-CI.
After make
a build/
folder shall have been created containing the compiled
and runnable files. Two libraries (one static the second dynamic) shall also be
present. You can use them for your project. You can type sudo make install
to
install them on your system.
If, after that, you want to modify code source, just do make
. You can type
make help
for displaying rules.
To compile API examples:
cd examples
make -j8
A build/
folder shall have been created containing the compiled and runnable
files. Run examples:
./build/OpenGLExamples
Will display the list of possible examples. Type ./build/OpenGLExamples 0
for
example for running the 1st example.
Multiple versions of this library can coexist thanks to their versioning number. After the compilation, just type:
cd OpenGLCppWrapper
sudo make install
This will install:
- in
/usr/lib
: the static and shared libraries libOpenGLCppWrapper. - in
/usr/include/openglcppwrapper-<version>
: all headers files (hpp). - in
/usr/lib/pkgconfig
: a pkg confile file for linking this API with your future projects. - in
/usr/share/OpenGLCppWrapper/<version>/
: documentation, examples and other files.
If you do not like the default location, Pass to Makefile options DESTDIR
,
PREFIX
and BINDIR
or directly edit the file .makefile/Makefile.header
(note: touching a makefile will force to recompile the whole project).
Check the presence of libraries in your system:
cd /usr/lib
ls -la libOpenGLCppWrapper*
Or better:
pkg-config openglcppwrapper --libs
Add the include in your cpp file: # include <OpenGLCppWrapper/OpenGLCppWrapper.hpp>
In debug mode, you can use the following macros:
-DCHECK_OPENGL
for checking bad parameters passed to OpenGL routines.-DENABLE_DEBUG
for activating console logs for debugging.
Compile using the pkg-config tool to add compilation flags to GCC or clang:
CFLAGS=
pkg-config openglcppwrapper --cflags``LDFLAGS=
pkg-config openglcppwrapper --libs``- Note: in pkg-config instead of
openglcppwrapper
which refers to the last installed version, you can specify your desired version (for example:openglcppwrapper-0.6
).
Example with a simple file main.cpp:
g++ -W -Wall --std=c++11 main.cpp -o prog `pkg-config openglcppwrapper --cflags --libs`
note: You may need indicate where are shared libraries. For example on Mac OS X:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/your/path/to/your/lib/folder
Example with Makefile given in here.
Documentation of the code source can be found here.
It can be localy generated as doc/html/index.html
by typing make doc
.
cd OpenGLCppWrapper/tests
make coverage
If all tests passed, a coverage report is created inside doc/coverage/
and the
index.html
is opened automatically.