error at assets
This commit is contained in:
parent
2bdd1b881d
commit
542a43ef0e
2 changed files with 4 additions and 12 deletions
|
@ -1,11 +1,3 @@
|
||||||
// +build android
|
// +build android
|
||||||
|
|
||||||
#include "_cgo_export.h"
|
|
||||||
|
|
||||||
struct android_app *GetAndroidApp();
|
|
||||||
|
|
||||||
void android_init() {
|
|
||||||
struct android_app *app;
|
|
||||||
app = GetAndroidApp();
|
|
||||||
asset_manager = app->activity->assetManager;
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,10 +10,11 @@ package rl
|
||||||
#include <android/native_activity.h>
|
#include <android/native_activity.h>
|
||||||
#include <android_native_app_glue.h>
|
#include <android_native_app_glue.h>
|
||||||
|
|
||||||
extern void android_init();
|
|
||||||
extern struct ANativeActivity *GetANativeActivity(void);
|
extern struct ANativeActivity *GetANativeActivity(void);
|
||||||
static AAssetManager* asset_manager;
|
|
||||||
|
|
||||||
|
static AAssetManager* getAssetManager(){
|
||||||
|
return GetANativeActivity()->assetManager;
|
||||||
|
}
|
||||||
static const char* getInternalStoragePath(){
|
static const char* getInternalStoragePath(){
|
||||||
return GetANativeActivity()->internalDataPath;
|
return GetANativeActivity()->internalDataPath;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,6 @@ func InitWindow(width int32, height int32, title string) {
|
||||||
defer C.free(unsafe.Pointer(ctitle))
|
defer C.free(unsafe.Pointer(ctitle))
|
||||||
|
|
||||||
C.InitWindow(cwidth, cheight, ctitle)
|
C.InitWindow(cwidth, cheight, ctitle)
|
||||||
C.android_init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCallbackFunc - Sets callback function
|
// SetCallbackFunc - Sets callback function
|
||||||
|
@ -102,7 +102,7 @@ func OpenAsset(name string) (Asset, error) {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
a := &asset{C.AAssetManager_open(C.asset_manager, cname, C.AASSET_MODE_UNKNOWN)}
|
a := &asset{C.AAssetManager_open(C.getAssetManager(), cname, C.AASSET_MODE_UNKNOWN)}
|
||||||
|
|
||||||
if a.ptr == nil {
|
if a.ptr == nil {
|
||||||
return nil, fmt.Errorf("asset file could not be opened")
|
return nil, fmt.Errorf("asset file could not be opened")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue