Mercurial > MadButterfly
annotate src/mbaf/mbapp.c @ 793:cad706a8f5b1
Simplify phone.js
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 31 Aug 2010 09:23:33 +0800 |
parents | af4b506ad56f |
children | 586e50f82c1f |
rev | line source |
---|---|
294 | 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 | 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 | 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 | 14 |
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 | 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 | 26 rdman_attach_backend(app->rdman, rt); |
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 | 29 return app; |
30 } | |
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 | 33 { |
34 app->private = (void *) data; | |
35 } | |
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 | 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 | 40 } |
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 | 43 { |
44 /* | |
45 * Start handle connections, includes one to X server. | |
46 * User start to interact with the application. | |
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 | 49 |
50 /* | |
51 * Clean | |
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 | 55 } |