annotate src/mbaf/mbapp.c @ 802:843f1b5548d7

Allow relative path
author wycc
date Wed, 01 Sep 2010 02:06:32 +0800
parents af4b506ad56f
children 586e50f82c1f
rev   line source
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
1 #include <mb.h>
456
26c302b47de1 Change name of header files.
Thinker K.F. Li <thinker@branda.to>
parents: 454
diff changeset
2 #include <mb_af.h>
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
3
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
4 mbaf_t *mbaf_init(const char *module, const char *module_dir)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
5 {
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
6 mbaf_t *app = (mbaf_t *) malloc(sizeof(mbaf_t));
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
7 void *rt;
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
8
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
9 rt = backend.init(":0.0", 800, 600);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
10 if(rt == NULL)
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
11 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
12
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
13 sprite_set_search_path(module_dir);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
14
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
15 app->rt = rt;
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
16 app->rdman = backend.rdman(rt);
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
17 app->kbevents = backend.kbevents(rt);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
18
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
19 app->rootsprite= sprite_load(module,app->rdman, app->rdman->root_coord);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
20 if(app->rootsprite == NULL) {
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
21 backend.free(rt);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
22 free(app);
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
23 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
24 }
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
25
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
26 rdman_attach_backend(app->rdman, rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
27 MB_SPRITE_GOTO_SCENE(app->rootsprite, 1);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
28
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
29 return app;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
30 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
31
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
32 void mbaf_set_data(mbaf_t *app,void *data)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
33 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
34 app->private = (void *) data;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
35 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
36
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
37 mb_tman_t *mbaf_get_timer(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
38 {
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
39 return backend.tman(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
40 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
41
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
42 void mbaf_loop(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
43 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
44 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
45 * Start handle connections, includes one to X server.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
46 * User start to interact with the application.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
47 */
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
48 backend.loop(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
49
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
50 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
51 * Clean
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
52 */
462
af4b506ad56f Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents: 456
diff changeset
53 backend.free(app->rt);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
54 free(app);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
55 }