3dphotoshoot

changeset 16:c6952cc82cca

asset manager, android version
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 09 Jun 2015 18:38:33 +0300
parents 2d48f65da357
children aef7f51f6397
files src/android/amain.c src/android/amain.h src/android/assman.c src/assman.h
diffstat 4 files changed, 42 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/src/android/amain.c	Sun Jun 07 20:40:37 2015 +0300
     1.2 +++ b/src/android/amain.c	Tue Jun 09 18:38:33 2015 +0300
     1.3 @@ -3,6 +3,7 @@
     1.4  #include <assert.h>
     1.5  #include <EGL/egl.h>
     1.6  #include <jni.h>
     1.7 +#include "amain.h"
     1.8  #include "native_glue.h"
     1.9  #include "logger.h"
    1.10  #include "game.h"
    1.11 @@ -20,7 +21,6 @@
    1.12  static EGLSurface surf;
    1.13  static EGLContext ctx;
    1.14  
    1.15 -static struct android_app *app;
    1.16  static int win_width, win_height;
    1.17  static int init_done;
    1.18  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/android/amain.h	Tue Jun 09 18:38:33 2015 +0300
     2.3 @@ -0,0 +1,6 @@
     2.4 +#ifndef AMAIN_H_
     2.5 +#define AMAIN_H_
     2.6 +
     2.7 +struct android_app *app;
     2.8 +
     2.9 +#endif	/* AMAIN_H_ */
     3.1 --- a/src/android/assman.c	Sun Jun 07 20:40:37 2015 +0300
     3.2 +++ b/src/android/assman.c	Tue Jun 09 18:38:33 2015 +0300
     3.3 @@ -1,5 +1,30 @@
     3.4 +#include <fcntl.h>
     3.5  #include <android/asset_manager.h>
     3.6 +#include "assman.h"
     3.7 +#include "native_glue.h"
     3.8 +#include "amain.h"
     3.9  
    3.10 -void *ass_open(const char *fname)
    3.11 +ass_file *ass_fopen(const char *fname)
    3.12  {
    3.13 +	AAsset *ass;
    3.14 +
    3.15 +	if(!(ass = AAssetManager_open(app->activity->assetManager, fname, O_RDONLY))) {
    3.16 +		return 0;
    3.17 +	}
    3.18 +	return (ass_file*)ass;
    3.19  }
    3.20 +
    3.21 +void ass_fclose(ass_file *fp)
    3.22 +{
    3.23 +	AAsset_close((AAsset*)fp);
    3.24 +}
    3.25 +
    3.26 +long ass_fseek(ass_file *fp, long offs, int whence)
    3.27 +{
    3.28 +	return AAsset_seek((AAsset*)fp, offs, whence);
    3.29 +}
    3.30 +
    3.31 +size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp)
    3.32 +{
    3.33 +	return AAsset_read((AAsset*)fp, buf, size * count) / size;
    3.34 +}
     4.1 --- a/src/assman.h	Sun Jun 07 20:40:37 2015 +0300
     4.2 +++ b/src/assman.h	Tue Jun 09 18:38:33 2015 +0300
     4.3 @@ -1,11 +1,15 @@
     4.4  #ifndef ASSMAN_H_
     4.5  #define ASSMAN_H_
     4.6  
     4.7 -void *ass_open(const char *fname);
     4.8 -void ass_close(void *fp);
     4.9 -void ass_rewind(void *fp);
    4.10 -long ass_seek(void *fp, long offs, int whence);
    4.11 -long ass_read(void *fp, void *buf, long bytes);
    4.12 +#include <stdlib.h>
    4.13 +
    4.14 +typedef void ass_file;
    4.15 +
    4.16 +ass_file *ass_fopen(const char *fname);
    4.17 +void ass_fclose(ass_file *fp);
    4.18 +long ass_fseek(ass_file *fp, long offs, int whence);
    4.19 +
    4.20 +size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp);
    4.21  
    4.22  
    4.23  #endif	/* ASSMAN_H_ */