diff --git a/android/tessellation/AndroidManifest.xml b/android/tessellation/AndroidManifest.xml index b1220378..4aab2ae7 100644 --- a/android/tessellation/AndroidManifest.xml +++ b/android/tessellation/AndroidManifest.xml @@ -15,6 +15,7 @@ android:label="Tessellation" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" + android:screenOrientation="landscape" android:configChanges="orientation|screenSize|keyboardHidden"> diff --git a/android/tessellation/build.bat b/android/tessellation/build.bat deleted file mode 100644 index 8026ebca..00000000 --- a/android/tessellation/build.bat +++ /dev/null @@ -1,26 +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\tessellation" - xcopy "..\..\data\shaders\tessellation\*.spv" "assets\shaders\tessellation" /Y - - mkdir "assets\textures" - xcopy "..\..\data\textures\deer.ktx" "assets\textures" /Y - - mkdir "assets\models\lowpoly" - xcopy "..\..\data\models\lowpoly\deer.dae" "assets\models\lowpoly" /Y - - mkdir "res\drawable" - xcopy "..\..\android\images\icon.png" "res\drawable" /Y - - call ant debug -Dout.final.file=vulkanTessellation.apk -) ELSE ( - echo error : ndk-build failed with errors! - cd.. -) diff --git a/android/tessellation/build.py b/android/tessellation/build.py new file mode 100644 index 00000000..5ac1297d --- /dev/null +++ b/android/tessellation/build.py @@ -0,0 +1,47 @@ +import os +import shutil +import subprocess +import sys +import glob + +APK_NAME = "vulkanTessellation" +SHADER_DIR = "tessellation" +ASSETS_MODELS = ["deer.dae"] +ASSETS_TEXTURES = ["deer_bc3_unorm.ktx", "deer_astc_8x8_unorm.ktx", "deer_etc2_unorm.ktx"] + +if subprocess.call("ndk-build", shell=True) == 0: + print("Build successful") + + # Assets + os.makedirs("./assets/shaders/base", exist_ok=True) + os.makedirs("./assets/shaders/%s" % SHADER_DIR, exist_ok=True) + os.makedirs("./assets/textures", exist_ok=True) + os.makedirs("./assets/models/lowpoly", 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/textures/%s" % file, "./assets/textures") + # Models + for file in ASSETS_MODELS: + shutil.copy("../../data/models/lowpoly/%s" % file, "./assets/models/lowpoly") + + # Icon + shutil.copy("../../android/images/icon.png", "./res/drawable") + + if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0: + for arg in sys.argv[1:]: + if arg == "-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/data/textures/deer_astc_8x8_unorm.ktx b/data/textures/deer_astc_8x8_unorm.ktx new file mode 100644 index 00000000..7bcf98d9 Binary files /dev/null and b/data/textures/deer_astc_8x8_unorm.ktx differ diff --git a/data/textures/deer.ktx b/data/textures/deer_bc3_unorm.ktx similarity index 100% rename from data/textures/deer.ktx rename to data/textures/deer_bc3_unorm.ktx diff --git a/data/textures/deer_etc2_unorm.ktx b/data/textures/deer_etc2_unorm.ktx new file mode 100644 index 00000000..5a26aa4c Binary files /dev/null and b/data/textures/deer_etc2_unorm.ktx differ diff --git a/data/textures/pattern_57_diffuse_bc3.ktx b/data/textures/pattern_57_diffuse_bc3.ktx deleted file mode 100644 index f9b03033..00000000 Binary files a/data/textures/pattern_57_diffuse_bc3.ktx and /dev/null differ diff --git a/data/textures/pattern_57_normal_bc3.ktx b/data/textures/pattern_57_normal_bc3.ktx deleted file mode 100644 index fca0470f..00000000 Binary files a/data/textures/pattern_57_normal_bc3.ktx and /dev/null differ diff --git a/tessellation/tessellation.cpp b/tessellation/tessellation.cpp index f3978ecb..deab9a89 100644 --- a/tessellation/tessellation.cpp +++ b/tessellation/tessellation.cpp @@ -134,7 +134,6 @@ public: } } - void reBuildCommandBuffers() { if (!checkCommandBuffers()) @@ -206,7 +205,18 @@ public: void loadAssets() { models.object.loadFromFile(getAssetPath() + "models/lowpoly/deer.dae", vertexLayout, 1.0f, vulkanDevice, queue); - textures.colorMap.loadFromFile(getAssetPath() + "textures/deer.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + if (deviceFeatures.textureCompressionBC) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/deer_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + } + else if (deviceFeatures.textureCompressionASTC_LDR) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/deer_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue); + } + else if (deviceFeatures.textureCompressionETC2) { + textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/deer_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, vulkanDevice, queue); + } + else { + vks::tools::exitFatal("Device does not support any compressed texture format!", "Error"); + } } void setupVertexDescriptions()