libSDL2pp
0.16.1
C++11 bindings/wrapper for SDL2
|
This library provides C++11 bindings/wrapper for SDL2 and satellite libraries.
There's also more elaborate tutorial.
Currently, the library provides wrapper classes for
each with a subset of methods corresponding to SDL functions working with specific types of objects and, in some cases, additional convenience methods. These classes support:
Set of functional extensions above SDL2 is also available:
To build libSDL2pp, you need a compiler with C++11 support, for example clang 3.4+ or gcc 4.8+.
Dependencies:
To build standalone version:
cmake . && make
Following variables may be supplied to CMake to affect build:
SDL2PP_WITH_IMAGE
- enable SDL_image support (default ON)SDL2PP_WITH_MIXER
- enable SDL_mixer support (default ON)SDL2PP_WITH_TTF
- enable SDL_ttf support (default ON)SDL2PP_WITH_WERROR
- treat warnings as errors, useful for CI (default OFF)SDL2PP_CXXSTD
- override C++ standard (default C++11). With C++1y some additional features are enabled such as usage of [[deprecated]] attribute and using stock experimental/optional from C++ standard librarySDL2PP_WITH_EXAMPLES
- enable building example programs (only for standalone build, default ON)SDL2PP_WITH_TESTS
- enable building tests (only for standalone build, default ON)SDL2PP_STATIC
- build static library instead of shared (only for standalone build, default OFF)SDL2PP_ENABLE_LIVE_TESTS
- enable tests which require X11 and/or audio device to run (only for standalone build, default ON)To install the library system-wide, run:
cmake . && make && make install
You can change installation prefix with CMAKE_INSTALL_PREFIX cmake variable:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local . && make && make install
SDL2pp installs pkg-config file, so it can be used with any build system that interacts with pkg-config, including CMake and GNU Autotools. It also installs CMake module file, which can be used from CMake directly:
SDL2pp is also already available from the following package repositories:
The library is easy to integrate into other CMake projects (and as the library has no stable API yet, this way of using it is still recommended).
Just place the library into dedicated directory in your project (for example, extlib/libSDL2pp) and add
into your core CMakeLists.txt. This will act similar to how FIND_PACKAGE usually does, and will provide ${SDL2PP_INCLUDE_DIRS} and ${SDL2PP_LIBRARIES} variables for your project. You will then be able to use them as usual:
If bundled, libSDL2pp does not build examples and becomes a static library, providing required SDL2 includes/libs in the mentioned variables.
The library still doesn't cover all aspects of SDL2, and the development is generally guided by the author's needs and interest without a goal for covering all SDL2 functions as soon as possible. However, if you need specific bits which are not yet implemented in the library, feel free to drop an issue. Patches are of course more than welcome.
It should be noted, however, that I currently do not plan to implement any wrappers over non object-oriented SDL2 code, as these will not bring any benefits over using plain C API. E.g. I see no point in implementing SDL2pp::Delay() as it won't bring any convenience over SDL_Delay().
The same strongly applies to the SDL2 bits which duplicate C++11 standard library, e.g. threads and atomic ops.
Projects using libSDL2pp:
libSDL2pp comes under zlib license, the same license as SDL2. See COPYING.txt.