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

first working android build

This commit is contained in:
anggape 2023-07-22 18:24:03 +07:00
commit f964d72806
No known key found for this signature in database
GPG key ID: 318EF680D0181D86
3 changed files with 39 additions and 7 deletions

View file

@ -1,13 +1,42 @@
using System.Runtime.InteropServices;
using Android.Content;
using Android.Content.PM;
namespace Raylib_cs.Android;
[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
[
Activity(
Label = "@string/app_name",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.Orientation
| ConfigChanges.KeyboardHidden
| ConfigChanges.ScreenSize,
ScreenOrientation = ScreenOrientation.Landscape,
ClearTaskOnLaunch = true
),
IntentFilter(new[] { Intent.ActionMain }),
MetaData(NativeActivity.MetaDataLibName, Value = "raylib")
]
public class MainActivity : NativeActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
static MainActivity()
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
RaylibSetAndroidCallback(Main);
}
private static void Main()
{
Raylib.InitWindow(0, 0, "android_window");
while (!Raylib.WindowShouldClose())
{
Raylib.BeginDrawing();
Raylib.ClearBackground(Color.WHITE);
Raylib.DrawFPS(10, 10);
Raylib.DrawText("Hello Raylib-cs.Android", 20, 100, 100, Color.BLACK);
Raylib.EndDrawing();
}
}
[DllImport("raylib")]
private static extern void RaylibSetAndroidCallback(Action callback);
}