/sdl2-cross

SDL2.0 cross platform Android/Desktop framework with OpenGL4/ES3

Primary LanguageC++

Swarming Logic cross-platform framework

SDL2, C++11, OpenGL 4.3, OpenGL ES 3, Android/Desktop Project.

A WIP project for game development currently supporting Android/Linux/Windows, with the intention to be easily extended to OSX, iOS.

This isn't a game engine (at least not in its current state), but serves as a good basis for doing cross-platform development. It has support for cross-platform compilation of a large collection of libraries (see below). Development is done on linux, with all tools developed with that in mind.

Implemented Features (summary):

  • Project initialization scripts for detecting required dependencies. screenshot
  • Utility for common development tasks (building android/linux, android logcat, unit testing, etc)
  • CxxTest based unit-testing (linux, windows and android)
  • Combined OpenGL/GLES files with #ifdef ES, #else, #endif directives.
  • Build system that supports many external libraries (bullet, flite, libnoise, polyvox, zmq, angelscript)
  • Script for generating html code coverage report.
  • Windows 64-bit cross-compilation using mingw-w64-x86-64
  • ZMQ + CZMQ for automatic service detection and networking

Future Features:

  • Deferred rendering
  • AngelScript based scripting language
  • Add external library SDL_net
  • emscriptem based HTML5 compilation

The framework relies on the following libraries

External Libraries (not included):

Library Version Description
SDL2 2.0.4 (0495816fec54) OpenGL glue, touch/gesture and keyboard input, and more
SDL_image 2.0.0 (2b0ada991468) png/jpg loading
SDL_mixer 2.0.0 (b28b41b93ba7) ogg loading, sound playback
SDL_ttf 2.0.12 (b773c1cd55a2) ttf loading
bullet 2.82-r2704 physics
GLM 0.9.5.2 math library similar to GLSL (headers only)
boost 1.55 boost (headers only)

External Libraries (included):

Library Version Description
flite 1.4 text to speech synthesization engine
libnoise 1.0.0 noise generation library
polyvox 0.2.1 voxel library
CxxTest 4.4 unit test code generation utility
angelscrip 2.29.2 scripting engine

External Libraries (script-download):

Library Version Description
ZeroMQ 4.1.0 Async network messaging library
CZMQ 3.0.0 Utility library built on top of ZeroMQ

Project Structure

├── android                    > Base android build files
│   ├── assets -> ../assets (symlink)
│   ├── jni
│   │   ├── bullet-android             { Android.mk for building bullet }
│   │   ├── bullet-src -> [Bullet Source]    (symlink)
│   │   ├── SDL ->        [SDL Source]       (symlink)
│   │   ├── SDL_image ->  [SDL_image Source] (symlink)
│   │   ├── SDL_mixer ->  [SDL_mixer Source] (symlink)
│   │   ├── SDL_ttf ->    [SDL_ttf Source]   (symlink)
│   │   └── src -> ../../src (symlink)
│   ├── res                        { Android specific assets }
│   └── src                        { JNI Java wrapper stuff }
├── assets                     { All resources used by the application }
│   ├── fonts
│   ├── images
│   ├── meshes
│   ├── music
│   ├── shaders
│   └── sounds
├── coveragehistory            { Unit test coverage history folder, used by gencoverage.sh}
├── external                   { External Libraries }
│   └── angelscript                { scripting library / engine }
│   └── flite                      { flite, TTS synthesis engine }
│   └── netlibs                    { networking libraries, e.g. zmq, czmq  }
│   └── noise                      { libnoise, noise generation library }
│   └── polyvox                    { polyvox, voxel library }
└── src                        { All code source files used by the application, excl. shaders }
│   ├── audio                      { Audio and music playback }
│   ├── core                       { Base that uses all other parts }
│   ├── extern                     { External libraries that might be moved to ../external }
│   ├── graphics                   { Graphics and OpenGL related}
│   ├── io                         { Input/Output, keyboard, mouse, gamecontroller, }
│   ├── math                       { Basic math classes }
│   ├── model                      { Physics and world related }
│   ├── net                        { Networking related }
│   └── util                       { Utility and helper classes }
└── utils                      { Misc utilities }
    ├── build_scripts               { Various files and scripts used related to building code }
    ├── cxxtest                     { Unit testing library, downloaded by initialize_project.sh}
    ├── patches                     { Patches used by initialize_project.sh}
    ├── scripts                     { Various minor helper scripts, some downloaded by initialize_project.sh}
    └── standalones            { Various standalone utilities }
        ├── obj2cobj                { Utility for compressing Wavefront OBJ files}
        ├── obj2info                { Utility for printing Wabefront OBJ data summary}
        ├── simpletextpreprocess    { Utility for preprocessing GL/GLES shader files}
        └── wordgen                 { Markov chain random text generator }

