annotate src/mbaf/mbapp.c @ 994:5d9def42df12 refine_backend_if

Rename mb_backend_t::tman() to mb_backend_t::timer_man()
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 22 Nov 2010 00:42:29 +0800
parents 5b58e74988bc
children 8c556e0839eb
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>
993
5b58e74988bc Use mb_backend_t::new instead of mb_backend_t::init
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
5 #include <mb_backend.h>
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
6
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
7 mbaf_t *mbaf_init(const char *module, const char *module_dir)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
8 {
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
9 mbaf_t *app = (mbaf_t *) malloc(sizeof(mbaf_t));
993
5b58e74988bc Use mb_backend_t::new instead of mb_backend_t::init
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
10 mb_rt_t *rt;
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
11
993
5b58e74988bc Use mb_backend_t::new instead of mb_backend_t::init
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
12 rt = backend.new(":0.0", 800, 600);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
13 if(rt == NULL)
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
14 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
15
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
16 sprite_set_search_path(module_dir);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
17
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
18 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
19 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
20 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
21
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
22 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
23 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
24 backend.free(rt);
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
25 free(app);
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
26 return NULL;
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 296
diff changeset
27 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 462
diff changeset
28
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
29 rdman_attach_backend(app->rdman, rt);
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
30 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
31
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
32 return app;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
33 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
34
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
35 void mbaf_set_data(mbaf_t *app,void *data)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
36 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
37 app->private = (void *) data;
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
38 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
39
994
5d9def42df12 Rename mb_backend_t::tman() to mb_backend_t::timer_man()
Thinker K.F. Li <thinker@codemud.net>
parents: 993
diff changeset
40 mb_timer_man_t *mbaf_get_timer(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
41 {
994
5d9def42df12 Rename mb_backend_t::tman() to mb_backend_t::timer_man()
Thinker K.F. Li <thinker@codemud.net>
parents: 993
diff changeset
42 return backend.timer_man(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
43 }
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
44
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
45 void mbaf_loop(mbaf_t *app)
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
46 {
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
47 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
48 * Start handle connections, includes one to X server.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
49 * User start to interact with the application.
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
50 */
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
51 backend.loop(app->rt);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
52
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
53 /*
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
54 * Clean
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
55 */
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
56 backend.free(app->rt);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
57 free(app);
294
2ca0773cd48d * Add MBAF files
wycc
parents:
diff changeset
58 }