* 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.
103 lines
2.4 KiB
Groovy
103 lines
2.4 KiB
Groovy
apply plugin: 'com.android.application'
|
|
apply plugin: 'kotlin-android'
|
|
apply plugin: 'kotlin-android-extensions'
|
|
|
|
apply from: '../../../build/filament-tasks.gradle'
|
|
|
|
compileMaterials {
|
|
group 'Filament'
|
|
description 'Compile materials'
|
|
|
|
inputDir = file("src/main/materials")
|
|
outputDir = file("src/main/assets/materials")
|
|
}
|
|
|
|
compileMesh {
|
|
group 'Filament'
|
|
description 'Compile mesh'
|
|
|
|
inputFile = file("../../../../third_party/models/shader_ball/shader_ball.obj")
|
|
outputDir = file("src/main/assets/models")
|
|
}
|
|
|
|
generateIbl {
|
|
group 'Filament'
|
|
description 'Generate IBL'
|
|
|
|
inputFile = file("../../../../third_party/environments/flower_road_no_sun_2k.hdr")
|
|
outputDir = file("src/main/assets/envs")
|
|
}
|
|
|
|
preBuild.dependsOn compileMaterials
|
|
preBuild.dependsOn compileMesh
|
|
preBuild.dependsOn generateIbl
|
|
|
|
clean.doFirst {
|
|
delete "src/main/assets"
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion 29
|
|
defaultConfig {
|
|
applicationId "com.google.android.filament.ibl"
|
|
minSdkVersion 19
|
|
targetSdkVersion 29
|
|
versionCode 1
|
|
versionName "1.0"
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
// Filament comes with native code, the following declarations
|
|
// can be used to generate architecture specific APKs
|
|
flavorDimensions 'cpuArch'
|
|
productFlavors {
|
|
arm8 {
|
|
dimension 'cpuArch'
|
|
ndk {
|
|
abiFilters 'arm64-v8a'
|
|
}
|
|
}
|
|
arm7 {
|
|
dimension 'cpuArch'
|
|
ndk {
|
|
abiFilters 'armeabi-v7a'
|
|
}
|
|
}
|
|
x86_64 {
|
|
dimension 'cpuArch'
|
|
ndk {
|
|
abiFilters 'x86_64'
|
|
}
|
|
}
|
|
x86 {
|
|
dimension 'cpuArch'
|
|
ndk {
|
|
abiFilters 'x86'
|
|
}
|
|
}
|
|
universal {
|
|
dimension 'cpuArch'
|
|
}
|
|
}
|
|
|
|
// We use the .filamat extension for materials compiled with matc
|
|
// Telling aapt to not compress them allows to load them efficiently
|
|
aaptOptions {
|
|
noCompress 'filamat'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
|
|
// Depend on Filament
|
|
implementation 'com.google.android.filament:filament-android'
|
|
}
|