annotate src/mbaf/mbapp.c @ 383:5b6230df7630

mgerge
author wycc
date Sun, 05 Apr 2009 12:29:35 +0800
parents 2e97e8082d83
children 84ce2d4a8c3f
rev   line source
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
1 #include <mb.h>
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
2 #include <mbapp.h>
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
3 MBApp *MBApp_Init(char *module)
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
4 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
5 MBApp *app = (MBApp *) malloc(sizeof(MBApp));
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
6 X_MB_runtime_t *rt;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
7
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
8 rt = X_MB_new(":0.0", 800, 600);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
9
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
10 app->rt = rt;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
11 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
12 app->kbevents = X_MB_kbevents(rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
13 app->rootsprite= sprite_load(module,app->rdman, app->rdman->root_coord);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
14 rdman_attach_backend(app->rdman, rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
15 MB_SPRITE_GOTO_SCENE(app->rootsprite, 1);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
16 return app;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
17 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
18
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
19 void MBApp_setData(MBApp *app,void *data)
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
20 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
21 app->private = (void *) data;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
22 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
23
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
24 mb_tman_t *MBApp_getTimer(MBApp *app)
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
25 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
26 return X_MB_tman(app->rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
27 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
28
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
29 void MBApp_loop(MBApp *en)
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
30 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
31 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
32 * Start handle connections, includes one to X server.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
33 * User start to interact with the application.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
34 */
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
35 X_MB_handle_connection(en->rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
36
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
37 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
38 * Clean
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
39 */
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
40 X_MB_free(en->rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
41 free(en);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
42 }