diff --git a/android/multisampling/AndroidManifest.xml b/android/multisampling/AndroidManifest.xml index 6df3d3c2..ec1f09ef 100644 --- a/android/multisampling/AndroidManifest.xml +++ b/android/multisampling/AndroidManifest.xml @@ -15,6 +15,7 @@ android:label="Multisampling" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" + android:screenOrientation="landscape" android:configChanges="orientation|screenSize|keyboardHidden"> diff --git a/android/multisampling/build.bat b/android/multisampling/build.bat deleted file mode 100644 index aec7b4d1..00000000 --- a/android/multisampling/build.bat +++ /dev/null @@ -1,24 +0,0 @@ -cd jni -call ndk-build -if %ERRORLEVEL% EQU 0 ( - echo ndk-build has failed, build cancelled - cd.. - - mkdir "assets\shaders\base" - xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y - - - mkdir "assets\shaders\mesh" - xcopy "..\..\data\shaders\mesh\*.spv" "assets\shaders\mesh" /Y - - mkdir "assets\models\voyager" - xcopy "..\..\data\models\voyager\*.*" "assets\models\voyager" /Y - - mkdir "res\drawable" - xcopy "..\..\android\images\icon.png" "res\drawable" /Y - - call ant debug -Dout.final.file=vulkanMultisampling.apk -) ELSE ( - echo error : ndk-build failed with errors! - cd.. -) diff --git a/android/multisampling/build.py b/android/multisampling/build.py new file mode 100644 index 00000000..06b6fe2a --- /dev/null +++ b/android/multisampling/build.py @@ -0,0 +1,47 @@ +import os +import shutil +import subprocess +import sys +import glob + +APK_NAME = "vulkanMultisampling" +SHADER_DIR = "mesh" +ASSETS_MODELS = ["voyager.dae"] +ASSETS_TEXTURES = ["voyager_astc_8x8_unorm.ktx", "voyager_bc3_unorm.ktx", "voyager_etc2_unorm.ktx"] + +if subprocess.call("ndk-build", shell=True) == 0: + print("Build successful") + + # Assets + os.makedirs("./assets/shaders", exist_ok=True) + os.makedirs("./assets/shaders/base", exist_ok=True) + os.makedirs("./assets/shaders/%s" % SHADER_DIR, exist_ok=True) + os.makedirs("./assets/models/voyager", exist_ok=True) + os.makedirs("./res/drawable", exist_ok=True) + + # Shaders + # Base + for file in glob.glob("../../data/shaders/base/*.spv"): + shutil.copy(file, "./assets/shaders/base") + # Sample + for file in glob.glob("../../data/shaders/%s/*.spv" %SHADER_DIR): + shutil.copy(file, "./assets/shaders/%s" % SHADER_DIR) + # Textures + for file in ASSETS_TEXTURES: + shutil.copy("../../data/models/voyager/%s" % file, "./assets/models/voyager") + # Models + for file in ASSETS_MODELS: + shutil.copy("../../data/models/voyager/%s" % file, "./assets/models/voyager") + + # Icon + shutil.copy("../../android/images/icon.png", "./res/drawable") + + if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0: + if len(sys.argv) > 1: + if sys.argv[1] == "-deploy": + if subprocess.call("adb install -r %s.apk" % APK_NAME, shell=True) != 0: + print("Could not deploy to device!") + else: + print("Error during build process!") +else: + print("Error building project!") \ No newline at end of file diff --git a/multisampling/multisampling.cpp b/multisampling/multisampling.cpp index 92247b47..7229bcd7 100644 --- a/multisampling/multisampling.cpp +++ b/multisampling/multisampling.cpp @@ -416,7 +416,18 @@ public: void loadAssets() { models.example.loadFromFile(getAssetPath() + "models/voyager/voyager.dae", vertexLayout, 1.0f, vulkanDevice, queue); - textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + if (deviceFeatures.textureCompressionBC) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + } + else if (deviceFeatures.textureCompressionASTC_LDR) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue); + } + else if (deviceFeatures.textureCompressionETC2) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, vulkanDevice, queue); + } + else { + vks::tools::exitFatal("Device does not support any compressed texture format!", "Error"); + } } void setupVertexDescriptions()