comparison Renderer/Simple/SimpleEngine.cpp @ 0:df32980116bd

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