Skip to content

Commit 50cbef3

Browse files
committed
integrated camera
1 parent f872c3e commit 50cbef3

30 files changed

+3102
-1
lines changed

.gitignore

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# QtCreator
2-
*.user
2+
*.user
3+
# Android
4+
build/
5+
app/jni/SDL*
6+
app/jni/visageSDK
7+
app/build
8+
app/.externalNativeBuild
9+
.gradle
10+
.idea
11+
gradle
12+
gradlew
13+
gradlew.bat
14+
local.properties

.gitmodules

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "app/jni/src/facesmash-sources"]
2+
path = app/jni/src/facesmash-sources
3+
url = [email protected]:gamee-boy/facesmash-sources.git
4+
[submodule "app/jni/src/entt"]
5+
path = app/jni/src/entt
6+
url = [email protected]:skypjack/entt.git
7+
[submodule "app/src/main/assets"]
8+
path = app/src/main/assets
9+
url = [email protected]:gamee-boy/facesmash-assets.git

app/app.iml

+229
Large diffs are not rendered by default.

app/build.gradle

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 27
5+
buildToolsVersion "27.0.3"
6+
defaultConfig {
7+
applicationId "com.cynny.gamee.facesmash"
8+
minSdkVersion 16
9+
targetSdkVersion 16
10+
versionCode 1
11+
versionName "1.0"
12+
ndk {
13+
abiFilters 'armeabi-v7a'
14+
}
15+
externalNativeBuild {
16+
ndkBuild {
17+
arguments "APP_PLATFORM=android-16"
18+
}
19+
}
20+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
21+
}
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
sourceSets.main {
29+
jniLibs.srcDir 'libs'
30+
}
31+
externalNativeBuild {
32+
ndkBuild {
33+
path 'jni/Android.mk'
34+
}
35+
}
36+
lintOptions {
37+
abortOnError false
38+
}
39+
}
40+
41+
dependencies {
42+
compile fileTree(include: ['*.jar'], dir: 'libs')
43+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
44+
exclude group: 'com.android.support', module: 'support-annotations'
45+
})
46+
testCompile 'junit:junit:4.12'
47+
}

app/jni/Android.mk

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include $(call all-subdir-makefiles)
2+
3+
APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64

app/jni/Application.mk

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Uncomment this if you're using STL in your project
3+
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
4+
APP_STL := gnustl_static
5+
6+
APP_ABI := armeabi-v7a
7+
8+
# Min SDK level
9+
APP_PLATFORM=android-14

app/jni/src/Android.mk

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
5+
LOCAL_MODULE := facesmash
6+
7+
SDL_PATH := ../SDL
8+
SDL_IMAGE_PATH := ../SDL_image
9+
SDL_TTF_PATH := ../SDL_ttf
10+
11+
ENTT_DIR := entt
12+
ENTT_SRC_DIR := $(ENTT_DIR)/src
13+
FACESMASH_DIR := facesmash-sources
14+
FACESMASH_SRC_DIR := $(FACESMASH_DIR)/src
15+
16+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
17+
$(LOCAL_PATH)/$(SDL_IMAGE_PATH) \
18+
$(LOCAL_PATH)/$(SDL_TTF_PATH) \
19+
$(LOCAL_PATH)/$(ENTT_SRC_DIR) \
20+
$(LOCAL_PATH)/$(FACESMASH_SRC_DIR)
21+
22+
# Add your application source files here...
23+
LOCAL_SRC_FILES := $(FACESMASH_SRC_DIR)/game/game_env.cpp \
24+
$(FACESMASH_SRC_DIR)/game/game_loop.cpp \
25+
$(FACESMASH_SRC_DIR)/game/game_renderer.cpp \
26+
$(FACESMASH_SRC_DIR)/input/user_input_handler.cpp \
27+
$(FACESMASH_SRC_DIR)/resource/font_resource.cpp \
28+
$(FACESMASH_SRC_DIR)/resource/texture_resource.cpp \
29+
$(FACESMASH_SRC_DIR)/service/audio_service.cpp \
30+
$(FACESMASH_SRC_DIR)/service/camera_android.cpp \
31+
$(FACESMASH_SRC_DIR)/service/camera_null.cpp \
32+
$(FACESMASH_SRC_DIR)/service/face_bus_service.cpp \
33+
$(FACESMASH_SRC_DIR)/system/combo_system.cpp \
34+
$(FACESMASH_SRC_DIR)/system/destroy_later_system.cpp \
35+
$(FACESMASH_SRC_DIR)/system/face_smash_system.cpp \
36+
$(FACESMASH_SRC_DIR)/system/face_spawner_system.cpp \
37+
$(FACESMASH_SRC_DIR)/system/fade_animation_system.cpp \
38+
$(FACESMASH_SRC_DIR)/system/frame_system.cpp \
39+
$(FACESMASH_SRC_DIR)/system/hud_system.cpp \
40+
$(FACESMASH_SRC_DIR)/system/movement_system.cpp \
41+
$(FACESMASH_SRC_DIR)/system/rendering_system.cpp \
42+
$(FACESMASH_SRC_DIR)/system/rotation_animation_system.cpp \
43+
$(FACESMASH_SRC_DIR)/system/scene_system.cpp \
44+
$(FACESMASH_SRC_DIR)/system/score_system.cpp \
45+
$(FACESMASH_SRC_DIR)/system/smash_button_system.cpp \
46+
$(FACESMASH_SRC_DIR)/system/sprite_animation_system.cpp \
47+
$(FACESMASH_SRC_DIR)/system/timer_system.cpp \
48+
$(FACESMASH_SRC_DIR)/system/ui_button_system.cpp \
49+
$(FACESMASH_SRC_DIR)/time/clock.cpp \
50+
$(FACESMASH_SRC_DIR)/main.cpp \
51+
facesmash_binding.cpp
52+
53+
LOCAL_SHARED_LIBRARIES := SDL2 \
54+
SDL2_image \
55+
SDL2_ttf
56+
57+
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
58+
59+
LOCAL_CPPFLAGS += -std=c++1z -DDEBUG
60+
61+
include $(BUILD_SHARED_LIBRARY)

app/jni/src/entt

Submodule entt added at 9761b6e

app/jni/src/facesmash-sources

Submodule facesmash-sources added at 6803a16

app/jni/src/facesmash_binding.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <jni.h>
2+
#include "locator/locator.hpp"
3+
#include "service/camera_android.h"
4+
#include <tuple>
5+
6+
7+
8+
namespace gamee {
9+
10+
static std::pair<int, int> resolution{-1, -1};
11+
static int bitsPerPixel = -1;
12+
13+
14+
std::tuple<int, int, int> facesmashGetCameraParams() {
15+
return std::make_tuple(resolution.first, resolution.second, bitsPerPixel);
16+
}
17+
18+
} // namespace gamee
19+
20+
21+
extern "C" {
22+
23+
void Java_com_cynny_gamee_facesmash_FaceSmashActivity_WriteFrameCamera(JNIEnv* env, jobject obj, jbyteArray frame) {
24+
jbyte* data = env->GetByteArrayElements(frame, 0);
25+
auto length = env->GetArrayLength(frame);
26+
std::vector v{data, data + length};
27+
auto& camera = static_cast<gamee::CameraAndroid&>(gamee::Locator::Camera::ref());
28+
camera.setPixels(data);
29+
env->ReleaseByteArrayElements(frame, data, 0);
30+
}
31+
32+
33+
void Java_com_cynny_gamee_facesmash_FaceSmashActivity_WriteCameraParams(JNIEnv* env, jobject obj, jint width, jint height, jint bits) {
34+
gamee::resolution = {width, height};
35+
gamee::bitsPerPixel = bits;
36+
}
37+
38+
} // extern "C"

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in [sdk]/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}

app/src/main/AndroidManifest.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Replace com.test.game with the identifier of your game below, e.g.
3+
com.gamemaker.game
4+
-->
5+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
6+
package="com.cynny.gamee.facesmash"
7+
android:installLocation="auto">
8+
9+
<!-- OpenGL ES 2.0 -->
10+
<uses-feature android:glEsVersion="0x00020000" />
11+
12+
<!-- Allow writing to external storage -->
13+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
14+
<!-- Allow access to the vibrator -->
15+
<uses-permission android:name="android.permission.VIBRATE" />
16+
<uses-permission android:name="android.permission.CAMERA" />
17+
<uses-feature android:name="android.hardware.camera" />
18+
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
19+
<uses-feature android:name="android.hardware.camera.autofocus" />
20+
21+
<!-- if you want to capture audio, uncomment this. -->
22+
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
23+
24+
<!-- Create a Java class extending SDLActivity and place it in a
25+
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
26+
27+
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
28+
in the XML below.
29+
30+
An example Java class can be found in README-android.md
31+
-->
32+
<application android:label="@string/app_name"
33+
android:icon="@mipmap/ic_launcher"
34+
android:allowBackup="true"
35+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
36+
android:hardwareAccelerated="true" >
37+
38+
<!-- Example of setting SDL hints from AndroidManifest.xml:
39+
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
40+
-->
41+
42+
<activity android:name="com.cynny.gamee.facesmash.FaceSmashActivity"
43+
android:label="@string/app_name"
44+
android:screenOrientation="portrait"
45+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
46+
>
47+
<intent-filter>
48+
<action android:name="android.intent.action.MAIN" />
49+
<category android:name="android.intent.category.LAUNCHER" />
50+
</intent-filter>
51+
<!-- Drop file event -->
52+
<!--
53+
<intent-filter>
54+
<action android:name="android.intent.action.VIEW" />
55+
<category android:name="android.intent.category.DEFAULT" />
56+
<data android:mimeType="*/*" />
57+
</intent-filter>
58+
-->
59+
</activity>
60+
</application>
61+
62+
</manifest>

app/src/main/assets

Submodule assets added at 4f0d96b

0 commit comments

Comments
 (0)