Watch
2
0
Fork
You've already forked raylib-cs
0

add Raylib-cs.Android project

This commit is contained in:
anggape 2023-08-23 12:43:13 +07:00
commit 570ccef6af
No known key found for this signature in database
GPG key ID: 318EF680D0181D86
8 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net7.0-android</TargetFrameworks>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<RootNamespace>Raylib_cs</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../Raylib-cs/Raylib-cs.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,17 @@
using System.Runtime.InteropServices;
namespace Raylib_cs;
public abstract class RaylibActivity : NativeActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
RaylibSetAndroidCallback(OnReady);
}
protected abstract void OnReady();
[DllImport(Raylib.NativeLibName, CallingConvention = CallingConvention.Cdecl)]
private static extern void RaylibSetAndroidCallback(Action callback);
}

View file

@ -0,0 +1,27 @@
diff --git a/src/rcore.c b/src/rcore.c
index eae4951..4400b22 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -1,3 +1,22 @@
+#if defined (PLATFORM_ANDROID)
+#include <stdlib.h>
+
+typedef void (*RaylibAndroidCallback)();
+static RaylibAndroidCallback _androidCallback = NULL;
+
+void RaylibSetAndroidCallback(RaylibAndroidCallback callback) {
+ _androidCallback = callback;
+}
+
+int main(int argc, char *argv[]) {
+ (void)argc;
+ (void)argv;
+ while (_androidCallback == NULL) {
+ }
+ _androidCallback();
+}
+#endif
+
/**********************************************************************************************
*
* rcore - Basic functions to manage windows, OpenGL context and input on multiple platforms