annotate TaskManager/Test/simple_render/viewer.cpp @ 101:c31499d11926

*** empty log message ***
author gongo
date Mon, 03 Mar 2008 14:06:33 +0900
parents 57bac9e07662
children 62679f4cae18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
1 #include <iostream>
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
2 #include <SDL.h>
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
3 #include "polygon.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
4 #include "viewer.h"
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
5 #include "sys.h"
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
6 #include "spu_span.h"
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
7 using namespace std;
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
8
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
9 #define redMask 0x00ff0000
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
10 #define greenMask 0x0000ff00
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
11 #define blueMask 0x000000ff
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
12 #define alphaMask 0
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
13
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
14 extern int create_sgp(Polygon *sg, SceneGraphPack *sgp);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
15 extern int update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp);
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
16 extern int create_pp(SceneGraphPack *sgp, PolygonPack *pp);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
17
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
18 Viewer::Viewer(int b, int w, int h)
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
19 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
20 bpp = b;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
21 width = w;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
22 height = h;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
23 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
24
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
25
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
26 void Viewer::sdl_init()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
27 {
67
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
28 if (SDL_Init( SDL_INIT_VIDEO ) < 0) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
29 fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
30 exit( 1 );
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
31 }
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
32
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
33 #ifndef _DEBUG
67
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
34 screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE);
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
35 if (screen == NULL) {
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
36 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
37 SDL_Quit();
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
38 exit(1);
7d2874fb0671 *** empty log message ***
gongo
parents: 63
diff changeset
39 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
40 #else
71
475e04db46c0 *** empty log message ***
gongo
parents: 70
diff changeset
41 void *_pixels = new Uint32[width*height*32/8];
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
42 //posix_memalign(&pixels, width*heigh/8, DEFAULT_ALIGNMENT);
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
43 screen = SDL_CreateRGBSurfaceFrom(_pixels, width, height, 32,
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
44 width*4, redMask, greenMask,
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
45 blueMask, alphaMask);
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
46 #endif
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
47 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
48
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
49
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
50 int Viewer::get_ticks()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
51 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
52 int time;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
53 time = SDL_GetTicks();
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
54 return time;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
55 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
56
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
57 bool Viewer::quit_check()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
58 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
59 bool quit = false;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
60 SDL_Event event;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
61 while(SDL_PollEvent(&event))
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
62 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
63 if(event.type==SDL_QUIT)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
64 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
65 quit = true;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
66 return quit;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
67 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
68 }
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
69 return quit;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
70 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
71
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
72 void Viewer::quit()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
73 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
74 SDL_Quit();
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
75 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
76
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
77
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
78 void Viewer::swap_buffers()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
79 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
80 SDL_GL_SwapBuffers();
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
81 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
82
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
83
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
84 void
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
85 Viewer::write_pixel(int x, int y,float z, Uint32 rgb)
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
86 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
87 SDL_PixelFormat *pf;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
88 pf = screen->format;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
89 x += width/2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
90 y += height/2;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
91
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
92 static int diffz,diffz1;
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
93
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
94 diffz1 = diffz;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
95 diffz = (zRow[x][y]>z);
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
96 if (z < zRow[x][y]) {
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
97 if (x < width && x > 0 && y > 0 && y < height) {
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
98 zRow[x][y] = z;
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
99 y = height - y;
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
100 pixels[width*y + x] = rgb;
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
101 }
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
102 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
103 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
104
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
105 void
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
106 Viewer::write_line(float x1, float y1, float x2, float y2, Uint32 rgb)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
107 {
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
108 if (x1 > x2) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
109 float x=0;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
110 float y=0;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
111 x=x1;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
112 y=y1;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
113 x1 = x2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
114 y1 = y2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
115 x2 = x;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
116 y2 = y;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
117 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
118
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
119 float s = y1;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
120
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
121 if ((int)x1 == (int)x2) {
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
122 if (y1 > y2) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
123 float y=0;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
124 y = y1;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
125 y1 = y2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
126 y2 = y;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
127 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
128
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
129 for (float i=y1; i<y2; i++) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
130 //write_pixel((int)x1,(int)i);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
131 write_pixel((int)x1,(int)i,0,rgb);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
132 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
133 } else {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
134 float t = (y2 - y1)/(x2 - x1);
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
135 if (t < -1) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
136 float f = 0;
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
137 for (float i=x1; i<x2; i++) {
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
138 for (float a=(int)t; a<0; a++) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
139 write_pixel((int)i,(int)s,0,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
140 s--;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
141 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
142
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
143 f += t-(int)t;
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
144
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
145 if (f <= -1) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
146 write_pixel((int)i,(int)s,0,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
147 f = 0;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
148 s--;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
149 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
150 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
151 } else if (t <= 1) {
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
152 for(float i=x1; i<x2; i++) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
153 //write_pixel((int)i,(int)s);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
154 write_pixel((int)i,(int)s,0,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
155 s += t;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
156 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
157 } else {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
158 float f = 0;
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
159 for (float i=x1; i<x2; i++) {
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
160 for (float a=0; a<(int)t; a++) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
161 write_pixel((int)i,(int)s,0,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
162 s++;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
163 }
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
164
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
165 f += t-(int)t;
51
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
166
c964110017c8 *** empty log message ***
gongo
parents: 50
diff changeset
167 if (f >= 1) {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
168 write_pixel((int)i,(int)s,0,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
169 f = 0;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
170 s++;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
171 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
172 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
173 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
174 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
175 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
176
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
177 void Viewer::write_triangle(float x1, float y1, float x2, float y2, float x3, float y3, Uint32 rgb)
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
178 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
179 write_line(x1,y1,x2,y2,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
180 write_line(x2,y2,x3,y3,rgb);
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
181 write_line(x3,y3,x1,y1,rgb);
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
182 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
183
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
184 void Viewer::clean_pixels()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
185 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
186 for(int i=0; i<width*height; i++)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
187 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
188 pixels[i] = 0x00;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
189 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
190 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
191
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
192 void Viewer::graph_line()
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
193 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
194 int xl = width*height/2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
195 int yl = width/2;
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
196 for(int i=0; i<width; i++)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
197 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
198 for(int t=0; t<height; t+=20)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
199 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
200 pixels[width*t+i] = 0x5a;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
201 }
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
202 pixels[xl +i] = 0xff;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
203 }
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
204 for(int i=0; i<height; i++)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
205 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
206 for(int t=0; t<width; t+=20)
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
207 {
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
208 pixels[i*width+t] = 0x5a;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
209 }
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
210 pixels[i*width+yl] = 0xff;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
211 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
212 }
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
213
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
214 int start_time;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
215 int this_time;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
216 int frames;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
217 SDL_Surface *bitmap;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
218 SDL_PixelFormat *pixelFormat;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
219 Uint32 background;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
220 Polygon *polygon;
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
221 SceneGraphPack *sgp;
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
222 PolygonPack *pp;
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
223 SPUSPANLIST *ssl;
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
224 DmaBuffer *sgp_buff;
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
225 DmaBuffer *pp_buff;
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
226 DmaBuffer *ssl_buff;
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
227
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
228 SPANPACK send_pack[6][10] __attribute__((aligned(16)));
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
229 unsigned int fbdev_addr;
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
230
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
231 void *__texture;
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
232
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
233 extern int get_fbdev_addr(void);
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
234
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
235 void
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
236 Viewer::run_init()
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
237 {
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
238 HTaskPtr task;
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
239 int fd;
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
240
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
241 //SceneGraphPack *sgp;
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
242 //PolygonPack *pp;
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
243 //SPUSPANLIST *ssl;
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
244
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
245 start_time = get_ticks();
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
246 this_time = 0;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
247 frames = 0;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
248
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
249 pixelFormat = screen->format;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
250 background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
251 polygon = new Polygon;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
252 polygon->set_data("cube.xml");
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
253 polygon->viewer = this;
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
254
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
255 #if 0 // USE DOUBLE BUFFER
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
256 sgp_buff = manager->allocate(sizeof(SceneGraphPack));
85
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
257 pp_buff = manager->allocate(sizeof(PolygonPack));
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
258 ssl_buff = manager->allocate(sizeof(SPUSPANLIST));
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
259
86
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
260 // DmaBuffer ¤Î½é´ü²½¡¢¤«¤Ã¤³¤¤¤¤ÊýË¡¤Ê¤¤¤«
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
261 for (int i = 0; i < 2; i ++) {
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
262 sgp_buff->get_buffer(&sgp);
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
263 ssl_buff->get_buffer(&ssl);
79
83b57e03d3ef *** empty log message ***
gongo
parents: 76
diff changeset
264
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
265 create_sgp(polygon, sgp);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
266 sgp->ssl = ssl;
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
267
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
268 sgp_buff->swap_buffer();
86
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
269 ssl_buff->swap_buffer();
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
270 }
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
271 #else
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
272 posix_memalign((void**)&sgp, 16, sizeof(SceneGraphPack));
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
273 posix_memalign((void**)&pp, 16, sizeof(SceneGraphPack));
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
274 posix_memalign((void**)&ssl, 16, sizeof(SceneGraphPack));
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
275 //sgp = new SceneGraphPack;
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
276 //pp = new PolygonPack;
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
277 //ssl = new SPUSPANLIST;
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
278 create_sgp(polygon, sgp);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
279 sgp->ssl = ssl;
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
280 #endif
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
281
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
282 pixels = new Uint32[width*height];
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
283
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
284 //graph_line();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
285
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
286 bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
287 width*4, redMask, greenMask,
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
288 blueMask, alphaMask);
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
289
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
290 fd = manager->open("ViewerRunLoop");
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
291 task = manager->create_task(fd, 0, 0, 0, NULL);
63
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
292 task->spawn();
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
293
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
294 //posix_memalign((void**)&__texture, 16, 128*128*3);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
295 //memcpy(__texture, polygon->texture_image->pixels, 128*128*3);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
296 //HTaskPtr task_init_tex = manager->create_task(0, 0, (uint32)__texture, 0, NULL);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
297 //task_init_tex->set_cpu(CPU_SPE);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
298 //task_init_tex->spawn();
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
299
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
300 //fbdev_addr = get_fbdev_addr();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
301 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
302
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
303 void
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
304 Viewer::run_loop(void)
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
305 {
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
306 HTaskPtr task_update_sgp = NULL;
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
307 HTaskPtr task_create_pp = NULL;
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
308 HTaskPtr task_create_sp = NULL;
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
309 HTaskPtr task_finish = NULL;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
310 int fd_update_sgp;
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
311 int fd_create_pp;
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
312 int fd_create_sp;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
313 int fd_finish;
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
314
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
315 HTaskPtr task;
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
316 int fd;
76
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
317 bool quit_flg;
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
318
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
319 quit_flg = quit_check();
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
320
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
321 if (quit_flg == true) {
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
322 this_time = get_ticks();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
323 fd_finish = manager->open("ViewerRunFinish");
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
324 task_finish = manager->create_task(fd_finish, 0, 0, 0, NULL);
63
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
325 task_finish->spawn();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
326 return;
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
327 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
328
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
329 // clean_pixels ¤ä zRow_init ¤Ï¡¢
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
330 // spe ¤Ç fb ¤Ë draw ¤¹¤ë»þ¤ÏɬÍפʤ¤¡£
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
331 // ppe ¦¤Ç draw ¤¹¤ë»þ¤Ë¤À¤±¸Æ¤Ö¤Ù¤­¡£
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
332 clean_pixels();
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
333 zRow_init();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
334
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
335 // ¤³¤ì¼«¿È¡¢°ì¤Ä¤Î¥¿¥¹¥¯¤È¤·¤Æ²ó¤¹Êý¤¬¤è¤¤¤«
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
336 graph_line();
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
337
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
338 fd_update_sgp = manager->open("UpdateSGP");
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
339 fd_create_pp = manager->open("CreatePP");
86
61bacd3b4405 *** empty log message ***
gongo
parents: 85
diff changeset
340 fd_create_sp = manager->open("CreateSP");
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
341 fd = manager->open("ViewerRunDraw");
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
342
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
343 #if 0 // USE DOUBLE BUFFER
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
344 task_update_sgp
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
345 = manager->create_task(fd_update_sgp, sizeof(SceneGraphPack),
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
346 sgp_buff, sgp_buff, NULL);
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
347 task_create_pp
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
348 = manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
349 sgp_buff, pp_buff, NULL);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
350 task_create_sp
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
351 = manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
352 pp_buff, ssl_buff, NULL);
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
353 #else
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
354 task_update_sgp
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
355 = manager->create_task(fd_update_sgp, sizeof(SceneGraphPack),
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
356 (uint32)sgp, (uint32)sgp, NULL);
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
357 task_create_pp
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
358 = manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
359 (uint32)sgp, (uint32)pp, NULL);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
360 task_create_sp
92
663bc2a213f5 *** empty log message ***
gongo
parents: 89
diff changeset
361 = manager->create_task(fd_create_sp, sizeof(PolygonPack),
663bc2a213f5 *** empty log message ***
gongo
parents: 89
diff changeset
362 (uint32)pp, 0, NULL);
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
363 #endif
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
364
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
365 #if 0
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
366
85
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
367 task_draw_finish = manager->create();
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
368 for (int i = 0; i < draw_spe_num; i++) {
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
369 task_spu_draw[i]
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
370 = manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
371 spuspan_buff, pp_buff, NULL);
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
372 task_spu_draw[i]->set_depend(task_spu_span);
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
373 task_draw_finish->set_depend(tas_spu_draw[i]);
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
374 }
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
375 #endif
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
376 task = manager->create_task(fd, 0, 0, 0, NULL);
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
377
63
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
378 task->set_depend(task_update_sgp);
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
379 task->set_depend(task_create_pp);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
380 task->set_depend(task_create_sp);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
381 task_create_sp->set_depend(task_create_pp);
85
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
382
74
5da437ae84db *** empty log message ***
gongo
parents: 73
diff changeset
383 //task_update_sgp->set_cpu(CPU_SPE);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
384 //task_create_pp->set_cpu(CPU_SPE);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
385
63
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
386 task_update_sgp->spawn();
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
387 task_create_pp->spawn();
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
388 task_create_sp->spawn();
63
54355e641172 *** empty log message ***
gongo
parents: 54
diff changeset
389 task->spawn();
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
390
73
811ffebd8deb *** empty log message ***
gongo
parents: 71
diff changeset
391 //sgp_buff->swap_buffer();
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
392 }
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
393
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
394 /**
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
395 * ËÜÅö¤Ï¥¿¥¹¥¯¤È¤·¤Æ TestDraw ¤òÁª¤Ö
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
396 */
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
397
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
398 //#define DRAW_POLYGON
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
399 #define DRAW_SPANPACK
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
400 //#define DRAW_SPUSPAN
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
401 void
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
402 Viewer::run_draw(void)
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
403 {
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
404 HTaskPtr task;
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
405 HTaskPtr task_draw[6][10];
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
406 int fd;
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
407
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
408 fd = manager->open("ViewerRunLoop");
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
409 task = manager->create_task(fd, 0, 0, 0, NULL);
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
410
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
411 #if 0
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
412 for (int j = 0; j < 6; j++) {
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
413 for (int i = 0; i < 10; i++) {
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
414 if (ssl->ss[j].spp[i].info.size < 1) continue;
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
415 memcpy(&send_pack[j][i], &ssl->ss[j].spp[i], sizeof(SPANPACK));
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
416 task_draw[j][i]
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
417 = manager->create_task(1, sizeof(SPANPACK),
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
418 (uint32)&send_pack[j][i], fbdev_addr, NULL);
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
419 task_draw[j][i]->set_cpu(CPU_SPE);
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
420 task->set_depend(task_draw[j][i]);
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
421 task_draw[j][i]->spawn();
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
422 }
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
423 }
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
424 #endif
94
588ab5f0e659 *** empty log message ***
gongo
parents: 92
diff changeset
425 task->spawn();
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
426
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
427 //return;
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
428
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
429 #if 0 // USE DOUBLE BUFFER
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
430 PolygonPack *pp;
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
431 SPUSPANLIST *ssl;
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
432
81
b03a4d3565c0 *** empty log message ***
gongo
parents: 79
diff changeset
433 pp_buff->get_buffer(&pp);
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
434 ssl_buff->get_buffer(&ssl);
88
504899860e66 *** empty log message ***
gongo
parents: 87
diff changeset
435 #endif
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
436
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
437 #ifdef DRAW_POLYGON
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
438 //polygon->draw(pp); // test draw of PolygonPack
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
439 polygon->draw(sgp); // test draw of PolygonPack
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
440 #else
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
441 # ifdef DRAW_SPANPACK // test draw of SpanPack
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
442 for (int j = 0; j < 6; j++) {
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
443 for (int i = 0; i < 10; i++) {
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
444 polygon->draw(&ssl->ss[j].spp[i]);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
445 }
89
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
446 }
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
447 # else
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
448 polygon->draw(&ssl->ss[0]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
449 polygon->draw(&ssl->ss[1]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
450 polygon->draw(&ssl->ss[2]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
451 polygon->draw(&ssl->ss[3]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
452 polygon->draw(&ssl->ss[4]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
453 polygon->draw(&ssl->ss[5]);
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
454 # endif
a309cf4eafc5 *** empty log message ***
gongo
parents: 88
diff changeset
455 #endif
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
456
101
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
457 SDL_BlitSurface(bitmap, NULL, screen, NULL);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
458 SDL_UpdateRect(screen, 0, 0, 0, 0);
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
459
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
460 frames++;
c31499d11926 *** empty log message ***
gongo
parents: 99
diff changeset
461
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
462 return;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
463 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
464
85
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
465 #if 0
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
466 void
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
467 Viewer::draw_finish(void)
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
468 {
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
469 //
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
470
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
471 HTaskPtr task = manager->create(task_r);
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
472
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
473 }
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
474 #endif
9b96b190cb73 *** empty log message ***
gongo
parents: 81
diff changeset
475
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
476 void
48
70a0ac46133e *** empty log message ***
gongo
parents: 42
diff changeset
477 Viewer::run_finish(void)
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
478 {
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
479 if (this_time != start_time) {
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
480 cout<< (((float)frames)/(this_time-start_time))*1000.0 << " FPS\n";
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
481 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
482
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
483 SDL_FreeSurface(bitmap);
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
484 delete [] pixels;
54
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
485 polygon->delete_data();
90523ccc4dff *** empty log message ***
gongo
parents: 51
diff changeset
486 delete polygon;
76
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
487 //delete sgp_buff;
5a1a5f4c28fd *** empty log message ***
gongo
parents: 74
diff changeset
488 //delete pp_buff;
99
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
489
57bac9e07662 rotate cube only polygon
gongo
parents: 94
diff changeset
490 free(__texture);
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
491 quit();
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
492 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 38
diff changeset
493
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
494 void
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
495 Viewer::zRow_init()
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
496 {
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
497 for (int i = 0; i < width; i++) {
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
498 for (int j = 0; j < height; j++) {
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
499 zRow[i][j] = 65535;
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
500 }
28
243ee0a1fe6f *** empty log message ***
gongo
parents: 26
diff changeset
501 }
26
3f68b2ef4fb0 *** empty log message ***
gongo
parents:
diff changeset
502 }