Added Android build files and screenshot for order independent transparency sample
This commit is contained in:
parent
82747df540
commit
2083a9839c
8 changed files with 198 additions and 4 deletions
35
android/examples/oit/CMakeLists.txt
Normal file
35
android/examples/oit/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR)
|
||||
|
||||
set(NAME oit)
|
||||
|
||||
set(SRC_DIR ../../../examples/${NAME})
|
||||
set(BASE_DIR ../../../base)
|
||||
set(EXTERNAL_DIR ../../../external)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES")
|
||||
|
||||
file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp")
|
||||
|
||||
add_library(native-lib SHARED ${EXAMPLE_SRC})
|
||||
|
||||
add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
||||
|
||||
add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
|
||||
|
||||
include_directories(${BASE_DIR})
|
||||
include_directories(${EXTERNAL_DIR})
|
||||
include_directories(${EXTERNAL_DIR}/glm)
|
||||
include_directories(${EXTERNAL_DIR}/imgui)
|
||||
include_directories(${EXTERNAL_DIR}/tinygltf)
|
||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||
|
||||
target_link_libraries(
|
||||
native-lib
|
||||
native-app-glue
|
||||
libbase
|
||||
android
|
||||
log
|
||||
z
|
||||
)
|
||||
71
android/examples/oit/build.gradle
Normal file
71
android/examples/oit/build.gradle
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply from: '../gradle/outputfilename.gradle'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
defaultConfig {
|
||||
applicationId "de.saschawillems.vulkanOrderIndependentTransparency"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a"
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-std=c++14"
|
||||
arguments "-DANDROID_STL=c++_shared", '-DANDROID_TOOLCHAIN=clang'
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main.assets.srcDirs = ['assets']
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task copyTask {
|
||||
copy {
|
||||
from '../../common/res/drawable'
|
||||
into "src/main/res/drawable"
|
||||
include 'icon.png'
|
||||
}
|
||||
|
||||
copy {
|
||||
from '../../../data/shaders/glsl/base'
|
||||
into 'assets/shaders/glsl/base'
|
||||
include '*.spv'
|
||||
}
|
||||
|
||||
copy {
|
||||
from '../../../data/shaders/glsl/oit'
|
||||
into 'assets/shaders/glsl/oit'
|
||||
include '*.*'
|
||||
}
|
||||
|
||||
copy {
|
||||
from '../../../data/models'
|
||||
into 'assets/models'
|
||||
include 'sphere.gltf'
|
||||
}
|
||||
|
||||
copy {
|
||||
from '../../../data/models'
|
||||
into 'assets/models'
|
||||
include 'cube.gltf'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preBuild.dependsOn copyTask
|
||||
24
android/examples/oit/src/main/AndroidManifest.xml
Normal file
24
android/examples/oit/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.saschawillems.vulkanOrderIndependentTransparency">
|
||||
|
||||
<application
|
||||
android:label="Vulkan order independent transparency"
|
||||
android:icon="@drawable/icon"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
<activity android:name="de.saschawillems.vulkanSample.VulkanActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="native-lib" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.gamepad" android:required="false" />
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (C) 2018 by Sascha Willems - www.saschawillems.de
|
||||
*
|
||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
package de.saschawillems.vulkanSample;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.NativeActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class VulkanActivity extends NativeActivity {
|
||||
|
||||
static {
|
||||
// Load native library
|
||||
System.loadLibrary("native-lib");
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
// Use a semaphore to create a modal dialog
|
||||
|
||||
private final Semaphore semaphore = new Semaphore(0, true);
|
||||
|
||||
public void showAlert(final String message)
|
||||
{
|
||||
final VulkanActivity activity = this;
|
||||
|
||||
ApplicationInfo applicationInfo = activity.getApplicationInfo();
|
||||
final String applicationName = applicationInfo.nonLocalizedLabel.toString();
|
||||
|
||||
this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert);
|
||||
builder.setTitle(applicationName);
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
try {
|
||||
semaphore.acquire();
|
||||
}
|
||||
catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
|
|
@ -58,6 +58,7 @@ PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
|
|||
PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
|
||||
PFN_vkCmdNextSubpass vkCmdNextSubpass;
|
||||
PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
|
||||
PFN_vkCmdClearColorImage vkCmdClearColorImage;
|
||||
PFN_vkCreateImage vkCreateImage;
|
||||
PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
||||
PFN_vkCreateImageView vkCreateImageView;
|
||||
|
|
@ -68,6 +69,7 @@ PFN_vkCreateFence vkCreateFence;
|
|||
PFN_vkDestroyFence vkDestroyFence;
|
||||
PFN_vkWaitForFences vkWaitForFences;
|
||||
PFN_vkResetFences vkResetFences;
|
||||
PFN_vkResetDescriptorPool vkResetDescriptorPool;
|
||||
PFN_vkCreateCommandPool vkCreateCommandPool;
|
||||
PFN_vkDestroyCommandPool vkDestroyCommandPool;
|
||||
PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
|
||||
|
|
@ -189,6 +191,7 @@ namespace vks
|
|||
vkCmdEndRenderPass = reinterpret_cast<PFN_vkCmdEndRenderPass>(vkGetInstanceProcAddr(instance, "vkCmdEndRenderPass"));
|
||||
vkCmdNextSubpass = reinterpret_cast<PFN_vkCmdNextSubpass>(vkGetInstanceProcAddr(instance, "vkCmdNextSubpass"));
|
||||
vkCmdExecuteCommands = reinterpret_cast<PFN_vkCmdExecuteCommands>(vkGetInstanceProcAddr(instance, "vkCmdExecuteCommands"));
|
||||
vkCmdClearColorImage = reinterpret_cast<PFN_vkCmdClearColorImage>(vkGetInstanceProcAddr(instance, "vkCmdClearColorImage"));
|
||||
|
||||
vkCreateImage = reinterpret_cast<PFN_vkCreateImage>(vkGetInstanceProcAddr(instance, "vkCreateImage"));
|
||||
vkGetImageMemoryRequirements = reinterpret_cast<PFN_vkGetImageMemoryRequirements>(vkGetInstanceProcAddr(instance, "vkGetImageMemoryRequirements"));
|
||||
|
|
@ -215,6 +218,7 @@ namespace vks
|
|||
vkDestroyFence = reinterpret_cast<PFN_vkDestroyFence>(vkGetInstanceProcAddr(instance, "vkDestroyFence"));
|
||||
vkWaitForFences = reinterpret_cast<PFN_vkWaitForFences>(vkGetInstanceProcAddr(instance, "vkWaitForFences"));
|
||||
vkResetFences = reinterpret_cast<PFN_vkResetFences>(vkGetInstanceProcAddr(instance, "vkResetFences"));;
|
||||
vkResetDescriptorPool = reinterpret_cast<PFN_vkResetDescriptorPool>(vkGetInstanceProcAddr(instance, "vkResetDescriptorPool"));
|
||||
|
||||
vkCreateCommandPool = reinterpret_cast<PFN_vkCreateCommandPool>(vkGetInstanceProcAddr(instance, "vkCreateCommandPool"));
|
||||
vkDestroyCommandPool = reinterpret_cast<PFN_vkDestroyCommandPool>(vkGetInstanceProcAddr(instance, "vkDestroyCommandPool"));;
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ extern PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
|
|||
extern PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
|
||||
extern PFN_vkCmdNextSubpass vkCmdNextSubpass;
|
||||
extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
|
||||
extern PFN_vkCmdClearColorImage vkCmdClearColorImage;
|
||||
extern PFN_vkCreateImage vkCreateImage;
|
||||
extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
||||
extern PFN_vkCreateImageView vkCreateImageView;
|
||||
|
|
@ -101,6 +102,7 @@ extern PFN_vkCreateFence vkCreateFence;
|
|||
extern PFN_vkDestroyFence vkDestroyFence;
|
||||
extern PFN_vkWaitForFences vkWaitForFences;
|
||||
extern PFN_vkResetFences vkResetFences;
|
||||
extern PFN_vkResetDescriptorPool vkResetDescriptorPool;
|
||||
extern PFN_vkCreateCommandPool vkCreateCommandPool;
|
||||
extern PFN_vkDestroyCommandPool vkDestroyCommandPool;
|
||||
extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
|
||||
|
|
|
|||
|
|
@ -82,13 +82,10 @@ public:
|
|||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
title = "Order independent transparency rendering";
|
||||
|
||||
camera.type = Camera::CameraType::lookat;
|
||||
camera.setPosition(glm::vec3(0.0f, 0.0f, -6.0f));
|
||||
camera.setRotation(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
camera.setPerspective(60.0f, (float) width / (float) height, 0.1f, 256.0f);
|
||||
|
||||
settings.validation = ENABLE_VALIDATION;
|
||||
settings.overlay = true;
|
||||
}
|
||||
|
||||
|
|
@ -111,8 +108,11 @@ public:
|
|||
|
||||
void getEnabledFeatures() override
|
||||
{
|
||||
if (deviceFeatures.fragmentStoresAndAtomics)
|
||||
if (deviceFeatures.fragmentStoresAndAtomics) {
|
||||
enabledFeatures.fragmentStoresAndAtomics = VK_TRUE;
|
||||
} else {
|
||||
vks::tools::exitFatal("Selected GPU does not support stores and atomic operations in the fragment stage", VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
}
|
||||
};
|
||||
|
||||
void prepare() override
|
||||
|
|
|
|||
BIN
screenshots/oit.jpg
Normal file
BIN
screenshots/oit.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
Loading…
Add table
Add a link
Reference in a new issue