# HG changeset patch # User gongo # Date 1201947339 -32400 # Node ID df32980116bd10345270a4f500d24c679f1a8aaf Initial revision diff -r 000000000000 -r df32980116bd Renderer/Cell/Engine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Cell/Engine.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,66 @@ +CellEngine::CellEngine() +{ + TaskManager manager = new TaskManager(); +} + +void +CellEngine::init(int width, int height, int bpp) +{ + if(SDL_Init( SDL_INIT_VIDEO ) < 0) + { + cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; + exit(1); + } + + // etc... +} + +TaskDepend +CellEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) +{ + SceneGraph *t, *nt; + t = now; + nt = next; + + SceneGraphPack *nt_pack = nt->data_pack(); + SceneGraphPack *t_pack; + Task* t_task = now->get_task(); + TaskDepend task; + + task = manager->create_task(function_id, now->task_size(), + (unsigned int *)now->get_task(), + (unsigned int *)next->get_task()); + + manager->set_task_depend(task, wait); + + task->run(); + + return task; +} + +TaskDepend +CellEngin::draw_all(SceneGraph* now, TaskDepend wait) +{ + /** + * SceneGraph => Polygon + * Polygon => Span, Texture + * Texture, Span => Rendering + */ + + SceneGraph *t, *nt; + t = now; + nt = next; + + SceneGraphPack *nt_pack = nt->data_pack(); + SceneGraphPack *t_pack; + Task* t_task = now->get_task(); + TaskDepend task; + + task = manager->create_task(function_id, now->task_size(), + (unsigned int *)now->get_task(), + (unsigned int *)next->get_task()); + + manager->set_task_depend(task, wait); + + task->run(); +} diff -r 000000000000 -r df32980116bd Renderer/Cell/Engine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Cell/Engine.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,4 @@ +class CellEngine : RenderingEngine { +public: + CellEngine(int width, int height, int bpp); +}; diff -r 000000000000 -r df32980116bd Renderer/Cell/SceneGraph2PolygonTask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Cell/SceneGraph2PolygonTask.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,2 @@ +class SceneGraph2PolygonTask : Task { +}; diff -r 000000000000 -r df32980116bd Renderer/DataPack/DataPackEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/DataPack/DataPackEngine.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,45 @@ +void +DataPackEngine::init(int width, int height, int bpp) +{ + if(SDL_Init( SDL_INIT_VIDEO ) < 0) + { + cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; + exit(1); + } + + // etc... +} + +TaskDepend +DataPackEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) +{ + SceneGraph *t, *nt; + t = now; + nt = next; + + SceneGraphPack *nt_pack = nt->data_pack(); + SceneGraphPack *t_pack; + Task* t_task = now->get_task(); + + for (t_pack = now->data_pack(); t_pack < not->data_pack;) { + t_task->update(t_pack, nt_pack); + t_pack = t_pack->next(); + nt_pack = nt_pack->next(); + } +} + +TaskDepend +DataPackEngin::draw_all(SceneGraph* now, TaskDepend wait) +{ + SceneGraph *t, *nt; + t = now; + nt = next; + + SceneGraphPack *t_pack; + Task* t_task = now->get_task(); + + for (t_pack = now->data_pack(); t_pack < now->data_pack;) { + t_task->draw(t_pack, nt_pack); + t_pack = t_pack->next(); + } +} diff -r 000000000000 -r df32980116bd Renderer/DataPack/DataPackEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/DataPack/DataPackEngine.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,4 @@ +class DataPackEngine : RenderingEngine { +public: + DataPackEngine(int width, int height, int bpp); +}; diff -r 000000000000 -r df32980116bd Renderer/Simple/SimpleEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Simple/SimpleEngine.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,108 @@ +void +SimpleEngine::init(int width, int height, int bpp) +{ + if(SDL_Init( SDL_INIT_VIDEO ) < 0) + { + cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; + exit(1); + } + + // etc... +} + +TaskDepend +SimpleEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) +{ + SceneGraph *t, *nt; + t = now; + nt = next; + + //glPushMatrix(); + int s=0; + while(t) + { + //t->draw(stack); + t->update(t->data_pack, nt->data_pack); + if(t->child != NULL) + { + stack[s++] = t->matrix; //push + t = t->child; + } + else if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + } + else + { + while(t) + { + if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + break; + } + else + { + t = t->parent; + if(t) + { + stack[--s] = NULL; //pop + } + } + } + } + } + //glPopMatrix(); +} + +TaskDepend +SimpleEngin::draw_all(SceneGraph* now, TaskDepend wait) +{ + Polygon *t; + + t = this; + + //glPushMatrix(); + int s=0; + while(t) + { + t->draw(stack); + if(t->child != NULL) + { + stack[s++] = t->matrix; //push + t = t->child; + } + else if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + } + else + { + while(t) + { + if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + break; + } + else + { + t = t->parent; + if(t) + { + stack[--s] = NULL; //pop + } + } + } + } + } + //glPopMatrix(); +} diff -r 000000000000 -r df32980116bd Renderer/Simple/SimpleEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Simple/SimpleEngine.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,4 @@ +class SimpleEngine : RenderingEngine { +public: + SimpleEngine(int width, int height, int bpp); +}; diff -r 000000000000 -r df32980116bd example/cube/CubeSceneGraph.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/CubeSceneGraph.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,13 @@ +#include "CubeSceneGraph.h" + +CubeSceneGraph::CubeSceneGraph(char *xml) +{ + SceneGraph::SceneGraph(xml); + task = new CubeTask(); +} + +void +CubeSceneGraph::update(CubeSceneGraph *old) +{ + task->update(old->data_pack, data_pack); +} diff -r 000000000000 -r df32980116bd example/cube/CubeSceneGraph.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/CubeSceneGraph.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,8 @@ +#include "SceneGraph.h" +#include "CubeTask.h" + +class CubeSceneGraph : SceneGraph { +public: + CubeTask* task; + CubeSceneGraph(char *xml); +}; diff -r 000000000000 -r df32980116bd example/cube/CubeTask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/CubeTask.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,5 @@ +void +CubeTask::update(CubeDataPack *input, CubeDataPack *output) +{ + output->angle[0] = input->angle[0] + 1; +} diff -r 000000000000 -r df32980116bd example/cube/CubeTask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/CubeTask.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,4 @@ +class CubeTask : Task { + void update(CubeDataPack *input, CubeDataPack *output); + +}; diff -r 000000000000 -r df32980116bd example/cube/RenderingEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/RenderingEngine.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,101 @@ +void +RenderingEngine::init(int width, int height, int bpp) +{ +} + +TaskDepend +RenderingEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) +{ + SceneGraph *t, *nt; + t = now; + nt = next; + + //glPushMatrix(); + int s=0; + while(t) + { + //t->draw(stack); + t->update(t->data_pack, nt->data_pack); + if(t->child != NULL) + { + stack[s++] = t->matrix; //push + t = t->child; + } + else if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + } + else + { + while(t) + { + if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + break; + } + else + { + t = t->parent; + if(t) + { + stack[--s] = NULL; //pop + } + } + } + } + } + //glPopMatrix(); +} + +TaskDepend +RenderingEngin::draw_all(SceneGraph* now, TaskDepend wait) +{ + Polygon *t; + + t = this; + + //glPushMatrix(); + int s=0; + while(t) + { + t->draw(stack); + if(t->child != NULL) + { + stack[s++] = t->matrix; //push + t = t->child; + } + else if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + } + else + { + while(t) + { + if(t->brother != NULL) + { + stack[--s] = NULL; //pop + stack[s++] = t->matrix; //push + t = t->brother; + break; + } + else + { + t = t->parent; + if(t) + { + stack[--s] = NULL; //pop + } + } + } + } + } + //glPopMatrix(); +} diff -r 000000000000 -r df32980116bd example/cube/RenderingEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/RenderingEngine.h Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,6 @@ +class RenderingEngine { +public: + RenderingEngine(); + + void init(int width, int height, int bpp); +}; diff -r 000000000000 -r df32980116bd example/cube/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/cube/main.cpp Sat Feb 02 19:15:39 2008 +0900 @@ -0,0 +1,23 @@ +int +main() +{ + CubeSceneGraph scg[2]; + TaskID wait = 0; + TaskID wait2 = 0; + int phase = 0; + + scg[0] = new CubeSceneGraph("cube.xml"); + scg[1] = scg[0]->copy(); + + // OPENGL, SHARED, DATAPACK, CELL + RenderingEngine *engine = RenderingEngineFactory(OPENGL); + engine->init(width, height, bpp); + + while (1) { + wait = engine->update_all(scg[1-phase], scg[phase], wait); + //scg[1-phase]->update_all(scg[phase]); + wait2 = engine->draw_all(scg[phase], wait2); + //scg[phase]->draw_all(engine); + phase ^= 1; + } +}