Mercurial > hg > Game > Cerium
changeset 737:ae881bd43459 draft
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 27 Dec 2009 20:49:38 +0900 |
parents | 01e3c74fd5b1 (diff) 1b225972ae88 (current diff) |
children | 819966538b8a |
files | Renderer/Engine/Application.h Renderer/Engine/SgChange.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h |
diffstat | 64 files changed, 682 insertions(+), 794 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Application.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/Application.h Sun Dec 27 20:49:38 2009 +0900 @@ -4,13 +4,11 @@ #include "SceneGraph.h" #include "MainLoop.h" #include "viewer.h" -#include "SgChange.h" typedef void (*Move_func)(SceneGraph* node, int screen_w, int screen_h); typedef void (*Coll_func)(SceneGraph* node, int screen_w, int screen_h, SceneGraphPtr tree); class Viewer; -class SgChange; class Application { public:
--- a/Renderer/Engine/SgChange.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/SgChange.cc Sun Dec 27 20:49:38 2009 +0900 @@ -33,128 +33,28 @@ extern int spackList_length; extern int spackList_length_align; -SgChange::SgChange(int b, int w, int h, int _num) -{ - bpp = b; - width = w; - height = h; - spe_num = _num; -} - -int -SgChange::get_ticks(void) -{ - int time; - time = SDL_GetTicks(); - return time; -} - -bool -SgChange::quit_check(void) -{ - SDL_Event event; - - while(SDL_PollEvent(&event)) { - if (event.type==SDL_QUIT) { - return true; - } - } - - Uint8 *keys=SDL_GetKeyState(NULL); - - if (keys[SDLK_q] == SDL_PRESSED) { - return true; - } - - return false; -} - void -SgChange::quit(void) -{ - SDL_Quit(); -} - - - -void -SgChange::run_init(TaskManager *manager, Application *app) +SgChange::run_init() { - this->manager = manager; - - start_time = get_ticks(); - this_time = 0; - frames = 0; - - // ココ! - sgroot_A = new SceneGraphRoot(this->width, this->height); - sgroot_A->tmanager = manager; - sgroot_B = new SceneGraphRoot(this->width, this->height); - sgroot_B->tmanager = manager; - - int size = sizeof(float)*4; - light_xyz[0] = 0.0f; - light_xyz[1] = 0.0f; - light_xyz[2] = 0.0f; - light_xyz[3] = 0.0f; - - HTaskPtr data_load; - for(int i = 0; i < spe_num; i++) { - data_load = manager->create_task(DataLoad); - data_load->set_param(0, (memaddr)size); - data_load->set_param(1, (memaddr)LOAD_ID); - data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); - data_load->spawn(); - } - - MainLoop *mainloop = app->init((Viewer *)this, this->width, this->height); - - mainloop->mainLoop(); + 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() { - HTaskPtr task_next; - HTaskPtr task_tex; - - sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack)); - sgpack->init(); - ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); - - spackList_length = (this->height + split_screen_h - 1) / split_screen_h; - spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length); - - spackList_length_align = (spackList_length + 3)&(~3); - - spackList_ptr = - (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align); - - for (int i = 0; i < spackList_length; i++) { - spackList_ptr[i] = &spackList[i]; - } - - for (int i = 1; i <= spackList_length; i++) { - spackList[i-1].init(i*split_screen_h); - } - - task_next = manager->create_task(Dummy); - - for (int i = 0; i < spe_num; i++) { - task_tex = manager->create_task(LoadTexture); - task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i)); - task_next->wait_for(task_tex); - task_tex->spawn(); - } - - return task_next; + 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(); } @@ -162,11 +62,11 @@ static void -post2runLoop(SchedTask *s, void *viewer_, void *arg) +post2runLoop(SchedTask *s, void *sgchange_, void *arg) { - SgChange *viewer = (SgChange*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(Dummy); - viewer->run_loop(task_next); + SgChange *sgchange = (SgChange*)sgchange_; + HTaskPtr task_next = sgchange->manager->create_task(Dummy); + sgchange->run_loop(task_next); psx_sync_n(); } @@ -183,36 +83,27 @@ void SgChange::run_loop(HTaskPtr task_next) { + viewer->dev->clear_screen(); + bool quit_flg; - quit_flg = quit_check(); + quit_flg = viewer->quit_check(); if (quit_flg == true) { - this_time = get_ticks(); - run_finish(); + this_time = viewer->get_ticks(); + viewer->run_finish(); return; } - clean_pixels(); + viewer->dev->clean_pixels(); for (int i = 1; i <= spackList_length; i++) { spackList[i-1].reinit(i*split_screen_h); } -#if 0 - exchange_sgroot(); - light_xyz_stock = sgroot_A->getLightVector(); - - //printf("Sgroot = %x\n", sgroot_A); - - //task_next->set_post(&post2runLoop, (void *)this, 0); - //task_next->spawn(); - - rendering(task_next); -#else //exchange_sgroot(); sgroot_A->updateControllerState(); - sgroot_A->allExecute(width, height); - light_xyz_stock = sgroot_A->getLightVector(); + 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); @@ -225,14 +116,13 @@ HTaskPtr dummy_task = manager->create_task(Dummy); - this->dummy_task = dummy_task; - loop_task->wait_for(dummy_task); + 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(); -#endif } static void @@ -246,192 +136,47 @@ void SgChange::run_move(HTaskPtr task_next) { - //sgroot_A->updateControllerState(); - //sgroot_A->allExecute(width, height); + sgroot_A->updateControllerState(); + sgroot_A->allExecute(viewer->width, viewer->height); } static void -post2rendering(SchedTask *s, void *viewer_, void *arg) +post2rendering(SchedTask *s, void *sgchange_, void *arg) { - SgChange *viewer = (SgChange *)viewer_; - HTaskPtr task_next = viewer->manager->create_task(Dummy); - viewer->run_draw(task_next); + SgChange *sgchange = (SgChange *)sgchange_; + HTaskPtr task_next = sgchange->manager->create_task(Dummy); + sgchange->rendering(task_next); } void SgChange::rendering(HTaskPtr task_next) { - common_rendering(task_next); + viewer->common_rendering(task_next, sgroot_A); task_next->set_post(post2runDraw, (void*)this, 0); task_next->spawn(); } -void -SgChange::common_rendering(HTaskPtr task_next) -{ - HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); - - //task_create_pp->set_param(0, (memaddr)sgroot_B->getDrawSceneGraph()); - task_create_pp->set_param(0, (memaddr)sgroot_A->getDrawSceneGraph()); - task_create_pp->set_param(1, (memaddr)ppack); - - task_next->wait_for(task_create_pp); - - int range_base = spe_num; - int range = (spackList_length + range_base - 1) / range_base; - - for (int i = 0; i < range_base; i++) { - int index_start = range*i; - int index_end = (index_start + range >= spackList_length) - ? spackList_length : index_start + range; - - HTaskPtr task_create_sp = manager->create_task(CreateSpan); - - task_create_sp->set_param(0,index_start); - - task_create_sp->set_param(1,index_start*split_screen_h + 1); - task_create_sp->set_param(2,index_end*split_screen_h); - - task_create_sp->add_inData(ppack, sizeof(PolygonPack)); - task_create_sp->add_inData(spackList_ptr, - sizeof(SpanPack*)*spackList_length_align); - task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); - - task_next->wait_for(task_create_sp); - task_create_sp->wait_for(task_create_pp); - - task_create_sp->set_cpu(SPE_ANY); - task_create_sp->spawn(); - } - - task_create_pp->spawn(); -} - static void -post2runDraw(SchedTask *s, void *viewer_, void *arg) +post2runDraw(SchedTask *s, void *sgchange_, void *arg) { - SgChange *viewer = (SgChange *)viewer_; - HTaskPtr task_next = viewer->manager->create_task(Dummy); - viewer->run_draw(task_next); + 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 を入れるようにする { - common_draw(task_next); + viewer->common_draw(task_next); -#if 0 - task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) + this->draw_finish->wait_for(task_next); task_next->spawn(); -#else - this->dummy_task->wait_for(task_next); - task_next->spawn(); - this->dummy_task->spawn(); -#endif + this->draw_finish->spawn(); frames++; } -void -SgChange::common_draw(HTaskPtr task_next) -{ - HTaskPtr task_draw; - - //Light info update - HTaskPtr data_update; - HTaskPtr data_update_wait; - int size = sizeof(float)*4; - - light_xyz[0] = light_xyz_stock[0]; - light_xyz[1] = light_xyz_stock[1]; - light_xyz[2] = light_xyz_stock[2]; - light_xyz[3] = light_xyz_stock[3]; - - data_update_wait = manager->create_task(DataUpdate); - data_update_wait->add_inData(light_xyz, size); - data_update_wait->set_param(0, size); - data_update_wait->set_param(1, LOAD_ID); - data_update_wait->set_cpu((CPU_TYPE)((int)SPE_0)); - - for (int i = 1; i < spe_num; i++) { - data_update = manager->create_task(DataUpdate); - data_update->add_inData(light_xyz, sizeof(float)*size); - data_update->set_param(0, size); - data_update->set_param(1, LOAD_ID); - data_update->set_cpu((CPU_TYPE)((int)SPE_0 + i)); - data_update_wait->wait_for(data_update); - data_update->spawn(); - } - - data_update_wait->spawn(); - - ppack->clear(); - for (int i = 0; i < spackList_length; i++) { - SpanPack *spack = &spackList[i]; - int startx = 1; - int endx = split_screen_w; - - int starty = spack->info.y_top - split_screen_h + 1; - //int endy = spack->info.y_top; - int rangey = (starty + split_screen_h - 1 > this->height) - ? this->height - starty + 1 : split_screen_h; - - while (startx < this->width) { - if (spack->info.size > 0) { - // Draw SpanPack - task_draw = manager->create_task(DrawSpan); - - task_draw->set_param(0, - (memaddr)&pixels[(startx-1) + this->width*(starty-1)]); - task_draw->set_param(1,this->width); - task_draw->set_param(2,startx); - task_draw->set_param(3,endx); - task_draw->set_param(4,rangey); - - task_draw->add_inData(spack, sizeof(SpanPack)); - - for (int i = 0; i < rangey; i++) { - task_draw->add_outData( - &pixels[(startx-1) + this->width*(starty-1 + i) ], - (endx-startx+1)*sizeof(int)); - } - } else { - // 7.7.3 SL1 Data Cache Range Set to Zero コマンド - // を使って、DMAでclearするべき... ということは、 - // それもSPEでやる方が良い? - memset(&pixels[(startx-1)+this->width*(starty-1)], - 0, (this->width)*sizeof(int)*rangey); - break; - } - - task_draw->set_cpu(SPE_ANY); - task_next->wait_for(task_draw); - task_draw->wait_for(data_update_wait); - task_draw->spawn(); - - startx += split_screen_w; - endx += split_screen_w; - - if (endx > this->width) { - endx = this->width; - } - } - } -} - -void -SgChange::run_finish(void) -{ - if (this_time != start_time) { - printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); - } - - delete sgroot_A; - //delete sgroot_B; - quit(); -} - /* end */
--- a/Renderer/Engine/SgChange.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/SgChange.h Sun Dec 27 20:49:38 2009 +0900 @@ -9,60 +9,39 @@ #include "MainLoop.h" #include "Application.h" #include "SceneGraphRoot.h" +#include "viewer.h" class SceneGraphRoot; - class Application; class SgChange : public MainLoop { public: - SgChange(int bpp, int width, int height, int spenum); + Viewer *viewer; + TaskManager *manager; + + SgChange(Viewer *v) { + viewer = v; + manager = v->manager; + } virtual ~SgChange() {} - Application *app; - - TaskManager *manager; - key_stat *keyPtr; - HTaskPtr dummy_task; SceneGraphRoot *sgroot_A; SceneGraphRoot *sgroot_B; - /* screen info */ - int width; - int height; - int bpp; - - int spe_num; - - float light_xyz[4] __attribute__((aligned(16))); - float *light_xyz_stock; - - int rgb_size[3]; - Uint32 video_flags; - Uint32 *pixels; + HTaskPtr draw_finish; - virtual void video_init(TaskManager *manager) = 0; - void init(); - - int get_ticks(); - bool quit_check(); - void quit(); - - virtual void clean_pixels() {} + void run_init(); + void run_loop(HTaskPtr task_next); + void run_move(HTaskPtr task_next); + void run_draw(HTaskPtr task_next); + void rendering(HTaskPtr task_next); + HTaskPtr initLoop(); - virtual void run_init(TaskManager *manager, Application *app); - virtual void run_loop(HTaskPtr task_next); - virtual void run_finish(); - virtual void run_draw(HTaskPtr task_next); - virtual void run_move(HTaskPtr task_next); virtual void exchange_sgroot(); - virtual void rendering(HTaskPtr task_next); - virtual void common_draw(HTaskPtr task_next); - virtual void common_rendering(HTaskPtr task_next); void mainLoop(); void createFromXMLfile(const char *file) @@ -99,16 +78,7 @@ { return sgroot_A->getLast(); } - - - - -private: - HTaskPtr initLoop(); }; -#define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK - - #endif
--- a/Renderer/Engine/SgMain.cc Sun Dec 27 20:39:33 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -#include "TaskManager.h" -#include "SgChange.h" -#include "sgchangeSDL.h" -#include "sgchangeFB.h" -#include "Application.h" - -/* prototype */ -extern void task_initialize(); -extern Application *application(); -extern int sg_init(TaskManager *manager, int argc, char *argv[]); - -int -sg_init(TaskManager *manager, int argc, char *argv[]) -{ - int bpp = 32; - int width = 640; - int height = 480; - int spenum = 1; - video_type vtype = VTYPE_SDL; - - for(int i = 1; argv[i]; ++i) - { - if (strcmp(argv[i], "-bpp") == 0) { - bpp = atoi(argv[++i]); - } - if (strcmp(argv[i], "-width") == 0) { - width = atoi(argv[++i]); - } - if (strcmp(argv[i], "-height") == 0) { - height = atoi(argv[++i]); - } - if (strcmp(argv[i], "-cpu") == 0) { - spenum = atoi(argv[++i]); - } - if (strcmp(argv[i], "-video") == 0) { - if (strcmp(argv[i+1], "sdl") == 0) { - vtype = VTYPE_SDL; - } else if (strcmp(argv[i+1], "fb") == 0) { - vtype = VTYPE_FB; - } - i++; - } - } - - /* - SgChange *screen = new SgChange(bpp, width, height, spenum); - screen->run_init(manager, application()); - */ - - SgChange *screen; - if (vtype == VTYPE_SDL) { - screen = new SgChangeSDL(manager, bpp, width, height, spenum); - } else if (vtype == VTYPE_FB) { - screen = new SgChangeFB(manager, bpp, width, height, spenum); - }else{ - screen = new SgChangeSDL(manager, bpp, width, height, spenum); - } - - screen->video_init(manager); - screen->run_init(manager, application()); - - return 0; -} - -#if 0 - -// These are defined in Application - -int -TMmain(TaskManager *manager, int argc, char *argv[]) -{ - task_initialize(); - manager->set_TMend(TMend); - return init(manager, argc, argv); - -} - -void -TMend(TaskManager *manager) -{ - printf("test_nogl end\n"); -} - -#endif - -/* end */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/ViewerDevice.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,9 @@ +#include "ViewerDevice.h" + +ViewerDevice::ViewerDevice() +{ +} + +ViewerDevice::~ViewerDevice() +{ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/ViewerDevice.h Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,21 @@ +#ifndef INCLUDED_VIEWER_DEV +#define INCLUDED_VIEWER_DEV + +#include "TaskManager.h" +#include "SDL.h" + +class ViewerDevice { +public: + ViewerDevice(); + virtual ~ViewerDevice(); + + ViewerDevice(TaskManager *m) {}; + + /* override function */ + virtual Uint32 *video_init(TaskManager *manager, int bpp, int width, int height) = 0; + virtual void clean_pixels() = 0; + virtual void clear_screen() = 0; + virtual void free_device() = 0; +}; + +#endif
--- a/Renderer/Engine/main.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/main.cc Sun Dec 27 20:49:38 2009 +0900 @@ -63,17 +63,18 @@ Viewer *screen; if (vtype == VTYPE_SDL) { - screen = new ViewerSDL(manager, bpp, width, height, spenum); + ViewerDevice *dev = new ViewerSDL(manager); + screen = new Viewer(manager, dev, bpp, width, height, spenum); } else if (vtype == VTYPE_FB) { - screen = new ViewerFB(manager, bpp, width, height, spenum); + ViewerDevice *dev = new ViewerFB(manager); + screen = new Viewer(manager, dev, bpp, width, height, spenum); }else{ - screen = new ViewerSDL(manager, bpp, width, height, spenum); + ViewerDevice *dev = new ViewerSDL(manager); + screen = new Viewer(manager, dev, bpp, width, height, spenum); } - - screen->video_init(manager); + screen->run_init(manager, application()); - return 0; }
--- a/Renderer/Engine/sgchangeFB.cc Sun Dec 27 20:39:33 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#include "sgchangeFB.h" -#include "Func.h" -#include "fb.h" - -//extern void post2runLoop(void *); - -void -SgChangeFB::video_init(TaskManager *manager) -{ - Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; - - if (SDL_Init(sdl_flag) < 0) { - fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError()); - exit(1); - } - - pixels = (Uint32*)get_fbdev_addr(); - - if (pixels == 0) { - pixels = (new Uint32[width*height*32/8]); - } -} - -void -SgChangeFB::clean_pixels() -{ - //bzero(pixels, sizeof(int)*width*height); - //memset(pixels, 0xFF, sizeof(int)*width*height); -}
--- a/Renderer/Engine/sgchangeFB.h Sun Dec 27 20:39:33 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#ifndef INCLUDED_SGCHANGE_FB -#define INCLUDED_SGCHANGE_FB - -#include "SgChange.h" - -class SgChangeFB : public SgChange { -public: -SgChangeFB(TaskManager *manager, int bpp, int width, int height, int spenum) - :SgChange(bpp, width, height, spenum) {} - - /* override function */ - void video_init(TaskManager *manager); - void clean_pixels(void); -}; - -#endif
--- a/Renderer/Engine/sgchangeSDL.cc Sun Dec 27 20:39:33 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#include "sgchangeSDL.h" -#include "Func.h" -#include "TaskManager.h" - -extern void post2runLoop(void *); - -extern - -void -SgChangeSDL::video_init(TaskManager *manager) -{ - Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; - Uint32 *p; - - if (SDL_Init(sdl_flag) < 0) { - fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE); - if (screen == NULL) { - fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); - SDL_Quit(); - exit(1); - } - - p = (Uint32*)manager->allocate(screen->pitch*height); - bitmap = SDL_CreateRGBSurfaceFrom((void *)p, - screen->w, screen->h, - screen->format->BitsPerPixel, - screen->pitch, - redMask, greenMask, blueMask, alphaMask); - - pixels = p; -} - -void -SgChangeSDL::clean_pixels() -{ - //bzero(pixels, sizeof(int)*width*height); - SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); -} - -void -SgChangeSDL::run_loop(HTaskPtr task_next) -{ - SDL_BlitSurface(bitmap, NULL, screen, NULL); - SDL_UpdateRect(screen, 0, 0, 0, 0); - - SgChange::run_loop(task_next); -} - -void -SgChangeSDL::run_finish() -{ - free(bitmap->pixels); - SDL_FreeSurface(bitmap); - - SgChange::run_finish(); -}
--- a/Renderer/Engine/sgchangeSDL.h Sun Dec 27 20:39:33 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#ifndef INCLUDED_SGCHANGE_SDL -#define INCLUDED_SGCHANGE_SDL - -#include "SgChange.h" - -class SgChangeSDL : public SgChange { -public: -SgChangeSDL(TaskManager* manager, int bpp, int width, int height, int spenum) - :SgChange(bpp, width, height, spenum) {} - - SDL_Surface *screen; - SDL_Surface *bitmap; - - /* override function */ - void video_init(TaskManager *manager); - void clean_pixels(); - void run_loop(HTaskPtr task_next); - void run_finish(); -}; - -#endif
--- a/Renderer/Engine/viewer.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewer.cc Sun Dec 27 20:49:38 2009 +0900 @@ -44,12 +44,15 @@ * */ -Viewer::Viewer(int b, int w, int h, int _num) +Viewer::Viewer(TaskManager *m, ViewerDevice *vd, int b, int w, int h, int _num) { bpp = b; width = w; height = h; spe_num = _num; + manager = m; + dev = vd; + pixels = dev->video_init(manager, b, w, h); } @@ -265,16 +268,6 @@ } -#if 0 -static void -post2speRunLoop(void *viewer_) -{ - Viewer *viewer = (Viewer *)viewer_; - HTaskPtr task_next = viewer->manager->create_task(Dummy); - viewer->run_move(task_next); -} -#endif - void Viewer::mainLoop() { @@ -284,23 +277,35 @@ task_next->spawn(); } -#if 0 void -post2runMove(void *viewer_) +Viewer::run_loop(HTaskPtr task_next) { - Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(Dummy); - viewer->run_move(task_next); + dev->clear_screen(); + + bool quit_flg; + quit_flg = quit_check(); + if (quit_flg == true) { + this_time = get_ticks(); + run_finish(); + return; + } + + dev->clean_pixels(); + + for (int i = 1; i <= spackList_length; i++) { + spackList[i-1].reinit(i*split_screen_h); + } + + sgroot->updateControllerState(); + sgroot->allExecute(width, height); + light_xyz_stock = sgroot->getLightVector(); + //sgroot->checkRemove(); + + // ここから下は Rendering という関数にする + rendering(task_next); } -#endif -void -Viewer::run_move(HTaskPtr task_next) -{ - sgroot->updateControllerState(); - sgroot->allExecute(width, height); -} void Viewer::run_collision() @@ -318,7 +323,7 @@ void Viewer::rendering(HTaskPtr task_next) { - common_rendering(task_next); + common_rendering(task_next, sgroot); // Barrier 同期 // run_draw() を呼ぶ post2runDraw @@ -338,33 +343,6 @@ psx_sync_n(); } -void -Viewer::run_loop(HTaskPtr task_next) -{ - bool quit_flg; - quit_flg = quit_check(); - if (quit_flg == true) { - this_time = get_ticks(); - run_finish(); - return; - } - - clean_pixels(); - - for (int i = 1; i <= spackList_length; i++) { - spackList[i-1].reinit(i*split_screen_h); - } - - //run_move(task_next); - sgroot->updateControllerState(); - sgroot->allExecute(width, height); - light_xyz_stock = sgroot->getLightVector(); - //sgroot->checkRemove(); - - // ここから下は Rendering という関数にする - rendering(task_next); -} - static void post2runDraw(SchedTask *s, void *viewer_, void *arg) { @@ -386,17 +364,6 @@ frames++; } -void -Viewer::run_finish(void) -{ - if (this_time != start_time) { - printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); - } - - delete sgroot; -// delete sgroot_2; - quit(); -} static void post2speRendering(SchedTask *s, void *viewer_, void *arg) @@ -409,7 +376,7 @@ void Viewer::spe_rendering(HTaskPtr task_next) { - common_rendering(task_next); + common_rendering(task_next, sgroot); this->draw_dummy->wait_for(task_next); task_next->set_post(post2speDraw, (void*)this, 0); @@ -438,14 +405,12 @@ } void -Viewer::common_rendering(HTaskPtr task_next) +Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) { HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); // SceneGraph(木構造) -> PolygonPack - - task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); task_create_pp->set_param(1,(memaddr)ppack); @@ -584,4 +549,17 @@ } +void +Viewer::run_finish() +{ + dev->free_device(); + if (this_time != start_time) { + printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); + } + + delete sgroot; +// delete sgroot_2; + quit(); +} + /* end */
--- a/Renderer/Engine/viewer.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewer.h Sun Dec 27 20:49:38 2009 +0900 @@ -9,7 +9,7 @@ #include "MainLoop.h" #include "Application.h" #include "SceneGraphRoot.h" -#include "base.h" +#include "ViewerDevice.h" class SceneGraphRoot; @@ -19,11 +19,12 @@ public: - Viewer(int bpp, int width, int height, int spenum); + Viewer(TaskManager *manager, ViewerDevice *dev, int bpp, int width, int height, int spenum); virtual ~Viewer() {} BASE_NEW_DELETE(Viewer); + ViewerDevice *dev; Application *app; TaskManager *manager; @@ -48,28 +49,29 @@ SceneGraphRoot *sgroot; - virtual void video_init(TaskManager *manager) = 0; + //Uint32 *video_init(TaskManager *manager, int bpp, int width, int height); void init(); int get_ticks(); bool quit_check(); void quit(); - - virtual void clean_pixels() {} + HTaskPtr initLoop(); - virtual void run_init(TaskManager *manager, Application *app); - virtual void run_loop(HTaskPtr task_next); - virtual void run_draw(HTaskPtr task_next); - virtual void run_finish(); - virtual void run_move(HTaskPtr task_next); - virtual void run_collision(); - virtual void rendering(HTaskPtr task_next); - virtual void common_draw(HTaskPtr task_next); - virtual void common_rendering(HTaskPtr task_next); + void clean_pixels() {} + + void run_init(TaskManager *manager, Application *app); + void run_loop(HTaskPtr task_next); + void run_draw(HTaskPtr task_next); + void run_finish(); + void run_move(HTaskPtr task_next); + void run_collision(); + void rendering(HTaskPtr task_next); + void common_draw(HTaskPtr task_next); + void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot); - virtual void spe_rendering(HTaskPtr task_next); - virtual void spe_draw(HTaskPtr task_next); - //virtual void exchange_sgroot(TaskManager *manager); + void spe_rendering(HTaskPtr task_next); + void spe_draw(HTaskPtr task_next); + // void exchange_sgroot(TaskManager *manager); void getKey(); void get_send_controll(); @@ -120,12 +122,6 @@ return sgroot->getLast(); } - - - -private: - HTaskPtr initLoop(); - }; #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK
--- a/Renderer/Engine/viewerFB.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewerFB.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,11 +1,13 @@ #include "viewerFB.h" -#include "Func.h" #include "fb.h" +#define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK //extern void post2runLoop(void *); +ViewerFB::ViewerFB() {} +ViewerFB::~ViewerFB() {} -void -ViewerFB::video_init(TaskManager *manager) +Uint32 * +ViewerFB::video_init(TaskManager *manager, int bpp, int width, int height) { Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; @@ -14,11 +16,13 @@ exit(1); } - pixels = (Uint32*)get_fbdev_addr(); + Uint32 *pixels = (Uint32*)get_fbdev_addr(); if (pixels == 0) { - pixels = (new Uint32[width*height*32/8]); + pixels = (new Uint32[width*height*32/8]); } + + return pixels; } void @@ -27,3 +31,16 @@ //bzero(pixels, sizeof(int)*width*height); //memset(pixels, 0xFF, sizeof(int)*width*height); } + +void +ViewerFB::clear_screen() +{ +} + + +void +ViewerFB::free_device() +{ +} + +
--- a/Renderer/Engine/viewerFB.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewerFB.h Sun Dec 27 20:49:38 2009 +0900 @@ -1,16 +1,19 @@ #ifndef INCLUDED_VIEWER_FB #define INCLUDED_VIEWER_FB -#include "viewer.h" +#include "ViewerDevice.h" -class ViewerFB : public Viewer { +class ViewerFB : public ViewerDevice { public: -ViewerFB(TaskManager *manager, int bpp, int width, int height, int spenum) - :Viewer(bpp, width, height, spenum) {} + ViewerFB(TaskManager *manager) {}; + ViewerFB(); + virtual ~ViewerFB(); /* override function */ - void video_init(TaskManager *manager); + Uint32 *video_init(TaskManager *manager, int bpp, int width, int height); void clean_pixels(void); + void clear_screen(); + void free_device(); }; #endif
--- a/Renderer/Engine/viewerSDL.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewerSDL.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,13 +1,17 @@ #include "viewerSDL.h" #include "Func.h" #include "TaskManager.h" +#include "viewer_types.h" extern void post2runLoop(void *); -extern +#define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK -void -ViewerSDL::video_init(TaskManager *manager) +ViewerSDL::ViewerSDL() {} +ViewerSDL::~ViewerSDL() {} + +Uint32 * +ViewerSDL::video_init(TaskManager *manager, int bpp, int width, int height) { Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; Uint32 *p; @@ -31,7 +35,7 @@ screen->pitch, redMask, greenMask, blueMask, alphaMask); - pixels = p; + return p; } void @@ -42,19 +46,15 @@ } void -ViewerSDL::run_loop(HTaskPtr task_next) +ViewerSDL::clear_screen() { SDL_BlitSurface(bitmap, NULL, screen, NULL); SDL_UpdateRect(screen, 0, 0, 0, 0); - - Viewer::run_loop(task_next); } void -ViewerSDL::run_finish() +ViewerSDL::free_device() { free(bitmap->pixels); SDL_FreeSurface(bitmap); - - Viewer::run_finish(); }
--- a/Renderer/Engine/viewerSDL.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Engine/viewerSDL.h Sun Dec 27 20:49:38 2009 +0900 @@ -1,21 +1,22 @@ #ifndef INCLUDED_VIEWER_SDL #define INCLUDED_VIEWER_SDL -#include "viewer.h" +#include "ViewerDevice.h" -class ViewerSDL : public Viewer { +class ViewerSDL : public ViewerDevice { public: -ViewerSDL(TaskManager* manager, int bpp, int width, int height, int spenum) - :Viewer(bpp, width, height, spenum) {} + ViewerSDL(TaskManager* manager) {}; + ViewerSDL(); + virtual ~ViewerSDL(); SDL_Surface *screen; SDL_Surface *bitmap; /* override function */ - void video_init(TaskManager *manager); + Uint32 *video_init(TaskManager *manager, int bpp, int width, int height); void clean_pixels(); - void run_loop(HTaskPtr task_next); - void run_finish(); + void clear_screen(); + void free_device(); }; #endif
--- a/Renderer/Test/Chain.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/Chain.h Sun Dec 27 20:49:38 2009 +0900 @@ -22,7 +22,6 @@ void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h); void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg); - MainLoopPtr init_only_sg(SgChange *sgchange, int w, int h); MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
--- a/Renderer/Test/Makefile.macosx Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/Makefile.macosx Sun Dec 27 20:49:38 2009 +0900 @@ -10,7 +10,9 @@ .cc.o: $(CC) $(CFLAGS) -c $< -o $@ -ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum send_linda dynamic writer chain_old SgRootChange +ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange +oFLAGS=-g -O2 +CFLAGt=-g -O2 all: $(ALL) BALL_BOUND_OBJ = ball_bound.o @@ -53,6 +55,10 @@ vacuum : $(VACUUM_OBJ) $(CC) -o $@ $? $(LIBS) +PROPERTY_OBJ = property_test.o +property_test : $(PROPERTY_OBJ) + $(CC) -o $@ $? $(LIBS) + DYNAMIC_OBJ = dynamic_create.o dynamic : $(DYNAMIC_OBJ) $(CC) -o $@ $? $(LIBS)
--- a/Renderer/Test/SgRootChange.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/SgRootChange.cc Sun Dec 27 20:49:38 2009 +0900 @@ -4,33 +4,126 @@ #include "MainLoop.h" #include "SgRootChange.h" +static void ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); +static void ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); +static void ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree); + + +static float vy = 0.0f; // y 方向速度 +static float dt = 1.0/1.0f; // frame rate + +static float e = -0.8f; // 反発係数 +static float g = 9.8f; // 重力加速度 +//static float v0 = 0.0f; // 初速は 0 + +static float h0; // 初期高さ +static float ball_radius = 100.0f; + +static float speed = 10.0f; + +static void +ball_move_idle2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) +{ + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; + Pad *pad = sgroot->getController(); + + if (pad->circle.isHold()) { + if (pad->left.isHold()) { + node->xyz[0] -= speed; + if(node->xyz[0] < ball_radius) + node->xyz[0] = ball_radius; + } else if (pad->right.isHold()) { + node->xyz[0] += speed; + if(node->xyz[0] > screen_w - ball_radius) + node->xyz[0] = screen_w - ball_radius; + } + + if (pad->up.isHold()) { + node->xyz[1] -= speed; + } else if (pad->down.isHold()) { + node->xyz[1] += speed; + if(node->xyz[1] > screen_h - ball_radius) + node->xyz[1] = screen_h - ball_radius; + } + } else { + node->set_move_collision(ball_move, ball_collision); + } +} + +static int time = 0; + +static void +ball_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) +{ + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; + Pad *pad = sgroot->getController(); + + if (pad->circle.isPush()) { + node->set_move_collision(ball_move_idle2, ball_collision_idle); + time = 0; + } + + time++; + + if (time > 90) { + float w = (float)random(); + + w = fmodf(w, screen_w - ball_radius*2); + node->xyz[0] = w + ball_radius; + node->xyz[1] = h0; + node->set_move_collision(ball_move, ball_collision); + time = 0; + } +} + static void ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - printf("test\n"); + vy += g * dt; + node->xyz[1] += vy * dt; + // node->xyz[0] += 10.0f; +} + +static void +ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree) +{ } static void ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { - printf("collision\n"); + if (node->xyz[1] > screen_h - ball_radius) { + node->xyz[1] = screen_h - ball_radius; + + vy *= e; + if (vy > -g && vy < 0) { + vy = 0.0; + node->set_move_collision(ball_move_idle, ball_collision_idle); + } + } } // prototype MainLoopPtr -SgRootChange::init(Viewer *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} +SgRootChange::init(Viewer *viewer, int screen_w, int screen_h) +{ + SgChange *sgroot = new SgChange(viewer); + SceneGraphPtr ball; + sgroot->run_init(); + srandom(100); -MainLoopPtr -SgRootChange::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - SceneGraphPtr ball; sgroot->createFromXMLfile("xml_file/Ball.xml"); ball = sgroot->createSceneGraph("Ball"); ball->set_move_collision(ball_move, ball_collision); + + h0 = screen_h/2; + h0 = -1000; + + ball->xyz[0] = screen_w/2; + ball->xyz[1] = h0; + ball->xyz[2] = 30.0f; + sgroot->setSceneData(ball); return sgroot; @@ -43,7 +136,7 @@ const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; -extern int sg_init(TaskManager *manager, int argc, char *argv[]); +extern int init(TaskManager *manager, int argc, char *argv[]); extern void task_initialize(); static void TMend(TaskManager *manager); @@ -52,7 +145,7 @@ { task_initialize(); manager->set_TMend(TMend); - return sg_init(manager, argc, argv); + return init(manager, argc, argv); }
--- a/Renderer/Test/SgRootChange.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/SgRootChange.h Sun Dec 27 20:49:38 2009 +0900 @@ -3,10 +3,10 @@ #include "SceneGraphRoot.h" #include "Application.h" #include "MainLoop.h" +#include "SgChange.h" class SgRootChange : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/ball_bound.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/ball_bound.cc Sun Dec 27 20:49:38 2009 +0900 @@ -133,12 +133,6 @@ return sgroot; } -MainLoopPtr -ball_bound::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new ball_bound();
--- a/Renderer/Test/ball_bound.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/ball_bound.h Sun Dec 27 20:49:38 2009 +0900 @@ -3,9 +3,9 @@ #include "SceneGraphRoot.h" #include "Application.h" #include "MainLoop.h" +#include "viewer.h" class ball_bound : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/boss1_action.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/boss1_action.cc Sun Dec 27 20:49:38 2009 +0900 @@ -209,12 +209,6 @@ } } -MainLoopPtr -boss1_action::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new boss1_action();
--- a/Renderer/Test/boss1_action.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/boss1_action.h Sun Dec 27 20:49:38 2009 +0900 @@ -10,7 +10,6 @@ class boss1_action : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); }; static const float player_speed = 10.0f;
--- a/Renderer/Test/chain_old.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/chain_old.cc Sun Dec 27 20:49:38 2009 +0900 @@ -161,13 +161,6 @@ return sgroot; } -MainLoopPtr -Chain::init_only_sg(SgChange *sgchange, int w, int h) -{ - return sgchange; -} - - extern Application * application() { return new Chain();
--- a/Renderer/Test/direction.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/direction.cc Sun Dec 27 20:49:38 2009 +0900 @@ -95,12 +95,6 @@ return sgroot; } -MainLoopPtr -direction::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new direction();
--- a/Renderer/Test/direction.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/direction.h Sun Dec 27 20:49:38 2009 +0900 @@ -6,6 +6,6 @@ class direction : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); + };
--- a/Renderer/Test/dynamic_create.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/dynamic_create.cc Sun Dec 27 20:49:38 2009 +0900 @@ -213,12 +213,6 @@ return sgroot; } -MainLoopPtr -dynamic_create::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new dynamic_create();
--- a/Renderer/Test/dynamic_create.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/dynamic_create.h Sun Dec 27 20:49:38 2009 +0900 @@ -7,5 +7,4 @@ class dynamic_create : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/gaplant.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/gaplant.cc Sun Dec 27 20:49:38 2009 +0900 @@ -33,12 +33,6 @@ return sgroot; } -MainLoopPtr -gaplant::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new gaplant();
--- a/Renderer/Test/gaplant.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/gaplant.h Sun Dec 27 20:49:38 2009 +0900 @@ -10,6 +10,5 @@ class gaplant : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/ieshoot.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/ieshoot.cc Sun Dec 27 20:49:38 2009 +0900 @@ -218,12 +218,6 @@ return sgroot; } -MainLoopPtr -ieshoot::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new ieshoot();
--- a/Renderer/Test/ieshoot.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/ieshoot.h Sun Dec 27 20:49:38 2009 +0900 @@ -7,6 +7,5 @@ class ieshoot : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/node.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/node.cc Sun Dec 27 20:49:38 2009 +0900 @@ -73,12 +73,6 @@ return sgroot; } -MainLoopPtr -node::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new node();
--- a/Renderer/Test/node.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/node.h Sun Dec 27 20:49:38 2009 +0900 @@ -6,6 +6,5 @@ class node : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/panel.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/panel.cc Sun Dec 27 20:49:38 2009 +0900 @@ -40,12 +40,6 @@ return sgroot; } -MainLoopPtr -panel::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new panel();
--- a/Renderer/Test/panel.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/panel.h Sun Dec 27 20:49:38 2009 +0900 @@ -6,6 +6,5 @@ class panel : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/property_test.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/property_test.cc Sun Dec 27 20:49:38 2009 +0900 @@ -10,7 +10,7 @@ ChainProperty cv[CHAIN_LEN]; -void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv); +void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, Viewer *sgroot); void init_chainold_vars(ChainPropertyPtr cv) { @@ -28,8 +28,9 @@ static void -chain_old_move_ope(SceneGraphPtr node, int screen_w, int screen_h) +chain_old_move_ope(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); if (pad->cross.isHold()) { @@ -49,12 +50,9 @@ cv[CHAIN_LEN-1].can_move = TRUE; } } + void -chain_old_move(ChainProperty cv, int w, int h) -{ -} -void -chain_old_move(SceneGraphPtr sg, int w, int h) +chain_old_move(SceneGraphPtr sg, void *sgroot_, int w, int h) { int id = sg->id; if(id == 0) { @@ -118,7 +116,7 @@ */ void -spe_move_collision(ChainProperty cv, spe_move_func new_move, spe_move_func new_collision) +spe_move_collision(ChainProperty cv, void *sgroot_,spe_move_func new_move, spe_move_func new_collision) { cv.move = new_move; @@ -128,7 +126,7 @@ void -chain_old_collision(void *cv, int w, int h, ChainPropertyPtr ocv) +chain_old_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr ocv) { //createSceneGraphFromProperty(cv, cv); } @@ -142,7 +140,7 @@ void -createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv) +createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, Viewer *sgroot) { SceneGraphPtr node; @@ -210,7 +208,7 @@ } - createSceneGraphFromProperty(root, cv); + createSceneGraphFromProperty(root, cv, sgroot); cv[0].can_move = FALSE; //sgroot->setSceneData(root);
--- a/Renderer/Test/property_test.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/property_test.h Sun Dec 27 20:49:38 2009 +0900 @@ -38,7 +38,7 @@ void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h); //void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg); void chain_collision(ChainPropertyPtr cv, int w, int h); - void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv); + //void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, Viewer *sgroot); //void property_swich(); //void set_properties(ChainPropertyPtr cv); MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
--- a/Renderer/Test/send_linda.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/send_linda.cc Sun Dec 27 20:49:38 2009 +0900 @@ -214,12 +214,6 @@ return sgr; } -MainLoopPtr -send_linda::init_only_sg(SgChange *sgchange, int w, int h) -{ - return sgchange; -} - extern Application * application() { return new send_linda();
--- a/Renderer/Test/send_linda.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/send_linda.h Sun Dec 27 20:49:38 2009 +0900 @@ -7,6 +7,5 @@ class send_linda : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *sgroot, int screen_w, int screen_h); };
--- a/Renderer/Test/universe.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/universe.cc Sun Dec 27 20:49:38 2009 +0900 @@ -68,12 +68,6 @@ return sgroot; } -MainLoopPtr -universe::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new universe();
--- a/Renderer/Test/universe.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/universe.h Sun Dec 27 20:49:38 2009 +0900 @@ -7,6 +7,5 @@ class universe : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/untitled.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/untitled.cc Sun Dec 27 20:49:38 2009 +0900 @@ -148,12 +148,6 @@ return sgroot; } -MainLoopPtr -untitled::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new untitled();
--- a/Renderer/Test/untitled.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/untitled.h Sun Dec 27 20:49:38 2009 +0900 @@ -7,6 +7,5 @@ class untitled : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/Renderer/Test/vacuum.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/vacuum.cc Sun Dec 27 20:49:38 2009 +0900 @@ -38,10 +38,10 @@ if(node->frame%ENCOUNT == ENCOUNT-1) { if(random()%2) { - add_cubecollision_object(redcube,node,screen_w,screen_h, sgroot); + add_cubecollision_object(redcube,node,screen_w,screen_h, sgroot); } else { - add_cubecollision_object(enemy,node,screen_w,screen_h, sgroot); + add_cubecollision_object(enemy,node,screen_w,screen_h, sgroot); } } @@ -182,12 +182,6 @@ return sgroot; } -MainLoopPtr -vacuum::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new vacuum();
--- a/Renderer/Test/vacuum.h Sun Dec 27 20:39:33 2009 +0900 +++ b/Renderer/Test/vacuum.h Sun Dec 27 20:49:38 2009 +0900 @@ -10,7 +10,6 @@ class vacuum : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); - MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h); };
--- a/TaskManager/kernel/ppe/DmaBuffer.cc Sun Dec 27 20:39:33 2009 +0900 +++ b/TaskManager/kernel/ppe/DmaBuffer.cc Sun Dec 27 20:49:38 2009 +0900 @@ -9,7 +9,7 @@ DmaBuffer::DmaBuffer(int size) { -#ifdef NO_POSIX_MEMALIGN +#ifndef HAS_POSIX_MEMALIGN buffer[0] = malloc(size); buffer[1] = malloc(size); #else
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ChangeLog Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,6 @@ +2008-05-27 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * memo + Fifo СǤϳǧޤ + Cell СϡCerium ޤ̤ʤΤǤ줫 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Func.h Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,6 @@ +enum { +#include "SysTasks.h" + Hello, + TwiceMain, +}; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,20 @@ +default: macosx + +macosx: FORCE + @echo "Make for Mac OS X" + @$(MAKE) -f Makefile.macosx + +linux: FORCE + @echo "Make for Linux" + @$(MAKE) -f Makefile.linux + +cell: FORCE + @echo "Make for PS3 (Cell)" + @$(MAKE) -f Makefile.cell + +FORCE: + +clean: + @$(MAKE) -f Makefile.macosx clean + @$(MAKE) -f Makefile.linux clean + @$(MAKE) -f Makefile.cell clean \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.cell Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,39 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lCellManager -lspe2 -lpthread -Wl,--gc-sections + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) speobject + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +speobject: + cd spe; $(MAKE) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo ppu-gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + cd spe; $(MAKE) clean
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.def Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,17 @@ +TARGET = hello + +# include/library path +# ex macosx +#CERIUM = /Users/gongo/Source/Cerium + +# ex linux/ps3 +CERIUM = ../../../Cerium + +CC = g++ +OPT = -g +CFLAGS = -Wall $(OPT) + +ABIBIT = 32 + +INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L${CERIUM}/TaskManager
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.linux Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,36 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lFifoManager + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + rm -f spe/*~ spe/\#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.macosx Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,37 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lFifoManager `sdl-config --libs` +CC += -m$(ABIBIT) + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + rm -f spe/*~ spe/\#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/main.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,70 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "TaskManager.h" +#include "Task.h" +#include "ListData.h" +#include "Func.h" + +extern void task_init(void); + +static int task_num = 1; +/*0 だと task_num が4つ以上の時に止まる。*/ +static int data_count = 1; + +const char *usr_help_str = "Usage: ./hello [-task task_num]\n\ + -task Number of task (default 1)\n"; + +static int +init(int argc, char **argv) +{ + for (int i = 1; argv[i]; ++i) { + + if (strcmp(argv[i], "-task") == 0) { + task_num = atoi(argv[++i]); + } + } + + return 0; +} + + +void +hello_init(TaskManager *manager) +{ + + + /** + * Create Task + * create_task(Task ID); + */ + + /*うしろ3つ param/inData/outData の数を指定する*/ + HTask *twice_main = manager->create_task_array(Hello,task_num,data_count,data_count,data_count); + Task *t = 0; + + for(int i = 0;i<task_num;i++) { + t = twice_main->next_task_array(Hello, t); + } + + twice_main->spawn_task_array(t->next()); + twice_main->set_cpu(SPE_ANY); + twice_main->spawn(); +} + +int +TMmain(TaskManager *manager,int argc, char *argv[]) +{ + + if (init(argc, argv) < 0) { + return -1; + } + + // Task Register + // ppe/task_init.cc + task_init(); + hello_init(manager); + + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,17 @@ +#include <stdio.h> +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.h Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,16 @@ +#ifndef INCLUDED_TASK_HELLO +#define INCLUDED_TASK_HELLO + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif +/* +class Twice : public SchedTask { +public: + SchedConstructor(Hello); + + int run(void *r, void *w); +}; + */ + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/task_init.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,17 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 必ずこの位置に書いて */ +SchedExternTask(Hello); + +/** + * この関数は ../spe/spe-main と違って + * 自分で呼び出せばいい関数なので + * 好きな関数名でおk (SchedRegisterTask は必須) + */ + +void +task_init(void) +{ + SchedRegister(Hello); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,17 @@ +#include <stdio.h> +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.h Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,16 @@ +#ifndef INCLUDED_TASK_HELLO +#define INCLUDED_TASK_HELLO + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif +/* +class Twice : public SchedTask { +public: + SchedConstructor(Hello); + + int run(void *r, void *w); +}; + */ + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Makefile Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,26 @@ +include ../Makefile.def + +TARGET = ../spe-main + +SRCS_TMP = $(wildcard *.cc) +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +CC = spu-g++ +CFLAGS = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG +INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L../${CERIUM}/TaskManager -lspemanager + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +clean: + rm -f $(TARGET) $(OBJS) + rm -f *~ \#* \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/spe-main.cc Sun Dec 27 20:49:38 2009 +0900 @@ -0,0 +1,14 @@ +#include "Func.h" +#include "SchedTask.h" + +SchedExternTask(Hello); + +/** + * この関数は SpeScheduler から呼ばれるので + * 必ずこの関数名でお願いします。 + */ +void +task_init(Scheduler *s) +{ + SchedRegister(Hello); +}