diff --git a/BUILD.md b/BUILD.md index cd6afe19..69870638 100644 --- a/BUILD.md +++ b/BUILD.md @@ -26,7 +26,7 @@ Note that you need [assimp](https://github.com/assimp/assimp) in order to compil ## [Android](android/) -Building on Android is done using the [Android NDK](http://developer.android.com/tools/sdk/ndk/index.html) and requires a device that supports Vulkan. Please see the [Android readme](./android/README.md) on how to build and deploy the examples. +Building on Android is done using [Android Studio](https://developer.android.com/studio/) (Google's own and free Android IDE) and requires a device that supports Vulkan. Please see the [Android readme](./android/README.md) for details on how to build and run the samples. ## [iOS and macOS](xcode/) diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 00000000..8db79c32 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,68 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +**/assets/ +**/src/main/res/drawable/ \ No newline at end of file diff --git a/android/README.md b/android/README.md index 7463ec2b..a9eb997d 100644 --- a/android/README.md +++ b/android/README.md @@ -1,88 +1,37 @@ -# Vulkan examples on Android - -## Vulkan on Android - -Since Vulkan is not yet part of the Android OS (like OpenGL ES) the library and function pointers need to be dynamically loaded before using any of the Vulkan functions. See the **vulkanandroid.h** and **vulkanandroid.cpp** files in the base folder of the repositoy root for how this is done. +# Vulkan examples on Android ## Device support - **To run these examples you need a device with an Android image that suports Vulkan** -- Builds currently only support arm-v7, x86 may follow at a later point -- Android TV leanback launcher is supported, so the examples will show up on the launcher +- Builds currently only support arm-v7, other architectures may be added later - Basic gamepad support is available too (zoom and rotate) - Basic touch control support (zoom, move, rotate, look) ## Building ### Requirements -- [Android NDK r11b](http://developer.android.com/ndk/downloads/index.html) (or newer) - Somewhere in your search path -- Examples are built against API level 23 (requires the SDK Platform installed) -- Python 3.x + +- [Android Studio](https://developer.android.com/studio/) +- [Android NDK](https://developer.android.com/ndk/downloads/) (r11b or higher) +- [Android SDK](https://developer.android.com/studio/index.html) + +### Update the asset pack + +During the Android build process, assets are copied over from the data folder, so it's important to make sure that a current version of the [asset pack](../data/README.md) has been downloaded and extracted. ### Building the Examples -### Grab Externals +Select **Import project** from the welcome screen (or from inside Android via **File->New**): -Make sure all submodules have been cloned using the [steps from main README](../README.md#cloning). + -### Complete set +Navigate to the **android** subfolder of this repository (should be higlighted with a gadle symbol): -**Please note that building (and deploying) all examples may take a while** + -#### Build only +Select OK to start the import. -``` -build-all.py -``` +**Note:** Initial import will take a while due to the number of examples. -This will build all apks and puts them into the **bin** folder. +Once the import is done, the samples can be build, debugged and run from inside Android Studio just like any other Android project. -#### Build and deploy - -``` -build-all.py -deploy -``` - -This will build all apks and deploys them to the currently attached android device. - -### Single examples - -These are for building and/or deploying a single example. - -#### Build only - -Call build(.bat) with the name of the example to build, e.g. : - -``` -build.py pbrtexture -``` - -This will build the apk for the triangle example and puts it into the **bin** folder. - -#### Build and deploy - -``` -build.py pbrtexture -deploy -``` - -This will build the apk for the triangle example and deploys it to the currently attached android device. - -#### Validation layers - -``` -build.py pbrtexture -validation (-deploy) -``` - -Builds the apk, adds the validation layer libraries and enables validation via a compiler define. - -**Note**: You need to manually build the validation layers and put them in the [proper folder](layers/). If the libaries are not present they won't be included with the apk and running the app will fail. - -## Removing - -A single file for removing all installed examples is provided in case you installed all of them and don't want to remove them by hand (which is especially tedious on Android TV). - - -``` -uninstall-all.py -``` - -This will remove any installed Android example from this repository from the attached device. +**Note:** If you update the repository at a later point you may have to resync to have additional examples added to the Android Studio project (**File->Sync Project with Gradle files**). diff --git a/android/androidstudio01.jpg b/android/androidstudio01.jpg new file mode 100644 index 00000000..85ab4b84 Binary files /dev/null and b/android/androidstudio01.jpg differ diff --git a/android/androidstudio02.jpg b/android/androidstudio02.jpg new file mode 100644 index 00000000..fe0b4e80 Binary files /dev/null and b/android/androidstudio02.jpg differ diff --git a/android/bloom/.gitignore b/android/bloom/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/bloom/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/bloom/AndroidManifest.xml b/android/bloom/AndroidManifest.xml deleted file mode 100644 index 880dd91f..00000000 --- a/android/bloom/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/bloom/example.json b/android/bloom/example.json deleted file mode 100644 index e8bc7770..00000000 --- a/android/bloom/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanBloom", - "directories": { - "shaders": "bloom" - }, - "assets": { - "models": [ - "retroufo.dae", - "retroufo_glow.dae", - "cube.obj" - ], - "textures": [ - "cubemap_space.ktx" - ] - } -} \ No newline at end of file diff --git a/android/build-all.py b/android/build-all.py deleted file mode 100755 index d4785215..00000000 --- a/android/build-all.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import subprocess -import sys - -import build - -EXAMPLES = [ - "bloom", - "computecullandlod", - "computecloth", - "computeheadless", - "computenbody", - "computeparticles", - "computeshader", - "debugmarker", - "deferred", - "deferredmultisampling", - "deferredshadows", - "displacement", - "distancefieldfonts", - "dynamicuniformbuffer", - "gears", - "geometryshader", - "hdr", - "imgui", - "indirectdraw", - "instancing", - "mesh", - "multisampling", - "multithreading", - "occlusionquery", - "offscreen", - "parallaxmapping", - "particlefire", - "pbrbasic", - "pbribl", - "pbrtexture", - "pipelines", - "pipelinestatistics", - "pushconstants", - "radialblur", - "raytracing", - "renderheadless", - "ssao", - "scenerendering", - "shadowmapping", - "shadowmappingcascade", - "shadowmappingomni", - "skeletalanimation", - "specializationconstants", - "sphericalenvmapping", - "stencilbuffer", - "subpasses", - "terraintessellation", - "tessellation", - "textoverlay", - "texture", - "texture3d", - "texturearray", - "texturecubemap", - "texturemipmapgen", - "triangle", - "viewportarray", - "vulkanscene" -] - -COLOR_GREEN = '\033[92m' -COLOR_END = '\033[0m' - -CURR_INDEX = 0 - -parser = argparse.ArgumentParser() -parser.add_argument('-deploy', default=False, action='store_true', help="install examples on device") -parser.add_argument('-validation', default=False, action='store_true') -args = parser.parse_args() - -print("Building all examples...") - -for example in EXAMPLES: - print(COLOR_GREEN + "Building %s (%d/%d)" % (example, CURR_INDEX, len(EXAMPLES)) + COLOR_END) - if not build.main(example, args.deploy, args.validation): - print("Error during build process for %s" % example) - sys.exit(-1) - CURR_INDEX += 1 - -print("Successfully build %d examples" % CURR_INDEX) diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 00000000..76d0d98b --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.1.1' + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} \ No newline at end of file diff --git a/android/build.py b/android/build.py deleted file mode 100755 index 555dd379..00000000 --- a/android/build.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys -import shutil -import glob -import json -import argparse - -def main(project_folder, deploy=False, validation=False): - - # Android SDK version used - SDK_VERSION = "android-23" - - # Check if python 3, python 2 not supported - if sys.version_info <= (3, 0): - print("Sorry, requires Python 3.x, not Python 2.x") - return False - - # Definitions (apk name, folders, etc.) will be taken from a json definition - if not os.path.isfile(os.path.join(project_folder, "example.json")): - print("Could not find json definition for example %s" % project_folder) - return False - - # Check if a build file is present, if not create one using the android SDK version specified - if not os.path.isfile(os.path.join(project_folder, "build.xml")): - print("Build.xml not present, generating with %s " % SDK_VERSION) - ANDROID_CMD = "android" - if os.name == 'nt': - ANDROID_CMD += ".bat" - if subprocess.call(("%s update project -p ./%s -t %s" % (ANDROID_CMD, project_folder, SDK_VERSION)).split(' ')) != 0: - print("Error: Project update failed!") - return False - - # Load example definition from json file - with open(os.path.join(project_folder, "example.json")) as json_file: - EXAMPLE_JSON = json.load(json_file) - - APK_NAME = EXAMPLE_JSON["apkname"] - SHADER_DIR = EXAMPLE_JSON["directories"]["shaders"] - - # Additional - ADDITIONAL_DIRS = [] - ADDITIONAL_FILES = [] - if "assets" in EXAMPLE_JSON and "additional" in EXAMPLE_JSON["assets"]: - ADDITIONAL = EXAMPLE_JSON["assets"]["additional"] - if "directories" in ADDITIONAL: - ADDITIONAL_DIRS = ADDITIONAL["directories"] - if "files" in ADDITIONAL: - ADDITIONAL_FILES = ADDITIONAL["files"] - - # Get assets to be copied - ASSETS_MODELS = [] - ASSETS_TEXTURES = [] - if "assets" in EXAMPLE_JSON: - ASSETS = EXAMPLE_JSON["assets"] - if "models" in ASSETS: - ASSETS_MODELS = EXAMPLE_JSON["assets"]["models"] - if "textures" in ASSETS: - ASSETS_TEXTURES = EXAMPLE_JSON["assets"]["textures"] - - # Enable validation - BUILD_ARGS = "" - - if validation: - # Use a define to force validation in code - BUILD_ARGS = "APP_CFLAGS=-D_VALIDATION" - - # Verify submodules are loaded in external folder - if not os.listdir("../external/glm/") or not os.listdir("../external/gli/"): - print("External submodules not loaded. Clone them using:") - print("\tgit submodule init\n\tgit submodule update") - return False - - # Build - old_cwd = os.getcwd() - os.chdir(project_folder) - - # Create android build files from templates - os.makedirs("./jni", exist_ok=True) - shutil.copy("./../templates/Application.mk", "./jni/") - with open("./../templates/Android.mk", "rt") as fin: - with open("./jni/Android.mk", "wt") as fout: - for line in fin: - fout.write(line.replace("%APK_NAME%", "%s" % APK_NAME).replace("%SRC_FOLDER%", "%s" % project_folder)) - - if subprocess.call("ndk-build %s" %BUILD_ARGS, shell=True) == 0: - print("Build successful") - - if validation: - # Copy validation layers - # todo: Currently only arm v7 - print("Validation enabled, copying validation layers...") - os.makedirs("./libs/armeabi-v7a", exist_ok=True) - for file in glob.glob("../layers/armeabi-v7a/*.so"): - print("\t" + file) - shutil.copy(file, "./libs/armeabi-v7a") - - # Create folders - os.makedirs("./assets/shaders/base", exist_ok=True) - os.makedirs("./assets/shaders/%s" % SHADER_DIR, exist_ok=True) - os.makedirs("./assets/models", exist_ok=True) - os.makedirs("./assets/textures", exist_ok=True) - for directory in ADDITIONAL_DIRS: - os.makedirs("./assets/%s" % directory, exist_ok=True) - os.makedirs("./res/drawable", exist_ok=True) - - # Copy assets - for filename in glob.glob("../../data/shaders/base/*.spv"): - shutil.copy(filename, "./assets/shaders/base") - for filename in glob.glob("../../data/shaders/%s/*.spv" % SHADER_DIR): - shutil.copy(filename, "./assets/shaders/%s" % SHADER_DIR) - for filename in ASSETS_MODELS: - shutil.copy("../../data/models/%s" % filename, "./assets/models") - for filename in ASSETS_TEXTURES: - shutil.copy("../../data/textures/%s" % filename, "./assets/textures") - for filename in ADDITIONAL_FILES: - if "*." in filename: - for fname in glob.glob("../../data/%s" % filename): - locfname = fname.replace("../../data/", "") - shutil.copy(fname, "./assets/%s" % locfname) - else: - shutil.copy("../../data/%s" % filename, "./assets/%s" % filename) - - shutil.copy("../../android/images/icon.png", "./res/drawable") - - if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0: - if deploy and subprocess.call("adb install -r %s.apk" % APK_NAME, shell=True) != 0: - print("Could not deploy to device!") - else: - print("Error during build process!") - return False - else: - print("Error building project!") - return False - - # Copy apk to bin folder - os.makedirs("../bin", exist_ok=True) - shutil.move('%s.apk' % APK_NAME, "../bin/%s.apk" % APK_NAME) - os.chdir(old_cwd) - return True - -class ReadableDir(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - if not os.path.isdir(values): - raise argparse.ArgumentTypeError("{0} is not a valid path".format(values)) - if not os.access(values, os.R_OK): - raise argparse.ArgumentTypeError("{0} is not a readable dir".format(values)) - setattr(namespace, self.dest,values) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Build and deploy a single example") - parser.add_argument('-deploy', default=False, action='store_true', help="install example on device") - parser.add_argument('-validation', default=False, action='store_true') - parser.add_argument('project_folder', action=ReadableDir) - try: - args = parser.parse_args() - except SystemExit: - sys.exit(1) - ok = main(args.project_folder, args.deploy, args.validation) - sys.exit(0 if ok else 1) diff --git a/android/cleanup.bat b/android/cleanup.bat deleted file mode 100644 index 909a2a2a..00000000 --- a/android/cleanup.bat +++ /dev/null @@ -1,10 +0,0 @@ -FOR /d /r . %%x IN (assets) DO @IF EXIST "%%x" rd /s /q "%%x" -FOR /d /r . %%x IN (bin) DO @IF EXIST "%%x" rd /s /q "%%x" -FOR /d /r . %%x IN (libs) DO @IF EXIST "%%x" rd /s /q "%%x" -FOR /d /r . %%x IN (obj) DO @IF EXIST "%%x" rd /s /q "%%x" -FOR /d /r . %%x IN (res) DO @IF EXIST "%%x" rd /s /q "%%x" -FOR /d /r . %%x IN (jni) DO @IF EXIST "%%x" rd /s /q "%%x" -del /s build.xml -del /s local.properties -del /s proguard-project.txt -del /s project.properties \ No newline at end of file diff --git a/android/images/icon.png b/android/common/res/drawable/icon.png similarity index 100% rename from android/images/icon.png rename to android/common/res/drawable/icon.png diff --git a/android/computecloth/.gitignore b/android/computecloth/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computecloth/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computecloth/AndroidManifest.xml b/android/computecloth/AndroidManifest.xml deleted file mode 100644 index 86dc355d..00000000 --- a/android/computecloth/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computecloth/example.json b/android/computecloth/example.json deleted file mode 100644 index 6fe3e02e..00000000 --- a/android/computecloth/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanComputecloth", - "directories": { - "shaders": "computecloth" - }, - "assets": { - "models": [ - "geosphere.obj" - ], - "textures": [ - "vulkan_cloth_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/computecullandlod/.gitignore b/android/computecullandlod/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computecullandlod/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computecullandlod/AndroidManifest.xml b/android/computecullandlod/AndroidManifest.xml deleted file mode 100644 index ccc68ea3..00000000 --- a/android/computecullandlod/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computecullandlod/example.json b/android/computecullandlod/example.json deleted file mode 100644 index d79c5596..00000000 --- a/android/computecullandlod/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanComputecullandlod", - "directories": { - "shaders": "computecullandlod" - }, - "assets": { - "models": [ - "suzanne_lods.dae" - ] - } -} \ No newline at end of file diff --git a/android/computeheadless/.gitignore b/android/computeheadless/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computeheadless/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computeheadless/AndroidManifest.xml b/android/computeheadless/AndroidManifest.xml deleted file mode 100644 index eedf7502..00000000 --- a/android/computeheadless/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computeheadless/example.json b/android/computeheadless/example.json deleted file mode 100644 index d1ac654e..00000000 --- a/android/computeheadless/example.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "apkname": "vulkanComputeheadless", - "directories": { - "shaders": "computeheadless" - }, - "assets": { - } -} \ No newline at end of file diff --git a/android/computenbody/.gitignore b/android/computenbody/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computenbody/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computenbody/AndroidManifest.xml b/android/computenbody/AndroidManifest.xml deleted file mode 100644 index a316e781..00000000 --- a/android/computenbody/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computenbody/example.json b/android/computenbody/example.json deleted file mode 100644 index 56e31f4b..00000000 --- a/android/computenbody/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "apkname": "vulkanComputenbody", - "directories": { - "shaders": "computenbody" - }, - "assets": { - "textures": [ - "particle01_rgba.ktx", - "particle_gradient_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/computeparticles/.gitignore b/android/computeparticles/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computeparticles/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computeparticles/AndroidManifest.xml b/android/computeparticles/AndroidManifest.xml deleted file mode 100644 index 291bb1ad..00000000 --- a/android/computeparticles/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computeparticles/example.json b/android/computeparticles/example.json deleted file mode 100644 index b1ebea49..00000000 --- a/android/computeparticles/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "apkname": "vulkanComputeparticles", - "directories": { - "shaders": "computeparticles" - }, - "assets": { - "textures": [ - "particle01_rgba.ktx", - "particle_gradient_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/computeshader/.gitignore b/android/computeshader/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/computeshader/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/computeshader/AndroidManifest.xml b/android/computeshader/AndroidManifest.xml deleted file mode 100644 index d04ca488..00000000 --- a/android/computeshader/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/computeshader/example.json b/android/computeshader/example.json deleted file mode 100644 index 66a29fe2..00000000 --- a/android/computeshader/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanComputeshader", - "directories": { - "shaders": "computeshader" - }, - "assets": { - "textures": [ - "vulkan_11_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/debugmarker/.gitignore b/android/debugmarker/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/debugmarker/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/debugmarker/AndroidManifest.xml b/android/debugmarker/AndroidManifest.xml deleted file mode 100644 index 65c11486..00000000 --- a/android/debugmarker/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/debugmarker/example.json b/android/debugmarker/example.json deleted file mode 100644 index 09b9df1c..00000000 --- a/android/debugmarker/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "apkname": "vulkanDebugmarker", - "directories": { - "shaders": "debugmarker" - }, - "assets": { - "models": [ - "treasure_smooth.dae", - "treasure_glow.dae" - ] - } -} \ No newline at end of file diff --git a/android/deferred/.gitignore b/android/deferred/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/deferred/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/deferred/AndroidManifest.xml b/android/deferred/AndroidManifest.xml deleted file mode 100644 index d40f2a3d..00000000 --- a/android/deferred/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/deferred/example.json b/android/deferred/example.json deleted file mode 100644 index f7b80757..00000000 --- a/android/deferred/example.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "apkname": "vulkanDeferred", - "directories": { - "shaders": "deferred" - }, - "assets": { - "models": [ - "plane.obj" - ], - "textures": [ - "stonefloor01_color_astc_8x8_unorm.ktx", - "stonefloor01_color_bc3_unorm.ktx", - "stonefloor01_normal_astc_8x8_unorm.ktx", - "stonefloor01_normal_bc3_unorm.ktx", - "stonefloor01_color_etc2_unorm.ktx", - "stonefloor01_normal_etc2_unorm.ktx" - ], - "additional" : { - "directories": ["models/armor"], - "files": [ - "models/armor/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/deferredmultisampling/.gitignore b/android/deferredmultisampling/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/deferredmultisampling/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/deferredmultisampling/AndroidManifest.xml b/android/deferredmultisampling/AndroidManifest.xml deleted file mode 100644 index 64906144..00000000 --- a/android/deferredmultisampling/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/deferredmultisampling/example.json b/android/deferredmultisampling/example.json deleted file mode 100644 index 7ce1dc65..00000000 --- a/android/deferredmultisampling/example.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "apkname": "vulkanDeferredmulitsampling", - "directories": { - "shaders": "deferredmultisampling" - }, - "assets": { - "models": [ - "openbox.dae" - ], - "textures": [ - "stonefloor02_color_astc_8x8_unorm.ktx", - "stonefloor02_color_bc3_unorm.ktx", - "stonefloor02_normal_astc_8x8_unorm.ktx", - "stonefloor02_normal_bc3_unorm.ktx", - "stonefloor02_color_etc2_unorm.ktx", - "stonefloor02_normal_etc2_unorm.ktx" - ], - "additional" : { - "directories": ["models/armor"], - "files": [ - "models/armor/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/deferredshadows/.gitignore b/android/deferredshadows/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/deferredshadows/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/deferredshadows/AndroidManifest.xml b/android/deferredshadows/AndroidManifest.xml deleted file mode 100644 index 7bead55f..00000000 --- a/android/deferredshadows/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/deferredshadows/example.json b/android/deferredshadows/example.json deleted file mode 100644 index 64fda99a..00000000 --- a/android/deferredshadows/example.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "apkname": "vulkanDeferredshadows", - "directories": { - "shaders": "deferredshadows" - }, - "assets": { - "models": [ - "openbox.dae" - ], - "textures": [ - "stonefloor02_color_astc_8x8_unorm.ktx", - "stonefloor02_color_bc3_unorm.ktx", - "stonefloor02_normal_astc_8x8_unorm.ktx", - "stonefloor02_normal_bc3_unorm.ktx", - "stonefloor02_color_etc2_unorm.ktx", - "stonefloor02_normal_etc2_unorm.ktx" - ], - "additional" : { - "directories": ["models/armor"], - "files": [ - "models/armor/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/descriptorsets/.gitignore b/android/descriptorsets/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/descriptorsets/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/descriptorsets/AndroidManifest.xml b/android/descriptorsets/AndroidManifest.xml deleted file mode 100644 index 985a732d..00000000 --- a/android/descriptorsets/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/descriptorsets/example.json b/android/descriptorsets/example.json deleted file mode 100644 index 6172a259..00000000 --- a/android/descriptorsets/example.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "apkname": "vulkanDescriptorsets", - "directories": { - "shaders": "descriptorsets" - }, - "assets": { - "models": [ - "cube.dae" - ], - "textures": [ - "crate01_color_height_rgba.ktx", - "crate02_color_height_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/displacement/.gitignore b/android/displacement/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/displacement/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/displacement/AndroidManifest.xml b/android/displacement/AndroidManifest.xml deleted file mode 100644 index 64b1b6f4..00000000 --- a/android/displacement/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/displacement/example.json b/android/displacement/example.json deleted file mode 100644 index 91199b88..00000000 --- a/android/displacement/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanDisplacement", - "directories": { - "shaders": "displacement" - }, - "assets": { - "models": [ - "plane.obj" - ], - "textures": [ - "stonefloor03_color_bc3_unorm.ktx", - "stonefloor03_color_astc_8x8_unorm.ktx", - "stonefloor03_color_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/distancefieldfonts/.gitignore b/android/distancefieldfonts/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/distancefieldfonts/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/distancefieldfonts/AndroidManifest.xml b/android/distancefieldfonts/AndroidManifest.xml deleted file mode 100644 index 27cf582a..00000000 --- a/android/distancefieldfonts/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/distancefieldfonts/example.json b/android/distancefieldfonts/example.json deleted file mode 100644 index 4809371c..00000000 --- a/android/distancefieldfonts/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apkname": "vulkanDistancefieldfonts", - "directories": { - "shaders": "distancefieldfonts" - }, - "assets": { - "textures": [ - "font_sdf_rgba.ktx", - "font_bitmap_rgba.ktx" - ], - "additional": { - "files": [ - "/font.fnt" - ] - } - } -} \ No newline at end of file diff --git a/android/dynamicuniformbuffer/.gitignore b/android/dynamicuniformbuffer/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/dynamicuniformbuffer/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/dynamicuniformbuffer/AndroidManifest.xml b/android/dynamicuniformbuffer/AndroidManifest.xml deleted file mode 100644 index ecd1f165..00000000 --- a/android/dynamicuniformbuffer/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/dynamicuniformbuffer/example.json b/android/dynamicuniformbuffer/example.json deleted file mode 100644 index cdee2177..00000000 --- a/android/dynamicuniformbuffer/example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "apkname": "vulkanDynamicuniformbuffer", - "directories": { - "shaders": "dynamicuniformbuffer" - }, - "assets": {} -} \ No newline at end of file diff --git a/android/examples/_template/CMakeLists.txt b/android/examples/_template/CMakeLists.txt new file mode 100644 index 00000000..055eaf34 --- /dev/null +++ b/android/examples/_template/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME %EXAMPLE_FOLDER%) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/_template/build.gradle b/android/examples/_template/build.gradle new file mode 100644 index 00000000..3aceaeb1 --- /dev/null +++ b/android/examples/_template/build.gradle @@ -0,0 +1,54 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.%PACKAGE_NAME%" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + +%ASSET_COPY% +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/_template/src/main/AndroidManifest.xml b/android/examples/_template/src/main/AndroidManifest.xml new file mode 100644 index 00000000..911142b2 --- /dev/null +++ b/android/examples/_template/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/_template/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/_template/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/_template/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/base/CMakeLists.txt b/android/examples/base/CMakeLists.txt new file mode 100644 index 00000000..4cc3c629 --- /dev/null +++ b/android/examples/base/CMakeLists.txt @@ -0,0 +1,21 @@ +file(GLOB BASE_SRC "../../../base/*.cpp" "../../../external/imgui/imgui.cpp" "../../../external/imgui/imgui_draw.cpp") + +add_library(libbase SHARED ${BASE_SRC}) + +add_library(libassimp STATIC IMPORTED) +set_target_properties(libassimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../../../libs/assimp/${ANDROID_ABI}/libassimp.a) + +include_directories(${BASE_DIR}) +include_directories(../../../external/glm) +include_directories(../../../external/gli) +include_directories(../../../external/imgui) +include_directories(../../../external/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + libbase + android + log + z + libassimp +) diff --git a/android/examples/bloom/CMakeLists.txt b/android/examples/bloom/CMakeLists.txt new file mode 100644 index 00000000..433796d3 --- /dev/null +++ b/android/examples/bloom/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME bloom) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/bloom/build.gradle b/android/examples/bloom/build.gradle new file mode 100644 index 00000000..57fa4a5e --- /dev/null +++ b/android/examples/bloom/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanBloom" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/bloom' + into 'assets/shaders/bloom' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'retroufo.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'retroufo_glow.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'cubemap_space.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/bloom/src/main/AndroidManifest.xml b/android/examples/bloom/src/main/AndroidManifest.xml new file mode 100644 index 00000000..07962bd4 --- /dev/null +++ b/android/examples/bloom/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/bloom/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/bloom/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/bloom/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computecloth/CMakeLists.txt b/android/examples/computecloth/CMakeLists.txt new file mode 100644 index 00000000..bf8ade81 --- /dev/null +++ b/android/examples/computecloth/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computecloth) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computecloth/build.gradle b/android/examples/computecloth/build.gradle new file mode 100644 index 00000000..56238abc --- /dev/null +++ b/android/examples/computecloth/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputecloth" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computecloth' + into 'assets/shaders/computecloth' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'vulkan_cloth_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computecloth/src/main/AndroidManifest.xml b/android/examples/computecloth/src/main/AndroidManifest.xml new file mode 100644 index 00000000..77117b52 --- /dev/null +++ b/android/examples/computecloth/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/computecloth/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computecloth/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computecloth/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computecullandlod/CMakeLists.txt b/android/examples/computecullandlod/CMakeLists.txt new file mode 100644 index 00000000..df02a19d --- /dev/null +++ b/android/examples/computecullandlod/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computecullandlod) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computecullandlod/build.gradle b/android/examples/computecullandlod/build.gradle new file mode 100644 index 00000000..e36c94f8 --- /dev/null +++ b/android/examples/computecullandlod/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputecullandlod" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computecullandlod' + into 'assets/shaders/computecullandlod' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'suzanne_lods.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computecullandlod/src/main/AndroidManifest.xml b/android/examples/computecullandlod/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3d8f09f9 --- /dev/null +++ b/android/examples/computecullandlod/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/computecullandlod/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computecullandlod/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computecullandlod/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computeheadless/CMakeLists.txt b/android/examples/computeheadless/CMakeLists.txt new file mode 100644 index 00000000..1b4d90ff --- /dev/null +++ b/android/examples/computeheadless/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computeheadless) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computeheadless/build.gradle b/android/examples/computeheadless/build.gradle new file mode 100644 index 00000000..3c60fad8 --- /dev/null +++ b/android/examples/computeheadless/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputeheadless" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computeheadless' + into 'assets/shaders/computeheadless' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computeheadless/src/main/AndroidManifest.xml b/android/examples/computeheadless/src/main/AndroidManifest.xml new file mode 100644 index 00000000..ff289197 --- /dev/null +++ b/android/examples/computeheadless/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/computeheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computeheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computeheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computenbody/CMakeLists.txt b/android/examples/computenbody/CMakeLists.txt new file mode 100644 index 00000000..39edb7eb --- /dev/null +++ b/android/examples/computenbody/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computenbody) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computenbody/build.gradle b/android/examples/computenbody/build.gradle new file mode 100644 index 00000000..bc76a50c --- /dev/null +++ b/android/examples/computenbody/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputenbody" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computenbody' + into 'assets/shaders/computenbody' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle01_rgba.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle_gradient_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computenbody/src/main/AndroidManifest.xml b/android/examples/computenbody/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d6a1348a --- /dev/null +++ b/android/examples/computenbody/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/computenbody/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computenbody/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computenbody/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computeparticles/CMakeLists.txt b/android/examples/computeparticles/CMakeLists.txt new file mode 100644 index 00000000..f4f5f624 --- /dev/null +++ b/android/examples/computeparticles/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computeparticles) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computeparticles/build.gradle b/android/examples/computeparticles/build.gradle new file mode 100644 index 00000000..66cb4419 --- /dev/null +++ b/android/examples/computeparticles/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputeparticles" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computeparticles' + into 'assets/shaders/computeparticles' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle01_rgba.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle_gradient_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computeparticles/src/main/AndroidManifest.xml b/android/examples/computeparticles/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a8c15e55 --- /dev/null +++ b/android/examples/computeparticles/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/computeparticles/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computeparticles/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computeparticles/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/computeshader/CMakeLists.txt b/android/examples/computeshader/CMakeLists.txt new file mode 100644 index 00000000..2e7916b6 --- /dev/null +++ b/android/examples/computeshader/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME computeshader) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/computeshader/build.gradle b/android/examples/computeshader/build.gradle new file mode 100644 index 00000000..d443b92f --- /dev/null +++ b/android/examples/computeshader/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanComputeshader" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/computeshader' + into 'assets/shaders/computeshader' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'vulkan_11_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/computeshader/src/main/AndroidManifest.xml b/android/examples/computeshader/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2f1fe254 --- /dev/null +++ b/android/examples/computeshader/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/computeshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/computeshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/computeshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/conservativeraster/CMakeLists.txt b/android/examples/conservativeraster/CMakeLists.txt new file mode 100644 index 00000000..50e23771 --- /dev/null +++ b/android/examples/conservativeraster/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME conservativeraster) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/conservativeraster/build.gradle b/android/examples/conservativeraster/build.gradle new file mode 100644 index 00000000..cd03506d --- /dev/null +++ b/android/examples/conservativeraster/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanConservativeraster" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/conservativeraster' + into 'assets/shaders/conservativeraster' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/conservativeraster/src/main/AndroidManifest.xml b/android/examples/conservativeraster/src/main/AndroidManifest.xml new file mode 100644 index 00000000..16854713 --- /dev/null +++ b/android/examples/conservativeraster/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/conservativeraster/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/conservativeraster/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/conservativeraster/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/debugmarker/CMakeLists.txt b/android/examples/debugmarker/CMakeLists.txt new file mode 100644 index 00000000..bb48c2d2 --- /dev/null +++ b/android/examples/debugmarker/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME debugmarker) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/debugmarker/build.gradle b/android/examples/debugmarker/build.gradle new file mode 100644 index 00000000..eb9576a9 --- /dev/null +++ b/android/examples/debugmarker/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDebugmarker" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/debugmarker' + into 'assets/shaders/debugmarker' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'treasure_smooth.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'treasure_glow.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/debugmarker/src/main/AndroidManifest.xml b/android/examples/debugmarker/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8dd2194a --- /dev/null +++ b/android/examples/debugmarker/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/debugmarker/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/debugmarker/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/debugmarker/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/deferred/CMakeLists.txt b/android/examples/deferred/CMakeLists.txt new file mode 100644 index 00000000..0d05931c --- /dev/null +++ b/android/examples/deferred/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME deferred) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/deferred/build.gradle b/android/examples/deferred/build.gradle new file mode 100644 index 00000000..6a784086 --- /dev/null +++ b/android/examples/deferred/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDeferred" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/deferred' + into 'assets/shaders/deferred' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor01_color_*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor01_normal_*.ktx' + } + + copy { + from '../../../data/models/armor' + into 'assets/models/armor' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/deferred/src/main/AndroidManifest.xml b/android/examples/deferred/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b5890663 --- /dev/null +++ b/android/examples/deferred/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/deferred/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/deferred/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/deferred/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/deferredmultisampling/CMakeLists.txt b/android/examples/deferredmultisampling/CMakeLists.txt new file mode 100644 index 00000000..7cd822b8 --- /dev/null +++ b/android/examples/deferredmultisampling/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME deferredmultisampling) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/deferredmultisampling/build.gradle b/android/examples/deferredmultisampling/build.gradle new file mode 100644 index 00000000..4ffabaa5 --- /dev/null +++ b/android/examples/deferredmultisampling/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDeferredmulitsampling" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/deferredmultisampling' + into 'assets/shaders/deferredmultisampling' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'openbox.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor02_color_*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor02_normal_*.ktx' + } + + copy { + from '../../../data/models/armor' + into 'assets/models/armor' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/deferredmultisampling/src/main/AndroidManifest.xml b/android/examples/deferredmultisampling/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a763ef48 --- /dev/null +++ b/android/examples/deferredmultisampling/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/deferredmultisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/deferredmultisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/deferredmultisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/deferredshadows/CMakeLists.txt b/android/examples/deferredshadows/CMakeLists.txt new file mode 100644 index 00000000..bf6b4254 --- /dev/null +++ b/android/examples/deferredshadows/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME deferredshadows) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/deferredshadows/build.gradle b/android/examples/deferredshadows/build.gradle new file mode 100644 index 00000000..da900f64 --- /dev/null +++ b/android/examples/deferredshadows/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDeferredshadows" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/deferredshadows' + into 'assets/shaders/deferredshadows' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'openbox.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor02_color_*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor02_normal_*.ktx' + } + + copy { + from '../../../data/models/armor' + into 'assets/models/armor' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/deferredshadows/src/main/AndroidManifest.xml b/android/examples/deferredshadows/src/main/AndroidManifest.xml new file mode 100644 index 00000000..504245db --- /dev/null +++ b/android/examples/deferredshadows/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/deferredshadows/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/deferredshadows/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/deferredshadows/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/descriptorsets/CMakeLists.txt b/android/examples/descriptorsets/CMakeLists.txt new file mode 100644 index 00000000..c0238824 --- /dev/null +++ b/android/examples/descriptorsets/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME descriptorsets) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/descriptorsets/build.gradle b/android/examples/descriptorsets/build.gradle new file mode 100644 index 00000000..ae61d21e --- /dev/null +++ b/android/examples/descriptorsets/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDescriptorsets" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/descriptorsets' + into 'assets/shaders/descriptorsets' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'crate01_color_height_rgba.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'crate02_color_height_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/descriptorsets/src/main/AndroidManifest.xml b/android/examples/descriptorsets/src/main/AndroidManifest.xml new file mode 100644 index 00000000..7f04a3e3 --- /dev/null +++ b/android/examples/descriptorsets/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/descriptorsets/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/descriptorsets/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/descriptorsets/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/displacement/CMakeLists.txt b/android/examples/displacement/CMakeLists.txt new file mode 100644 index 00000000..7653875e --- /dev/null +++ b/android/examples/displacement/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME displacement) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/displacement/build.gradle b/android/examples/displacement/build.gradle new file mode 100644 index 00000000..a8fe4945 --- /dev/null +++ b/android/examples/displacement/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDisplacement" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/displacement' + into 'assets/shaders/displacement' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'stonefloor03_color*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/displacement/src/main/AndroidManifest.xml b/android/examples/displacement/src/main/AndroidManifest.xml new file mode 100644 index 00000000..edf236b9 --- /dev/null +++ b/android/examples/displacement/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/displacement/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/displacement/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/displacement/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/distancefieldfonts/CMakeLists.txt b/android/examples/distancefieldfonts/CMakeLists.txt new file mode 100644 index 00000000..c0939b32 --- /dev/null +++ b/android/examples/distancefieldfonts/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME distancefieldfonts) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/distancefieldfonts/build.gradle b/android/examples/distancefieldfonts/build.gradle new file mode 100644 index 00000000..8f61c00a --- /dev/null +++ b/android/examples/distancefieldfonts/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDistancefieldfonts" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/distancefieldfonts' + into 'assets/shaders/distancefieldfonts' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'font_sdf_rgba.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'font_bitmap_rgba.ktx' + } + + copy { + from '../../../data/./' + into 'assets/./' + include 'font.fnt' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/distancefieldfonts/src/main/AndroidManifest.xml b/android/examples/distancefieldfonts/src/main/AndroidManifest.xml new file mode 100644 index 00000000..070a14d7 --- /dev/null +++ b/android/examples/distancefieldfonts/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/distancefieldfonts/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/distancefieldfonts/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/distancefieldfonts/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/dynamicuniformbuffer/CMakeLists.txt b/android/examples/dynamicuniformbuffer/CMakeLists.txt new file mode 100644 index 00000000..ccb9dee6 --- /dev/null +++ b/android/examples/dynamicuniformbuffer/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME dynamicuniformbuffer) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/dynamicuniformbuffer/build.gradle b/android/examples/dynamicuniformbuffer/build.gradle new file mode 100644 index 00000000..e49f6d5a --- /dev/null +++ b/android/examples/dynamicuniformbuffer/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanDynamicuniformbuffer" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/dynamicuniformbuffer' + into 'assets/shaders/dynamicuniformbuffer' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/dynamicuniformbuffer/src/main/AndroidManifest.xml b/android/examples/dynamicuniformbuffer/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f6ed456f --- /dev/null +++ b/android/examples/dynamicuniformbuffer/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/dynamicuniformbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/dynamicuniformbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/dynamicuniformbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/gears/CMakeLists.txt b/android/examples/gears/CMakeLists.txt new file mode 100644 index 00000000..f40e2bdf --- /dev/null +++ b/android/examples/gears/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME gears) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/gears/build.gradle b/android/examples/gears/build.gradle new file mode 100644 index 00000000..f39d5ad4 --- /dev/null +++ b/android/examples/gears/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanGears" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/gears' + into 'assets/shaders/gears' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/gears/src/main/AndroidManifest.xml b/android/examples/gears/src/main/AndroidManifest.xml new file mode 100644 index 00000000..c8338ffc --- /dev/null +++ b/android/examples/gears/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/gears/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/gears/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/gears/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/geometryshader/CMakeLists.txt b/android/examples/geometryshader/CMakeLists.txt new file mode 100644 index 00000000..480f2169 --- /dev/null +++ b/android/examples/geometryshader/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME geometryshader) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/geometryshader/build.gradle b/android/examples/geometryshader/build.gradle new file mode 100644 index 00000000..ff5e40c5 --- /dev/null +++ b/android/examples/geometryshader/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanGeometryshader" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/geometryshader' + into 'assets/shaders/geometryshader' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'suzanne.obj' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/geometryshader/src/main/AndroidManifest.xml b/android/examples/geometryshader/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a975812f --- /dev/null +++ b/android/examples/geometryshader/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/geometryshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/geometryshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/geometryshader/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/gradle/outputfilename.gradle b/android/examples/gradle/outputfilename.gradle new file mode 100644 index 00000000..e71624b3 --- /dev/null +++ b/android/examples/gradle/outputfilename.gradle @@ -0,0 +1,7 @@ +android { + applicationVariants.all { variant -> + variant.outputs.all { + outputFileName = "../../../../../bin/" + outputFileName + } + } +} \ No newline at end of file diff --git a/android/examples/hdr/CMakeLists.txt b/android/examples/hdr/CMakeLists.txt new file mode 100644 index 00000000..468a5e42 --- /dev/null +++ b/android/examples/hdr/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME hdr) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/hdr/build.gradle b/android/examples/hdr/build.gradle new file mode 100644 index 00000000..ae38c9b0 --- /dev/null +++ b/android/examples/hdr/build.gradle @@ -0,0 +1,96 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanHDR" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/hdr' + into 'assets/shaders/hdr' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'torusknot.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'venus.fbx' + } + + copy { + from '../../../data/textures/hdr' + into 'assets/textures/hdr' + include 'uffizi_cube.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/hdr/src/main/AndroidManifest.xml b/android/examples/hdr/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2ec30ec5 --- /dev/null +++ b/android/examples/hdr/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/hdr/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/hdr/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/hdr/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/imgui/CMakeLists.txt b/android/examples/imgui/CMakeLists.txt new file mode 100644 index 00000000..5d74847c --- /dev/null +++ b/android/examples/imgui/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME imgui) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") +file(GLOB ADD_SOURCE "${EXTERNAL_DIR}/imgui/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC} ${ADD_SOURCE}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/imgui/build.gradle b/android/examples/imgui/build.gradle new file mode 100644 index 00000000..dda8ad55 --- /dev/null +++ b/android/examples/imgui/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanImGui" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/imgui' + into 'assets/shaders/imgui' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenemodels.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenebackground.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenelogos.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/imgui/src/main/AndroidManifest.xml b/android/examples/imgui/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4941885f --- /dev/null +++ b/android/examples/imgui/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/imgui/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/imgui/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/imgui/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/indirectdraw/CMakeLists.txt b/android/examples/indirectdraw/CMakeLists.txt new file mode 100644 index 00000000..77318ca3 --- /dev/null +++ b/android/examples/indirectdraw/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME indirectdraw) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/indirectdraw/build.gradle b/android/examples/indirectdraw/build.gradle new file mode 100644 index 00000000..19ac498f --- /dev/null +++ b/android/examples/indirectdraw/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanIndirectdraw" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/indirectdraw' + into 'assets/shaders/indirectdraw' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plants.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane_circle.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'skysphere.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'texturearray_plants*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'ground_dry*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/indirectdraw/src/main/AndroidManifest.xml b/android/examples/indirectdraw/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6ae1ef86 --- /dev/null +++ b/android/examples/indirectdraw/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/indirectdraw/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/indirectdraw/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/indirectdraw/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/instancing/CMakeLists.txt b/android/examples/instancing/CMakeLists.txt new file mode 100644 index 00000000..1a120fc7 --- /dev/null +++ b/android/examples/instancing/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME instancing) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/instancing/build.gradle b/android/examples/instancing/build.gradle new file mode 100644 index 00000000..25984d8a --- /dev/null +++ b/android/examples/instancing/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanInstancing" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/instancing' + into 'assets/shaders/instancing' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'rock01.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'sphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'texturearray_rocks*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'lavaplanet*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/instancing/src/main/AndroidManifest.xml b/android/examples/instancing/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2d98c6e3 --- /dev/null +++ b/android/examples/instancing/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/instancing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/instancing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/instancing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/mesh/CMakeLists.txt b/android/examples/mesh/CMakeLists.txt new file mode 100644 index 00000000..d90f4fb8 --- /dev/null +++ b/android/examples/mesh/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME mesh) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/mesh/build.gradle b/android/examples/mesh/build.gradle new file mode 100644 index 00000000..80d87db9 --- /dev/null +++ b/android/examples/mesh/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanMesh" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/mesh' + into 'assets/shaders/mesh' + include '*.*' + } + + copy { + from '../../../data/models/voyager' + into 'assets/models/voyager' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/mesh/src/main/AndroidManifest.xml b/android/examples/mesh/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4e24788b --- /dev/null +++ b/android/examples/mesh/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/mesh/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/mesh/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/mesh/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/multisampling/CMakeLists.txt b/android/examples/multisampling/CMakeLists.txt new file mode 100644 index 00000000..b6aa7a64 --- /dev/null +++ b/android/examples/multisampling/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME multisampling) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/multisampling/build.gradle b/android/examples/multisampling/build.gradle new file mode 100644 index 00000000..7de52a38 --- /dev/null +++ b/android/examples/multisampling/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanMultisampling" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/mesh' + into 'assets/shaders/mesh' + include '*.*' + } + + copy { + from '../../../data/models/voyager' + into 'assets/models/voyager' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/multisampling/src/main/AndroidManifest.xml b/android/examples/multisampling/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5ae16c0c --- /dev/null +++ b/android/examples/multisampling/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/multisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/multisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/multisampling/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/multithreading/CMakeLists.txt b/android/examples/multithreading/CMakeLists.txt new file mode 100644 index 00000000..8014732e --- /dev/null +++ b/android/examples/multithreading/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME multithreading) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/multithreading/build.gradle b/android/examples/multithreading/build.gradle new file mode 100644 index 00000000..bd627539 --- /dev/null +++ b/android/examples/multithreading/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanMultithreading" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/multithreading' + into 'assets/shaders/multithreading' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'retroufo_red_lowpoly.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'sphere.obj' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/multithreading/src/main/AndroidManifest.xml b/android/examples/multithreading/src/main/AndroidManifest.xml new file mode 100644 index 00000000..fac79734 --- /dev/null +++ b/android/examples/multithreading/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/multithreading/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/multithreading/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/multithreading/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/occlusionquery/CMakeLists.txt b/android/examples/occlusionquery/CMakeLists.txt new file mode 100644 index 00000000..4ac9ceb7 --- /dev/null +++ b/android/examples/occlusionquery/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME occlusionquery) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/occlusionquery/build.gradle b/android/examples/occlusionquery/build.gradle new file mode 100644 index 00000000..297d6837 --- /dev/null +++ b/android/examples/occlusionquery/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanOcclusionquery" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/occlusionquery' + into 'assets/shaders/occlusionquery' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane_z.3ds' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.3ds' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'sphere.3ds' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/occlusionquery/src/main/AndroidManifest.xml b/android/examples/occlusionquery/src/main/AndroidManifest.xml new file mode 100644 index 00000000..1e50e184 --- /dev/null +++ b/android/examples/occlusionquery/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/occlusionquery/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/occlusionquery/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/occlusionquery/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/offscreen/CMakeLists.txt b/android/examples/offscreen/CMakeLists.txt new file mode 100644 index 00000000..3ea0ac38 --- /dev/null +++ b/android/examples/offscreen/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME offscreen) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/offscreen/build.gradle b/android/examples/offscreen/build.gradle new file mode 100644 index 00000000..da5feee4 --- /dev/null +++ b/android/examples/offscreen/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanOffscreen" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/offscreen' + into 'assets/shaders/offscreen' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'chinesedragon.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'darkmetal_*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/offscreen/src/main/AndroidManifest.xml b/android/examples/offscreen/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5572e30a --- /dev/null +++ b/android/examples/offscreen/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/offscreen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/offscreen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/offscreen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/parallaxmapping/CMakeLists.txt b/android/examples/parallaxmapping/CMakeLists.txt new file mode 100644 index 00000000..8e87f03a --- /dev/null +++ b/android/examples/parallaxmapping/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME parallaxmapping) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/parallaxmapping/build.gradle b/android/examples/parallaxmapping/build.gradle new file mode 100644 index 00000000..7c0c3b82 --- /dev/null +++ b/android/examples/parallaxmapping/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanParallaxmapping" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/parallaxmapping' + into 'assets/shaders/parallaxmapping' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane_z.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'rocks_normal_height_rgba.dds' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'rocks_color*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/parallaxmapping/src/main/AndroidManifest.xml b/android/examples/parallaxmapping/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e40d99da --- /dev/null +++ b/android/examples/parallaxmapping/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/parallaxmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/parallaxmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/parallaxmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/particlefire/CMakeLists.txt b/android/examples/particlefire/CMakeLists.txt new file mode 100644 index 00000000..5a181c69 --- /dev/null +++ b/android/examples/particlefire/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME particlefire) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/particlefire/build.gradle b/android/examples/particlefire/build.gradle new file mode 100644 index 00000000..17306247 --- /dev/null +++ b/android/examples/particlefire/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanParticlefire" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/particlefire' + into 'assets/shaders/particlefire' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'fireplace.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle_fire.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle_smoke.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'fireplace_normalmap*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'fireplace_colormap*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/particlefire/src/main/AndroidManifest.xml b/android/examples/particlefire/src/main/AndroidManifest.xml new file mode 100644 index 00000000..c8f97268 --- /dev/null +++ b/android/examples/particlefire/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/particlefire/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/particlefire/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/particlefire/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pbrbasic/CMakeLists.txt b/android/examples/pbrbasic/CMakeLists.txt new file mode 100644 index 00000000..163901ab --- /dev/null +++ b/android/examples/pbrbasic/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pbrbasic) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pbrbasic/build.gradle b/android/examples/pbrbasic/build.gradle new file mode 100644 index 00000000..312a84df --- /dev/null +++ b/android/examples/pbrbasic/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPBRBasic" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pbrbasic' + into 'assets/shaders/pbrbasic' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'torusknot.objdae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'venus.fbx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pbrbasic/src/main/AndroidManifest.xml b/android/examples/pbrbasic/src/main/AndroidManifest.xml new file mode 100644 index 00000000..ed399c39 --- /dev/null +++ b/android/examples/pbrbasic/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pbrbasic/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pbrbasic/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pbrbasic/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pbribl/CMakeLists.txt b/android/examples/pbribl/CMakeLists.txt new file mode 100644 index 00000000..c7e25e66 --- /dev/null +++ b/android/examples/pbribl/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pbribl) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pbribl/build.gradle b/android/examples/pbribl/build.gradle new file mode 100644 index 00000000..03733d6d --- /dev/null +++ b/android/examples/pbribl/build.gradle @@ -0,0 +1,96 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPBRIBL" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pbribl' + into 'assets/shaders/pbribl' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'torusknot.objdae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'venus.fbx' + } + + copy { + from '../../../data/textures/hdr' + into 'assets/textures/hdr' + include 'pisa_cube.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pbribl/src/main/AndroidManifest.xml b/android/examples/pbribl/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e3288148 --- /dev/null +++ b/android/examples/pbribl/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pbribl/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pbribl/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pbribl/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pbrtexture/CMakeLists.txt b/android/examples/pbrtexture/CMakeLists.txt new file mode 100644 index 00000000..b7907bfc --- /dev/null +++ b/android/examples/pbrtexture/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pbrtexture) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pbrtexture/build.gradle b/android/examples/pbrtexture/build.gradle new file mode 100644 index 00000000..7988fb29 --- /dev/null +++ b/android/examples/pbrtexture/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPBRTexture" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pbrtexture' + into 'assets/shaders/pbrtexture' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/textures/hdr' + into 'assets/textures/hdr' + include 'gcanyon_cube.ktx' + } + + copy { + from '../../../data/models/cerberus' + into 'assets/models/cerberus' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pbrtexture/src/main/AndroidManifest.xml b/android/examples/pbrtexture/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8ed371b9 --- /dev/null +++ b/android/examples/pbrtexture/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pbrtexture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pbrtexture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pbrtexture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pipelines/CMakeLists.txt b/android/examples/pipelines/CMakeLists.txt new file mode 100644 index 00000000..ecfbf208 --- /dev/null +++ b/android/examples/pipelines/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pipelines) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pipelines/build.gradle b/android/examples/pipelines/build.gradle new file mode 100644 index 00000000..dff91b29 --- /dev/null +++ b/android/examples/pipelines/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPipelines" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pipelines' + into 'assets/shaders/pipelines' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'treasure_smooth.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pipelines/src/main/AndroidManifest.xml b/android/examples/pipelines/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a6e7bc8a --- /dev/null +++ b/android/examples/pipelines/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pipelines/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pipelines/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pipelines/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pipelinestatistics/CMakeLists.txt b/android/examples/pipelinestatistics/CMakeLists.txt new file mode 100644 index 00000000..5938fdb0 --- /dev/null +++ b/android/examples/pipelinestatistics/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pipelinestatistics) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pipelinestatistics/build.gradle b/android/examples/pipelinestatistics/build.gradle new file mode 100644 index 00000000..4552acea --- /dev/null +++ b/android/examples/pipelinestatistics/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPipelinestatistics" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pipelinestatistics' + into 'assets/shaders/pipelinestatistics' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'torusknot.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'venus.fbx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pipelinestatistics/src/main/AndroidManifest.xml b/android/examples/pipelinestatistics/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a26c688c --- /dev/null +++ b/android/examples/pipelinestatistics/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pipelinestatistics/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pipelinestatistics/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pipelinestatistics/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pushconstants/CMakeLists.txt b/android/examples/pushconstants/CMakeLists.txt new file mode 100644 index 00000000..bdcaf273 --- /dev/null +++ b/android/examples/pushconstants/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pushconstants) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pushconstants/build.gradle b/android/examples/pushconstants/build.gradle new file mode 100644 index 00000000..4b177b84 --- /dev/null +++ b/android/examples/pushconstants/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPushconstants" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pushconstants' + into 'assets/shaders/pushconstants' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'samplescene.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pushconstants/src/main/AndroidManifest.xml b/android/examples/pushconstants/src/main/AndroidManifest.xml new file mode 100644 index 00000000..da183bf2 --- /dev/null +++ b/android/examples/pushconstants/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pushconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pushconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pushconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/pushdescriptors/CMakeLists.txt b/android/examples/pushdescriptors/CMakeLists.txt new file mode 100644 index 00000000..20c83bb7 --- /dev/null +++ b/android/examples/pushdescriptors/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME pushdescriptors) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/pushdescriptors/build.gradle b/android/examples/pushdescriptors/build.gradle new file mode 100644 index 00000000..b90091aa --- /dev/null +++ b/android/examples/pushdescriptors/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanPushdescriptors" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/pushdescriptors' + into 'assets/shaders/pushdescriptors' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'crate01_color_height_rgba.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'crate02_color_height_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/pushdescriptors/src/main/AndroidManifest.xml b/android/examples/pushdescriptors/src/main/AndroidManifest.xml new file mode 100644 index 00000000..66b5cbbe --- /dev/null +++ b/android/examples/pushdescriptors/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/pushdescriptors/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/pushdescriptors/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/pushdescriptors/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/radialblur/CMakeLists.txt b/android/examples/radialblur/CMakeLists.txt new file mode 100644 index 00000000..231874d8 --- /dev/null +++ b/android/examples/radialblur/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME radialblur) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/radialblur/build.gradle b/android/examples/radialblur/build.gradle new file mode 100644 index 00000000..9d48447c --- /dev/null +++ b/android/examples/radialblur/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanRadialblur" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/radialblur' + into 'assets/shaders/radialblur' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'glowsphere.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'particle_gradient_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/radialblur/src/main/AndroidManifest.xml b/android/examples/radialblur/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f0ee4f17 --- /dev/null +++ b/android/examples/radialblur/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/radialblur/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/radialblur/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/radialblur/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/raytracing/CMakeLists.txt b/android/examples/raytracing/CMakeLists.txt new file mode 100644 index 00000000..49af10e2 --- /dev/null +++ b/android/examples/raytracing/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME raytracing) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/raytracing/build.gradle b/android/examples/raytracing/build.gradle new file mode 100644 index 00000000..9289e4b6 --- /dev/null +++ b/android/examples/raytracing/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanRaytracing" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/raytracing' + into 'assets/shaders/raytracing' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/raytracing/src/main/AndroidManifest.xml b/android/examples/raytracing/src/main/AndroidManifest.xml new file mode 100644 index 00000000..710c4237 --- /dev/null +++ b/android/examples/raytracing/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/raytracing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/raytracing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/raytracing/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/renderheadless/CMakeLists.txt b/android/examples/renderheadless/CMakeLists.txt new file mode 100644 index 00000000..b5b60f37 --- /dev/null +++ b/android/examples/renderheadless/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME renderheadless) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/renderheadless/build.gradle b/android/examples/renderheadless/build.gradle new file mode 100644 index 00000000..be0dc864 --- /dev/null +++ b/android/examples/renderheadless/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanRenderheadless" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/renderheadless' + into 'assets/shaders/renderheadless' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/renderheadless/src/main/AndroidManifest.xml b/android/examples/renderheadless/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6dd6b227 --- /dev/null +++ b/android/examples/renderheadless/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/renderheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/renderheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/renderheadless/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/scenerendering/CMakeLists.txt b/android/examples/scenerendering/CMakeLists.txt new file mode 100644 index 00000000..343a518c --- /dev/null +++ b/android/examples/scenerendering/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME scenerendering) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/scenerendering/build.gradle b/android/examples/scenerendering/build.gradle new file mode 100644 index 00000000..e413f590 --- /dev/null +++ b/android/examples/scenerendering/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanScenerendering" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/scenerendering' + into 'assets/shaders/scenerendering' + include '*.*' + } + + copy { + from '../../../data/models/sibenik' + into 'assets/models/sibenik' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/scenerendering/src/main/AndroidManifest.xml b/android/examples/scenerendering/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a12e04f2 --- /dev/null +++ b/android/examples/scenerendering/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/scenerendering/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/scenerendering/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/scenerendering/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/screenshot/CMakeLists.txt b/android/examples/screenshot/CMakeLists.txt new file mode 100644 index 00000000..295a1e32 --- /dev/null +++ b/android/examples/screenshot/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME screenshot) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/screenshot/build.gradle b/android/examples/screenshot/build.gradle new file mode 100644 index 00000000..2b3896cc --- /dev/null +++ b/android/examples/screenshot/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanScreenshot" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/screenshot' + into 'assets/shaders/screenshot' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'chinesedragon.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/screenshot/src/main/AndroidManifest.xml b/android/examples/screenshot/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e2d9fd33 --- /dev/null +++ b/android/examples/screenshot/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/screenshot/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/screenshot/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/screenshot/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/shadowmapping/CMakeLists.txt b/android/examples/shadowmapping/CMakeLists.txt new file mode 100644 index 00000000..d82a20ad --- /dev/null +++ b/android/examples/shadowmapping/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME shadowmapping) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/shadowmapping/build.gradle b/android/examples/shadowmapping/build.gradle new file mode 100644 index 00000000..7b7c55db --- /dev/null +++ b/android/examples/shadowmapping/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanShadowmapping" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/shadowmapping' + into 'assets/shaders/shadowmapping' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscene_shadow.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/shadowmapping/src/main/AndroidManifest.xml b/android/examples/shadowmapping/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2f98411a --- /dev/null +++ b/android/examples/shadowmapping/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/shadowmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/shadowmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/shadowmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/shadowmappingcascade/CMakeLists.txt b/android/examples/shadowmappingcascade/CMakeLists.txt new file mode 100644 index 00000000..ca55209f --- /dev/null +++ b/android/examples/shadowmappingcascade/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME shadowmappingcascade) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/shadowmappingcascade/build.gradle b/android/examples/shadowmappingcascade/build.gradle new file mode 100644 index 00000000..9869f4ea --- /dev/null +++ b/android/examples/shadowmappingcascade/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanShadowmappingcascade" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/shadowmappingcascade' + into 'assets/shaders/shadowmappingcascade' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'terrain_simple.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'oak_*.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'gridlines.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'oak*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/shadowmappingcascade/src/main/AndroidManifest.xml b/android/examples/shadowmappingcascade/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5306205 --- /dev/null +++ b/android/examples/shadowmappingcascade/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/shadowmappingcascade/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/shadowmappingcascade/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/shadowmappingcascade/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/shadowmappingomni/CMakeLists.txt b/android/examples/shadowmappingomni/CMakeLists.txt new file mode 100644 index 00000000..41e5045f --- /dev/null +++ b/android/examples/shadowmappingomni/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME shadowmappingomni) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/shadowmappingomni/build.gradle b/android/examples/shadowmappingomni/build.gradle new file mode 100644 index 00000000..39776996 --- /dev/null +++ b/android/examples/shadowmappingomni/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanShadowmappingomni" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/shadowmapomni' + into 'assets/shaders/shadowmapomni' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'shadowscene_fire.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/shadowmappingomni/src/main/AndroidManifest.xml b/android/examples/shadowmappingomni/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8bf397dc --- /dev/null +++ b/android/examples/shadowmappingomni/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/shadowmappingomni/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/shadowmappingomni/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/shadowmappingomni/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/skeletalanimation/CMakeLists.txt b/android/examples/skeletalanimation/CMakeLists.txt new file mode 100644 index 00000000..53af56a8 --- /dev/null +++ b/android/examples/skeletalanimation/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME skeletalanimation) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/skeletalanimation/build.gradle b/android/examples/skeletalanimation/build.gradle new file mode 100644 index 00000000..03a26fb1 --- /dev/null +++ b/android/examples/skeletalanimation/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanSkeletalanimation" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/skeletalanimation' + into 'assets/shaders/skeletalanimation' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'goblin.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'plane_z.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'trail*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'goblin*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/skeletalanimation/src/main/AndroidManifest.xml b/android/examples/skeletalanimation/src/main/AndroidManifest.xml new file mode 100644 index 00000000..95e4a668 --- /dev/null +++ b/android/examples/skeletalanimation/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/skeletalanimation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/skeletalanimation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/skeletalanimation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/specializationconstants/CMakeLists.txt b/android/examples/specializationconstants/CMakeLists.txt new file mode 100644 index 00000000..7812d01d --- /dev/null +++ b/android/examples/specializationconstants/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME specializationconstants) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/specializationconstants/build.gradle b/android/examples/specializationconstants/build.gradle new file mode 100644 index 00000000..01ab4439 --- /dev/null +++ b/android/examples/specializationconstants/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanSpecializationconstants" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/specializationconstants' + into 'assets/shaders/specializationconstants' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'color_teapot_spheres.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'metalplate_nomips_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/specializationconstants/src/main/AndroidManifest.xml b/android/examples/specializationconstants/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f51c7827 --- /dev/null +++ b/android/examples/specializationconstants/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/specializationconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/specializationconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/specializationconstants/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/sphericalenvmapping/CMakeLists.txt b/android/examples/sphericalenvmapping/CMakeLists.txt new file mode 100644 index 00000000..d8c309c5 --- /dev/null +++ b/android/examples/sphericalenvmapping/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME sphericalenvmapping) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/sphericalenvmapping/build.gradle b/android/examples/sphericalenvmapping/build.gradle new file mode 100644 index 00000000..b47d8973 --- /dev/null +++ b/android/examples/sphericalenvmapping/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanSphericalenvmapping" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/sphericalenvmapping' + into 'assets/shaders/sphericalenvmapping' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'chinesedragon.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'matcap_array_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/sphericalenvmapping/src/main/AndroidManifest.xml b/android/examples/sphericalenvmapping/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3b6be14b --- /dev/null +++ b/android/examples/sphericalenvmapping/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/sphericalenvmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/sphericalenvmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/sphericalenvmapping/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/ssao/CMakeLists.txt b/android/examples/ssao/CMakeLists.txt new file mode 100644 index 00000000..604ef625 --- /dev/null +++ b/android/examples/ssao/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME ssao) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/ssao/build.gradle b/android/examples/ssao/build.gradle new file mode 100644 index 00000000..a3c8e473 --- /dev/null +++ b/android/examples/ssao/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanSSAO" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/ssao' + into 'assets/shaders/ssao' + include '*.*' + } + + copy { + from '../../../data/models/sibenik' + into 'assets/models/sibenik' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/ssao/src/main/AndroidManifest.xml b/android/examples/ssao/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8f5a7639 --- /dev/null +++ b/android/examples/ssao/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/ssao/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/ssao/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/ssao/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/stencilbuffer/CMakeLists.txt b/android/examples/stencilbuffer/CMakeLists.txt new file mode 100644 index 00000000..e6158903 --- /dev/null +++ b/android/examples/stencilbuffer/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME stencilbuffer) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/stencilbuffer/build.gradle b/android/examples/stencilbuffer/build.gradle new file mode 100644 index 00000000..4dba45c6 --- /dev/null +++ b/android/examples/stencilbuffer/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanStencilbuffer" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/stencilbuffer' + into 'assets/shaders/stencilbuffer' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'venus.fbx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/stencilbuffer/src/main/AndroidManifest.xml b/android/examples/stencilbuffer/src/main/AndroidManifest.xml new file mode 100644 index 00000000..42e98050 --- /dev/null +++ b/android/examples/stencilbuffer/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/stencilbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/stencilbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/stencilbuffer/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/subpasses/CMakeLists.txt b/android/examples/subpasses/CMakeLists.txt new file mode 100644 index 00000000..2eb057ae --- /dev/null +++ b/android/examples/subpasses/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME subpasses) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/subpasses/build.gradle b/android/examples/subpasses/build.gradle new file mode 100644 index 00000000..aaafe4ed --- /dev/null +++ b/android/examples/subpasses/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanSubpasses" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/subpasses' + into 'assets/shaders/subpasses' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'samplebuilding.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'samplebuilding_glass.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'colored_glass_*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/subpasses/src/main/AndroidManifest.xml b/android/examples/subpasses/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8c6043de --- /dev/null +++ b/android/examples/subpasses/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/subpasses/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/subpasses/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/subpasses/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/terraintessellation/CMakeLists.txt b/android/examples/terraintessellation/CMakeLists.txt new file mode 100644 index 00000000..1204c7df --- /dev/null +++ b/android/examples/terraintessellation/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME terraintessellation) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/terraintessellation/build.gradle b/android/examples/terraintessellation/build.gradle new file mode 100644 index 00000000..535482a3 --- /dev/null +++ b/android/examples/terraintessellation/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTerraintessellation" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/terraintessellation' + into 'assets/shaders/terraintessellation' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'geosphere.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'skysphere*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'terrain_texturearray*.ktx' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'terrain_heightmap_r16.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/terraintessellation/src/main/AndroidManifest.xml b/android/examples/terraintessellation/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4723f70f --- /dev/null +++ b/android/examples/terraintessellation/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/terraintessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/terraintessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/terraintessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/tessellation/CMakeLists.txt b/android/examples/tessellation/CMakeLists.txt new file mode 100644 index 00000000..f9dc03f6 --- /dev/null +++ b/android/examples/tessellation/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME tessellation) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/tessellation/build.gradle b/android/examples/tessellation/build.gradle new file mode 100644 index 00000000..99a88354 --- /dev/null +++ b/android/examples/tessellation/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTessellation" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/tessellation' + into 'assets/shaders/tessellation' + include '*.*' + } + + copy { + from '../../../data/models/lowpoly' + into 'assets/models/lowpoly' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'retroufo_glow.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'deer*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/tessellation/src/main/AndroidManifest.xml b/android/examples/tessellation/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6f7c645c --- /dev/null +++ b/android/examples/tessellation/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/tessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/tessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/tessellation/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/textoverlay/CMakeLists.txt b/android/examples/textoverlay/CMakeLists.txt new file mode 100644 index 00000000..7107d8c3 --- /dev/null +++ b/android/examples/textoverlay/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME textoverlay) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/textoverlay/build.gradle b/android/examples/textoverlay/build.gradle new file mode 100644 index 00000000..b24ffbf2 --- /dev/null +++ b/android/examples/textoverlay/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTextoverlay" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/textoverlay' + into 'assets/shaders/textoverlay' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/textoverlay/src/main/AndroidManifest.xml b/android/examples/textoverlay/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f3a05228 --- /dev/null +++ b/android/examples/textoverlay/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/textoverlay/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/textoverlay/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/textoverlay/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/texture/CMakeLists.txt b/android/examples/texture/CMakeLists.txt new file mode 100644 index 00000000..b4f5c875 --- /dev/null +++ b/android/examples/texture/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME texture) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/texture/build.gradle b/android/examples/texture/build.gradle new file mode 100644 index 00000000..4e2a2164 --- /dev/null +++ b/android/examples/texture/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTexture" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/texture' + into 'assets/shaders/texture' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'metalplate01_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/texture/src/main/AndroidManifest.xml b/android/examples/texture/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5482b681 --- /dev/null +++ b/android/examples/texture/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/texture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/texture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/texture/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/texture3d/CMakeLists.txt b/android/examples/texture3d/CMakeLists.txt new file mode 100644 index 00000000..82f56cf5 --- /dev/null +++ b/android/examples/texture3d/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME texture3d) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/texture3d/build.gradle b/android/examples/texture3d/build.gradle new file mode 100644 index 00000000..2f40d229 --- /dev/null +++ b/android/examples/texture3d/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTexture3d" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/texture3d' + into 'assets/shaders/texture3d' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/texture3d/src/main/AndroidManifest.xml b/android/examples/texture3d/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5ba25310 --- /dev/null +++ b/android/examples/texture3d/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/texture3d/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/texture3d/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/texture3d/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/texturearray/CMakeLists.txt b/android/examples/texturearray/CMakeLists.txt new file mode 100644 index 00000000..1afb3b78 --- /dev/null +++ b/android/examples/texturearray/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME texturearray) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/texturearray/build.gradle b/android/examples/texturearray/build.gradle new file mode 100644 index 00000000..3e8232b3 --- /dev/null +++ b/android/examples/texturearray/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTexturearray" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/texturearray' + into 'assets/shaders/texturearray' + include '*.*' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'texturearray*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/texturearray/src/main/AndroidManifest.xml b/android/examples/texturearray/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a466469a --- /dev/null +++ b/android/examples/texturearray/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/texturearray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/texturearray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/texturearray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/texturecubemap/CMakeLists.txt b/android/examples/texturecubemap/CMakeLists.txt new file mode 100644 index 00000000..31c350e2 --- /dev/null +++ b/android/examples/texturecubemap/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME texturecubemap) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/texturecubemap/build.gradle b/android/examples/texturecubemap/build.gradle new file mode 100644 index 00000000..e9deaa48 --- /dev/null +++ b/android/examples/texturecubemap/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTexturecubemap" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/texturecubemap' + into 'assets/shaders/texturecubemap' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'sphere.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'teapot.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'torusknot.obj' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'cubemap_yokohama*.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/texturecubemap/src/main/AndroidManifest.xml b/android/examples/texturecubemap/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a1e81a20 --- /dev/null +++ b/android/examples/texturecubemap/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/texturecubemap/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/texturecubemap/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/texturecubemap/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/texturemipmapgen/CMakeLists.txt b/android/examples/texturemipmapgen/CMakeLists.txt new file mode 100644 index 00000000..f9f6af6b --- /dev/null +++ b/android/examples/texturemipmapgen/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME texturemipmapgen) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/texturemipmapgen/build.gradle b/android/examples/texturemipmapgen/build.gradle new file mode 100644 index 00000000..1913bc41 --- /dev/null +++ b/android/examples/texturemipmapgen/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTexturemipmapgen" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/texturemipmapgen' + into 'assets/shaders/texturemipmapgen' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'tunnel_cylinder.dae' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'metalplate_nomips_rgba.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/texturemipmapgen/src/main/AndroidManifest.xml b/android/examples/texturemipmapgen/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d197eef0 --- /dev/null +++ b/android/examples/texturemipmapgen/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/texturemipmapgen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/texturemipmapgen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/texturemipmapgen/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/triangle/CMakeLists.txt b/android/examples/triangle/CMakeLists.txt new file mode 100644 index 00000000..2faa4ed6 --- /dev/null +++ b/android/examples/triangle/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME triangle) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/triangle/build.gradle b/android/examples/triangle/build.gradle new file mode 100644 index 00000000..7c3fd7b0 --- /dev/null +++ b/android/examples/triangle/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanTriangle" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/triangle' + into 'assets/shaders/triangle' + include '*.*' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/triangle/src/main/AndroidManifest.xml b/android/examples/triangle/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3dd53b0b --- /dev/null +++ b/android/examples/triangle/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/triangle/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/triangle/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/triangle/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/viewportarray/CMakeLists.txt b/android/examples/viewportarray/CMakeLists.txt new file mode 100644 index 00000000..9afd51b5 --- /dev/null +++ b/android/examples/viewportarray/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME viewportarray) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/viewportarray/build.gradle b/android/examples/viewportarray/build.gradle new file mode 100644 index 00000000..316137e6 --- /dev/null +++ b/android/examples/viewportarray/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanViewportarray" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/viewportarray' + into 'assets/shaders/viewportarray' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'sampleroom.dae' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/viewportarray/src/main/AndroidManifest.xml b/android/examples/viewportarray/src/main/AndroidManifest.xml new file mode 100644 index 00000000..edbb29de --- /dev/null +++ b/android/examples/viewportarray/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/viewportarray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/viewportarray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/viewportarray/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/examples/vulkanscene/CMakeLists.txt b/android/examples/vulkanscene/CMakeLists.txt new file mode 100644 index 00000000..7735add3 --- /dev/null +++ b/android/examples/vulkanscene/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR) + +set(NAME vulkanscene) + +set(SRC_DIR ../../../examples/${NAME}) +set(BASE_DIR ../../../base) +set(EXTERNAL_DIR ../../../external) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") + +file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") + +add_library(native-lib SHARED ${EXAMPLE_SRC}) + +add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base) + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +include_directories(${BASE_DIR}) +include_directories(${EXTERNAL_DIR}) +include_directories(${EXTERNAL_DIR}/glm) +include_directories(${EXTERNAL_DIR}/gli) +include_directories(${EXTERNAL_DIR}/imgui) +include_directories(${EXTERNAL_DIR}/assimp) +include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + +target_link_libraries( + native-lib + native-app-glue + libbase + android + log + z +) diff --git a/android/examples/vulkanscene/build.gradle b/android/examples/vulkanscene/build.gradle new file mode 100644 index 00000000..1ad6fe37 --- /dev/null +++ b/android/examples/vulkanscene/build.gradle @@ -0,0 +1,90 @@ +apply plugin: 'com.android.application' +apply from: '../gradle/outputfilename.gradle' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "de.saschawillems.vulkanVulkanscene" + minSdkVersion 19 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + ndk { + abiFilters "armeabi-v7a" + } + externalNativeBuild { + cmake { + cppFlags "-std=c++14" + arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang' + } + } + } + sourceSets { + main.assets.srcDirs = ['assets'] + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} + +task copyTask << { + copy { + from '../../common/res/drawable' + into "src/main/res/drawable" + include 'icon.png' + } + + copy { + from '../../../data/shaders/base' + into "assets/shaders/base" + include '*.spv' + } + + copy { + from '../../../data/shaders/vulkanscene' + into 'assets/shaders/vulkanscene' + include '*.*' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenelogos.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenebackground.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'vulkanscenemodels.dae' + } + + copy { + from '../../../data/models' + into 'assets/models' + include 'cube.obj' + } + + copy { + from '../../../data/textures' + into 'assets/textures' + include 'cubemap_vulkan.ktx' + } + + +} + +preBuild.dependsOn copyTask \ No newline at end of file diff --git a/android/examples/vulkanscene/src/main/AndroidManifest.xml b/android/examples/vulkanscene/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6005450d --- /dev/null +++ b/android/examples/vulkanscene/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/android/examples/vulkanscene/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java b/android/examples/vulkanscene/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java new file mode 100644 index 00000000..12e14fc6 --- /dev/null +++ b/android/examples/vulkanscene/src/main/java/de/saschawillems/vulkanSample/VulkanActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ +package de.saschawillems.vulkanSample; + +import android.app.AlertDialog; +import android.app.NativeActivity; +import android.content.DialogInterface; +import android.content.pm.ApplicationInfo; +import android.os.Bundle; + +import java.util.concurrent.Semaphore; + +public class VulkanActivity extends NativeActivity { + + static { + // Load native library + System.loadLibrary("native-lib"); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + // Use a semaphore to create a modal dialog + + private final Semaphore semaphore = new Semaphore(0, true); + + public void showAlert(final String message) + { + final VulkanActivity activity = this; + + ApplicationInfo applicationInfo = activity.getApplicationInfo(); + final String applicationName = applicationInfo.nonLocalizedLabel.toString(); + + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert); + builder.setTitle(applicationName); + builder.setMessage(message); + builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + semaphore.release(); + } + }); + builder.setCancelable(false); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + try { + semaphore.acquire(); + } + catch (InterruptedException e) { } + } +} diff --git a/android/gears/.gitignore b/android/gears/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/gears/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/gears/AndroidManifest.xml b/android/gears/AndroidManifest.xml deleted file mode 100644 index b06d0c5a..00000000 --- a/android/gears/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/gears/example.json b/android/gears/example.json deleted file mode 100644 index 2abf6a15..00000000 --- a/android/gears/example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "apkname": "vulkanGears", - "directories": { - "shaders": "gears" - }, - "assets": {} -} \ No newline at end of file diff --git a/android/geometryshader/.gitignore b/android/geometryshader/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/geometryshader/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/geometryshader/AndroidManifest.xml b/android/geometryshader/AndroidManifest.xml deleted file mode 100644 index e2369a7c..00000000 --- a/android/geometryshader/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/geometryshader/example.json b/android/geometryshader/example.json deleted file mode 100644 index dca01d7e..00000000 --- a/android/geometryshader/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanGeometryshader", - "directories": { - "shaders": "geometryshader" - }, - "assets": { - "models": [ - "suzanne.obj" - ] - } -} \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..13372aef Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..36bca093 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Apr 17 21:10:32 CEST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/android/gradlew b/android/gradlew new file mode 100644 index 00000000..9d82f789 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/hdr/.gitignore b/android/hdr/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/hdr/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/hdr/AndroidManifest.xml b/android/hdr/AndroidManifest.xml deleted file mode 100644 index 7b4a825b..00000000 --- a/android/hdr/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/hdr/example.json b/android/hdr/example.json deleted file mode 100644 index 595df0ca..00000000 --- a/android/hdr/example.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "apkname": "vulkanHDR", - "directories": { - "shaders": "hdr" - }, - "assets": { - "models": [ - "cube.obj", - "geosphere.obj", - "teapot.dae", - "torusknot.obj", - "venus.fbx" - ], - "additional" : { - "directories": [ - "textures/hdr" - ], - "files": [ - "textures/hdr/uffizi_cube.ktx" - ] - } - } -} \ No newline at end of file diff --git a/android/imgui/.gitignore b/android/imgui/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/imgui/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/imgui/AndroidManifest.xml b/android/imgui/AndroidManifest.xml deleted file mode 100644 index dba0fa3b..00000000 --- a/android/imgui/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/imgui/example.json b/android/imgui/example.json deleted file mode 100644 index 1341f23e..00000000 --- a/android/imgui/example.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apkname": "vulkanImGui", - "directories": { - "shaders": "imgui" - }, - "assets": { - "models": [ - "vulkanscenemodels.dae", - "vulkanscenebackground.dae", - "vulkanscenelogos.dae" - ] - } -} \ No newline at end of file diff --git a/android/indirectdraw/.gitignore b/android/indirectdraw/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/indirectdraw/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/indirectdraw/AndroidManifest.xml b/android/indirectdraw/AndroidManifest.xml deleted file mode 100644 index 56e76021..00000000 --- a/android/indirectdraw/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/indirectdraw/example.json b/android/indirectdraw/example.json deleted file mode 100644 index 83135e1a..00000000 --- a/android/indirectdraw/example.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "apkname": "vulkanIndirectdraw", - "directories": { - "shaders": "indirectdraw" - }, - "assets": { - "models": [ - "plants.dae", - "plane_circle.dae", - "skysphere.dae" - ], - "textures": [ - "texturearray_plants_bc3_unorm.ktx", - "texturearray_plants_astc_8x8_unorm.ktx", - "texturearray_plants_etc2_unorm.ktx", - "ground_dry_bc3_unorm.ktx", - "ground_dry_astc_8x8_unorm.ktx", - "ground_dry_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/instancing/.gitignore b/android/instancing/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/instancing/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/instancing/AndroidManifest.xml b/android/instancing/AndroidManifest.xml deleted file mode 100644 index 70490828..00000000 --- a/android/instancing/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/instancing/example.json b/android/instancing/example.json deleted file mode 100644 index 76bf7d50..00000000 --- a/android/instancing/example.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "apkname": "vulkanInstancing", - "directories": { - "shaders": "instancing" - }, - "assets": { - "models": [ - "rock01.dae", - "sphere.obj" - ], - "textures": [ - "texturearray_rocks_bc3_unorm.ktx", - "texturearray_rocks_astc_8x8_unorm.ktx", - "texturearray_rocks_etc2_unorm.ktx", - "lavaplanet_bc3_unorm.ktx", - "lavaplanet_astc_8x8_unorm.ktx", - "lavaplanet_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/layers/README.md b/android/layers/README.md deleted file mode 100644 index 94d8bcea..00000000 --- a/android/layers/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Android validation layers - -Put the pre-built validation layers into the folder for the architecture you're targeting. - -E.g. for armeabi-v7a: - -- ./armeabi-v7a/libVkLayer_core_validation.so -- ./armeabi-v7a/libVkLayer_object_tracker.so -- ... - -After this, build the example you want validation to be enabled for with the "-validation" flag, e.g.: - -``` -build pbrtexture -validation -``` \ No newline at end of file diff --git a/android/mesh/.gitignore b/android/mesh/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/mesh/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/mesh/AndroidManifest.xml b/android/mesh/AndroidManifest.xml deleted file mode 100644 index a6d918f0..00000000 --- a/android/mesh/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/mesh/example.json b/android/mesh/example.json deleted file mode 100644 index 734e36f3..00000000 --- a/android/mesh/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanMesh", - "directories": { - "shaders": "mesh" - }, - "assets": { - "additional": { - "directories": [ - "models/voyager" - ], - "files": [ - "models/voyager/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/multisampling/.gitignore b/android/multisampling/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/multisampling/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/multisampling/AndroidManifest.xml b/android/multisampling/AndroidManifest.xml deleted file mode 100644 index ec1f09ef..00000000 --- a/android/multisampling/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/multisampling/example.json b/android/multisampling/example.json deleted file mode 100644 index 2150538a..00000000 --- a/android/multisampling/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanMultisampling", - "directories": { - "shaders": "mesh" - }, - "assets": { - "additional": { - "directories": [ - "models/voyager" - ], - "files": [ - "models/voyager/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/multithreading/.gitignore b/android/multithreading/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/multithreading/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/multithreading/AndroidManifest.xml b/android/multithreading/AndroidManifest.xml deleted file mode 100644 index 656c5d43..00000000 --- a/android/multithreading/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/multithreading/example.json b/android/multithreading/example.json deleted file mode 100644 index 888d24e0..00000000 --- a/android/multithreading/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "apkname": "vulkanMultithreading", - "directories": { - "shaders": "multithreading" - }, - "assets": { - "models": [ - "retroufo_red_lowpoly.dae", - "sphere.obj" - ] - } -} \ No newline at end of file diff --git a/android/occlusionquery/.gitignore b/android/occlusionquery/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/occlusionquery/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/occlusionquery/AndroidManifest.xml b/android/occlusionquery/AndroidManifest.xml deleted file mode 100644 index cde9428a..00000000 --- a/android/occlusionquery/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/occlusionquery/example.json b/android/occlusionquery/example.json deleted file mode 100644 index f7f4b5d7..00000000 --- a/android/occlusionquery/example.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apkname": "vulkanOcclusionquery", - "directories": { - "shaders": "occlusionquery" - }, - "assets": { - "models": [ - "plane_z.3ds", - "teapot.3ds", - "sphere.3ds" - ] - } -} \ No newline at end of file diff --git a/android/offscreen/.gitignore b/android/offscreen/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/offscreen/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/offscreen/AndroidManifest.xml b/android/offscreen/AndroidManifest.xml deleted file mode 100644 index 2e20569f..00000000 --- a/android/offscreen/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/offscreen/example.json b/android/offscreen/example.json deleted file mode 100644 index db98376e..00000000 --- a/android/offscreen/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apkname": "vulkanOffscreen", - "directories": { - "shaders": "offscreen" - }, - "assets": { - "models": [ - "plane.obj", - "chinesedragon.dae" - ], - "textures": [ - "darkmetal_bc3_unorm.ktx", - "darkmetal_astc_8x8_unorm.ktx", - "darkmetal_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/parallaxmapping/.gitignore b/android/parallaxmapping/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/parallaxmapping/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/parallaxmapping/AndroidManifest.xml b/android/parallaxmapping/AndroidManifest.xml deleted file mode 100644 index 1d700370..00000000 --- a/android/parallaxmapping/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/parallaxmapping/example.json b/android/parallaxmapping/example.json deleted file mode 100644 index 7cc51c3d..00000000 --- a/android/parallaxmapping/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apkname": "vulkanParallaxmapping", - "directories": { - "shaders": "parallaxmapping" - }, - "assets": { - "models": [ - "plane_z.obj" - ], - "textures": [ - "rocks_normal_height_rgba.dds", - "rocks_color_bc3_unorm.dds", - "rocks_color_astc_8x8_unorm.ktx", - "rocks_color_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/particlefire/.gitignore b/android/particlefire/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/particlefire/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/particlefire/AndroidManifest.xml b/android/particlefire/AndroidManifest.xml deleted file mode 100644 index 49383d38..00000000 --- a/android/particlefire/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/particlefire/example.json b/android/particlefire/example.json deleted file mode 100644 index 30f12040..00000000 --- a/android/particlefire/example.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "apkname": "vulkanParticlefire", - "directories": { - "shaders": "particlefire" - }, - "assets": { - "models": [ - "fireplace.obj" - ], - "textures": [ - "particle_fire.ktx", - "particle_smoke.ktx", - "fireplace_normalmap_bc3_unorm.ktx", - "fireplace_normalmap_astc_8x8_unorm.ktx", - "fireplace_normalmap_etc2_unorm.ktx", - "fireplace_colormap_bc3_unorm.ktx", - "fireplace_colormap_astc_8x8_unorm.ktx", - "fireplace_colormap_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/pbrbasic/.gitignore b/android/pbrbasic/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pbrbasic/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pbrbasic/AndroidManifest.xml b/android/pbrbasic/AndroidManifest.xml deleted file mode 100644 index 537ac5a9..00000000 --- a/android/pbrbasic/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pbrbasic/example.json b/android/pbrbasic/example.json deleted file mode 100644 index fc12510a..00000000 --- a/android/pbrbasic/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanPBRBasic", - "directories": { - "shaders": "pbrbasic" - }, - "assets": { - "models": [ - "geosphere.obj", - "teapot.dae", - "torusknot.obj", - "venus.fbx" - ] - } -} \ No newline at end of file diff --git a/android/pbribl/.gitignore b/android/pbribl/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pbribl/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pbribl/AndroidManifest.xml b/android/pbribl/AndroidManifest.xml deleted file mode 100644 index f0673290..00000000 --- a/android/pbribl/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pbribl/example.json b/android/pbribl/example.json deleted file mode 100644 index f2620b81..00000000 --- a/android/pbribl/example.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "apkname": "vulkanPBRIBL", - "directories": { - "shaders": "pbribl" - }, - "assets": { - "models": [ - "cube.obj", - "geosphere.obj", - "teapot.dae", - "torusknot.obj", - "venus.fbx" - ], - "additional" : { - "directories": [ - "textures/hdr" - ], - "files": [ - "textures/hdr/pisa_cube.ktx" - ] - } - } -} \ No newline at end of file diff --git a/android/pbrtexture/.gitignore b/android/pbrtexture/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pbrtexture/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pbrtexture/AndroidManifest.xml b/android/pbrtexture/AndroidManifest.xml deleted file mode 100644 index e43a7d97..00000000 --- a/android/pbrtexture/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pbrtexture/example.json b/android/pbrtexture/example.json deleted file mode 100644 index 32584555..00000000 --- a/android/pbrtexture/example.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "apkname": "vulkanPBRTexture", - "directories": { - "shaders": "pbrtexture" - }, - "assets": { - "models": [ - "cube.obj" - ], - "additional" : { - "directories": ["textures/hdr", "models/cerberus"], - "files": [ - "textures/hdr/gcanyon_cube.ktx", - "models/cerberus/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/pipelines/.gitignore b/android/pipelines/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pipelines/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pipelines/AndroidManifest.xml b/android/pipelines/AndroidManifest.xml deleted file mode 100644 index 65a7b2b9..00000000 --- a/android/pipelines/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pipelines/example.json b/android/pipelines/example.json deleted file mode 100644 index 49856b43..00000000 --- a/android/pipelines/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanPipelines", - "directories": { - "shaders": "pipelines" - }, - "assets": { - "models": [ - "treasure_smooth.dae" - ] - } -} \ No newline at end of file diff --git a/android/pipelinestatistics/.gitignore b/android/pipelinestatistics/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pipelinestatistics/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pipelinestatistics/AndroidManifest.xml b/android/pipelinestatistics/AndroidManifest.xml deleted file mode 100644 index 7e73dc1a..00000000 --- a/android/pipelinestatistics/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pipelinestatistics/example.json b/android/pipelinestatistics/example.json deleted file mode 100644 index ee6eebfd..00000000 --- a/android/pipelinestatistics/example.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "apkname": "vulkanPipelinestatistics", - "directories": { - "shaders": "pipelinestatistics" - }, - "assets": { - "models": [ - "cube.obj", - "geosphere.obj", - "teapot.dae", - "torusknot.obj", - "venus.fbx" - ] - } -} \ No newline at end of file diff --git a/android/pushconstants/.gitignore b/android/pushconstants/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pushconstants/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pushconstants/AndroidManifest.xml b/android/pushconstants/AndroidManifest.xml deleted file mode 100644 index 95bac500..00000000 --- a/android/pushconstants/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pushconstants/example.json b/android/pushconstants/example.json deleted file mode 100644 index ab370ffc..00000000 --- a/android/pushconstants/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanPushconstants", - "directories": { - "shaders": "pushconstants" - }, - "assets": { - "models": [ - "samplescene.dae" - ] - } -} \ No newline at end of file diff --git a/android/pushdescriptors/.gitignore b/android/pushdescriptors/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/pushdescriptors/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/pushdescriptors/AndroidManifest.xml b/android/pushdescriptors/AndroidManifest.xml deleted file mode 100644 index 754e9167..00000000 --- a/android/pushdescriptors/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/pushdescriptors/example.json b/android/pushdescriptors/example.json deleted file mode 100644 index b04a71a3..00000000 --- a/android/pushdescriptors/example.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "apkname": "vulkanPushdescriptors", - "directories": { - "shaders": "pushdescriptors" - }, - "assets": { - "models": [ - "cube.dae" - ], - "textures": [ - "crate01_color_height_rgba.ktx", - "crate02_color_height_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/radialblur/.gitignore b/android/radialblur/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/radialblur/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/radialblur/AndroidManifest.xml b/android/radialblur/AndroidManifest.xml deleted file mode 100644 index 39719255..00000000 --- a/android/radialblur/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/radialblur/example.json b/android/radialblur/example.json deleted file mode 100644 index 871a206f..00000000 --- a/android/radialblur/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanRadialblur", - "directories": { - "shaders": "radialblur" - }, - "assets": { - "models": [ - "glowsphere.dae" - ], - "textures": [ - "particle_gradient_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/raytracing/.gitignore b/android/raytracing/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/raytracing/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/raytracing/AndroidManifest.xml b/android/raytracing/AndroidManifest.xml deleted file mode 100644 index 9af99ae2..00000000 --- a/android/raytracing/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/raytracing/example.json b/android/raytracing/example.json deleted file mode 100644 index daa22f46..00000000 --- a/android/raytracing/example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "apkname": "vulkanRaytracing", - "directories": { - "shaders": "raytracing" - }, - "assets": {} -} \ No newline at end of file diff --git a/android/renderheadless/.gitignore b/android/renderheadless/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/renderheadless/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/renderheadless/AndroidManifest.xml b/android/renderheadless/AndroidManifest.xml deleted file mode 100644 index af83adff..00000000 --- a/android/renderheadless/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/renderheadless/example.json b/android/renderheadless/example.json deleted file mode 100644 index 555f5de0..00000000 --- a/android/renderheadless/example.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "apkname": "vulkanRenderheadless", - "directories": { - "shaders": "renderheadless" - }, - "assets": { - } -} \ No newline at end of file diff --git a/android/scenerendering/.gitignore b/android/scenerendering/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/scenerendering/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/scenerendering/AndroidManifest.xml b/android/scenerendering/AndroidManifest.xml deleted file mode 100644 index 5c4c9c14..00000000 --- a/android/scenerendering/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/scenerendering/example.json b/android/scenerendering/example.json deleted file mode 100644 index bdc959ef..00000000 --- a/android/scenerendering/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanScenerendering", - "directories": { - "shaders": "scenerendering" - }, - "assets": { - "additional" : { - "directories" : [ - "models/sibenik" - ], - "files" : [ - "models/sibenik/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 00000000..89a5af44 --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,61 @@ +include 'examples/:bloom' +include 'examples/:computecloth' +include 'examples/:computecullandlod' +include 'examples/:computeheadless' +include 'examples/:computenbody' +include 'examples/:computeparticles' +include 'examples/:computeshader' +include 'examples/:conservativeraster' +include 'examples/:debugmarker' +include 'examples/:deferred' +include 'examples/:deferredmultisampling' +include 'examples/:deferredshadows' +include 'examples/:descriptorsets' +include 'examples/:displacement' +include 'examples/:distancefieldfonts' +include 'examples/:dynamicuniformbuffer' +include 'examples/:gears' +include 'examples/:geometryshader' +include 'examples/:hdr' +include 'examples/:imgui' +include 'examples/:indirectdraw' +include 'examples/:instancing' +include 'examples/:mesh' +include 'examples/:multisampling' +include 'examples/:multithreading' +include 'examples/:occlusionquery' +include 'examples/:offscreen' +include 'examples/:parallaxmapping' +include 'examples/:particlefire' +include 'examples/:pbrbasic' +include 'examples/:pbribl' +include 'examples/:pbrtexture' +include 'examples/:pipelines' +include 'examples/:pipelinestatistics' +include 'examples/:pushconstants' +include 'examples/:pushdescriptors' +include 'examples/:radialblur' +include 'examples/:raytracing' +include 'examples/:renderheadless' +include 'examples/:scenerendering' +include 'examples/:screenshot' +include 'examples/:shadowmapping' +include 'examples/:shadowmappingcascade' +include 'examples/:shadowmappingomni' +include 'examples/:skeletalanimation' +include 'examples/:specializationconstants' +include 'examples/:sphericalenvmapping' +include 'examples/:ssao' +include 'examples/:stencilbuffer' +include 'examples/:subpasses' +include 'examples/:terraintessellation' +include 'examples/:tessellation' +include 'examples/:textoverlay' +include 'examples/:texture' +include 'examples/:texture3d' +include 'examples/:texturearray' +include 'examples/:texturecubemap' +include 'examples/:texturemipmapgen' +include 'examples/:triangle' +include 'examples/:viewportarray' +include 'examples/:vulkanscene' diff --git a/android/shadowmapping/.gitignore b/android/shadowmapping/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/shadowmapping/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/shadowmapping/AndroidManifest.xml b/android/shadowmapping/AndroidManifest.xml deleted file mode 100644 index 3c925452..00000000 --- a/android/shadowmapping/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/shadowmapping/example.json b/android/shadowmapping/example.json deleted file mode 100644 index edbd65ce..00000000 --- a/android/shadowmapping/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanShadowmapping", - "directories": { - "shaders": "shadowmapping" - }, - "assets": { - "models": [ - "vulkanscene_shadow.dae" - ] - } -} \ No newline at end of file diff --git a/android/shadowmappingcascade/.gitignore b/android/shadowmappingcascade/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/shadowmappingcascade/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/shadowmappingcascade/AndroidManifest.xml b/android/shadowmappingcascade/AndroidManifest.xml deleted file mode 100644 index 5dcde9fc..00000000 --- a/android/shadowmappingcascade/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/shadowmappingcascade/example.json b/android/shadowmappingcascade/example.json deleted file mode 100644 index 4ee83b2c..00000000 --- a/android/shadowmappingcascade/example.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "apkname": "vulkanShadowmappingcascade", - "directories": { - "shaders": "shadowmappingcascade" - }, - "assets": { - "models": [ - "terrain_simple.dae", - "oak_trunk.dae", - "oak_leafs.dae" - ], - "textures": [ - "gridlines.ktx", - "oak_bark.ktx", - "oak_leafs.ktx" - ] - } -} \ No newline at end of file diff --git a/android/shadowmappingomni/.gitignore b/android/shadowmappingomni/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/shadowmappingomni/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/shadowmappingomni/AndroidManifest.xml b/android/shadowmappingomni/AndroidManifest.xml deleted file mode 100644 index c17eb35d..00000000 --- a/android/shadowmappingomni/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/shadowmappingomni/example.json b/android/shadowmappingomni/example.json deleted file mode 100644 index 907f1421..00000000 --- a/android/shadowmappingomni/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "apkname": "vulkanShadowmappingomni", - "directories": { - "shaders": "shadowmapomni" - }, - "assets": { - "models": [ - "shadowscene_fire.dae", - "cube.obj" - ] - } -} \ No newline at end of file diff --git a/android/skeletalanimation/.gitignore b/android/skeletalanimation/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/skeletalanimation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/skeletalanimation/AndroidManifest.xml b/android/skeletalanimation/AndroidManifest.xml deleted file mode 100644 index dfea8a0b..00000000 --- a/android/skeletalanimation/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/skeletalanimation/example.json b/android/skeletalanimation/example.json deleted file mode 100644 index 992ce5cc..00000000 --- a/android/skeletalanimation/example.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "apkname": "vulkanSkeletalanimation", - "directories": { - "shaders": "skeletalanimation" - }, - "assets": { - "models": [ - "goblin.dae", - "plane_z.obj" - ], - "textures": [ - "trail_bc3_unorm.ktx", - "goblin_bc3_unorm.ktx", - "trail_astc_8x8_unorm.ktx", - "goblin_astc_8x8_unorm.ktx", - "trail_etc2_unorm.ktx", - "goblin_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/specializationconstants/.gitignore b/android/specializationconstants/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/specializationconstants/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/specializationconstants/AndroidManifest.xml b/android/specializationconstants/AndroidManifest.xml deleted file mode 100644 index 724e4fb8..00000000 --- a/android/specializationconstants/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/specializationconstants/example.json b/android/specializationconstants/example.json deleted file mode 100644 index e0d87e78..00000000 --- a/android/specializationconstants/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanSpecializationconstants", - "directories": { - "shaders": "specializationconstants" - }, - "assets": { - "models": [ - "color_teapot_spheres.dae" - ], - "textures" : [ - "metalplate_nomips_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/sphericalenvmapping/.gitignore b/android/sphericalenvmapping/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/sphericalenvmapping/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/sphericalenvmapping/AndroidManifest.xml b/android/sphericalenvmapping/AndroidManifest.xml deleted file mode 100644 index 04ac63c3..00000000 --- a/android/sphericalenvmapping/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/sphericalenvmapping/example.json b/android/sphericalenvmapping/example.json deleted file mode 100644 index 0db9c325..00000000 --- a/android/sphericalenvmapping/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanSphericalenvmapping", - "directories": { - "shaders": "sphericalenvmapping" - }, - "assets": { - "models": [ - "chinesedragon.dae" - ], - "textures": [ - "matcap_array_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/ssao/.gitignore b/android/ssao/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/ssao/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/ssao/AndroidManifest.xml b/android/ssao/AndroidManifest.xml deleted file mode 100644 index 049ef2e9..00000000 --- a/android/ssao/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/ssao/example.json b/android/ssao/example.json deleted file mode 100644 index 085ad64c..00000000 --- a/android/ssao/example.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "apkname": "vulkanSSAO", - "directories": { - "shaders": "ssao" - }, - "assets": { - "additional" : { - "directories" : [ - "models/sibenik" - ], - "files" : [ - "models/sibenik/*.*" - ] - } - } -} \ No newline at end of file diff --git a/android/stencilbuffer/.gitignore b/android/stencilbuffer/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/stencilbuffer/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/stencilbuffer/AndroidManifest.xml b/android/stencilbuffer/AndroidManifest.xml deleted file mode 100644 index 56fb2a79..00000000 --- a/android/stencilbuffer/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/stencilbuffer/example.json b/android/stencilbuffer/example.json deleted file mode 100644 index b044522a..00000000 --- a/android/stencilbuffer/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanStencilbuffer", - "directories": { - "shaders": "stencilbuffer" - }, - "assets": { - "models": [ - "venus.fbx" - ] - } -} \ No newline at end of file diff --git a/android/subpasses/.gitignore b/android/subpasses/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/subpasses/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/subpasses/AndroidManifest.xml b/android/subpasses/AndroidManifest.xml deleted file mode 100644 index 868bbdf1..00000000 --- a/android/subpasses/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/subpasses/example.json b/android/subpasses/example.json deleted file mode 100644 index 4ae16f32..00000000 --- a/android/subpasses/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apkname": "vulkanSubpasses", - "directories": { - "shaders": "subpasses" - }, - "assets": { - "models": [ - "samplebuilding.dae", - "samplebuilding_glass.dae" - ], - "textures": [ - "colored_glass_bc3_unorm.ktx", - "colored_glass_etc2_unorm.ktx", - "colored_glass_astc_8x8_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/templates/Android.mk b/android/templates/Android.mk deleted file mode 100644 index 484d9601..00000000 --- a/android/templates/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -LOCAL_PATH := $(call my-dir)/../../%SRC_FOLDER% - -# assimp - -include $(CLEAR_VARS) - -LOCAL_MODULE := assimp -LOCAL_SRC_FILES := $(LOCAL_PATH)/../../libs/assimp/$(TARGET_ARCH_ABI)/libassimp.a -include $(PREBUILT_STATIC_LIBRARY) - -# vulkan example - -DATADIR := $(LOCAL_PATH)/../../data - -include $(CLEAR_VARS) - -LOCAL_MODULE := %APK_NAME% - -PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../examples/%SRC_FOLDER%/*.cpp) -PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.cpp) -PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../external/imgui/imgui.cpp $(LOCAL_PATH)/../../external/imgui/imgui_draw.cpp) - -LOCAL_CPPFLAGS := -std=c++11 -LOCAL_CPPFLAGS += -D__STDC_LIMIT_MACROS -LOCAL_CPPFLAGS += -DVK_NO_PROTOTYPES -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../external/ -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/glm -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/gli -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/assimp -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/imgui -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/ - -LOCAL_SRC_FILES := $(PROJECT_FILES) - -LOCAL_LDLIBS := -landroid -llog -lz - -LOCAL_DISABLE_FORMAT_STRING_CHECKS := true -LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true - -LOCAL_STATIC_LIBRARIES += android_native_app_glue -LOCAL_STATIC_LIBRARIES += cpufeatures -LOCAL_STATIC_LIBRARIES += libassimp - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module, android/native_app_glue) -$(call import-module, android/cpufeatures) diff --git a/android/templates/Application.mk b/android/templates/Application.mk deleted file mode 100644 index 3bedee99..00000000 --- a/android/templates/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -APP_PLATFORM := android-19 -APP_ABI := armeabi-v7a -APP_STL := c++_static -APP_CPPFLAGS := -std=c++11 -APP_CPPFLAGS += -fexceptions -NDK_TOOLCHAIN_VERSION := clang - diff --git a/android/terraintessellation/.gitignore b/android/terraintessellation/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/terraintessellation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/terraintessellation/AndroidManifest.xml b/android/terraintessellation/AndroidManifest.xml deleted file mode 100644 index 943a86a0..00000000 --- a/android/terraintessellation/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/terraintessellation/example.json b/android/terraintessellation/example.json deleted file mode 100644 index 94e8d7e4..00000000 --- a/android/terraintessellation/example.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "apkname": "vulkanTerraintessellation", - "directories": { - "shaders": "terraintessellation" - }, - "assets": { - "models": [ - "geosphere.obj" - ], - "textures": [ - "skysphere_bc3_unorm.ktx", - "skysphere_astc_8x8_unorm.ktx", - "skysphere_etc2_unorm.ktx", - "terrain_texturearray_bc3_unorm.ktx", - "terrain_texturearray_astc_8x8_unorm.ktx", - "terrain_texturearray_etc2_unorm.ktx", - "terrain_heightmap_r16.ktx" - ] - } -} \ No newline at end of file diff --git a/android/tessellation/.gitignore b/android/tessellation/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/tessellation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/tessellation/AndroidManifest.xml b/android/tessellation/AndroidManifest.xml deleted file mode 100644 index 4aab2ae7..00000000 --- a/android/tessellation/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/tessellation/example.json b/android/tessellation/example.json deleted file mode 100644 index 54d5edeb..00000000 --- a/android/tessellation/example.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "apkname": "vulkanTessellation", - "directories": { - "shaders": "tessellation" - }, - "assets": { - "textures": [ - "deer_bc3_unorm.ktx", - "deer_astc_8x8_unorm.ktx", - "deer_etc2_unorm.ktx" - ], - "additional": { - "directories": [ - "models/lowpoly" - ], - "files" : [ - "models/lowpoly/deer.dae" - ] - } - } -} \ No newline at end of file diff --git a/android/textoverlay/.gitignore b/android/textoverlay/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/textoverlay/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/textoverlay/AndroidManifest.xml b/android/textoverlay/AndroidManifest.xml deleted file mode 100644 index 3b726bca..00000000 --- a/android/textoverlay/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/textoverlay/example.json b/android/textoverlay/example.json deleted file mode 100644 index cc973316..00000000 --- a/android/textoverlay/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanTextoverlay", - "directories": { - "shaders": "textoverlay" - }, - "assets": { - "models": [ - "cube.dae" - ] - } -} \ No newline at end of file diff --git a/android/texture/.gitignore b/android/texture/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/texture/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/texture/AndroidManifest.xml b/android/texture/AndroidManifest.xml deleted file mode 100644 index 000250a7..00000000 --- a/android/texture/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/texture/example.json b/android/texture/example.json deleted file mode 100644 index 24ec5bb7..00000000 --- a/android/texture/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanTexture", - "directories": { - "shaders": "texture" - }, - "assets": { - "textures": [ - "metalplate01_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/texture3d/.gitignore b/android/texture3d/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/texture3d/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/texture3d/AndroidManifest.xml b/android/texture3d/AndroidManifest.xml deleted file mode 100644 index 3c0030b8..00000000 --- a/android/texture3d/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/texture3d/example.json b/android/texture3d/example.json deleted file mode 100644 index 470e6e74..00000000 --- a/android/texture3d/example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "apkname": "vulkanTexture3d", - "directories": { - "shaders": "texture3d" - }, - "assets": {} -} \ No newline at end of file diff --git a/android/texturearray/.gitignore b/android/texturearray/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/texturearray/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/texturearray/AndroidManifest.xml b/android/texturearray/AndroidManifest.xml deleted file mode 100644 index 2964192a..00000000 --- a/android/texturearray/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/texturearray/example.json b/android/texturearray/example.json deleted file mode 100644 index 8bffb1a9..00000000 --- a/android/texturearray/example.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apkname": "vulkanTexturearray", - "directories": { - "shaders": "texturearray" - }, - "assets": { - "textures": [ - "texturearray_bc3_unorm.ktx", - "texturearray_astc_8x8_unorm.ktx", - "texturearray_etc2_unorm.ktx" - ] - } -} \ No newline at end of file diff --git a/android/texturecubemap/.gitignore b/android/texturecubemap/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/texturecubemap/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/texturecubemap/AndroidManifest.xml b/android/texturecubemap/AndroidManifest.xml deleted file mode 100644 index 9cf18008..00000000 --- a/android/texturecubemap/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/texturecubemap/example.json b/android/texturecubemap/example.json deleted file mode 100644 index 71ce4787..00000000 --- a/android/texturecubemap/example.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "apkname": "vulkanTexturecubemap", - "directories": { - "shaders": "texturecubemap" - }, - "assets": { - "models": [ - "sphere.obj", - "teapot.dae", - "torusknot.obj", - "cube.obj" - ], - "textures": [ - "cubemap_yokohama_bc3_unorm.ktx", - "cubemap_yokohama_etc2_unorm.ktx", - "cubemap_yokohama_astc_8x8_unorm.ktx" - ] - } -} diff --git a/android/texturemipmapgen/.gitignore b/android/texturemipmapgen/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/texturemipmapgen/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/texturemipmapgen/AndroidManifest.xml b/android/texturemipmapgen/AndroidManifest.xml deleted file mode 100644 index 0eea6e7e..00000000 --- a/android/texturemipmapgen/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/texturemipmapgen/example.json b/android/texturemipmapgen/example.json deleted file mode 100644 index b54f2dd0..00000000 --- a/android/texturemipmapgen/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "apkname": "vulkanTexturemipmapgen", - "directories": { - "shaders": "texturemipmapgen" - }, - "assets": { - "models": [ - "tunnel_cylinder.dae" - ], - "textures": [ - "metalplate_nomips_rgba.ktx" - ] - } -} \ No newline at end of file diff --git a/android/triangle/.gitignore b/android/triangle/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/triangle/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/triangle/AndroidManifest.xml b/android/triangle/AndroidManifest.xml deleted file mode 100644 index 3a80cf84..00000000 --- a/android/triangle/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/triangle/example.json b/android/triangle/example.json deleted file mode 100644 index 081ad343..00000000 --- a/android/triangle/example.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "apkname": "vulkanTriangle", - "directories": { - "shaders": "triangle" - } -} \ No newline at end of file diff --git a/android/uninstall-all.py b/android/uninstall-all.py deleted file mode 100755 index 9ec637ce..00000000 --- a/android/uninstall-all.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python3 - -# Remove all examples from connected device(s) -import subprocess -import sys - -APP_NAMES = [ - "de.saschawillems.vulkanBloom", - "de.saschawillems.vulkanComputecullandlod", - "de.saschawillems.vulkanComputecloth", - "de.saschawillems.vulkanComputeheadless", - "de.saschawillems.vulkanComputenbody", - "de.saschawillems.vulkanComputeparticles", - "de.saschawillems.vulkanComputeshader", - "de.saschawillems.vulkanDebugmarker", - "de.saschawillems.vulkanDeferred", - "de.saschawillems.vulkanDeferredmulitsampling", - "de.saschawillems.vulkanDeferredshadows", - "de.saschawillems.vulkanDisplacement", - "de.saschawillems.vulkanDistancefieldfonts", - "de.saschawillems.vulkanDynamicuniformbuffer", - "de.saschawillems.vulkanGears", - "de.saschawillems.vulkanGeometryshader", - "de.saschawillems.vulkanHDR", - "de.saschawillems.vulkanImGui", - "de.saschawillems.vulkanIndirectdraw", - "de.saschawillems.vulkanInstancing", - "de.saschawillems.vulkanMesh", - "de.saschawillems.vulkanMultisampling", - "de.saschawillems.vulkanMultithreading", - "de.saschawillems.vulkanOcclusionquery", - "de.saschawillems.vulkanOffscreen", - "de.saschawillems.vulkanPBRBasic", - "de.saschawillems.vulkanPBRIBL", - "de.saschawillems.vulkanPBRTexture", - "de.saschawillems.vulkanParallaxmapping", - "de.saschawillems.vulkanParticlefire", - "de.saschawillems.vulkanPipelines", - "de.saschawillems.vulkanPipelinestatistics", - "de.saschawillems.vulkanPushconstants", - "de.saschawillems.vulkanRadialblur", - "de.saschawillems.vulkanRaytracing", - "de.saschawillems.vulkanRenderheadless", - "de.saschawillems.vulkanSSAO", - "de.saschawillems.vulkanScenerendering", - "de.saschawillems.vulkanShadowmapping", - "de.saschawillems.vulkanShadowmappingomni", - "de.saschawillems.vulkanShadowmappingcascade" - "de.saschawillems.vulkanSkeletalanimation", - "de.saschawillems.vulkanSpecializationconstants", - "de.saschawillems.vulkanSphericalenvmapping", - "de.saschawillems.vulkanStencilbuffer", - "de.saschawillems.vulkanSubpasses", - "de.saschawillems.vulkanTerraintessellation", - "de.saschawillems.vulkanTessellation", - "de.saschawillems.vulkanTextoverlay", - "de.saschawillems.vulkanTexture", - "de.saschawillems.vulkanTexture3d", - "de.saschawillems.vulkanTexturearray", - "de.saschawillems.vulkanTexturecubemap", - "de.saschawillems.vulkanTexturemipmapgen", - "de.saschawillems.vulkanTriangle", - "de.saschawillems.vulkanViewportarray", - "de.saschawillems.vulkanVulkanscene" -] - -CURR_INDEX = 0 - -answer = input("Uninstall all vulkan examples from attached device (Y/N)").lower() == 'y' -if answer: - for app in APP_NAMES: - print("Uninstalling %s (%d/%d)" % (app, CURR_INDEX, len(APP_NAMES))) - subprocess.call("adb uninstall %s" % (app)) - CURR_INDEX += 1 - diff --git a/android/viewportarray/.gitignore b/android/viewportarray/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/viewportarray/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/viewportarray/AndroidManifest.xml b/android/viewportarray/AndroidManifest.xml deleted file mode 100644 index e632dd83..00000000 --- a/android/viewportarray/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/viewportarray/example.json b/android/viewportarray/example.json deleted file mode 100644 index e4a7ce92..00000000 --- a/android/viewportarray/example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "apkname": "vulkanViewportarray", - "directories": { - "shaders": "viewportarray" - }, - "assets": { - "models": [ - "sampleroom.dae" - ] - } -} \ No newline at end of file diff --git a/android/vulkanscene/.gitignore b/android/vulkanscene/.gitignore deleted file mode 100644 index 7a5d249c..00000000 --- a/android/vulkanscene/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/assets/ -/res/ -/bin/ -/libs/ -/obj/ -/build.xml -/local.properties -/project.properties -/proguard-project.txt -*.apk \ No newline at end of file diff --git a/android/vulkanscene/AndroidManifest.xml b/android/vulkanscene/AndroidManifest.xml deleted file mode 100644 index af49f7e5..00000000 --- a/android/vulkanscene/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/android/vulkanscene/example.json b/android/vulkanscene/example.json deleted file mode 100644 index 7820ea2e..00000000 --- a/android/vulkanscene/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apkname": "vulkanVulkanscene", - "directories": { - "shaders": "vulkanscene" - }, - "assets": { - "models": [ - "vulkanscenelogos.dae", - "vulkanscenebackground.dae", - "vulkanscenemodels.dae", - "cube.obj" - ], - "textures": [ - "cubemap_vulkan.ktx" - ] - } -} \ No newline at end of file diff --git a/base/VulkanAndroid.cpp b/base/VulkanAndroid.cpp index aba260ae..a0aa2b8c 100644 --- a/base/VulkanAndroid.cpp +++ b/base/VulkanAndroid.cpp @@ -11,6 +11,7 @@ #if defined(__ANDROID__) #include #include + #include android_app* androidApp; @@ -292,6 +293,23 @@ namespace vks vks::android::screenDensity = AConfiguration_getDensity(config); AConfiguration_delete(config); } + + // Displays a native alert dialog using JNI + void showAlert(const char* message) { + JNIEnv* jni; + androidApp->activity->vm->AttachCurrentThread(&jni, NULL); + + jstring jmessage = jni->NewStringUTF(message); + + jclass clazz = jni->GetObjectClass(androidApp->activity->clazz); + // Signature has to match java implementation (arguments) + jmethodID methodID = jni->GetMethodID(clazz, "showAlert", "(Ljava/lang/String;)V"); + jni->CallVoidMethod(androidApp->activity->clazz, methodID, jmessage); + jni->DeleteLocalRef(jmessage); + + androidApp->activity->vm->DetachCurrentThread(); + return; + } } } diff --git a/base/VulkanAndroid.h b/base/VulkanAndroid.h index 372b36ef..f3a2d68c 100644 --- a/base/VulkanAndroid.h +++ b/base/VulkanAndroid.h @@ -26,6 +26,7 @@ #include #include #include +#include // Missing from the NDK namespace std @@ -169,6 +170,7 @@ namespace vks void loadVulkanFunctions(VkInstance instance); void freeVulkanLibrary(); void getDeviceConfig(); + void showAlert(const char* message); } } diff --git a/base/VulkanTools.cpp b/base/VulkanTools.cpp index 12f6c101..8d43d660 100644 --- a/base/VulkanTools.cpp +++ b/base/VulkanTools.cpp @@ -268,11 +268,14 @@ namespace vks if (!errorModeSilent) { MessageBox(NULL, message.c_str(), NULL, MB_OK | MB_ICONERROR); } -#elif defined(__ANDROID__) - LOGE("Fatal error: %s", message.c_str()); +#elif defined(__ANDROID__) + LOGE("Fatal error: %s", message.c_str()); + vks::android::showAlert(message.c_str()); #endif std::cerr << message << "\n"; +#if !defined(__ANDROID__) exit(exitCode); +#endif } void exitFatal(std::string message, VkResult resultCode) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 9fc7dd09..9695724e 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -333,6 +333,7 @@ void VulkanExampleBase::renderLoop() // Exit loop, example will be destroyed in application main if (destroy) { + ANativeActivity_finish(androidApp->activity); break; } @@ -555,8 +556,10 @@ void VulkanExampleBase::renderLoop() updateOverlay(); } #endif - // Flush device to make sure all resources can be freed - vkDeviceWaitIdle(device); + // Flush device to make sure all resources can be freed + if (device != VK_NULL_HANDLE) { + vkDeviceWaitIdle(device); + } } void VulkanExampleBase::updateOverlay() @@ -831,7 +834,7 @@ VulkanExampleBase::~VulkanExampleBase() #endif } -void VulkanExampleBase::initVulkan() +bool VulkanExampleBase::initVulkan() { VkResult err; @@ -839,6 +842,7 @@ void VulkanExampleBase::initVulkan() err = createInstance(settings.validation); if (err) { vks::tools::exitFatal("Could not create Vulkan instance : \n" + vks::tools::errorString(err), err); + return false; } #if defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -865,6 +869,7 @@ void VulkanExampleBase::initVulkan() err = vkEnumeratePhysicalDevices(instance, &gpuCount, physicalDevices.data()); if (err) { vks::tools::exitFatal("Could not enumerate physical devices : \n" + vks::tools::errorString(err), err); + return false; } // GPU selection @@ -940,6 +945,7 @@ void VulkanExampleBase::initVulkan() VkResult res = vulkanDevice->createLogicalDevice(enabledFeatures, enabledDeviceExtensions); if (res != VK_SUCCESS) { vks::tools::exitFatal("Could not create Vulkan device: \n" + vks::tools::errorString(res), res); + return false; } device = vulkanDevice->logicalDevice; @@ -989,6 +995,8 @@ void VulkanExampleBase::initVulkan() }; LOGD("androidProduct = %s", androidProduct.c_str()); #endif + + return true; } #if defined(_WIN32) @@ -1419,9 +1427,14 @@ void VulkanExampleBase::handleAppCommand(android_app * app, int32_t cmd) LOGD("APP_CMD_INIT_WINDOW"); if (androidApp->window != NULL) { - vulkanExample->initVulkan(); - vulkanExample->prepare(); - assert(vulkanExample->prepared); + if (vulkanExample->initVulkan()) { + vulkanExample->prepare(); + assert(vulkanExample->prepared); + } + else { + LOGE("Could not initialize Vulkan, exiting!"); + androidApp->destroyRequested = 1; + } } else { @@ -1439,7 +1452,9 @@ void VulkanExampleBase::handleAppCommand(android_app * app, int32_t cmd) case APP_CMD_TERM_WINDOW: // Window is hidden or closed, clean up resources LOGD("APP_CMD_TERM_WINDOW"); - vulkanExample->swapChain.cleanup(); + if (vulkanExample->prepared) { + vulkanExample->swapChain.cleanup(); + } break; } } diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 547dd58d..efe7978d 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -251,7 +251,7 @@ public: virtual ~VulkanExampleBase(); // Setup the vulkan instance, enable required extensions and connect to the physical device (GPU) - void initVulkan(); + bool initVulkan(); #if defined(_WIN32) void setupConsole(std::string title); @@ -428,12 +428,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) \ } #elif defined(VK_USE_PLATFORM_ANDROID_KHR) // Android entry point -// A note on app_dummy(): This is required as the compiler may otherwise remove the main entry point of the application #define VULKAN_EXAMPLE_MAIN() \ VulkanExample *vulkanExample; \ void android_main(android_app* state) \ { \ - app_dummy(); \ vulkanExample = new VulkanExample(); \ state->userData = vulkanExample; \ state->onAppCmd = VulkanExample::handleAppCommand; \ diff --git a/examples/computeheadless/computeheadless.cpp b/examples/computeheadless/computeheadless.cpp index cda2deb1..9e6b13f3 100644 --- a/examples/computeheadless/computeheadless.cpp +++ b/examples/computeheadless/computeheadless.cpp @@ -76,7 +76,7 @@ public: VkPipeline pipeline; VkShaderModule shaderModule; - VkDebugReportCallbackEXT debugReportCallback; + VkDebugReportCallbackEXT debugReportCallback{}; VkResult createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkBuffer *buffer, VkDeviceMemory *memory, VkDeviceSize size, void *data = nullptr) { @@ -142,18 +142,41 @@ public: uint32_t layerCount = 0; #if defined(VK_USE_PLATFORM_ANDROID_KHR) - const char* validationlayers[] = { "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker","VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects" }; + const char* validationLayers[] = { "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker","VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects" }; layerCount = 6; #else - const char* validationlayers[] = { "VK_LAYER_LUNARG_standard_validation" }; + const char* validationLayers[] = { "VK_LAYER_LUNARG_standard_validation" }; layerCount = 1; #endif #if DEBUG - instanceCreateInfo.ppEnabledLayerNames = validationlayers; - const char* validationExt = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; - instanceCreateInfo.enabledLayerCount = layerCount; - instanceCreateInfo.enabledExtensionCount = 1; - instanceCreateInfo.ppEnabledExtensionNames = &validationExt; + // Check if layers are available + uint32_t instanceLayerCount; + vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr); + std::vector instanceLayers(instanceLayerCount); + vkEnumerateInstanceLayerProperties(&instanceLayerCount, instanceLayers.data()); + + bool layersAvailable = true; + for (auto layerName : validationLayers) { + bool layerAvailable = false; + for (auto instanceLayer : instanceLayers) { + if (strcmp(instanceLayer.layerName, layerName) == 0) { + layerAvailable = true; + break; + } + } + if (!layerAvailable) { + layersAvailable = false; + break; + } + } + + if (layersAvailable) { + instanceCreateInfo.ppEnabledLayerNames = validationLayers; + const char *validationExt = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; + instanceCreateInfo.enabledLayerCount = layerCount; + instanceCreateInfo.enabledExtensionCount = 1; + instanceCreateInfo.ppEnabledExtensionNames = &validationExt; + } #endif VK_CHECK_RESULT(vkCreateInstance(&instanceCreateInfo, nullptr, &instance)); @@ -161,15 +184,17 @@ public: vks::android::loadVulkanFunctions(instance); #endif #if DEBUG - VkDebugReportCallbackCreateInfoEXT debugReportCreateInfo = {}; - debugReportCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; - debugReportCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT; - debugReportCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback; + if (layersAvailable) { + VkDebugReportCallbackCreateInfoEXT debugReportCreateInfo = {}; + debugReportCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; + debugReportCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT; + debugReportCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback; - // We have to explicitly load this function. - PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT")); - assert(vkCreateDebugReportCallbackEXT); - VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT(instance, &debugReportCreateInfo, nullptr, &debugReportCallback)); + // We have to explicitly load this function. + PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT")); + assert(vkCreateDebugReportCallbackEXT); + VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT(instance, &debugReportCreateInfo, nullptr, &debugReportCallback)); + } #endif /* @@ -492,9 +517,11 @@ public: vkDestroyShaderModule(device, shaderModule, nullptr); vkDestroyDevice(device, nullptr); #if DEBUG - PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT")); - assert(vkDestroyDebugReportCallback); - vkDestroyDebugReportCallback(instance, debugReportCallback, nullptr); + if (debugReportCallback) { + PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT")); + assert(vkDestroyDebugReportCallback); + vkDestroyDebugReportCallback(instance, debugReportCallback, nullptr); + } #endif vkDestroyInstance(instance, nullptr); } @@ -509,7 +536,6 @@ void handleAppCommand(android_app * app, int32_t cmd) { } } void android_main(android_app* state) { - app_dummy(); androidapp = state; androidapp->onAppCmd = handleAppCommand; int ident, events; diff --git a/examples/imgui/main.cpp b/examples/imgui/main.cpp index 158b675c..572516df 100644 --- a/examples/imgui/main.cpp +++ b/examples/imgui/main.cpp @@ -343,8 +343,8 @@ public: ImVec4 clear_color = ImColor(114, 144, 154); static float f = 0.0f; - ImGui::Text(example->title.c_str()); - ImGui::Text(device->properties.deviceName); + ImGui::TextUnformatted(example->title.c_str()); + ImGui::TextUnformatted(device->properties.deviceName); // Update frame time display if (updateFrameGraph) { diff --git a/examples/instancing/instancing.cpp b/examples/instancing/instancing.cpp index 6d87ef99..6e0122a9 100644 --- a/examples/instancing/instancing.cpp +++ b/examples/instancing/instancing.cpp @@ -28,7 +28,11 @@ #define VERTEX_BUFFER_BIND_ID 0 #define INSTANCE_BUFFER_BIND_ID 1 #define ENABLE_VALIDATION false +#if defined(__ANDROID__) +#define INSTANCE_COUNT 4096 +#else #define INSTANCE_COUNT 8192 +#endif class VulkanExample : public VulkanExampleBase { diff --git a/examples/offscreen/offscreen.cpp b/examples/offscreen/offscreen.cpp index 73f7ad58..a7887677 100644 --- a/examples/offscreen/offscreen.cpp +++ b/examples/offscreen/offscreen.cpp @@ -125,7 +125,6 @@ public: timerSpeed *= 0.25f; title = "Offscreen rendering"; settings.overlay = true; - enabledFeatures.shaderClipDistance = VK_TRUE; } ~VulkanExample() diff --git a/examples/renderheadless/renderheadless.cpp b/examples/renderheadless/renderheadless.cpp index cfd18369..a9fb704a 100644 --- a/examples/renderheadless/renderheadless.cpp +++ b/examples/renderheadless/renderheadless.cpp @@ -89,7 +89,7 @@ public: FrameBufferAttachment colorAttachment, depthAttachment; VkRenderPass renderPass; - VkDebugReportCallbackEXT debugReportCallback; + VkDebugReportCallbackEXT debugReportCallback{}; uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) { VkPhysicalDeviceMemoryProperties deviceMemoryProperties; @@ -172,18 +172,41 @@ public: uint32_t layerCount = 0; #if defined(VK_USE_PLATFORM_ANDROID_KHR) - const char* validationlayers[] = { "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker","VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects" }; + const char* validationLayers[] = { "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker","VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects" }; layerCount = 6; #else - const char* validationlayers[] = { "VK_LAYER_LUNARG_standard_validation" }; + const char* validationLayers[] = { "VK_LAYER_LUNARG_standard_validation" }; layerCount = 1; #endif #if DEBUG - instanceCreateInfo.ppEnabledLayerNames = validationlayers; - const char* validationExt = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; - instanceCreateInfo.enabledLayerCount = layerCount; - instanceCreateInfo.enabledExtensionCount = 1; - instanceCreateInfo.ppEnabledExtensionNames = &validationExt; + // Check if layers are available + uint32_t instanceLayerCount; + vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr); + std::vector instanceLayers(instanceLayerCount); + vkEnumerateInstanceLayerProperties(&instanceLayerCount, instanceLayers.data()); + + bool layersAvailable = true; + for (auto layerName : validationLayers) { + bool layerAvailable = false; + for (auto instanceLayer : instanceLayers) { + if (strcmp(instanceLayer.layerName, layerName) == 0) { + layerAvailable = true; + break; + } + } + if (!layerAvailable) { + layersAvailable = false; + break; + } + } + + if (layersAvailable) { + instanceCreateInfo.ppEnabledLayerNames = validationLayers; + const char *validationExt = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; + instanceCreateInfo.enabledLayerCount = layerCount; + instanceCreateInfo.enabledExtensionCount = 1; + instanceCreateInfo.ppEnabledExtensionNames = &validationExt; + } #endif VK_CHECK_RESULT(vkCreateInstance(&instanceCreateInfo, nullptr, &instance)); @@ -191,15 +214,17 @@ public: vks::android::loadVulkanFunctions(instance); #endif #if DEBUG - VkDebugReportCallbackCreateInfoEXT debugReportCreateInfo = {}; - debugReportCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; - debugReportCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT; - debugReportCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback; + if (layersAvailable) { + VkDebugReportCallbackCreateInfoEXT debugReportCreateInfo = {}; + debugReportCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; + debugReportCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT; + debugReportCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback; - // We have to explicitly load this function. - PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT")); - assert(vkCreateDebugReportCallbackEXT); - VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT(instance, &debugReportCreateInfo, nullptr, &debugReportCallback)); + // We have to explicitly load this function. + PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT")); + assert(vkCreateDebugReportCallbackEXT); + VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT(instance, &debugReportCreateInfo, nullptr, &debugReportCallback)); + } #endif /* @@ -824,9 +849,11 @@ public: } vkDestroyDevice(device, nullptr); #if DEBUG - PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT")); - assert(vkDestroyDebugReportCallback); - vkDestroyDebugReportCallback(instance, debugReportCallback, nullptr); + if (debugReportCallback) { + PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT")); + assert(vkDestroyDebugReportCallback); + vkDestroyDebugReportCallback(instance, debugReportCallback, nullptr); + } #endif vkDestroyInstance(instance, nullptr); #if defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -844,7 +871,6 @@ void handleAppCommand(android_app * app, int32_t cmd) { } } void android_main(android_app* state) { - app_dummy(); androidapp = state; androidapp->onAppCmd = handleAppCommand; int ident, events; diff --git a/examples/triangle/triangle.cpp b/examples/triangle/triangle.cpp index 095a472d..5e53500f 100644 --- a/examples/triangle/triangle.cpp +++ b/examples/triangle/triangle.cpp @@ -1123,11 +1123,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLin #elif defined(__ANDROID__) // Android entry point -// A note on app_dummy(): This is required as the compiler may otherwise remove the main entry point of the application VulkanExample *vulkanExample; void android_main(android_app* state) { - app_dummy(); vulkanExample = new VulkanExample(); state->userData = vulkanExample; state->onAppCmd = VulkanExample::handleAppCommand;