diff --git a/.gitignore b/.gitignore index d5b850d..b178ea3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/android/.gradle build/android/*.apk +build/android/*.idsig build/android/app/.cxx build/android/app/build build/android/build diff --git a/README.md b/README.md index 570857b..d6eca97 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ A simple, cross-platform 2D game engine with OpenGL and Vulkan renderers. -Supports Linux and Android (lolipop+) platforms. +Supports Linux and Android platforms. This is a personal hobby project. I've published a little game on [Google Play](https://play.google.com/store/apps/details?id=com.woom.game) based on this engine. Full game code and assets are included in this repository. diff --git a/build/android/app/CMakeLists.txt b/build/android/app/CMakeLists.txt index 3d66eaf..b9b03e5 100644 --- a/build/android/app/CMakeLists.txt +++ b/build/android/app/CMakeLists.txt @@ -14,7 +14,8 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.22.1) +project(kaliber) # OBOE Library set (OBOE_DIR ../../../src/third_party/oboe) @@ -36,9 +37,9 @@ add_library(native_app_glue STATIC # now build app's shared lib if (CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror -D_DEBUG -DVK_USE_PLATFORM_ANDROID_KHR") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Werror -Wno-unused-but-set-variable -Wno-deprecated-enum-enum-conversion -Wno-unused-parameter -Wno-unsequenced -D_DEBUG -DVK_USE_PLATFORM_ANDROID_KHR") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror -DVK_USE_PLATFORM_ANDROID_KHR") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Werror -Wno-unused-but-set-variable -Wno-deprecated-enum-enum-conversion -Wno-unused-parameter -Wno-unsequenced -DVK_USE_PLATFORM_ANDROID_KHR") endif () @@ -141,6 +142,7 @@ add_library(kaliber SHARED ../../../src/third_party/minizip/ioapi.c ../../../src/third_party/minizip/unzip.c ../../../src/third_party/spirv-reflect/spirv_reflect.c + ../../../src/third_party/stb/stb_image.c ../../../src/third_party/texture_compressor/dxt_encoder_internals.cc ../../../src/third_party/texture_compressor/dxt_encoder.cc ../../../src/third_party/texture_compressor/texture_compressor_etc1.cc diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle index dd1b471..9544c53 100644 --- a/build/android/app/build.gradle +++ b/build/android/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 - ndkVersion '21.3.6528147' + compileSdk 33 + ndkVersion '25.1.8937393' defaultConfig { applicationId = 'com.woom.game' - minSdkVersion 21 - targetSdkVersion 29 + minSdk 24 + targetSdk 33 externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_static' @@ -29,7 +29,7 @@ android { } externalNativeBuild { cmake { - version '3.10.2' + version '3.22.1' path 'CMakeLists.txt' } } @@ -39,11 +39,12 @@ android { assets.srcDirs = ['../../../assets'] } } + namespace 'com.woom.game' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'com.google.android.gms:play-services-ads:19.1.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.google.android.gms:play-services-ads:22.0.0' } diff --git a/build/android/app/src/main/AndroidManifest.xml b/build/android/app/src/main/AndroidManifest.xml index 3555ac8..19493fe 100644 --- a/build/android/app/src/main/AndroidManifest.xml +++ b/build/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ @@ -20,6 +19,7 @@ android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:screenOrientation="portrait" + android:exported="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> diff --git a/build/android/build.gradle b/build/android/build.gradle index c032b58..1ca8dd7 100644 --- a/build/android/build.gradle +++ b/build/android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:8.0.1' } } diff --git a/build/android/gradle.properties b/build/android/gradle.properties index 7bef3c2..a1f14e6 100644 --- a/build/android/gradle.properties +++ b/build/android/gradle.properties @@ -9,9 +9,13 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.defaults.buildfeatures.buildconfig=true android.enableJetifier=true +android.nonFinalResIds=false +android.nonTransitiveRClass=false android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m +android.native.buildOutput=verbose # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/build/android/gradle/wrapper/gradle-wrapper.properties b/build/android/gradle/wrapper/gradle-wrapper.properties index 401bb9f..627015e 100644 --- a/build/android/gradle/wrapper/gradle-wrapper.properties +++ b/build/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip diff --git a/build/android/sign b/build/android/sign index f809c9e..c2f0c48 100755 --- a/build/android/sign +++ b/build/android/sign @@ -1,2 +1,2 @@ -jarsigner -keystore ~/key_store/apk_key_store.jks -storepass xxx -keypass xxx -signedjar app-release.apk ./app/build/outputs/apk/release/app-release-unsigned.apk upload -zipalign -f 4 ./app-release.apk ./app-release-aligned.apk +~/Android/Sdk/build-tools/31.0.0/zipalign -p -f 4 ./app/build/outputs/apk/release/app-release-unsigned.apk ./app-release-aligned.apk +~/Android/Sdk/build-tools/31.0.0/apksigner sign -ks ~/key_store/apk_key_store.jks --ks-key-alias upload --ks-pass stdin ./app-release-aligned.apk diff --git a/src/engine/animator.cc b/src/engine/animator.cc index 13bb454..c976297 100644 --- a/src/engine/animator.cc +++ b/src/engine/animator.cc @@ -1,4 +1,4 @@ -#include "animator.h" +#include "engine/animator.h" #include "base/interpolation.h" #include "base/log.h" diff --git a/src/engine/platform/java/com/kaliber/base/KaliberActivity.java b/src/engine/platform/java/com/kaliber/base/KaliberActivity.java index 44e17b6..145a0dd 100644 --- a/src/engine/platform/java/com/kaliber/base/KaliberActivity.java +++ b/src/engine/platform/java/com/kaliber/base/KaliberActivity.java @@ -11,11 +11,18 @@ import android.util.Log; import android.view.WindowManager; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.core.content.FileProvider; -import com.google.android.gms.ads.AdListener; +import com.google.android.gms.ads.AdError; import com.google.android.gms.ads.AdRequest; -import com.google.android.gms.ads.InterstitialAd; +import com.google.android.gms.ads.FullScreenContentCallback; +import com.google.android.gms.ads.LoadAdError; +import com.google.android.gms.ads.MobileAds; +import com.google.android.gms.ads.initialization.InitializationStatus; +import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; +import com.google.android.gms.ads.interstitial.InterstitialAd; +import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback; import com.woom.game.R; import java.io.File; @@ -35,7 +42,13 @@ public class KaliberActivity extends NativeActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mInterstitialAd = newInterstitialAd(); + + MobileAds.initialize(this, new OnInitializationCompleteListener() { + @Override + public void onInitializationComplete(InitializationStatus initializationStatus) { + Log.d("kaliber", "MobileAds initialization complete."); + } + }); loadInterstitialAd(); } @@ -52,44 +65,13 @@ public class KaliberActivity extends NativeActivity { }); } - private InterstitialAd newInterstitialAd() { - InterstitialAd interstitialAd = new InterstitialAd(this); - interstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id)); - interstitialAd.setAdListener(new AdListener() { - @Override - public void onAdLoaded() { - Log.w("kaliber", "Ad loaded."); - } - - @Override - public void onAdFailedToLoad(int errorCode) { - Log.w("kaliber", "Ad failed to load. errorCode: " + errorCode); - sHandler.postDelayed(new Runnable() { - @Override - public void run() { - if (!mInterstitialAd.isLoaded()) - loadInterstitialAd(); - } - }, 1000 * 10); - } - - @Override - public void onAdClosed() { - loadInterstitialAd(); - onShowAdResult(true); - } - }); - return interstitialAd; - } - public void showInterstitialAd() { runOnUiThread(new Runnable() { @Override public void run() { - if (mInterstitialAd.isLoaded()) { - mInterstitialAd.show(); + if (mInterstitialAd != null) { + mInterstitialAd.show(KaliberActivity.this); } else { - loadInterstitialAd(); onShowAdResult(false); } } @@ -123,10 +105,49 @@ public class KaliberActivity extends NativeActivity { } private void loadInterstitialAd() { - if (!mInterstitialAd.isLoading()) { - AdRequest adRequest = new AdRequest.Builder() - .setRequestAgent("android_studio:ad_template").build(); - mInterstitialAd.loadAd(adRequest); - } + AdRequest adRequest = new AdRequest.Builder().build(); + InterstitialAd.load(this, getString(R.string.interstitial_ad_unit_id), adRequest, + new InterstitialAdLoadCallback() { + @Override + public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { + Log.d("kaliber", "Ad loaded."); + mInterstitialAd = interstitialAd; + interstitialAd.setFullScreenContentCallback( + new FullScreenContentCallback() { + @Override + public void onAdDismissedFullScreenContent() { + Log.d("kaliber", "The ad was dismissed."); + mInterstitialAd = null; + loadInterstitialAd(); + onShowAdResult(true); + } + + @Override + public void onAdFailedToShowFullScreenContent(AdError adError) { + Log.d("kaliber", "The ad failed to show."); + mInterstitialAd = null; + loadInterstitialAd(); + onShowAdResult(false); + } + + @Override + public void onAdShowedFullScreenContent() { + Log.d("kaliber", "The ad was shown."); + } + }); + } + + @Override + public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { + Log.d("kaliber", "Ad failed to load. errorCode: " + loadAdError); + mInterstitialAd = null; + sHandler.postDelayed(new Runnable() { + @Override + public void run() { + loadInterstitialAd(); + } + }, 1000 * 10); + } + }); } } diff --git a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResampler.cpp b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResampler.cpp index 4862ad8..02780a7 100644 --- a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResampler.cpp +++ b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResampler.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "IntegerRatio.h" #include "PolyphaseResampler.h" diff --git a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerMono.cpp b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerMono.cpp index 2dcdc8e..0f01aee 100644 --- a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerMono.cpp +++ b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerMono.cpp @@ -16,6 +16,8 @@ #include "PolyphaseResamplerMono.h" +#include + using namespace resampler; #define MONO 1 diff --git a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerStereo.cpp b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerStereo.cpp index 5c73a8e..b556e19 100644 --- a/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerStereo.cpp +++ b/src/third_party/oboe/src/flowgraph/resampler/PolyphaseResamplerStereo.cpp @@ -16,6 +16,8 @@ #include "PolyphaseResamplerStereo.h" +#include + using namespace resampler; #define STEREO 2 diff --git a/src/third_party/oboe/src/flowgraph/resampler/SincResampler.cpp b/src/third_party/oboe/src/flowgraph/resampler/SincResampler.cpp index 1084356..335c612 100644 --- a/src/third_party/oboe/src/flowgraph/resampler/SincResampler.cpp +++ b/src/third_party/oboe/src/flowgraph/resampler/SincResampler.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "SincResampler.h" diff --git a/src/third_party/oboe/src/flowgraph/resampler/SincResamplerStereo.cpp b/src/third_party/oboe/src/flowgraph/resampler/SincResamplerStereo.cpp index bde658a..9888777 100644 --- a/src/third_party/oboe/src/flowgraph/resampler/SincResamplerStereo.cpp +++ b/src/third_party/oboe/src/flowgraph/resampler/SincResamplerStereo.cpp @@ -18,6 +18,8 @@ #include "SincResamplerStereo.h" +#include + using namespace resampler; #define STEREO 2