Mercurial > hg > Game > Cerium
view Renderer/Engine/SgChange.cc @ 728:c7afc21e448d draft
add Engine/ViewerDevice , SgRootChange not work
author | aaa |
---|---|
date | Sat, 19 Dec 2009 20:32:02 +0900 |
parents | ba00ee770616 |
children | 232e9d38b6bb |
line wrap: on
line source
#include <SDL.h> #include "SgChange.h" #include "viewer_types.h" #include "SceneGraph.h" #include "SceneGraphRoot.h" #include "scene_graph_pack.h" #include "sys.h" #include "Func.h" #include "error.h" #include "TaskManager.h" #include <wchar.h> #include "Pad.h" #include "Application.h" #include "lindaapi.h" #include "global_alloc.h" static void post2runLoop(SchedTask *s, void *viewer, void *s1); static void post2runDraw(SchedTask *s, void *viewer, void *s1); static void post2runMove(SchedTask *s, void *viewer, void *s1); static void post2rendering(SchedTask *s, void *viewer, void *s1); /* measure for FPS (Frame Per Second) */ extern int start_time; extern int this_time; extern int frames; /* Data Pack sent to Other CPUs (ex. SPE) */ extern SceneGraphPack *sgpack; extern PolygonPack *ppack; extern SpanPackPtr spackList; extern SpanPackPtr *spackList_ptr; extern int spackList_length; extern int spackList_length_align; void SgChange::run_init() { int width = viewer->width; int height = viewer->height; sgroot_A = new SceneGraphRoot(width, height); sgroot_A->tmanager = viewer->manager; sgroot_B = new SceneGraphRoot(width, height); sgroot_B->tmanager = viewer->manager; } HTaskPtr SgChange::initLoop() { return viewer->initLoop(); } void SgChange::mainLoop() { HTaskPtr task_next = initLoop(); task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) task_next->spawn(); } static void post2runLoop(SchedTask *s, void *sgchange_, void *arg) { SgChange *sgchange = (SgChange*)sgchange_; HTaskPtr task_next = sgchange->manager->create_task(Dummy); sgchange->run_loop(task_next); psx_sync_n(); } void SgChange::exchange_sgroot() { SceneGraphRoot *tmp; tmp = sgroot_A; sgroot_A = sgroot_B; sgroot_B = tmp; } void SgChange::run_loop(HTaskPtr task_next) { bool quit_flg; quit_flg = viewer->quit_check(); if (quit_flg == true) { this_time = viewer->get_ticks(); viewer->run_finish(); return; } viewer->clean_pixels(); for (int i = 1; i <= spackList_length; i++) { spackList[i-1].reinit(i*split_screen_h); } //exchange_sgroot(); sgroot_A->updateControllerState(); sgroot_A->allExecute(viewer->width, viewer->height); viewer->light_xyz_stock = sgroot_A->getLightVector(); HTaskPtr loop_task = manager->create_task(Dummy); loop_task->set_post(post2runLoop, (void *)this, 0); HTaskPtr draw_task = manager->create_task(Dummy); draw_task->set_post(post2rendering, (void *)this, 0); HTaskPtr move_task = manager->create_task(Dummy); move_task->set_post(post2runMove, (void *)this, 0); HTaskPtr dummy_task = manager->create_task(Dummy); draw_finish = dummy_task; loop_task->wait_for(draw_finish); loop_task->wait_for(move_task); move_task->spawn(); draw_task->spawn(); loop_task->spawn(); } static void post2runMove(SchedTask *s, void *viewer_, void *arg) { SgChange *viewer = (SgChange *)viewer_; HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_move(task_next); } void SgChange::run_move(HTaskPtr task_next) { sgroot_A->updateControllerState(); sgroot_A->allExecute(viewer->width, viewer->height); } static void post2rendering(SchedTask *s, void *sgchange_, void *arg) { SgChange *sgchange = (SgChange *)sgchange_; HTaskPtr task_next = sgchange->manager->create_task(Dummy); sgchange->rendering(task_next); } void SgChange::rendering(HTaskPtr task_next) { viewer->common_rendering(task_next, sgroot_A); task_next->set_post(post2runDraw, (void*)this, 0); task_next->spawn(); } static void post2runDraw(SchedTask *s, void *sgchange_, void *arg) { SgChange *sgchange = (SgChange *)sgchange_; HTaskPtr task_next = sgchange->manager->create_task(Dummy); sgchange->run_draw(task_next); } void SgChange::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする { viewer->common_draw(task_next); this->draw_finish->wait_for(task_next); task_next->spawn(); this->draw_finish->spawn(); frames++; } /* end */