Added android support for bloom, computeshader and offscreen examples (#97)
This commit is contained in:
parent
eb4e1d018c
commit
c69af6cdca
21 changed files with 452 additions and 62 deletions
10
android/bloom/.gitignore
vendored
Normal file
10
android/bloom/.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/bloom/AndroidManifest.xml
Normal file
27
android/bloom/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.vulkanBloom"
|
||||
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="vulkanBloom" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Vulkan Bloom"
|
||||
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="vulkanBloom" />
|
||||
<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/bloom/build.bat
Normal file
25
android/bloom/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\bloom"
|
||||
xcopy "..\..\data\shaders\bloom\*.spv" "assets\shaders\bloom" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\cubemap_space.ktx" "assets\textures" /Y
|
||||
|
||||
mkdir "assets\models"
|
||||
xcopy "..\..\data\models\retroufo.dae" "assets\models" /Y
|
||||
xcopy "..\..\data\models\retroufo_glow.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=vulkanBloom.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/bloom/jni/Android.mk
Normal file
47
android/bloom/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../bloom
|
||||
|
||||
# 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 := vulkanBloom
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../bloom/*.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/bloom/jni/Application.mk
Normal file
5
android/bloom/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
|
||||
1
android/build-bloom.bat
Normal file
1
android/build-bloom.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build bloom %1
|
||||
1
android/build-computeshader.bat
Normal file
1
android/build-computeshader.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build computeshader %1
|
||||
1
android/build-offscreen.bat
Normal file
1
android/build-offscreen.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
_build offscreen %1
|
||||
10
android/computeshader/.gitignore
vendored
Normal file
10
android/computeshader/.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/computeshader/AndroidManifest.xml
Normal file
27
android/computeshader/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.vulkanComputeshader"
|
||||
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="vulkanComputeshader" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Vulkan Compute Shader"
|
||||
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="vulkanComputeshader" />
|
||||
<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/computeshader/build.bat
Normal file
21
android/computeshader/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\computeshader"
|
||||
xcopy "..\..\data\shaders\computeshader\*.spv" "assets\shaders\computeshader" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\igor_and_pal_rgba.ktx" "assets\textures" /Y
|
||||
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
||||
call ant debug -Dout.final.file=vulkanComputeshader.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/computeshader/jni/Android.mk
Normal file
47
android/computeshader/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../computeshader
|
||||
|
||||
# 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 := vulkanComputeshader
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../computeshader/*.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/computeshader/jni/Application.mk
Normal file
5
android/computeshader/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/offscreen/.gitignore
vendored
Normal file
10
android/offscreen/.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/offscreen/AndroidManifest.xml
Normal file
27
android/offscreen/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.vulkanOffscreen"
|
||||
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="vulkanOffscreen" android:icon="@drawable/icon" android:hasCode="false">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="Vulkan Offscreen"
|
||||
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="vulkanOffscreen" />
|
||||
<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/offscreen/build.bat
Normal file
24
android/offscreen/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\offscreen"
|
||||
xcopy "..\..\data\shaders\offscreen\*.spv" "assets\shaders\offscreen" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\darkmetal_bc3.ktx" "assets\textures" /Y
|
||||
|
||||
mkdir "assets\models"
|
||||
xcopy "..\..\data\models\plane.obj" "assets\models" /Y
|
||||
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=vulkanOffscreen.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
47
android/offscreen/jni/Android.mk
Normal file
47
android/offscreen/jni/Android.mk
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
LOCAL_PATH := $(call my-dir)/../../offscreen
|
||||
|
||||
# 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 := vulkanOffscreen
|
||||
|
||||
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../offscreen/*.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)
|
||||
4
android/offscreen/jni/Application.mk
Normal file
4
android/offscreen/jni/Application.mk
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
APP_PLATFORM := android-19
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
|
|
@ -607,7 +607,7 @@ public:
|
|||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadCubemap(
|
||||
"./../data/textures/cubemap_space.ktx",
|
||||
getAssetPath() + "textures/cubemap_space.ktx",
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
&textures.cubemap);
|
||||
}
|
||||
|
|
@ -741,9 +741,9 @@ public:
|
|||
|
||||
void loadMeshes()
|
||||
{
|
||||
loadMesh("./../data/models/retroufo.X", &meshes.ufo, vertexLayout, 0.05f);
|
||||
loadMesh("./../data/models/retroufo_glow.X", &meshes.ufoGlow, vertexLayout, 0.05f);
|
||||
loadMesh("./../data/models/cube.obj", &meshes.skyBox, vertexLayout, 1.0f);
|
||||
loadMesh(getAssetPath() + "models/retroufo.dae", &meshes.ufo, vertexLayout, 0.05f);
|
||||
loadMesh(getAssetPath() + "models/retroufo_glow.dae", &meshes.ufoGlow, vertexLayout, 0.05f);
|
||||
loadMesh(getAssetPath() + "models/cube.obj", &meshes.skyBox, vertexLayout, 1.0f);
|
||||
}
|
||||
|
||||
// Setup vertices for a single uv-mapped quad
|
||||
|
|
@ -1072,8 +1072,8 @@ public:
|
|||
|
||||
// Vertical gauss blur
|
||||
// Load shaders
|
||||
shaderStages[0] = loadShader("./../data/shaders/bloom/gaussblur.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/bloom/gaussblur.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/bloom/gaussblur.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/bloom/gaussblur.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -1106,8 +1106,8 @@ public:
|
|||
assert(!err);
|
||||
|
||||
// Phong pass (3D model)
|
||||
shaderStages[0] = loadShader("./../data/shaders/bloom/phongpass.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/bloom/phongpass.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/bloom/phongpass.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/bloom/phongpass.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
pipelineCreateInfo.layout = pipelineLayouts.scene;
|
||||
blendAttachmentState.blendEnable = VK_FALSE;
|
||||
|
|
@ -1117,15 +1117,15 @@ public:
|
|||
assert(!err);
|
||||
|
||||
// Color only pass (offscreen blur base)
|
||||
shaderStages[0] = loadShader("./../data/shaders/bloom/colorpass.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/bloom/colorpass.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/bloom/colorpass.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/bloom/colorpass.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.colorPass);
|
||||
assert(!err);
|
||||
|
||||
// Skybox (cubemap
|
||||
shaderStages[0] = loadShader("./../data/shaders/bloom/skybox.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/bloom/skybox.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/bloom/skybox.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/bloom/skybox.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
depthStencilState.depthWriteEnable = VK_FALSE;
|
||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.skyBox);
|
||||
assert(!err);
|
||||
|
|
@ -1305,8 +1305,7 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -1330,9 +1329,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)
|
||||
|
|
@ -1342,21 +1339,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
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ public:
|
|||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadTexture(
|
||||
"./../data/textures/igor_and_pal_rgba.ktx",
|
||||
getAssetPath() + "textures/igor_and_pal_rgba.ktx",
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
&textureColorMap,
|
||||
false,
|
||||
|
|
@ -602,8 +602,8 @@ public:
|
|||
// Load shaders
|
||||
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
|
||||
|
||||
shaderStages[0] = loadShader("./../data/shaders/computeshader/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/computeshader/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/computeshader/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/computeshader/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -721,7 +721,7 @@ public:
|
|||
|
||||
for (auto& shaderName : shaderNames)
|
||||
{
|
||||
std::string fileName = "./../data/shaders/computeshader/" + shaderName + ".comp.spv";
|
||||
std::string fileName = getAssetPath() + "shaders/computeshader/" + shaderName + ".comp.spv";
|
||||
computePipelineCreateInfo.stage = loadShader(fileName.c_str(), VK_SHADER_STAGE_COMPUTE_BIT);
|
||||
VkPipeline pipeline;
|
||||
err = vkCreateComputePipelines(device, pipelineCache, 1, &computePipelineCreateInfo, nullptr, &pipeline);
|
||||
|
|
@ -843,29 +843,23 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
{
|
||||
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam);
|
||||
if (uMsg == WM_KEYDOWN)
|
||||
switch (wParam)
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_ADD:
|
||||
case VK_SUBTRACT:
|
||||
vulkanExample->switchComputePipeline((wParam == VK_ADD) ? 1 : -1);
|
||||
break;
|
||||
}
|
||||
case VK_ADD:
|
||||
case VK_SUBTRACT:
|
||||
vulkanExample->switchComputePipeline((wParam == VK_ADD) ? 1 : -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||
static void handleEvent(const xcb_generic_event_t *event)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -875,21 +869,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,14 +633,14 @@ public:
|
|||
|
||||
void loadMeshes()
|
||||
{
|
||||
loadMesh("./../data/models/plane.obj", &meshes.plane, vertexLayout, 0.4f);
|
||||
loadMesh("./../data/models/chinesedragon.X", &meshes.example, vertexLayout, 0.3f);
|
||||
loadMesh(getAssetPath() + "models/plane.obj", &meshes.plane, vertexLayout, 0.4f);
|
||||
loadMesh(getAssetPath() + "models/chinesedragon.dae", &meshes.example, vertexLayout, 0.3f);
|
||||
}
|
||||
|
||||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadTexture(
|
||||
"./../data/textures/darkmetal_bc3.ktx",
|
||||
getAssetPath() + "textures/darkmetal_bc3.ktx",
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
&textures.colorMap);
|
||||
}
|
||||
|
|
@ -949,8 +949,8 @@ public:
|
|||
// Load shaders
|
||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||
|
||||
shaderStages[0] = loadShader("./../data/shaders/offscreen/quad.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/offscreen/quad.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/offscreen/quad.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/offscreen/quad.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
|
|
@ -973,15 +973,15 @@ public:
|
|||
assert(!err);
|
||||
|
||||
// Mirror
|
||||
shaderStages[0] = loadShader("./../data/shaders/offscreen/mirror.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/offscreen/mirror.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/offscreen/mirror.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/offscreen/mirror.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.mirror);
|
||||
assert(!err);
|
||||
|
||||
// Solid shading pipeline
|
||||
shaderStages[0] = loadShader("./../data/shaders/offscreen/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader("./../data/shaders/offscreen/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/offscreen/offscreen.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/offscreen/offscreen.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
pipelineCreateInfo.layout = pipelineLayouts.offscreen;
|
||||
|
||||
|
|
@ -1135,8 +1135,7 @@ public:
|
|||
|
||||
VulkanExample *vulkanExample;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32)
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (vulkanExample != NULL)
|
||||
|
|
@ -1145,9 +1144,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)
|
||||
|
|
@ -1157,21 +1154,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