This is basic OpenGL based demo application.
This demo application was originally developed in C, around 1999 with OpenGL 1.1 and targed Windows systems.
I have recoded it as a means to keep myself updated with the C++11/C++14 changes and how to use to target Android systems with NDK and Open GL ES 2.0.
The graphics were kept as simple as the original one, because the main goal was to learn the said technologies and not to write a game engine.
This code requires the following libraries:
- GLM (a C++ math library)
- SDL (a C portable library for multimedia applications)
- GLEW (OpenGL extensions loader, only required on Windows systems)
For building TownGL on Windows, a few steps are required:
- Download the binary relase of SDL for Windows from http://www.libsdl.org/
- Copy the SDL binaries into libs location
- Download GLM from http://glm.g-truc.net
- Copy the GLM source code into libs location
- Download the binary relase of GLEW for Windows from http://glew.sourceforge.net/
- Copy the GLEW binaries into libs location
Note: I only tested with 32bit binaries so far. In principle 64bit should work as well, but it hasn't been tested.
- Open the Visual Studio 2013 project file
- Build the solution
For building TownGL with the NDK, a few steps are required:
- Download SDL from http://www.libsdl.org/
- Expand the package contents
- Copy the full SDL source code into app/jni location
- Copy the Java code from android-project/src into app/src/main/java
- Download GLM from http://glm.g-truc.net
- Copy GLM source code into app/jni location
- Make sure ndk-build is on the PATH
- gradlew assembleDebug
- Start Android Studio;
- Use import existing project for adding the project into the workspace;
- Verify that you have a valid path for the NDK at File->Project Structure->Android NDK location settings panel;
- Build the project
- Finally deploy it either to the emulator or plugged device
Since the demo makes use of OpenGL ES, it will only work in the emulator if the requirements are fullfiled:
- HAXM is installed
- The emulator is configured with an Intel CPU
- The image has graphics accelaration via host GPU enabled
This code is under the GPL v2 license.