Mercurial > hg > Members > kono > Cerium
diff TaskManager/Test/simple_render/viewer.cpp @ 54:90523ccc4dff
*** empty log message ***
author | gongo |
---|---|
date | Sat, 16 Feb 2008 14:38:36 +0900 |
parents | c964110017c8 |
children | 54355e641172 |
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/viewer.cpp Fri Feb 15 20:58:50 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.cpp Sat Feb 16 14:38:36 2008 +0900 @@ -209,37 +209,69 @@ SDL_PixelFormat *pf; Uint32 background; Polygon *p; - SceneGraphPack *sgp; - PolygonPack *pp; + //SceneGraphPack *sgp; + //PolygonPack *pp; + DmaManager *sgp_buff; + DmaManager *pp_buff; }; struct run_arg_t *arg; +// run_arg_t に書くのがめんどいからって +// global に書くのもどうか +int start_time; +int this_time; +int frames; +SDL_Surface *bitmap; +SDL_PixelFormat *pixelFormat; +Uint32 background; +Polygon *polygon; +//SceneGraphPack *sgp; +//PolygonPack *pp; +DmaBuffer *sgp_buff; +DmaBuffer *pp_buff; + void Viewer::run_init() { - arg = new run_arg_t; HTaskPtr task; int fd; - arg->start_time = get_ticks(); - arg->this_time = 0; - arg->frames = 0; + SceneGraphPack *sgp; + + start_time = get_ticks(); + this_time = 0; + frames = 0; + + pixelFormat = screen->format; + background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); + polygon = new Polygon; + polygon->set_data("cube.xml"); + polygon->viewer = this; + + //sgp = new SceneGraphPack; + //create_sgp(arg->p, arg->sgp); - arg->pf = screen->format; - arg->background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); - arg->p = new Polygon; - arg->p->set_data("cube.xml"); - arg->p->viewer = this; - arg->sgp = new SceneGraphPack; - create_sgp(arg->p, arg->sgp); - arg->pp = new PolygonPack; + // 通信用 buffer の allocate + // これじゃないと通信用に使えない(ように処理を書かないと!) + sgp_buff = manager->allocate(sizeof(SceneGraphPack)); + + sgp_buff->get_buffer(&sgp); + create_sgp(polygon, sgp); + sgp_buff->swap_buffer(); + + sgp_buff->get_buffer(&sgp); + create_sgp(polygon, sgp); + sgp_buff->swap_buffer(); + + //pp = new PolygonPack; + pp_buff = manager->allocate(sizeof(PolygonPack)); pixels = new Uint32[width*height]; graph_line(); - arg->bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32, + bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32, width*4, redMask, greenMask, blueMask, alphaMask); @@ -262,7 +294,7 @@ int fd; if (quit_check()) { - arg->this_time = get_ticks(); + this_time = get_ticks(); fd_finish = manager->open("ViewerRunFinish"); task_finish = manager->create_task(fd_finish, 0, 0, 0, NULL); manager->spawn_task(task_finish); @@ -279,14 +311,10 @@ fd = manager->open("ViewerRunDraw"); task_update_sgp = manager->create_task(fd_update_sgp, sizeof(SceneGraphPack), - (unsigned int)arg->sgp, - (unsigned int)arg->sgp, - NULL); + sgp_buff, sgp_buff, NULL); task_create_pp = manager->create_task(fd_create_pp, sizeof(SceneGraphPack), - (unsigned int)arg->sgp, - (unsigned int)arg->pp, - NULL); + sgp_buff, pp_buff, NULL); task = manager->create_task(fd, 0, 0, 0, NULL); manager->set_task_depend(task_update_sgp, task); @@ -295,6 +323,8 @@ manager->spawn_task(task_update_sgp); manager->spawn_task(task_create_pp); manager->spawn_task(task); + + sgp_buff->swap_buffer(); } void @@ -303,12 +333,15 @@ HTaskPtr task; int fd; - arg->p->draw(arg->pp); // test draw of PolygonPack - - SDL_BlitSurface(arg->bitmap, NULL, screen, NULL); + PolygonPack *pp; + + pp_buff->get_buffer(&pp); + + polygon->draw(pp); // test draw of PolygonPack + SDL_BlitSurface(bitmap, NULL, screen, NULL); SDL_UpdateRect(screen, 0, 0, 0, 0); - arg->frames++; + frames++; fd = manager->open("ViewerRunLoop"); task = manager->create_task(fd, 0, 0, 0, NULL); @@ -318,16 +351,16 @@ void Viewer::run_finish(void) { - if (arg->this_time != arg->start_time) { - cout<< (((float)arg->frames)/(arg->this_time-arg->start_time))*1000.0 << " FPS\n"; + if (this_time != start_time) { + cout<< (((float)frames)/(this_time-start_time))*1000.0 << " FPS\n"; } - SDL_FreeSurface(arg->bitmap); + SDL_FreeSurface(bitmap); delete [] pixels; - arg->p->delete_data(); - delete arg->p; - delete arg->sgp; - delete arg->pp; + polygon->delete_data(); + delete polygon; + delete sgp_buff; + delete pp_buff; quit(); delete arg;