* Lower limit from API 21 to API 19 This was requested by an internal application. API 19 is when OpenGL ES 3.0 support was added so there is no good reason for us to not support this API level. The only trick is to avoid referring to the glTexStorage2DMultisample symbol directly as it only exists in 3.1. * Compile out code we never use * Use reflection to handle shared EGL contexts pre-API 21. * Remove comment * More fixes required to run on API level 19 - dlym() fails for ashmem on API 19, so we only try on API 26+ instead. - Older emulation for OpenGL ES 3.0 returns error states for valid API calls so we need to clear the GL error bit before we create the GL driver. - Activity lifecycle changes since API 19 would cause animations to keep running and to reference destroyed objects. - EGLContext.getNativeHandle() is new in API 21, we need to use reflection on API 19. The new code path uses the class loading trick to avoid a bytecode verification error on API 19. * Filament now runs properly on API level 19 This commit adds a new api_level() API to libutils which can be used to query the platform's API level. On Android it works as expected, other platforms currently return 0.
Filament sample Android apps
This directory contains several sample Android applications that demonstrate how to use the Filament APIs:
hello-triangle
Demonstrates how to setup a rendering surface for Filament:
lit-cube
Demonstrates how to create a light and a mesh with the attributes required for lighting:
image-based-lighting
Demonstrates how to create image-based lights and load complex meshes:
textured-object
Demonstrates how to load and use textures for complex materials:
transparent-rendering
Demonstrates how to render into a transparent SurfaceView:
texture-view
Demonstrates how to render into a TextureView instead of a SurfaceView:
material-builder
Demonstrates how to programatically generate Filament materials, as opposed to compiling them on the host machine:
gltf-bloom
Demonstrates how to load glTF models and render to an offscreen buffer:
Prerequisites
Before you start, make sure to read Filament's README. You need to be able to compile Filament's native library and Filament's AAR for this project. The easiest way to proceed is to install all the required dependencies and to run the following commands at the root of the source tree:
$ ./build.sh -p desktop -i release
$ ./build.sh -p android release
This will build all the native components and the AAR required by this sample application.
If you do not use the build script, you must set the filament_tools_dir property when invoking
Gradle, either from the command line or from local.properties. This property must point to the
distribution/install directory for desktop (produced by make/ninja install). This directory must
contain bin/matc and bin/cmgen.
Example:
$ ./gradlew -Pfilament_tools_dir=../../dist-release assembleDebug
Important: SDK location
Either ensure your ANDROID_HOME environment variable is set or make sure each project contains a
local.properties file with the sdk.dir property pointing to your installation of the Android
SDK. This includes the project filament-android in the parent directory.
Android Studio
You must use Android Studio 3.3 or higher to open these projects.
Compiling
To compile and run each sample make sure you have selected the appropriate build variant (arm7, arm8, x86 or x86_64). If you are not sure you can simply select the "universal" variant which includes all the other ones.






