annotate old/simple_render/main.cpp @ 1740:5a294d8e5643 draft

fix
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Tue, 12 Nov 2013 16:56:43 +0900
parents 3bc98f6d31ff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
1 #include <iostream>
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
2 #include "viewer.h"
105
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
3 #include "Func.h"
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
4 #include "polygon.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
5 #include "demonstration.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
6 #include "pad.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
7 #include "TaskManager.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
8 using namespace std;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
9
49
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
10 #include "error.h"
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
11
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
12 // あとで直す
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
13 // 引数からできるように
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
14 #define SPENUM 6
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
15
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
16 /* prototype */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
17 void init(int argc, char *argc[]);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
18 int sdl_init(void*, void*);
105
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
19 int run_init(void*, void*);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
20 int finish(void*, void*);
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
21
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
22 extern void task_initialize();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 35
diff changeset
23
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
24 TaskManager *manager;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
25 Viewer *screen;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
27 struct init_arg {
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
28 int bpp;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
29 int w;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
30 int h;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
31 };
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
32
49
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
33 struct init_arg *initArg;
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
34
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
35
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
36 // クラス関数は単純にポインタで扱えないので
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
37 // 現状は間接的に呼ぶことに
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
38 int run_loop(void *r, void *w)
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
39 {
94
588ab5f0e659 *** empty log message ***
gongo
parents: 85
diff changeset
40 __debug("[%s] start\n", __FUNCTION__);
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
41 screen->run_loop();
94
588ab5f0e659 *** empty log message ***
gongo
parents: 85
diff changeset
42 __debug("[%s] end\n", __FUNCTION__);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
43 return 0;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
44 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
45
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
46 int run_draw(void *r, void *w)
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
47 {
94
588ab5f0e659 *** empty log message ***
gongo
parents: 85
diff changeset
48 __debug("[%s] start\n", __FUNCTION__);
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
49 screen->run_draw();
94
588ab5f0e659 *** empty log message ***
gongo
parents: 85
diff changeset
50 __debug("[%s] end\n", __FUNCTION__);
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
51 return 0;
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
52 }
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
53
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
54 int run_finish(void *r, void *w)
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
55 {
49
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
56 __debug("[%s]\n", __FUNCTION__);
85
9b96b190cb73 *** empty log message ***
gongo
parents: 79
diff changeset
57 screen->run_finish();
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
58 return 0;
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
59 }
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
60
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
61 int finish(void *w, void *r)
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
62 {
49
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
63 __debug("[%s]\n", __FUNCTION__);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
64 delete screen;
50
7927e00fb8e2 *** empty log message ***
gongo
parents: 49
diff changeset
65 delete manager;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
66 return 0;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
67 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
68
49
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
69 int
64ef030deb22 *** empty log message ***
gongo
parents: 48
diff changeset
70 main(int argc, char *argv[])
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
71 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
72 manager = new TaskManager(SPENUM);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
73 manager->init();
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
74
35
1e17e0b441a7 *** empty log message ***
gongo
parents: 31
diff changeset
75 task_initialize();
1e17e0b441a7 *** empty log message ***
gongo
parents: 31
diff changeset
76
105
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
77 manager->set_func(FINISH, finish);
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
78 manager->set_func(VIEWER_RUN_LOOP, run_loop);
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
79 manager->set_func(VIEWER_RUN_DRAW, run_draw);
3e331f7576a1 *** empty log message ***
gongo
parents: 94
diff changeset
80 manager->set_func(VIEWER_RUN_FINISH, run_finish);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
81
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
82 init(argc, argv);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
83
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
84 manager->run();
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
85
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
86 finish(NULL, NULL);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
87 return 0;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
88 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
89
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
90 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
91 init(int argc, char *argv[])
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
92 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
93 int bpp = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
94 int width = 640;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
95 int height = 480;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
96 char *xml = "cube.xml";
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
97
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
98 for(int i = 1; argv[i]; ++i)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
99 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
100 if (strcmp(argv[i], "-bpp") == 0) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
101 bpp = atoi(argv[++i]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
102 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
103 if (strcmp(argv[i], "-width") == 0) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
104 width = atoi(argv[++i]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
105 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
106 if (strcmp(argv[i], "-height") == 0) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
107 height = atoi(argv[++i]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
108 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
109 if (strcmp(argv[i], "-xml") == 0) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
110 xml = argv[++i];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
111 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
112 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
113
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
114 //screen = new Viewer(bpp, width, height);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
115 screen = new Viewer(bpp, width, height, SPENUM);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
116
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
117 screen->sdl_init();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
118 screen->run_init(xml);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
119 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 105
diff changeset
120