Mercurial > MadButterfly
annotate src/mbaf/mbapp.c @ 454:9b8dda201ccb
Make naming convention consistent with MadButterfly.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 06 Aug 2009 09:38:51 +0800 |
parents | 84ce2d4a8c3f |
children | 26c302b47de1 |
rev | line source |
---|---|
294 | 1 #include <mb.h> |
2 #include <mbapp.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)); |
294 | 7 X_MB_runtime_t *rt; |
8 | |
9 rt = X_MB_new(":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; | |
16 app->rdman = X_MB_rdman(rt); | |
296
2e97e8082d83
* Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
294
diff
changeset
|
17 app->kbevents = X_MB_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) { |
84ce2d4a8c3f
Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents:
296
diff
changeset
|
21 X_MB_free(rt); |
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 { |
39 return X_MB_tman(app->rt); | |
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 */ | |
454
9b8dda201ccb
Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
453
diff
changeset
|
48 X_MB_handle_connection(app->rt); |
294 | 49 |
50 /* | |
51 * Clean | |
52 */ | |
454
9b8dda201ccb
Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
453
diff
changeset
|
53 X_MB_free(app->rt); |
9b8dda201ccb
Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
453
diff
changeset
|
54 free(app); |
294 | 55 } |