Added android support for shadow mapping (projected and omni) and texture (array and cubemap ) example (#97)
This commit is contained in:
parent
c6bdca128a
commit
08fc2feecc
33 changed files with 1363 additions and 77 deletions
1
android/build-shadowmapping.bat
Normal file
1
android/build-shadowmapping.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
_build shadowmapping %1
|
||||||
1
android/build-shadowmappingomni.bat
Normal file
1
android/build-shadowmappingomni.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
_build shadowmappingomni %1
|
||||||
1
android/build-texturearray.bat
Normal file
1
android/build-texturearray.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
_build texturearray %1
|
||||||
1
android/build-texturecubemap.bat
Normal file
1
android/build-texturecubemap.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
_build texturecubemap %1
|
||||||
10
android/shadowmapping/.gitignore
vendored
Normal file
10
android/shadowmapping/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/assets/
|
||||||
|
/res/
|
||||||
|
/bin/
|
||||||
|
/libs/
|
||||||
|
/obj/
|
||||||
|
/build.xml
|
||||||
|
/local.properties
|
||||||
|
/project.properties
|
||||||
|
/proguard-project.txt
|
||||||
|
*.apk
|
||||||
27
android/shadowmapping/AndroidManifest.xml
Normal file
27
android/shadowmapping/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="de.saschawillems.vulkanShadowmapping"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="19" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false"/>
|
||||||
|
|
||||||
|
<application android:label="vulkanShadowmapping" android:icon="@drawable/icon" android:hasCode="false">
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="Shadow mapping"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="vulkanShadowmapping" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
20
android/shadowmapping/build.bat
Normal file
20
android/shadowmapping/build.bat
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
cd jni
|
||||||
|
call ndk-build
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo ndk-build has failed, build cancelled
|
||||||
|
cd..
|
||||||
|
|
||||||
|
mkdir "assets\shaders\shadowmapping"
|
||||||
|
xcopy "..\..\data\shaders\shadowmapping\*.spv" "assets\shaders\shadowmapping" /Y
|
||||||
|
|
||||||
|
mkdir "assets\models"
|
||||||
|
xcopy "..\..\data\models\vulkanscene_shadow.dae" "assets\models" /Y
|
||||||
|
|
||||||
|
mkdir "res\drawable"
|
||||||
|
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||||
|
|
||||||
|
call ant debug -Dout.final.file=vulkanShadowmapping.apk
|
||||||
|
) ELSE (
|
||||||
|
echo error : ndk-build failed with errors!
|
||||||
|
cd..
|
||||||
|
)
|
||||||
47
android/shadowmapping/jni/Android.mk
Normal file
47
android/shadowmapping/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)/../../shadowmapping
|
||||||
|
|
||||||
|
# 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 := vulkanShadowmapping
|
||||||
|
|
||||||
|
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../shadowmapping/*.cpp)
|
||||||
|
PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.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)/../../base/
|
||||||
|
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(PROJECT_FILES)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -landroid -llog -lz
|
||||||
|
|
||||||
|
LOCAL_DISABLE_FORMAT_STRING_CHECKS := 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)
|
||||||
5
android/shadowmapping/jni/Application.mk
Normal file
5
android/shadowmapping/jni/Application.mk
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
APP_PLATFORM := android-19
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_STL := c++_static
|
||||||
|
APP_CPPFLAGS := -std=c++11
|
||||||
|
NDK_TOOLCHAIN_VERSION := clang
|
||||||
10
android/shadowmappingomni/.gitignore
vendored
Normal file
10
android/shadowmappingomni/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/assets/
|
||||||
|
/res/
|
||||||
|
/bin/
|
||||||
|
/libs/
|
||||||
|
/obj/
|
||||||
|
/build.xml
|
||||||
|
/local.properties
|
||||||
|
/project.properties
|
||||||
|
/proguard-project.txt
|
||||||
|
*.apk
|
||||||
27
android/shadowmappingomni/AndroidManifest.xml
Normal file
27
android/shadowmappingomni/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="de.saschawillems.vulkanShadowmappingomni"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="19" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false"/>
|
||||||
|
|
||||||
|
<application android:label="vulkanShadowmappingomni" android:icon="@drawable/icon" android:hasCode="false">
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="Omni-directional shadow mapping"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="vulkanShadowmappingomni" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
21
android/shadowmappingomni/build.bat
Normal file
21
android/shadowmappingomni/build.bat
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
cd jni
|
||||||
|
call ndk-build
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo ndk-build has failed, build cancelled
|
||||||
|
cd..
|
||||||
|
|
||||||
|
mkdir "assets\shaders\shadowmapomni"
|
||||||
|
xcopy "..\..\data\shaders\shadowmapomni\*.spv" "assets\shaders\shadowmapomni" /Y
|
||||||
|
|
||||||
|
mkdir "assets\models"
|
||||||
|
xcopy "..\..\data\models\shadowscene_fire.dae" "assets\models" /Y
|
||||||
|
xcopy "..\..\data\models\cube.obj" "assets\models" /Y
|
||||||
|
|
||||||
|
mkdir "res\drawable"
|
||||||
|
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||||
|
|
||||||
|
call ant debug -Dout.final.file=vulkanShadowmappingomni.apk
|
||||||
|
) ELSE (
|
||||||
|
echo error : ndk-build failed with errors!
|
||||||
|
cd..
|
||||||
|
)
|
||||||
47
android/shadowmappingomni/jni/Android.mk
Normal file
47
android/shadowmappingomni/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)/../../shadowmappingomni
|
||||||
|
|
||||||
|
# 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 := vulkanShadowmappingomni
|
||||||
|
|
||||||
|
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../shadowmappingomni/*.cpp)
|
||||||
|
PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.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)/../../base/
|
||||||
|
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(PROJECT_FILES)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -landroid -llog -lz
|
||||||
|
|
||||||
|
LOCAL_DISABLE_FORMAT_STRING_CHECKS := 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)
|
||||||
5
android/shadowmappingomni/jni/Application.mk
Normal file
5
android/shadowmappingomni/jni/Application.mk
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
APP_PLATFORM := android-19
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_STL := c++_static
|
||||||
|
APP_CPPFLAGS := -std=c++11
|
||||||
|
NDK_TOOLCHAIN_VERSION := clang
|
||||||
10
android/texturearray/.gitignore
vendored
Normal file
10
android/texturearray/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/assets/
|
||||||
|
/res/
|
||||||
|
/bin/
|
||||||
|
/libs/
|
||||||
|
/obj/
|
||||||
|
/build.xml
|
||||||
|
/local.properties
|
||||||
|
/project.properties
|
||||||
|
/proguard-project.txt
|
||||||
|
*.apk
|
||||||
27
android/texturearray/AndroidManifest.xml
Normal file
27
android/texturearray/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="de.saschawillems.vulkanTexturearray"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="19" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false"/>
|
||||||
|
|
||||||
|
<application android:label="vulkanTexturearray" android:icon="@drawable/icon" android:hasCode="false">
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="Texture Array"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="vulkanTexturearray" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
20
android/texturearray/build.bat
Normal file
20
android/texturearray/build.bat
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
cd jni
|
||||||
|
call ndk-build
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo ndk-build has failed, build cancelled
|
||||||
|
cd..
|
||||||
|
|
||||||
|
mkdir "assets\shaders\texturearray"
|
||||||
|
xcopy "..\..\data\shaders\texturearray\*.spv" "assets\shaders\texturearray" /Y
|
||||||
|
|
||||||
|
mkdir "assets\textures"
|
||||||
|
xcopy "..\..\data\textures\texturearray_bc3.ktx" "assets\textures" /Y
|
||||||
|
|
||||||
|
mkdir "res\drawable"
|
||||||
|
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||||
|
|
||||||
|
call ant debug -Dout.final.file=vulkanTexturearray.apk
|
||||||
|
) ELSE (
|
||||||
|
echo error : ndk-build failed with errors!
|
||||||
|
cd..
|
||||||
|
)
|
||||||
47
android/texturearray/jni/Android.mk
Normal file
47
android/texturearray/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)/../../texturearray
|
||||||
|
|
||||||
|
# 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 := vulkanTexturearray
|
||||||
|
|
||||||
|
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../texturearray/*.cpp)
|
||||||
|
PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.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)/../../base/
|
||||||
|
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(PROJECT_FILES)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -landroid -llog -lz
|
||||||
|
|
||||||
|
LOCAL_DISABLE_FORMAT_STRING_CHECKS := 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)
|
||||||
5
android/texturearray/jni/Application.mk
Normal file
5
android/texturearray/jni/Application.mk
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
APP_PLATFORM := android-19
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_STL := c++_static
|
||||||
|
APP_CPPFLAGS := -std=c++11
|
||||||
|
NDK_TOOLCHAIN_VERSION := clang
|
||||||
10
android/texturecubemap/.gitignore
vendored
Normal file
10
android/texturecubemap/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/assets/
|
||||||
|
/res/
|
||||||
|
/bin/
|
||||||
|
/libs/
|
||||||
|
/obj/
|
||||||
|
/build.xml
|
||||||
|
/local.properties
|
||||||
|
/project.properties
|
||||||
|
/proguard-project.txt
|
||||||
|
*.apk
|
||||||
27
android/texturecubemap/AndroidManifest.xml
Normal file
27
android/texturecubemap/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="de.saschawillems.vulkanTexturecubemap"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="19" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false"/>
|
||||||
|
|
||||||
|
<application android:label="vulkanTexturecubemap" android:icon="@drawable/icon" android:hasCode="false">
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="Cubemap Texture"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="vulkanTexturecubemap" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
24
android/texturecubemap/build.bat
Normal file
24
android/texturecubemap/build.bat
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
cd jni
|
||||||
|
call ndk-build
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo ndk-build has failed, build cancelled
|
||||||
|
cd..
|
||||||
|
|
||||||
|
mkdir "assets\shaders\cubemap"
|
||||||
|
xcopy "..\..\data\shaders\cubemap\*.spv" "assets\shaders\cubemap" /Y
|
||||||
|
|
||||||
|
mkdir "assets\textures"
|
||||||
|
xcopy "..\..\data\textures\cubemap_yokohama.ktx" "assets\textures" /Y
|
||||||
|
|
||||||
|
mkdir "assets\models"
|
||||||
|
xcopy "..\..\data\models\sphere.obj" "assets\models" /Y
|
||||||
|
xcopy "..\..\data\models\cube.obj" "assets\models" /Y
|
||||||
|
|
||||||
|
mkdir "res\drawable"
|
||||||
|
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||||
|
|
||||||
|
call ant debug -Dout.final.file=vulkanTexturecubemap.apk
|
||||||
|
) ELSE (
|
||||||
|
echo error : ndk-build failed with errors!
|
||||||
|
cd..
|
||||||
|
)
|
||||||
47
android/texturecubemap/jni/Android.mk
Normal file
47
android/texturecubemap/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)/../../texturecubemap
|
||||||
|
|
||||||
|
# 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 := vulkanTexturecubemap
|
||||||
|
|
||||||
|
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../texturecubemap/*.cpp)
|
||||||
|
PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.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)/../../base/
|
||||||
|
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(PROJECT_FILES)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -landroid -llog -lz
|
||||||
|
|
||||||
|
LOCAL_DISABLE_FORMAT_STRING_CHECKS := 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)
|
||||||
5
android/texturecubemap/jni/Application.mk
Normal file
5
android/texturecubemap/jni/Application.mk
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
APP_PLATFORM := android-19
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_STL := c++_static
|
||||||
|
APP_CPPFLAGS := -std=c++11
|
||||||
|
NDK_TOOLCHAIN_VERSION := clang
|
||||||
|
|
@ -367,7 +367,8 @@ public:
|
||||||
for (unsigned int i = 0; i < paiMesh->mNumFaces; i++)
|
for (unsigned int i = 0; i < paiMesh->mNumFaces; i++)
|
||||||
{
|
{
|
||||||
const aiFace& Face = paiMesh->mFaces[i];
|
const aiFace& Face = paiMesh->mFaces[i];
|
||||||
assert(Face.mNumIndices == 3);
|
if (Face.mNumIndices != 3)
|
||||||
|
continue;
|
||||||
m_Entries[index].Indices.push_back(Face.mIndices[0]);
|
m_Entries[index].Indices.push_back(Face.mIndices[0]);
|
||||||
m_Entries[index].Indices.push_back(Face.mIndices[1]);
|
m_Entries[index].Indices.push_back(Face.mIndices[1]);
|
||||||
m_Entries[index].Indices.push_back(Face.mIndices[2]);
|
m_Entries[index].Indices.push_back(Face.mIndices[2]);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,8 @@ PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
|
||||||
PFN_vkCmdSetViewport vkCmdSetViewport;
|
PFN_vkCmdSetViewport vkCmdSetViewport;
|
||||||
PFN_vkCmdSetScissor vkCmdSetScissor;
|
PFN_vkCmdSetScissor vkCmdSetScissor;
|
||||||
PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
||||||
|
PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
|
||||||
|
PFN_vkCmdPushConstants vkCmdPushConstants;
|
||||||
PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
||||||
PFN_vkCmdDraw vkCmdDraw;
|
PFN_vkCmdDraw vkCmdDraw;
|
||||||
PFN_vkCmdDispatch vkCmdDispatch;
|
PFN_vkCmdDispatch vkCmdDispatch;
|
||||||
|
|
@ -210,7 +212,9 @@ void loadVulkanFunctions(VkInstance instance)
|
||||||
|
|
||||||
vkCmdSetViewport = reinterpret_cast<PFN_vkCmdSetViewport>(vkGetInstanceProcAddr(instance, "vkCmdSetViewport"));
|
vkCmdSetViewport = reinterpret_cast<PFN_vkCmdSetViewport>(vkGetInstanceProcAddr(instance, "vkCmdSetViewport"));
|
||||||
vkCmdSetScissor = reinterpret_cast<PFN_vkCmdSetScissor>(vkGetInstanceProcAddr(instance, "vkCmdSetScissor"));
|
vkCmdSetScissor = reinterpret_cast<PFN_vkCmdSetScissor>(vkGetInstanceProcAddr(instance, "vkCmdSetScissor"));
|
||||||
vkCmdSetLineWidth = reinterpret_cast<PFN_vkCmdSetLineWidth>(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth"));;
|
vkCmdSetLineWidth = reinterpret_cast<PFN_vkCmdSetLineWidth>(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth"));
|
||||||
|
vkCmdSetDepthBias = reinterpret_cast<PFN_vkCmdSetDepthBias>(vkGetInstanceProcAddr(instance, "vkCmdSetDepthBias"));
|
||||||
|
vkCmdPushConstants = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetInstanceProcAddr(instance, "vkCmdPushConstants"));;
|
||||||
|
|
||||||
vkCmdDrawIndexed = reinterpret_cast<PFN_vkCmdDrawIndexed>(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed"));
|
vkCmdDrawIndexed = reinterpret_cast<PFN_vkCmdDrawIndexed>(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed"));
|
||||||
vkCmdDraw = reinterpret_cast<PFN_vkCmdDraw>(vkGetInstanceProcAddr(instance, "vkCmdDraw"));
|
vkCmdDraw = reinterpret_cast<PFN_vkCmdDraw>(vkGetInstanceProcAddr(instance, "vkCmdDraw"));
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
|
||||||
extern PFN_vkCmdSetViewport vkCmdSetViewport;
|
extern PFN_vkCmdSetViewport vkCmdSetViewport;
|
||||||
extern PFN_vkCmdSetScissor vkCmdSetScissor;
|
extern PFN_vkCmdSetScissor vkCmdSetScissor;
|
||||||
extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
||||||
|
extern PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
|
||||||
|
extern PFN_vkCmdPushConstants vkCmdPushConstants;
|
||||||
extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
||||||
extern PFN_vkCmdDraw vkCmdDraw;
|
extern PFN_vkCmdDraw vkCmdDraw;
|
||||||
extern PFN_vkCmdDispatch vkCmdDispatch;
|
extern PFN_vkCmdDispatch vkCmdDispatch;
|
||||||
|
|
|
||||||
Binary file not shown.
731
data/models/shadowscene_fire.dae
Normal file
731
data/models/shadowscene_fire.dae
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -51,7 +51,7 @@ std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
||||||
class VulkanExample : public VulkanExampleBase
|
class VulkanExample : public VulkanExampleBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool displayShadowMap = true;
|
bool displayShadowMap = false;
|
||||||
bool lightPOV = false;
|
bool lightPOV = false;
|
||||||
|
|
||||||
// Keep depth range as small as possible
|
// Keep depth range as small as possible
|
||||||
|
|
@ -613,7 +613,7 @@ public:
|
||||||
|
|
||||||
void loadMeshes()
|
void loadMeshes()
|
||||||
{
|
{
|
||||||
loadMesh("./../data/models/vulkanscene_shadow.dae", &meshes.scene, vertexLayout, 4.0f);
|
loadMesh(getAssetPath() + "models/vulkanscene_shadow.dae", &meshes.scene, vertexLayout, 4.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateQuad()
|
void generateQuad()
|
||||||
|
|
@ -892,8 +892,8 @@ public:
|
||||||
// Load shaders
|
// Load shaders
|
||||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||||
|
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapping/quad.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapping/quad.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapping/quad.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapping/quad.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||||
vkTools::initializers::pipelineCreateInfo(
|
vkTools::initializers::pipelineCreateInfo(
|
||||||
|
|
@ -918,15 +918,15 @@ public:
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// 3D scene
|
// 3D scene
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapping/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapping/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapping/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapping/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
rasterizationState.cullMode = VK_CULL_MODE_NONE;
|
rasterizationState.cullMode = VK_CULL_MODE_NONE;
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.scene);
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.scene);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// Offscreen pipeline
|
// Offscreen pipeline
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapping/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapping/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapping/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapping/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
pipelineCreateInfo.layout = pipelineLayouts.offscreen;
|
pipelineCreateInfo.layout = pipelineLayouts.offscreen;
|
||||||
// Cull front faces
|
// Cull front faces
|
||||||
depthStencilState.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
|
depthStencilState.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
|
||||||
|
|
@ -1167,8 +1167,7 @@ public:
|
||||||
|
|
||||||
VulkanExample *vulkanExample;
|
VulkanExample *vulkanExample;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -1189,9 +1188,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||||
}
|
}
|
||||||
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||||
#else
|
|
||||||
|
|
||||||
static void handleEvent(const xcb_generic_event_t *event)
|
static void handleEvent(const xcb_generic_event_t *event)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -1201,21 +1198,42 @@ static void handleEvent(const xcb_generic_event_t *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
// Main entry point
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Windows entry point
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Android entry point
|
||||||
|
void android_main(android_app* state)
|
||||||
|
#elif defined(__linux__)
|
||||||
|
// Linux entry point
|
||||||
int main(const int argc, const char *argv[])
|
int main(const int argc, const char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Removing this may cause the compiler to omit the main entry point
|
||||||
|
// which would make the application crash at start
|
||||||
|
app_dummy();
|
||||||
|
#endif
|
||||||
vulkanExample = new VulkanExample();
|
vulkanExample = new VulkanExample();
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
vulkanExample->setupWindow(hInstance, WndProc);
|
vulkanExample->setupWindow(hInstance, WndProc);
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Attach vulkan example to global android application state
|
||||||
|
state->userData = vulkanExample;
|
||||||
|
state->onAppCmd = VulkanExample::handleAppCommand;
|
||||||
|
state->onInputEvent = VulkanExample::handleAppInput;
|
||||||
|
vulkanExample->androidApp = state;
|
||||||
|
#elif defined(__linux__)
|
||||||
vulkanExample->setupWindow();
|
vulkanExample->setupWindow();
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
vulkanExample->initSwapchain();
|
vulkanExample->initSwapchain();
|
||||||
vulkanExample->prepare();
|
vulkanExample->prepare();
|
||||||
|
#endif
|
||||||
vulkanExample->renderLoop();
|
vulkanExample->renderLoop();
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
delete(vulkanExample);
|
delete(vulkanExample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -714,8 +714,8 @@ public:
|
||||||
|
|
||||||
void loadMeshes()
|
void loadMeshes()
|
||||||
{
|
{
|
||||||
loadMesh("./../data/models/cube.obj", &meshes.skybox, vertexLayout, 2.0f);
|
loadMesh(getAssetPath() + "models/cube.obj", &meshes.skybox, vertexLayout, 2.0f);
|
||||||
loadMesh("./../data/models/shadowscene_fire.X", &meshes.scene, vertexLayout, 2.0f);
|
loadMesh(getAssetPath() + "models/shadowscene_fire.dae", &meshes.scene, vertexLayout, 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupVertexDescriptions()
|
void setupVertexDescriptions()
|
||||||
|
|
@ -942,8 +942,8 @@ public:
|
||||||
// Load shaders
|
// Load shaders
|
||||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||||
|
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapomni/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapomni/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapomni/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapomni/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||||
vkTools::initializers::pipelineCreateInfo(
|
vkTools::initializers::pipelineCreateInfo(
|
||||||
|
|
@ -966,15 +966,15 @@ public:
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// Cube map display pipeline
|
// Cube map display pipeline
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapomni/cubemapdisplay.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapomni/cubemapdisplay.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapomni/cubemapdisplay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapomni/cubemapdisplay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.cubeMap);
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.cubeMap);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// Offscreen pipeline
|
// Offscreen pipeline
|
||||||
shaderStages[0] = loadShader("./../data/shaders/shadowmapomni/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/shadowmapomni/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/shadowmapomni/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/shadowmapomni/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||||
pipelineCreateInfo.layout = pipelineLayouts.offscreen;
|
pipelineCreateInfo.layout = pipelineLayouts.offscreen;
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.offscreen);
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.offscreen);
|
||||||
|
|
@ -1089,10 +1089,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
VulkanExample *vulkanExample;
|
VulkanExample *vulkanExample;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -1110,9 +1110,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||||
}
|
}
|
||||||
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||||
#else
|
|
||||||
|
|
||||||
static void handleEvent(const xcb_generic_event_t *event)
|
static void handleEvent(const xcb_generic_event_t *event)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -1122,21 +1120,42 @@ static void handleEvent(const xcb_generic_event_t *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
// Main entry point
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Windows entry point
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Android entry point
|
||||||
|
void android_main(android_app* state)
|
||||||
|
#elif defined(__linux__)
|
||||||
|
// Linux entry point
|
||||||
int main(const int argc, const char *argv[])
|
int main(const int argc, const char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Removing this may cause the compiler to omit the main entry point
|
||||||
|
// which would make the application crash at start
|
||||||
|
app_dummy();
|
||||||
|
#endif
|
||||||
vulkanExample = new VulkanExample();
|
vulkanExample = new VulkanExample();
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
vulkanExample->setupWindow(hInstance, WndProc);
|
vulkanExample->setupWindow(hInstance, WndProc);
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Attach vulkan example to global android application state
|
||||||
|
state->userData = vulkanExample;
|
||||||
|
state->onAppCmd = VulkanExample::handleAppCommand;
|
||||||
|
state->onInputEvent = VulkanExample::handleAppInput;
|
||||||
|
vulkanExample->androidApp = state;
|
||||||
|
#elif defined(__linux__)
|
||||||
vulkanExample->setupWindow();
|
vulkanExample->setupWindow();
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
vulkanExample->initSwapchain();
|
vulkanExample->initSwapchain();
|
||||||
vulkanExample->prepare();
|
vulkanExample->prepare();
|
||||||
|
#endif
|
||||||
vulkanExample->renderLoop();
|
vulkanExample->renderLoop();
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
delete(vulkanExample);
|
delete(vulkanExample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -110,12 +110,25 @@ public:
|
||||||
delete[] uboVS.instance;
|
delete[] uboVS.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadTextureArray(const char* filename, VkFormat format)
|
void loadTextureArray(std::string filename, VkFormat format)
|
||||||
{
|
{
|
||||||
VkFormatProperties formatProperties;
|
#if defined(__ANDROID__)
|
||||||
VkResult err;
|
// Textures are stored inside the apk on Android (compressed)
|
||||||
|
// So they need to be loaded via the asset manager
|
||||||
|
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
|
||||||
|
assert(asset);
|
||||||
|
size_t size = AAsset_getLength(asset);
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
void *textureData = malloc(size);
|
||||||
|
AAsset_read(asset, textureData, size);
|
||||||
|
AAsset_close(asset);
|
||||||
|
|
||||||
|
gli::texture2DArray tex2DArray(gli::load((const char*)textureData, size));
|
||||||
|
#else
|
||||||
gli::texture2DArray tex2DArray(gli::load(filename));
|
gli::texture2DArray tex2DArray(gli::load(filename));
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(!tex2DArray.empty());
|
assert(!tex2DArray.empty());
|
||||||
|
|
||||||
textureArray.width = tex2DArray.dimensions().x;
|
textureArray.width = tex2DArray.dimensions().x;
|
||||||
|
|
@ -123,6 +136,7 @@ public:
|
||||||
layerCount = tex2DArray.layers();
|
layerCount = tex2DArray.layers();
|
||||||
|
|
||||||
// Get device properites for the requested texture format
|
// Get device properites for the requested texture format
|
||||||
|
VkFormatProperties formatProperties;
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
||||||
|
|
||||||
VkImageCreateInfo imageCreateInfo = vkTools::initializers::imageCreateInfo();
|
VkImageCreateInfo imageCreateInfo = vkTools::initializers::imageCreateInfo();
|
||||||
|
|
@ -155,7 +169,7 @@ public:
|
||||||
cmdPool,
|
cmdPool,
|
||||||
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||||
1);
|
1);
|
||||||
err = vkAllocateCommandBuffers(device, &cmdBufAlllocatInfo, &cmdBuffer);
|
VkResult err = vkAllocateCommandBuffers(device, &cmdBufAlllocatInfo, &cmdBuffer);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo =
|
VkCommandBufferBeginInfo cmdBufInfo =
|
||||||
|
|
@ -332,7 +346,9 @@ public:
|
||||||
|
|
||||||
void loadTextures()
|
void loadTextures()
|
||||||
{
|
{
|
||||||
loadTextureArray("./../data/textures/texturearray_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK);
|
loadTextureArray(
|
||||||
|
getAssetPath() + "textures/texturearray_bc3.ktx",
|
||||||
|
VK_FORMAT_BC3_UNORM_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
|
|
@ -629,8 +645,8 @@ public:
|
||||||
// Load shaders
|
// Load shaders
|
||||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||||
|
|
||||||
shaderStages[0] = loadShader("./../data/shaders/texturearray/instancing.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/texturearray/instancing.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/texturearray/instancing.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/texturearray/instancing.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||||
vkTools::initializers::pipelineCreateInfo(
|
vkTools::initializers::pipelineCreateInfo(
|
||||||
|
|
@ -747,8 +763,7 @@ public:
|
||||||
|
|
||||||
VulkanExample *vulkanExample;
|
VulkanExample *vulkanExample;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -757,9 +772,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||||
}
|
}
|
||||||
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||||
#else
|
|
||||||
|
|
||||||
static void handleEvent(const xcb_generic_event_t *event)
|
static void handleEvent(const xcb_generic_event_t *event)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -769,21 +782,42 @@ static void handleEvent(const xcb_generic_event_t *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
// Main entry point
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Windows entry point
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Android entry point
|
||||||
|
void android_main(android_app* state)
|
||||||
|
#elif defined(__linux__)
|
||||||
|
// Linux entry point
|
||||||
int main(const int argc, const char *argv[])
|
int main(const int argc, const char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Removing this may cause the compiler to omit the main entry point
|
||||||
|
// which would make the application crash at start
|
||||||
|
app_dummy();
|
||||||
|
#endif
|
||||||
vulkanExample = new VulkanExample();
|
vulkanExample = new VulkanExample();
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
vulkanExample->setupWindow(hInstance, WndProc);
|
vulkanExample->setupWindow(hInstance, WndProc);
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Attach vulkan example to global android application state
|
||||||
|
state->userData = vulkanExample;
|
||||||
|
state->onAppCmd = VulkanExample::handleAppCommand;
|
||||||
|
state->onInputEvent = VulkanExample::handleAppInput;
|
||||||
|
vulkanExample->androidApp = state;
|
||||||
|
#elif defined(__linux__)
|
||||||
vulkanExample->setupWindow();
|
vulkanExample->setupWindow();
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
vulkanExample->initSwapchain();
|
vulkanExample->initSwapchain();
|
||||||
vulkanExample->prepare();
|
vulkanExample->prepare();
|
||||||
|
#endif
|
||||||
vulkanExample->renderLoop();
|
vulkanExample->renderLoop();
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
delete(vulkanExample);
|
delete(vulkanExample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -103,18 +103,32 @@ public:
|
||||||
vkTools::destroyUniformData(device, &uniformData.skyboxVS);
|
vkTools::destroyUniformData(device, &uniformData.skyboxVS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadTexture(const char* filename, VkFormat format, bool forceLinearTiling)
|
void loadCubemap(std::string filename, VkFormat format, bool forceLinearTiling)
|
||||||
{
|
{
|
||||||
VkFormatProperties formatProperties;
|
#if defined(__ANDROID__)
|
||||||
VkResult err;
|
// Textures are stored inside the apk on Android (compressed)
|
||||||
|
// So they need to be loaded via the asset manager
|
||||||
|
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
|
||||||
|
assert(asset);
|
||||||
|
size_t size = AAsset_getLength(asset);
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
void *textureData = malloc(size);
|
||||||
|
AAsset_read(asset, textureData, size);
|
||||||
|
AAsset_close(asset);
|
||||||
|
|
||||||
|
gli::textureCube texCube(gli::load((const char*)textureData, size));
|
||||||
|
#else
|
||||||
gli::textureCube texCube(gli::load(filename));
|
gli::textureCube texCube(gli::load(filename));
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(!texCube.empty());
|
assert(!texCube.empty());
|
||||||
|
|
||||||
cubeMap.width = texCube[0].dimensions().x;
|
cubeMap.width = texCube[0].dimensions().x;
|
||||||
cubeMap.height = texCube[0].dimensions().y;
|
cubeMap.height = texCube[0].dimensions().y;
|
||||||
|
|
||||||
// Get device properites for the requested texture format
|
// Get device properites for the requested texture format
|
||||||
|
VkFormatProperties formatProperties;
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProperties);
|
||||||
|
|
||||||
VkImageCreateInfo imageCreateInfo = vkTools::initializers::imageCreateInfo();
|
VkImageCreateInfo imageCreateInfo = vkTools::initializers::imageCreateInfo();
|
||||||
|
|
@ -145,7 +159,7 @@ public:
|
||||||
cmdPool,
|
cmdPool,
|
||||||
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||||
1);
|
1);
|
||||||
err = vkAllocateCommandBuffers(device, &cmdBufAlllocatInfo, &cmdBuffer);
|
VkResult err = vkAllocateCommandBuffers(device, &cmdBufAlllocatInfo, &cmdBuffer);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo =
|
VkCommandBufferBeginInfo cmdBufInfo =
|
||||||
|
|
@ -420,8 +434,8 @@ public:
|
||||||
|
|
||||||
void loadMeshes()
|
void loadMeshes()
|
||||||
{
|
{
|
||||||
loadMesh("./../data/models/sphere.obj", &meshes.object, vertexLayout, 0.05f);
|
loadMesh(getAssetPath() + "models/sphere.obj", &meshes.object, vertexLayout, 0.05f);
|
||||||
loadMesh("./../data/models/cube.obj", &meshes.skybox, vertexLayout, 0.05f);
|
loadMesh(getAssetPath() + "models/cube.obj", &meshes.skybox, vertexLayout, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupVertexDescriptions()
|
void setupVertexDescriptions()
|
||||||
|
|
@ -627,8 +641,8 @@ public:
|
||||||
// Skybox pipeline (background cube)
|
// Skybox pipeline (background cube)
|
||||||
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
|
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
|
||||||
|
|
||||||
shaderStages[0] = loadShader("./../data/shaders/cubemap/skybox.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/cubemap/skybox.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/cubemap/skybox.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/cubemap/skybox.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||||
vkTools::initializers::pipelineCreateInfo(
|
vkTools::initializers::pipelineCreateInfo(
|
||||||
|
|
@ -651,8 +665,8 @@ public:
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// Cube map reflect pipeline
|
// Cube map reflect pipeline
|
||||||
shaderStages[0] = loadShader("./../data/shaders/cubemap/reflect.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/cubemap/reflect.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader("./../data/shaders/cubemap/reflect.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/cubemap/reflect.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
depthStencilState.depthWriteEnable = VK_TRUE;
|
depthStencilState.depthWriteEnable = VK_TRUE;
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.reflect);
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.reflect);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
@ -721,8 +735,8 @@ public:
|
||||||
loadMeshes();
|
loadMeshes();
|
||||||
setupVertexDescriptions();
|
setupVertexDescriptions();
|
||||||
prepareUniformBuffers();
|
prepareUniformBuffers();
|
||||||
loadTexture(
|
loadCubemap(
|
||||||
"./../data/textures/cubemap_yokohama.ktx",
|
getAssetPath() + "textures/cubemap_yokohama.ktx",
|
||||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||||
false);
|
false);
|
||||||
setupDescriptorSetLayout();
|
setupDescriptorSetLayout();
|
||||||
|
|
@ -751,8 +765,7 @@ public:
|
||||||
|
|
||||||
VulkanExample *vulkanExample;
|
VulkanExample *vulkanExample;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -761,9 +774,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||||
}
|
}
|
||||||
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||||
#else
|
|
||||||
|
|
||||||
static void handleEvent(const xcb_generic_event_t *event)
|
static void handleEvent(const xcb_generic_event_t *event)
|
||||||
{
|
{
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
|
|
@ -773,21 +784,42 @@ static void handleEvent(const xcb_generic_event_t *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
// Main entry point
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Windows entry point
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Android entry point
|
||||||
|
void android_main(android_app* state)
|
||||||
|
#elif defined(__linux__)
|
||||||
|
// Linux entry point
|
||||||
int main(const int argc, const char *argv[])
|
int main(const int argc, const char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Removing this may cause the compiler to omit the main entry point
|
||||||
|
// which would make the application crash at start
|
||||||
|
app_dummy();
|
||||||
|
#endif
|
||||||
vulkanExample = new VulkanExample();
|
vulkanExample = new VulkanExample();
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
vulkanExample->setupWindow(hInstance, WndProc);
|
vulkanExample->setupWindow(hInstance, WndProc);
|
||||||
#else
|
#elif defined(__ANDROID__)
|
||||||
|
// Attach vulkan example to global android application state
|
||||||
|
state->userData = vulkanExample;
|
||||||
|
state->onAppCmd = VulkanExample::handleAppCommand;
|
||||||
|
state->onInputEvent = VulkanExample::handleAppInput;
|
||||||
|
vulkanExample->androidApp = state;
|
||||||
|
#elif defined(__linux__)
|
||||||
vulkanExample->setupWindow();
|
vulkanExample->setupWindow();
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
vulkanExample->initSwapchain();
|
vulkanExample->initSwapchain();
|
||||||
vulkanExample->prepare();
|
vulkanExample->prepare();
|
||||||
|
#endif
|
||||||
vulkanExample->renderLoop();
|
vulkanExample->renderLoop();
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
delete(vulkanExample);
|
delete(vulkanExample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue