Skip to content

Commit 326a1fe

Browse files
committed
Replaced NativeActivity with GameActivity
1 parent 72c144a commit 326a1fe

File tree

98 files changed

+1654
-1406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1654
-1406
lines changed

common/nativeactivity/build.gradle

-38
This file was deleted.

common/nativeactivity/proguard-rules.pro

-17
This file was deleted.

common/nativeactivity/src/main/AndroidManifest.xml

-7
This file was deleted.

common/src/GameActivitySources.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2022 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// GameActivity's C/C++ code
16+
#include <game-activity/GameActivity.cpp>
17+
#include <game-text-input/gametextinput.cpp>
18+
19+
// Glue from GameActivity to android_main()
20+
// Passing GameActivity event from main thread to app native thread.
21+
extern "C" {
22+
#include <game-activity/native_app_glue/android_native_app_glue.c>
23+
}
+32-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,49 @@
1+
// Copyright 2022 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
apply plugin: 'com.android.application'
216

317
android {
4-
compileSdkVersion 30
18+
compileSdkVersion 31
519
ndkVersion '22.1.7171670'
620

721
defaultConfig {
8-
applicationId "com.google.vulkan.tutorials.one"
22+
applicationId "com.android.example.vulkan.tutorials.one"
923
minSdkVersion 24
10-
targetSdkVersion 30
11-
versionCode 1
12-
versionName "0.0.1"
24+
targetSdkVersion 31
25+
26+
versionCode 272
27+
versionName "1.1.0"
1328
externalNativeBuild {
1429
cmake {
1530
abiFilters "armeabi-v7a", 'arm64-v8a', 'x86', 'x86_64'
1631
arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static'
1732
}
1833
}
1934
}
20-
externalNativeBuild.cmake.path = 'src/main/jni/CMakeLists.txt'
35+
externalNativeBuild {
36+
cmake {
37+
version '3.18.1'
38+
path 'src/main/cpp/CMakeLists.txt'
39+
}
40+
}
2141

2242
buildTypes.release.minifyEnabled = false
43+
buildFeatures.prefab = true
44+
}
45+
46+
dependencies {
47+
implementation 'androidx.appcompat:appcompat:1.4.1'
48+
implementation "androidx.games:games-activity:1.1.0"
2349
}

tutorial01_load_vulkan/app/src/main/AndroidManifest.xml

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2022 Google Inc. All Rights Reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http:www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<!-- BEGIN_INCLUDE(manifest) -->
318
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
4-
package="com.google.vulkan.tutorials.one"
5-
android:versionCode="1"
6-
android:versionName="1.0">
19+
package="com.android.example.vulkan.tutorials.one"
20+
android:versionCode="272"
21+
android:versionName="1.1.0">
722

823
<application android:label="@string/app_name"
9-
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
24+
android:theme="@style/Application.Fullscreen">
25+
<activity
26+
android:name=".MainActivity"
27+
android:exported="true"
28+
android:configChanges="orientation|keyboardHidden">
1029

11-
<!-- Our activity is the built-in NativeActivity framework class.
12-
This will take care of integrating with our NDK code. -->
13-
<activity android:name="android.app.NativeActivity"
14-
android:label="@string/app_name"
15-
android:configChanges="orientation|keyboardHidden">
16-
<!-- Tell NativeActivity the name of or .so -->
30+
<!-- Tell GameActivity the name of our .so.
31+
This will be optional after the release 1.1.0 -->
1732
<meta-data android:name="android.app.lib_name"
1833
android:value="vktuts" />
1934
<intent-filter>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#[[
2+
Copyright 2022 Google Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
]]
16+
cmake_minimum_required(VERSION 3.4.1)
17+
18+
project(vktuts)
19+
20+
# Integrate GameActivity, refer to
21+
# https://d.android.com/games/agdk/integrate-game-activity
22+
# for the detailed instructions.
23+
find_package(game-activity REQUIRED CONFIG)
24+
25+
set(SRC_DIR ${CMAKE_SOURCE_DIR})
26+
get_filename_component(REPO_ROOT_DIR
27+
${CMAKE_SOURCE_DIR}/../../../../.. ABSOLUTE)
28+
set(COMMON_DIR ${REPO_ROOT_DIR}/common)
29+
30+
add_library(${CMAKE_PROJECT_NAME} SHARED
31+
main.cpp
32+
${COMMON_DIR}/vulkan_wrapper/vulkan_wrapper.cpp
33+
${COMMON_DIR}/src/GameActivitySources.cpp)
34+
35+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -std=c++11 \
36+
-DVK_USE_PLATFORM_ANDROID_KHR")
37+
38+
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
39+
${COMMON_DIR}/vulkan_wrapper)
40+
target_link_libraries(${CMAKE_PROJECT_NAME}
41+
game-activity::game-activity
42+
log
43+
android)

tutorial01_load_vulkan/app/src/main/jni/main.cpp tutorial01_load_vulkan/app/src/main/cpp/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 Google Inc. All Rights Reserved.
1+
// Copyright 2022 Google Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -13,10 +13,10 @@
1313
// limitations under the License.
1414

1515
#include <android/log.h>
16-
#include <android_native_app_glue.h>
1716
#include <cassert>
1817
#include <vector>
19-
#include "vulkan_wrapper.h"
18+
#include <vulkan_wrapper.h>
19+
#include <game-activity/native_app_glue/android_native_app_glue.h>
2020

2121
// Android log function wrappers
2222
static const char* kTAG = "Vulkan-Tutorial01";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2022 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.android.example.vulkan.tutorials.one;
16+
17+
import com.google.androidgamesdk.GameActivity;
18+
import android.os.Bundle;
19+
20+
public class MainActivity extends GameActivity {
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
}
26+
static {
27+
System.loadLibrary("vktuts");
28+
}
29+
}
30+

tutorial01_load_vulkan/app/src/main/jni/CMakeLists.txt

-16
This file was deleted.

0 commit comments

Comments
 (0)