forked from SaschaWillems/Vulkan
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
141 changed files
with
2,924 additions
and
2,336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,51 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
apply plugin: 'com.android.application' | ||
|
||
buildscript { | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
android { | ||
compileSdkVersion 26 | ||
defaultConfig { | ||
applicationId "org.saintandreas.vulkanexamples" | ||
minSdkVersion 26 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
ndk { abiFilter "arm64-v8a" } | ||
externalNativeBuild { | ||
cmake { | ||
arguments '-DANDROID_PLATFORM=android-26', | ||
'-DANDROID_TOOLCHAIN=clang', | ||
'-DANDROID_STL=c++_shared', | ||
'-DVULKAN_SDK=' + vulkan_sdk | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.1' | ||
|
||
sourceSets { | ||
main { | ||
jniLibs.srcDirs += "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs" | ||
assets.srcDirs += "$projectDir.absolutePath/../data" | ||
} | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
path '../CMakeLists.txt' | ||
} | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:26.1.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.0' | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// | ||
// Created by Brad on 12/21/2017. | ||
// | ||
|
||
#pragma once | ||
#ifndef VULKAN_ANDROIDNATIVEAPP_H | ||
#define VULKAN_ANDROIDNATIVEAPP_H | ||
|
||
#include "android_native_app_glue.h" | ||
#include <type_traits> | ||
|
||
namespace android { | ||
class NativeApp { | ||
public: | ||
virtual ~NativeApp() {} | ||
|
||
protected: | ||
static int32_t inputCallback(struct android_app* app, AInputEvent* event) { | ||
NativeApp* appClass = (NativeApp*)app->userData; | ||
return appClass->onInput(event); | ||
} | ||
|
||
static void appCmdCallback(struct android_app* app, int32_t cmd) { | ||
NativeApp* appClass = (NativeApp*)app->userData; | ||
appClass->onCmd(cmd); | ||
} | ||
|
||
virtual int32_t onInput(AInputEvent* event) { return 0; } | ||
|
||
virtual void onCmd(int32_t cmd) { | ||
switch (cmd) { | ||
case APP_CMD_CONFIG_CHANGED: | ||
onConfigChanged(); | ||
break; | ||
case APP_CMD_CONTENT_RECT_CHANGED: | ||
onContentRectChanged(); | ||
break; | ||
case APP_CMD_DESTROY: | ||
onDestroy(); | ||
break; | ||
case APP_CMD_GAINED_FOCUS: | ||
onGainedFocus(); | ||
break; | ||
case APP_CMD_INIT_WINDOW: | ||
onInitWindow(); | ||
break; | ||
case APP_CMD_INPUT_CHANGED: | ||
onInputCHanged(); | ||
break; | ||
case APP_CMD_LOST_FOCUS: | ||
onLostFocus(); | ||
break; | ||
case APP_CMD_LOW_MEMORY: | ||
onLowMemory(); | ||
break; | ||
case APP_CMD_PAUSE: | ||
onPause(); | ||
break; | ||
case APP_CMD_RESUME: | ||
onResume(); | ||
break; | ||
case APP_CMD_SAVE_STATE: | ||
onSaveState(); | ||
break; | ||
case APP_CMD_START: | ||
onStart(); | ||
break; | ||
case APP_CMD_STOP: | ||
onStop(); | ||
break; | ||
case APP_CMD_TERM_WINDOW: | ||
onTermWindow(); | ||
break; | ||
case APP_CMD_WINDOW_REDRAW_NEEDED: | ||
onWindowRedrawNeeded(); | ||
break; | ||
case APP_CMD_WINDOW_RESIZED: | ||
onWindowResized(); | ||
break; | ||
} | ||
} | ||
|
||
virtual void onConfigChanged() {} | ||
|
||
virtual void onContentRectChanged() {} | ||
|
||
virtual void onDestroy() {} | ||
|
||
virtual void onGainedFocus() {} | ||
|
||
virtual void onInitWindow() {} | ||
|
||
virtual void onInputCHanged() {} | ||
|
||
virtual void onLostFocus() {} | ||
|
||
virtual void onLowMemory() {} | ||
|
||
virtual void onPause() {} | ||
|
||
virtual void onResume() {} | ||
|
||
virtual void onSaveState() {} | ||
|
||
virtual void onStart() {} | ||
|
||
virtual void onStop() {} | ||
|
||
virtual void onTermWindow() {} | ||
|
||
virtual void onWindowRedrawNeeded() {} | ||
|
||
virtual void onWindowResized() {} | ||
|
||
protected: | ||
NativeApp(android_app* app) | ||
: app(app) { | ||
app->userData = this; | ||
app->onAppCmd = appCmdCallback; | ||
app->onInputEvent = inputCallback; | ||
} | ||
|
||
android_app* const app; | ||
}; | ||
|
||
template <typename T> | ||
class NativeStatefulApp : public NativeApp { | ||
using Parent = NativeApp; | ||
// FIXME | ||
// static_assert(std::is_trivally_copyable<T>::value); | ||
|
||
public: | ||
NativeStatefulApp(android_app* app) | ||
: Parent(app) { | ||
if (app->savedState != nullptr) { | ||
// We are starting with a previous saved state; restore from it. | ||
state = *reinterpret_cast<const T*>(app->savedState); | ||
} | ||
} | ||
|
||
protected: | ||
void onSaveState() override { | ||
size_t size = sizeof(T); | ||
app->savedStateSize = size; | ||
app->savedState = malloc(size); | ||
*((T*)app->savedState) = state; | ||
} | ||
|
||
T state; | ||
}; | ||
} // namespace android | ||
|
||
#endif //VULKAN_ANDROIDNATIVEAPP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.