Added android support for deferred, displacement and spherical environment mapping examples (#97)
This commit is contained in:
parent
c69af6cdca
commit
c6bdca128a
25 changed files with 604 additions and 230725 deletions
1
android/build-deferred.bat
Normal file
1
android/build-deferred.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build deferred %1
|
||||
1
android/build-displacement.bat
Normal file
1
android/build-displacement.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build displacement %1
|
||||
1
android/build-sphericalenvmapping.bat
Normal file
1
android/build-sphericalenvmapping.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build sphericalenvmapping %1
|
||||
10
android/deferred/.gitignore
vendored
Normal file
10
android/deferred/.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/deferred/AndroidManifest.xml
Normal file
27
android/deferred/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.vulkanDeferred"
|
||||
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="vulkanDeferred" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Vulkan Deferred"
|
||||
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="vulkanDeferred" />
|
||||
<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/deferred/build.bat
Normal file
20
android/deferred/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\deferred"
|
||||
xcopy "..\..\data\shaders\deferred\*.spv" "assets\shaders\deferred" /Y
|
||||
|
||||
mkdir "assets\models\armor"
|
||||
xcopy "..\..\data\models\armor\*.*" "assets\models\armor" /Y
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
||||
call ant debug -Dout.final.file=vulkanDeferred.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/deferred/jni/Android.mk
Normal file
47
android/deferred/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../deferred
|
||||
|
||||
# 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 := vulkanDeferred
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../deferred/*.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/deferred/jni/Application.mk
Normal file
5
android/deferred/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/displacement/.gitignore
vendored
Normal file
10
android/displacement/.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/displacement/AndroidManifest.xml
Normal file
27
android/displacement/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.vulkanDisplacement"
|
||||
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="vulkanDisplacement" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Displacement 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="vulkanDisplacement" />
|
||||
<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>
|
||||
25
android/displacement/build.bat
Normal file
25
android/displacement/build.bat
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
cd jni
|
||||
call ndk-build
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo ndk-build has failed, build cancelled
|
||||
cd..
|
||||
|
||||
mkdir "assets\shaders\displacement"
|
||||
xcopy "..\..\data\shaders\displacement\*.spv" "assets\shaders\displacement" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\stonewall_colormap_bc3.dds" "assets\textures" /Y
|
||||
xcopy "..\..\data\textures\stonewall_heightmap_rgba.dds" "assets\textures" /Y
|
||||
|
||||
|
||||
mkdir "assets\models"
|
||||
xcopy "..\..\data\models\torus.obj" "assets\models" /Y
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
||||
call ant debug -Dout.final.file=vulkanDisplacement.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/displacement/jni/Android.mk
Normal file
47
android/displacement/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../displacement
|
||||
|
||||
# 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 := vulkanDisplacement
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../displacement/*.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/displacement/jni/Application.mk
Normal file
5
android/displacement/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/sphericalenvmapping/.gitignore
vendored
Normal file
10
android/sphericalenvmapping/.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/sphericalenvmapping/AndroidManifest.xml
Normal file
27
android/sphericalenvmapping/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.vulkanSphericalenvmapping"
|
||||
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="vulkanSphericalenvmapping" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Spherical Environment 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="vulkanSphericalenvmapping" />
|
||||
<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>
|
||||
23
android/sphericalenvmapping/build.bat
Normal file
23
android/sphericalenvmapping/build.bat
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
cd jni
|
||||
call ndk-build
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo ndk-build has failed, build cancelled
|
||||
cd..
|
||||
|
||||
mkdir "assets\shaders\sphericalenvmapping"
|
||||
xcopy "..\..\data\shaders\sphericalenvmapping\*.spv" "assets\shaders\sphericalenvmapping" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\matcap_array_rgba.ktx" "assets\textures" /Y
|
||||
|
||||
mkdir "assets\models"
|
||||
xcopy "..\..\data\models\chinesedragon.dae" "assets\models" /Y
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
||||
call ant debug -Dout.final.file=vulkanSphericalenvmapping.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/sphericalenvmapping/jni/Android.mk
Normal file
47
android/sphericalenvmapping/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../sphericalenvmapping
|
||||
|
||||
# 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 := vulkanSphericalenvmapping
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../sphericalenvmapping/*.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/sphericalenvmapping/jni/Application.mk
Normal file
5
android/sphericalenvmapping/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
|
||||
|
|
@ -80,6 +80,7 @@ PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
|
|||
PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
|
||||
PFN_vkCmdSetViewport vkCmdSetViewport;
|
||||
PFN_vkCmdSetScissor vkCmdSetScissor;
|
||||
PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
||||
PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
||||
PFN_vkCmdDraw vkCmdDraw;
|
||||
PFN_vkCmdDispatch vkCmdDispatch;
|
||||
|
|
@ -209,6 +210,7 @@ void loadVulkanFunctions(VkInstance instance)
|
|||
|
||||
vkCmdSetViewport = reinterpret_cast<PFN_vkCmdSetViewport>(vkGetInstanceProcAddr(instance, "vkCmdSetViewport"));
|
||||
vkCmdSetScissor = reinterpret_cast<PFN_vkCmdSetScissor>(vkGetInstanceProcAddr(instance, "vkCmdSetScissor"));
|
||||
vkCmdSetLineWidth = reinterpret_cast<PFN_vkCmdSetLineWidth>(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth"));;
|
||||
|
||||
vkCmdDrawIndexed = reinterpret_cast<PFN_vkCmdDrawIndexed>(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed"));
|
||||
vkCmdDraw = reinterpret_cast<PFN_vkCmdDraw>(vkGetInstanceProcAddr(instance, "vkCmdDraw"));
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ extern PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
|
|||
extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
|
||||
extern PFN_vkCmdSetViewport vkCmdSetViewport;
|
||||
extern PFN_vkCmdSetScissor vkCmdSetScissor;
|
||||
extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
|
||||
extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
|
||||
extern PFN_vkCmdDraw vkCmdDraw;
|
||||
extern PFN_vkCmdDispatch vkCmdDispatch;
|
||||
|
|
|
|||
158
data/models/armor/armor.dae
Normal file
158
data/models/armor/armor.dae
Normal file
File diff suppressed because one or more lines are too long
230672
data/models/armor/armor.x
230672
data/models/armor/armor.x
File diff suppressed because it is too large
Load diff
|
|
@ -636,7 +636,7 @@ public:
|
|||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadTexture(
|
||||
"./../data/models/armor/colormap.ktx",
|
||||
getAssetPath() + "models/armor/colormap.ktx",
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
&textures.colorMap);
|
||||
}
|
||||
|
|
@ -755,7 +755,7 @@ public:
|
|||
|
||||
void loadMeshes()
|
||||
{
|
||||
loadMesh("./../data/models/armor/armor.x", &meshes.example, vertexLayout, 1.0f);
|
||||
loadMesh(getAssetPath() + "models/armor/armor.dae", &meshes.example, vertexLayout, 1.0f);
|
||||
}
|
||||
|
||||
void generateQuads()
|
||||
|
|
@ -1081,8 +1081,8 @@ public:
|
|||
// Final fullscreen pass pipeline
|
||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||
|
||||
shaderStages[0] = loadShader("./../data/shaders/deferred/deferred.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/deferred/deferred.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/deferred.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/deferred.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -1105,14 +1105,14 @@ public:
|
|||
assert(!err);
|
||||
|
||||
// Debug display pipeline
|
||||
shaderStages[0] = loadShader("./../data/shaders/deferred/debug.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/deferred/debug.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/debug.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/debug.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.debug);
|
||||
assert(!err);
|
||||
|
||||
// Offscreen pipeline
|
||||
shaderStages[0] = loadShader("./../data/shaders/deferred/mrt.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/deferred/mrt.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/mrt.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/mrt.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
// Separate render pass
|
||||
pipelineCreateInfo.renderPass = offScreenFrameBuf.renderPass;
|
||||
|
|
@ -1298,8 +1298,7 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -1317,34 +1316,52 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||
static void handleEvent(const xcb_generic_event_t *event)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
{
|
||||
vulkanExample->handleEvent(event);
|
||||
// todo : keys
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// Main entry point
|
||||
#if defined(_WIN32)
|
||||
// Windows entry point
|
||||
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[])
|
||||
#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();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
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();
|
||||
#endif
|
||||
#if !defined(__ANDROID__)
|
||||
vulkanExample->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
#endif
|
||||
vulkanExample->renderLoop();
|
||||
#if !defined(__ANDROID__)
|
||||
delete(vulkanExample);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -113,11 +113,11 @@ public:
|
|||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadTexture(
|
||||
"./../data/textures/stonewall_colormap_bc3.dds",
|
||||
getAssetPath() + "textures/stonewall_colormap_bc3.dds",
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
&textures.colorMap);
|
||||
textureLoader->loadTexture(
|
||||
"./../data/textures/stonewall_heightmap_rgba.dds",
|
||||
getAssetPath() + "textures/stonewall_heightmap_rgba.dds",
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
&textures.heightMap);
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ public:
|
|||
|
||||
void loadMeshes()
|
||||
{
|
||||
loadMesh("./../data/models/torus.obj", &meshes.object, vertexLayout, 0.25f);
|
||||
loadMesh(getAssetPath() + "models/torus.obj", &meshes.object, vertexLayout, 0.25f);
|
||||
}
|
||||
|
||||
void setupVertexDescriptions()
|
||||
|
|
@ -457,10 +457,10 @@ public:
|
|||
// Tessellation pipeline
|
||||
// Load shaders
|
||||
std::array<VkPipelineShaderStageCreateInfo, 4> shaderStages;
|
||||
shaderStages[0] = loadShader("./../data/shaders/displacement/base.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/displacement/base.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[2] = loadShader("./../data/shaders/displacement/displacement.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
||||
shaderStages[3] = loadShader("./../data/shaders/displacement/displacement.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/displacement/base.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/displacement/base.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[2] = loadShader(getAssetPath() + "shaders/displacement/displacement.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
||||
shaderStages[3] = loadShader(getAssetPath() + "shaders/displacement/displacement.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -491,8 +491,8 @@ public:
|
|||
|
||||
// Pass through pipelines
|
||||
// Load pass through tessellation shaders (Vert and frag are reused)
|
||||
shaderStages[2] = loadShader("./../data/shaders/displacement/passthrough.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
||||
shaderStages[3] = loadShader("./../data/shaders/displacement/passthrough.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
||||
shaderStages[2] = loadShader(getAssetPath() + "shaders/displacement/passthrough.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
||||
shaderStages[3] = loadShader(getAssetPath() + "shaders/displacement/passthrough.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
||||
// Solid
|
||||
rasterizationState.polygonMode = VK_POLYGON_MODE_FILL;
|
||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solidPassThrough);
|
||||
|
|
@ -618,8 +618,7 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -646,34 +645,52 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||
static void handleEvent(const xcb_generic_event_t *event)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
{
|
||||
vulkanExample->handleEvent(event);
|
||||
// TODO : Keys for tessellation level changes
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// Main entry point
|
||||
#if defined(_WIN32)
|
||||
// Windows entry point
|
||||
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[])
|
||||
#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();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
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();
|
||||
#endif
|
||||
#if !defined(__ANDROID__)
|
||||
vulkanExample->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
#endif
|
||||
vulkanExample->renderLoop();
|
||||
#if !defined(__ANDROID__)
|
||||
delete(vulkanExample);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ public:
|
|||
// so they can easily be switched inside the shader
|
||||
// just by updating the index in a uniform buffer
|
||||
textureLoader->loadTextureArray(
|
||||
"./../data/textures/matcap_array_rgba.ktx",
|
||||
getAssetPath() + "textures/matcap_array_rgba.ktx",
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
&textures.matCapArray);
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ public:
|
|||
|
||||
void loadMeshes()
|
||||
{
|
||||
loadMesh("./../data/models/chinesedragon.X", &meshes.object, vertexLayout, 0.05f);
|
||||
loadMesh(getAssetPath() + "models/chinesedragon.dae", &meshes.object, vertexLayout, 0.05f);
|
||||
}
|
||||
|
||||
void prepareVertices()
|
||||
|
|
@ -391,8 +391,8 @@ public:
|
|||
// Spherical environment rendering pipeline
|
||||
// Load shaders
|
||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||
shaderStages[0] = loadShader("./../data/shaders/sphericalenvmapping/sem.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/sphericalenvmapping/sem.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/sphericalenvmapping/sem.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/sphericalenvmapping/sem.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -514,8 +514,7 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -524,9 +523,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||
static void handleEvent(const xcb_generic_event_t *event)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -536,21 +533,42 @@ static void handleEvent(const xcb_generic_event_t *event)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// Main entry point
|
||||
#if defined(_WIN32)
|
||||
// Windows entry point
|
||||
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[])
|
||||
#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();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
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();
|
||||
#endif
|
||||
#if !defined(__ANDROID__)
|
||||
vulkanExample->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
#endif
|
||||
vulkanExample->renderLoop();
|
||||
#if !defined(__ANDROID__)
|
||||
delete(vulkanExample);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue