annotate src/mbaf/mbapp.c @ 842:76fe4afce640

The inkscape:bbox is defined as the global coordinate system. However, the center.x and center.y must be the coordiante system of the parent group of the SVG entity. Therefore, we need to do coordinate transformation from the global coordination system to the local coordination system.
author wycc
date Sat, 18 Sep 2010 21:23:51 +0800
parents 586e50f82c1f
children 5b58e74988bc
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
2 // vim: sw=4:ts=8:sts=4
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
3 #include <mb.h>
456
26c302b47de1 Change name of header files.
Thinker K.F. Li <thinker@branda.to>
parents: 454
diff changeset
4 #include <mb_af.h>
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
5
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
6 mbaf_t *mbaf_init(const char *module, const char *module_dir)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
7 {
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
8 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
9 void *rt;
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
10
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
11 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
12 if(rt == NULL)
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
13 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
14
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
15 sprite_set_search_path(module_dir);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
16
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
17 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
18 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
19 app->kbevents = backend.kbevents(rt);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
20
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
21 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
22 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
23 backend.free(rt);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
24 free(app);
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
25 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
26 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
27
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
28 rdman_attach_backend(app->rdman, rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
29 MB_SPRITE_GOTO_SCENE(app->rootsprite, 1);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
30
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
31 return app;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
32 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
33
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
34 void mbaf_set_data(mbaf_t *app,void *data)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
35 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
36 app->private = (void *) data;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
37 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
38
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
39 mb_tman_t *mbaf_get_timer(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
40 {
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
41 return backend.tman(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
42 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
43
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
44 void mbaf_loop(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
45 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
46 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
47 * Start handle connections, includes one to X server.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
48 * User start to interact with the application.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
49 */
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
50 backend.loop(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
51
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
52 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
53 * Clean
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
54 */
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
55 backend.free(app->rt);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
56 free(app);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
57 }