annotate TaskManager/Test/test_render/viewer.cpp @ 138:3fd24be89d02

オブジェクトを増やして複数の表示に成功。 TODO:オブジェクトの削除
author gongo@charles.cr.ie.u-ryukyu.ac.jp
date Fri, 28 Nov 2008 12:16:24 +0900
parents 6cf991f28c6c
children 861271089c43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include "viewer.h"
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
2 #include "viewer_types.h"
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
3 #include "SceneGraph.h"
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
4 #include "scene_graph_pack.h"
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "sys.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "Func.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include "error.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8 #include "TaskManager.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 extern void post2runLoop(void *);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 extern void post2runDraw(void *);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 /* measure for FPS (Frame Per Second) */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 int start_time;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 int this_time;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 int frames;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
18 SceneGraph *scene_graph;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 /* Data Pack */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 SceneGraphPack *sgpack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 PolygonPack *ppack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 SpanPackPtr spackList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 SpanPackPtr *spackList_ptr;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 int spackList_length;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 int spackList_length_align;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 void *__texture;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 Viewer::Viewer(int b, int w, int h, int _num)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 bpp = b;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 width = w;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 height = h;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 spe_num = _num;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 Viewer::get_ticks()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 int time;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 time = SDL_GetTicks();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 return time;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 bool
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 Viewer::quit_check()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 SDL_Event event;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51 while(SDL_PollEvent(&event)) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 if (event.type==SDL_QUIT) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 return true;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 Uint8 *keys=SDL_GetKeyState(NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 if (keys[SDLK_q] == SDL_PRESSED) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 return true;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 return false;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 Viewer::quit()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 SDL_Quit();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73 Viewer::swap_buffers()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 SDL_GL_SwapBuffers();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
78 extern void node_init(void);
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
79
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 Viewer::run_init(char *xml)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 HTaskPtr task_next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 HTaskPtr task_init_tex;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 start_time = get_ticks();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87 this_time = 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 frames = 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
90 scene_graph = SceneGraph::createFromXMLfile(xml);
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
91 //polygon->viewer = this;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
92
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
93 node_init();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95 sgpack = (SceneGraphPack*)manager->malloc(sizeof(SceneGraphPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 sgpack->init();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 ppack = (PolygonPack*)manager->malloc(sizeof(PolygonPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99 spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 spackList = (SpanPack*)manager->malloc(sizeof(SpanPack)*spackList_length);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
102 // SPU に送る address list は 16 倍数でないといけない。
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
103 // spackList_length*sizeof(SpanPack*) が 16 倍数になるような
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
104 // length_align を求めている。
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105 spackList_length_align = (spackList_length + 3)&(~3);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
107 /* 各 SPU が持つ、SpanPack の address list */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
108 spackList_ptr = (SpanPack**)manager->malloc(sizeof(SpanPack*)*spackList_length_align);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110 for (int i = 0; i < spackList_length; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
111 spackList_ptr[i] = &spackList[i];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
112 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
113
126
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
114 for (int i = 1; i <= spackList_length; i++) {
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
115 spackList[i-1].init(i*split_screen_h);
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
116 }
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
117
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
118 task_next = manager->create_task(TASK_DUMMY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
119 task_next->set_post(&post2runLoop, NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
120
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
121 #if 0
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
122 // 諸事情で、今は SceneGraphPack を作らずに
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
123 // そのまま SceneGraph でやっています
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
124 HTaskPtr task_sgp;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
125 task_sgp = manager->create_task(TASK_CREATE_SGP);
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
126 task_sgp->add_param((uint32)scene_graph);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
127 task_sgp->add_param((uint32)sgpack);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
128 task_next->wait_for(task_sgp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
129 task_sgp->spawn();
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
130 #endif
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
131
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
132 int tex_width = scene_graph->texture_image->w;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
133 int tex_height = scene_graph->texture_image->h;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
134 int tex_blocksize = tex_width*tex_height*4;
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
135
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
136 __texture = (void*)manager->malloc(tex_blocksize);
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
137 memcpy(__texture, scene_graph->texture_image->pixels, tex_blocksize);
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
138
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
139 uint32 *tex_src = (uint32*)scene_graph->texture_image->pixels;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
140 uint32 *tex_dest = (uint32*)manager->malloc(tex_blocksize);
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
141 int tile_size = TEXTURE_SPLIT_PIXEL*TEXTURE_SPLIT_PIXEL;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
142 int tile_num = tex_width*tex_height/tile_size;
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
143 tile_num = (tile_num + 15)&(~15);
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
144 void **tex_addrList = (void**)manager->malloc(sizeof(void*)*tile_num);
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
145
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
146 {
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
147 int t = 0;
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
148
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
149 for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL) {
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
150 for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL) {
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
151 for (int j = 0; j < TEXTURE_SPLIT_PIXEL; j++) {
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
152 for (int i = 0; i < TEXTURE_SPLIT_PIXEL; i++) {
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
153 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
154 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
155 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
156 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
157 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
158
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
159 t = 0;
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
160
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
161 for (int i = 0, t = 0; i < tex_width*tex_height; i += tile_size, t++) {
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
162 tex_addrList[t] = (void*)&tex_dest[i];
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
163 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
164 }
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
165
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
166 for (int i = 0; i < spe_num; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
167 task_init_tex = manager->create_task(TASK_INIT_TEXTURE);
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
168 task_init_tex->add_inData(tex_addrList, sizeof(void*)*tile_num);
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
169 task_init_tex->add_param(tile_num);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
170 task_init_tex->set_cpu(SPE_ANY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
171 task_next->wait_for(task_init_tex);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
172 task_init_tex->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
173 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
174
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
175 task_next->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
176 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
177
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
178 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
179 Viewer::run_loop(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
180 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
181 HTaskPtr task_create_pp = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
182 HTaskPtr task_create_sp = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
183 HTaskPtr task_next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
184 bool quit_flg;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
185
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
186 quit_flg = quit_check();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
187
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
188 if (quit_flg == true) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
189 this_time = get_ticks();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
190 run_finish();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
191 return;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
192 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
193
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
194 clean_pixels();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
195
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
196 for (int i = 1; i <= spackList_length; i++) {
126
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
197 spackList[i-1].reinit(i*split_screen_h);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
198 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
199
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
200 task_next = manager->create_task(TASK_DUMMY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
201 task_next->set_post(post2runDraw, NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
202
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
203 #if 0
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
204 HTaskPtr task_update_sgp = NULL;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
205 task_update_sgp = manager->create_task(TASK_UPDATE_SGP);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
206 task_update_sgp->add_inData(sgpack, sizeof(SceneGraphPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
207 task_update_sgp->add_outData(sgpack, sizeof(SceneGraphPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
208 task_update_sgp->add_param(width);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
209 task_update_sgp->add_param(height);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
210 task_next->wait_for(task_update_sgp);
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
211 task_update_sgp->spawn();
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
212 #else
138
3fd24be89d02 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
213 scene_graph->all_execute(width, height);
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
214 #endif
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
215
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
216 #if 0
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
217 task_create_pp = manager->create_task(TASK_CREATE_PP);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
218 task_create_pp->add_inData(sgpack, sizeof(SceneGraphPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
219 task_create_pp->add_param((uint32)ppack);
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
220 #else
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
221 task_create_pp = manager->create_task(TASK_CREATE_PP2);
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
222 task_create_pp->add_param((uint32)scene_graph);
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
223 task_create_pp->add_param((uint32)ppack);
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
224 #endif
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
225 task_next->wait_for(task_create_pp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
226
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
227 int range_base = spe_num;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
228 // 切り上げのつもり
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
229 int range = (spackList_length + range_base - 1) / range_base;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
230
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
231 for (int i = 0; i < range_base; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
232 int index_start = range*i;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
233 int index_end = (index_start + range >= spackList_length)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
234 ? spackList_length : index_start + range;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
235
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
236 task_create_sp = manager->create_task(TASK_CREATE_SPAN);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
237 task_create_sp->add_inData(ppack, sizeof(PolygonPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
238 task_create_sp->add_inData(spackList_ptr,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
239 sizeof(SpanPack*)*spackList_length_align);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
240 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
241
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
242 task_create_sp->add_param(index_start);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
243
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
244 /**
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 130
diff changeset
245 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
246 * [ 1.. 80] [ 81..160] [161..240]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
247 * [241..320] [321..400] [401..480]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
248 *
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
249 * ex. screen_height が 1080, spenum が 5 の場合、
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
250 * [ 1..216] [217..432] [433..648]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
251 * [649..864] [865..1080]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
252 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
253 task_create_sp->add_param(index_start*split_screen_h + 1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 task_create_sp->add_param(index_end*split_screen_h);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
256 task_next->wait_for(task_create_sp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
257 task_create_sp->wait_for(task_create_pp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
258
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
259 task_create_sp->set_cpu(SPE_ANY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
260 task_create_sp->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
261 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
262
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
263 task_create_pp->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
264 task_next->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
265 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
266
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
267 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
268 Viewer::run_draw(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
269 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
270 HTaskPtr task_next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
271 HTaskPtr task_draw;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
272
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
273 task_next = manager->create_task(TASK_DUMMY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
274 task_next->set_post(post2runLoop, NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
275
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
276 ppack->clear();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
277
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
278 for (int i = 0; i < spackList_length; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
279 SpanPack *spack = &spackList[i];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
280 int startx = 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
281 int endx = split_screen_w;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
282
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
283 int start_y = spack->info.y_top - split_screen_h + 1;
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
284 //int end_y = spack->info.y_top;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
285 int rangey = (start_y + split_screen_h - 1 > this->height)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
286 ? this->height - start_y + 1 : split_screen_h;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
287
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
288 while (startx < this->width) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289 if (spack->info.size > 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
290 // Draw SpanPack
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
291 task_draw = manager->create_task(TASK_DRAW_SPAN);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
292 task_draw->add_inData(spack, sizeof(SpanPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
293 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
294 // Draw Background (現在は塗りつぶし)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
295 task_draw = manager->create_task(TASK_DRAW_BACK);
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 130
diff changeset
296 task_draw->add_param(0xffffff);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
297 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
298
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
299 for (int k = 0; k < rangey; k++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
300 task_draw->add_outData(
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
301 &pixels[(startx-1)+this->width*(k+start_y-1)],
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
302 (endx - startx + 1)*sizeof(int));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
303 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
304
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
305 task_draw->add_param(startx);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
306 task_draw->add_param(endx);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
307 task_draw->add_param(rangey);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
308 task_draw->set_cpu(SPE_ANY);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
309 task_next->wait_for(task_draw);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
310 task_draw->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
311
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
312 startx += split_screen_w;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
313 endx += split_screen_w;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
314
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
315 if (endx > this->width) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
316 endx = this->width;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
317 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
318 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
319 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
320
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
321 task_next->spawn();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
322
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
323 frames++;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
324 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
325
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
326 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
327 Viewer::run_finish(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
328 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
329 if (this_time != start_time) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
330 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
331 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
332
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
333 scene_graph->delete_data();
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
334 delete scene_graph;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
335
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
336 free(__texture);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
337 quit();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
338 }