annotate Renderer/Simple/SimpleEngine.cpp @ 503:516d5c91d5b4 draft double-linked-task-list

comment
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 11 Oct 2009 19:35:33 +0900
parents df32980116bd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
df32980116bd Initial revision
gongo
parents:
diff changeset
1 void
df32980116bd Initial revision
gongo
parents:
diff changeset
2 SimpleEngine::init(int width, int height, int bpp)
df32980116bd Initial revision
gongo
parents:
diff changeset
3 {
df32980116bd Initial revision
gongo
parents:
diff changeset
4 if(SDL_Init( SDL_INIT_VIDEO ) < 0)
df32980116bd Initial revision
gongo
parents:
diff changeset
5 {
df32980116bd Initial revision
gongo
parents:
diff changeset
6 cout << "Couldn't initialize SDL:" << SDL_GetError() << endl;
df32980116bd Initial revision
gongo
parents:
diff changeset
7 exit(1);
df32980116bd Initial revision
gongo
parents:
diff changeset
8 }
df32980116bd Initial revision
gongo
parents:
diff changeset
9
df32980116bd Initial revision
gongo
parents:
diff changeset
10 // etc...
df32980116bd Initial revision
gongo
parents:
diff changeset
11 }
df32980116bd Initial revision
gongo
parents:
diff changeset
12
df32980116bd Initial revision
gongo
parents:
diff changeset
13 TaskDepend
df32980116bd Initial revision
gongo
parents:
diff changeset
14 SimpleEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait)
df32980116bd Initial revision
gongo
parents:
diff changeset
15 {
df32980116bd Initial revision
gongo
parents:
diff changeset
16 SceneGraph *t, *nt;
df32980116bd Initial revision
gongo
parents:
diff changeset
17 t = now;
df32980116bd Initial revision
gongo
parents:
diff changeset
18 nt = next;
df32980116bd Initial revision
gongo
parents:
diff changeset
19
df32980116bd Initial revision
gongo
parents:
diff changeset
20 //glPushMatrix();
df32980116bd Initial revision
gongo
parents:
diff changeset
21 int s=0;
df32980116bd Initial revision
gongo
parents:
diff changeset
22 while(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
23 {
df32980116bd Initial revision
gongo
parents:
diff changeset
24 //t->draw(stack);
df32980116bd Initial revision
gongo
parents:
diff changeset
25 t->update(t->data_pack, nt->data_pack);
df32980116bd Initial revision
gongo
parents:
diff changeset
26 if(t->child != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
27 {
df32980116bd Initial revision
gongo
parents:
diff changeset
28 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
29 t = t->child;
df32980116bd Initial revision
gongo
parents:
diff changeset
30 }
df32980116bd Initial revision
gongo
parents:
diff changeset
31 else if(t->brother != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
32 {
df32980116bd Initial revision
gongo
parents:
diff changeset
33 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
34 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
35 t = t->brother;
df32980116bd Initial revision
gongo
parents:
diff changeset
36 }
df32980116bd Initial revision
gongo
parents:
diff changeset
37 else
df32980116bd Initial revision
gongo
parents:
diff changeset
38 {
df32980116bd Initial revision
gongo
parents:
diff changeset
39 while(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
40 {
df32980116bd Initial revision
gongo
parents:
diff changeset
41 if(t->brother != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
42 {
df32980116bd Initial revision
gongo
parents:
diff changeset
43 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
44 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
45 t = t->brother;
df32980116bd Initial revision
gongo
parents:
diff changeset
46 break;
df32980116bd Initial revision
gongo
parents:
diff changeset
47 }
df32980116bd Initial revision
gongo
parents:
diff changeset
48 else
df32980116bd Initial revision
gongo
parents:
diff changeset
49 {
df32980116bd Initial revision
gongo
parents:
diff changeset
50 t = t->parent;
df32980116bd Initial revision
gongo
parents:
diff changeset
51 if(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
52 {
df32980116bd Initial revision
gongo
parents:
diff changeset
53 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
54 }
df32980116bd Initial revision
gongo
parents:
diff changeset
55 }
df32980116bd Initial revision
gongo
parents:
diff changeset
56 }
df32980116bd Initial revision
gongo
parents:
diff changeset
57 }
df32980116bd Initial revision
gongo
parents:
diff changeset
58 }
df32980116bd Initial revision
gongo
parents:
diff changeset
59 //glPopMatrix();
df32980116bd Initial revision
gongo
parents:
diff changeset
60 }
df32980116bd Initial revision
gongo
parents:
diff changeset
61
df32980116bd Initial revision
gongo
parents:
diff changeset
62 TaskDepend
df32980116bd Initial revision
gongo
parents:
diff changeset
63 SimpleEngin::draw_all(SceneGraph* now, TaskDepend wait)
df32980116bd Initial revision
gongo
parents:
diff changeset
64 {
df32980116bd Initial revision
gongo
parents:
diff changeset
65 Polygon *t;
df32980116bd Initial revision
gongo
parents:
diff changeset
66
df32980116bd Initial revision
gongo
parents:
diff changeset
67 t = this;
df32980116bd Initial revision
gongo
parents:
diff changeset
68
df32980116bd Initial revision
gongo
parents:
diff changeset
69 //glPushMatrix();
df32980116bd Initial revision
gongo
parents:
diff changeset
70 int s=0;
df32980116bd Initial revision
gongo
parents:
diff changeset
71 while(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
72 {
df32980116bd Initial revision
gongo
parents:
diff changeset
73 t->draw(stack);
df32980116bd Initial revision
gongo
parents:
diff changeset
74 if(t->child != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
75 {
df32980116bd Initial revision
gongo
parents:
diff changeset
76 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
77 t = t->child;
df32980116bd Initial revision
gongo
parents:
diff changeset
78 }
df32980116bd Initial revision
gongo
parents:
diff changeset
79 else if(t->brother != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
80 {
df32980116bd Initial revision
gongo
parents:
diff changeset
81 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
82 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
83 t = t->brother;
df32980116bd Initial revision
gongo
parents:
diff changeset
84 }
df32980116bd Initial revision
gongo
parents:
diff changeset
85 else
df32980116bd Initial revision
gongo
parents:
diff changeset
86 {
df32980116bd Initial revision
gongo
parents:
diff changeset
87 while(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
88 {
df32980116bd Initial revision
gongo
parents:
diff changeset
89 if(t->brother != NULL)
df32980116bd Initial revision
gongo
parents:
diff changeset
90 {
df32980116bd Initial revision
gongo
parents:
diff changeset
91 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
92 stack[s++] = t->matrix; //push
df32980116bd Initial revision
gongo
parents:
diff changeset
93 t = t->brother;
df32980116bd Initial revision
gongo
parents:
diff changeset
94 break;
df32980116bd Initial revision
gongo
parents:
diff changeset
95 }
df32980116bd Initial revision
gongo
parents:
diff changeset
96 else
df32980116bd Initial revision
gongo
parents:
diff changeset
97 {
df32980116bd Initial revision
gongo
parents:
diff changeset
98 t = t->parent;
df32980116bd Initial revision
gongo
parents:
diff changeset
99 if(t)
df32980116bd Initial revision
gongo
parents:
diff changeset
100 {
df32980116bd Initial revision
gongo
parents:
diff changeset
101 stack[--s] = NULL; //pop
df32980116bd Initial revision
gongo
parents:
diff changeset
102 }
df32980116bd Initial revision
gongo
parents:
diff changeset
103 }
df32980116bd Initial revision
gongo
parents:
diff changeset
104 }
df32980116bd Initial revision
gongo
parents:
diff changeset
105 }
df32980116bd Initial revision
gongo
parents:
diff changeset
106 }
df32980116bd Initial revision
gongo
parents:
diff changeset
107 //glPopMatrix();
df32980116bd Initial revision
gongo
parents:
diff changeset
108 }