Dependency tree

To enforce decoupling, and quicker build times, the source is structured into modules, compiled as shared libraries. This currently only applies to the desktop linux.

Libraries within [] are static.

    +––––––––––––––––––––––––––––––––––––––––––––––––––––––+
    |                  Common libraries                    |
    |                                                      |
    |    +––––––––––––+      +––––––––––––+                |
    |    |    math    |      |   extern   |                |
    |    |            |      |            |                |
    |    |            |      |            |                |
    |    +–––––+––––––+      +––––––+–––––+                |
    |           \                  /                       |
    |            \______   _______/                        |
    |                   \ /                                |
    |            +–––––––+–––––––+                         |
    |            |     util      |                         |
    |            |               |                         |
    |            | SDL, [noise]  |                         |
    |            | [angelscript] |                         |
    |            +–––––––––––––––+                         |
    |                                                      |
    |                                                      |
    +–––––––––––––––––––––––––+––––––––––––––––––––––––––––+
                              |
    +–––––––––––––––––––––––––+––––––––––––––––––––––––––––+
    |                   System libaries                    |
    |                                                      |
    |   +––––––––––––––––+  +–––––––––––––––––––––+        |
    |   |     audio      |  |     graphics        |        |
    |   |                |  |                     |        |
    |   | SDL, SDL_Mixer |  | SDL_image, SDL_ttf  |        |
    |   | [flite]        |  | SDL, OpenGL         |        |
    |   +––––––––––––––––+  +–––––––––––––––––––––+        |
    |                                                      |
    |   +––––––––––––––––+  +–––––––––+  +–––––––––––––+   |
    |   |      model     |  |    io   |  |     net     |   |
    |   |                |  |         |  |             |   |
    |   | SDL, bullet    |  | SDL     |  | [zmq, czmq] |   |
    |   | [polyvox]      |  +–––––––––+  +–––––––––––––+   |
    |   +––––––––––––––––+                                 |
    |                                                      |
    +–––––––––––––––––––––––––+––––––––––––––––––––––––––––+
                              |
    +–––––––––––––––––––––––––+––––––––––––––––––––––––––––+
    |                                                      |
    |             +–––––––––––––––––––––––+                |
    |             |         core          |                |
    |             |                       |                |
    |             |    all of the above   |                |
    |             +–––––––––––––––––––––––+                |
    |                         |                            |
    |                    src/main.cpp                      |
    |                                                      |
    +––––––––––––––––––––––––––––––––––––––––––––––––––––––+

Special Files

  • Special files:
File Description
./devtools.sh Utility for simplifying development commands
./src/util/gitrev.h Automatically generated file for accessing current git id

Building & running

  • Configuring dependencies and patching files, etc : Run . ./devtools.sh init Note that it is . ./devtools.sh init and not ./devtools.sh init

If everything passes, you are good to go. Otherwise, follow instructions.

  • See ./devtools.sh help for all development related commands.

Suggested .gitignore content

common_build.pyc
bin/
build/
lib/
android/bin/
android/gen/
android/libs/
android/obj/
android/project.properties
android/local.properties
android/jni/SDL_image
android/jni/SDL_mixer
android/jni/SDL_ttf
android/jni/SDL
android/jni/bullet-src
android/jni/flite
android/jni/noise
android/jni/polyvox
android/jni/angelscript
android/jni/netlibs
external/angelscript/add_on/
external/angelscript/include/
external/angelscript/source/
external/netlibs/zeromq-4.1.0
external/netlibs/czmq-3.0.0
src/util/gitrev.h
html/
utils/cxxtest
utils/scripts/watchfile
utils/scripts/glslangValidator
coveragehistory/
src/main_android_tests.cpp
.coverage*
runtime.log

Preferences/Settings File Format

The internal format for user preferences follows Boost.PropertyTree's INFO-format.

This is a more versatile format than the typical INI format.

For emacs users, a major mode can be found here