fix android platform

This commit is contained in:
MatejMagat305 2024-03-23 17:11:00 +01:00 committed by GitHub
parent 7fd1b89d00
commit 7f0babcdd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View file

@ -8,5 +8,4 @@ void android_init() {
struct android_app *app; struct android_app *app;
app = GetAndroidApp(); app = GetAndroidApp();
asset_manager = app->activity->assetManager; asset_manager = app->activity->assetManager;
internal_storage_path = app->activity->internalDataPath;
} }

View file

@ -7,12 +7,16 @@ package rl
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> #include <stdlib.h>
#include <android/asset_manager.h> #include <android/asset_manager.h>
#include <android/native_activity.h>
#include <android_native_app_glue.h> #include <android_native_app_glue.h>
extern void android_init(); extern void android_init();
extern struct ANativeActivity *GetANativeActivity(void);
static AAssetManager* asset_manager; static AAssetManager* asset_manager;
static const char* internal_storage_path; static const char* getInternalStoragePath(){
return GetANativeActivity()->internalDataPath;
}
*/ */
import "C" import "C"
@ -133,5 +137,5 @@ func (a *asset) Close() error {
} }
func getInternalStoragePath() string { func getInternalStoragePath() string {
return C.GoString(C.internal_storage_path) return C.GoString(C.getInternalStoragePath())
} }

View file

@ -50,7 +50,6 @@
#include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others #include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
//#include <android/sensor.h> // Required for: Android sensors functions (accelerometer, gyroscope, light...) //#include <android/sensor.h> // Required for: Android sensors functions (accelerometer, gyroscope, light...)
#include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL()] #include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL()]
#include <EGL/egl.h> // Native platform windowing system interface #include <EGL/egl.h> // Native platform windowing system interface
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -134,6 +133,11 @@ struct android_app *GetAndroidApp(void)
return platform.app; return platform.app;
} }
extern struct ANativeActivity *GetANativeActivity(void)
{
return platform.app->activity;
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition: Window and Graphics Device // Module Functions Definition: Window and Graphics Device
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------