annotate examples/dynamic/mbapp.c @ 303:f894b30676e9

Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
author wycc
date Sun, 15 Feb 2009 08:34:57 +0800
parents 248a40d51473
children
rev   line source
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
1 #include <mb.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
2 #include <mbapp.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
3 MBApp *MBApp_Init(char *module)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
4 {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
5 MBApp *app = (MBApp *) malloc(sizeof(MBApp));
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
6 X_MB_runtime_t *rt;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
7
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
8 rt = X_MB_new(":0.0", 800, 600);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
9
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
10 app->rt = rt;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
11 app->rdman = X_MB_rdman(rt);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
12 app->rootsprite= sprite_load(module,app->rdman, app->rdman->root_coord);
249
ab8284c8dcee * Add loopback reference from rdman to the backend. This is only required when we need to acquire the tman for the animation. This is not a reasonable arrangement since the animation should be backend transparent. We should not touch the backend directly from the animation. We should relocate the tman to the rdman.
wycc
parents: 247
diff changeset
13 rdman_attach_backend(app->rdman, rt);
285
248a40d51473 Check in test program for sh_text_set_text for debugging. It is not working yet.
wycc
parents: 249
diff changeset
14 MB_SPRITE_GOTO_SCENE(app->rootsprite, 1);
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
15 return app;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
16 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
17
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
18 void MBApp_setData(MBApp *app,void *data)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
19 {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
20 app->private = (void *) data;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
21 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
22
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
23 mb_tman_t *MBApp_getTimer(MBApp *app)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
24 {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
25 return X_MB_tman(app->rt);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
26 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
27
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
28 void MBApp_loop(MBApp *en)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
29 {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
30 /*
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
31 * Start handle connections, includes one to X server.
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
32 * User start to interact with the application.
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
33 */
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
34 X_MB_handle_connection(en->rt);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
35
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
36 /*
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
37 * Clean
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
38 */
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
39 X_MB_free(en->rt);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
40 free(en);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
41 }