comparison Renderer/Engine/SgChange.cc @ 715:0d8d2b7a3438

not work SgChange
author hiroki@localhost.localdomain
date Wed, 16 Dec 2009 16:29:31 +0900
parents fc0227b5cb5a
children 6d11ecef3b74
comparison
equal deleted inserted replaced
693:fc0227b5cb5a 715:0d8d2b7a3438
14 #include "lindaapi.h" 14 #include "lindaapi.h"
15 #include "global_alloc.h" 15 #include "global_alloc.h"
16 16
17 static void post2runLoop(SchedTask *s, void *viewer, void *s1); 17 static void post2runLoop(SchedTask *s, void *viewer, void *s1);
18 static void post2runDraw(SchedTask *s, void *viewer, void *s1); 18 static void post2runDraw(SchedTask *s, void *viewer, void *s1);
19 static void post2runMove(SchedTask *s, void *viewer, void *s1);
20 static void post2rendering(SchedTask *s, void *viewer, void *s1);
19 21
20 /* measure for FPS (Frame Per Second) */ 22 /* measure for FPS (Frame Per Second) */
21 int start_time; 23 int start_time;
22 int this_time; 24 int this_time;
23 int frames; 25 int frames;
90 frames = 0; 92 frames = 0;
91 93
92 // ココ! 94 // ココ!
93 sgroot_A = new SceneGraphRoot(this->width, this->height); 95 sgroot_A = new SceneGraphRoot(this->width, this->height);
94 sgroot_A->tmanager = manager; 96 sgroot_A->tmanager = manager;
95 //sgroot_B = new SceneGraphRoot(this->width, this->height); 97 sgroot_B = new SceneGraphRoot(this->width, this->height);
96 //sgroot_B->tmanager = manager; 98 sgroot_B->tmanager = manager;
97 99
98 int size = 4; 100 int size = 4;
99 light_xyz[0] = 0.0f; 101 light_xyz[0] = 0.0f;
100 light_xyz[1] = 0.0f; 102 light_xyz[1] = 0.0f;
101 light_xyz[2] = 0.0f; 103 light_xyz[2] = 0.0f;
198 200
199 for (int i = 1; i <= spackList_length; i++) { 201 for (int i = 1; i <= spackList_length; i++) {
200 spackList[i-1].reinit(i*split_screen_h); 202 spackList[i-1].reinit(i*split_screen_h);
201 } 203 }
202 204
205 #if 0
206 exchange_sgroot();
207 light_xyz_stock = sgroot_A->getLightVector();
208
209 //printf("Sgroot = %x\n", sgroot_A);
210
211 //task_next->set_post(&post2runLoop, (void *)this, 0);
212 //task_next->spawn();
213
214 rendering(task_next);
215 #else
203 //exchange_sgroot(); 216 //exchange_sgroot();
217
204 sgroot_A->updateControllerState(); 218 sgroot_A->updateControllerState();
205 sgroot_A->allExecute(width, height); 219 sgroot_A->allExecute(width, height);
206 light_xyz_stock = sgroot_A->getLightVector(); 220 light_xyz_stock = sgroot_A->getLightVector();
207 221
208 //printf("Sgroot = %x\n", sgroot_A); 222 HTaskPtr loop_task = manager->create_task(Dummy);
209 223 loop_task->set_post(post2runLoop, (void *)this, 0);
210 //task_next->set_post(&post2runLoop, (void *)this, 0); 224
211 //task_next->spawn(); 225 HTaskPtr draw_task = manager->create_task(Dummy);
212 226 draw_task->set_post(post2rendering, (void *)this, 0);
213 rendering(task_next); 227
228 HTaskPtr move_task = manager->create_task(Dummy);
229 move_task->set_post(post2runMove, (void *)this, 0);
230
231 HTaskPtr dummy_task = manager->create_task(Dummy);
232
233 this->dummy_task = dummy_task;
234 loop_task->wait_for(dummy_task);
235 loop_task->wait_for(move_task);
236
237 move_task->spawn();
238 draw_task->spawn();
239 loop_task->spawn();
240 #endif
241 }
242
243 static void
244 post2runMove(SchedTask *s, void *viewer_, void *arg)
245 {
246 SgChange *viewer = (SgChange *)viewer_;
247 HTaskPtr task_next = viewer->manager->create_task(Dummy);
248 viewer->run_move(task_next);
249 }
250
251 void
252 SgChange::run_move(HTaskPtr task_next)
253 {
254 //sgroot_A->updateControllerState();
255 //sgroot_A->allExecute(width, height);
256 }
257
258 static void
259 post2rendering(SchedTask *s, void *viewer_, void *arg)
260 {
261 SgChange *viewer = (SgChange *)viewer_;
262 HTaskPtr task_next = viewer->manager->create_task(Dummy);
263 viewer->run_draw(task_next);
264
214 } 265 }
215 266
216 void 267 void
217 SgChange::rendering(HTaskPtr task_next) 268 SgChange::rendering(HTaskPtr task_next)
218 { 269 {
219 common_rendering(task_next); 270 common_rendering(task_next);
220 271
221 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL) 272 task_next->set_post(post2runDraw, (void*)this, 0);
222 task_next->spawn(); 273 task_next->spawn();
223 } 274 }
224 275
225 void 276 void
226 SgChange::common_rendering(HTaskPtr task_next) 277 SgChange::common_rendering(HTaskPtr task_next)
261 } 312 }
262 313
263 task_create_pp->spawn(); 314 task_create_pp->spawn();
264 } 315 }
265 316
317
266 static void 318 static void
267 post2runDraw(SchedTask *s, void *viewer_, void *arg) 319 post2runDraw(SchedTask *s, void *viewer_, void *arg)
268 { 320 {
269 SgChange *viewer = (SgChange *)viewer_; 321 SgChange *viewer = (SgChange *)viewer_;
270 HTaskPtr task_next = viewer->manager->create_task(Dummy); 322 HTaskPtr task_next = viewer->manager->create_task(Dummy);
274 void 326 void
275 SgChange::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする 327 SgChange::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする
276 { 328 {
277 common_draw(task_next); 329 common_draw(task_next);
278 330
331 #if 0
279 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) 332 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL)
280 task_next->spawn(); 333 task_next->spawn();
334 #else
335 this->dummy_task->wait_for(task_next);
336 task_next->spawn();
337 this->dummy_task->spawn();
338 #endif
281 339
282 frames++; 340 frames++;
283 } 341 }
284 342
285 void 343 void