26
|
1 #include <iostream>
|
|
2 #include "viewer.h"
|
105
|
3 #include "Func.h"
|
26
|
4 #include "polygon.h"
|
|
5 #include "demonstration.h"
|
|
6 #include "pad.h"
|
|
7 #include "TaskManager.h"
|
|
8 using namespace std;
|
|
9
|
49
|
10 #include "error.h"
|
|
11
|
321
|
12 // あとで直す
|
|
13 // 引数からできるように
|
109
|
14 #define SPENUM 6
|
|
15
|
|
16 /* prototype */
|
|
17 void init(int argc, char *argc[]);
|
26
|
18 int sdl_init(void*, void*);
|
105
|
19 int run_init(void*, void*);
|
26
|
20 int finish(void*, void*);
|
|
21
|
48
|
22 extern void task_initialize();
|
42
|
23
|
26
|
24 TaskManager *manager;
|
|
25 Viewer *screen;
|
|
26
|
|
27 struct init_arg {
|
|
28 int bpp;
|
|
29 int w;
|
|
30 int h;
|
|
31 };
|
|
32
|
49
|
33 struct init_arg *initArg;
|
|
34
|
26
|
35
|
321
|
36 // クラス関数は単純にポインタで扱えないので
|
|
37 // 現状は間接的に呼ぶことに
|
48
|
38 int run_loop(void *r, void *w)
|
|
39 {
|
94
|
40 __debug("[%s] start\n", __FUNCTION__);
|
48
|
41 screen->run_loop();
|
94
|
42 __debug("[%s] end\n", __FUNCTION__);
|
26
|
43 return 0;
|
|
44 }
|
|
45
|
48
|
46 int run_draw(void *r, void *w)
|
|
47 {
|
94
|
48 __debug("[%s] start\n", __FUNCTION__);
|
48
|
49 screen->run_draw();
|
94
|
50 __debug("[%s] end\n", __FUNCTION__);
|
48
|
51 return 0;
|
|
52 }
|
|
53
|
|
54 int run_finish(void *r, void *w)
|
|
55 {
|
49
|
56 __debug("[%s]\n", __FUNCTION__);
|
85
|
57 screen->run_finish();
|
48
|
58 return 0;
|
|
59 }
|
|
60
|
26
|
61 int finish(void *w, void *r)
|
|
62 {
|
49
|
63 __debug("[%s]\n", __FUNCTION__);
|
26
|
64 delete screen;
|
50
|
65 delete manager;
|
26
|
66 return 0;
|
|
67 }
|
|
68
|
49
|
69 int
|
|
70 main(int argc, char *argv[])
|
26
|
71 {
|
109
|
72 manager = new TaskManager(SPENUM);
|
26
|
73 manager->init();
|
|
74
|
35
|
75 task_initialize();
|
|
76
|
105
|
77 manager->set_func(FINISH, finish);
|
|
78 manager->set_func(VIEWER_RUN_LOOP, run_loop);
|
|
79 manager->set_func(VIEWER_RUN_DRAW, run_draw);
|
|
80 manager->set_func(VIEWER_RUN_FINISH, run_finish);
|
26
|
81
|
109
|
82 init(argc, argv);
|
|
83
|
26
|
84 manager->run();
|
48
|
85
|
|
86 finish(NULL, NULL);
|
26
|
87 return 0;
|
|
88 }
|
109
|
89
|
|
90 void
|
|
91 init(int argc, char *argv[])
|
|
92 {
|
|
93 int bpp = 0;
|
|
94 int width = 640;
|
|
95 int height = 480;
|
|
96 char *xml = "cube.xml";
|
|
97
|
|
98 for(int i = 1; argv[i]; ++i)
|
|
99 {
|
|
100 if (strcmp(argv[i], "-bpp") == 0) {
|
|
101 bpp = atoi(argv[++i]);
|
|
102 }
|
|
103 if (strcmp(argv[i], "-width") == 0) {
|
|
104 width = atoi(argv[++i]);
|
|
105 }
|
|
106 if (strcmp(argv[i], "-height") == 0) {
|
|
107 height = atoi(argv[++i]);
|
|
108 }
|
|
109 if (strcmp(argv[i], "-xml") == 0) {
|
|
110 xml = argv[++i];
|
|
111 }
|
|
112 }
|
|
113
|
|
114 //screen = new Viewer(bpp, width, height);
|
|
115 screen = new Viewer(bpp, width, height, SPENUM);
|
|
116
|
|
117 screen->sdl_init();
|
|
118 screen->run_init(xml);
|
|
119 }
|
|
120
|