Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/polygon.cc @ 526:413667c70a1d draft
fix
author | tkaito@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 22 Oct 2009 01:31:09 +0900 |
parents | 0d2dc1869cbe |
children |
rev | line source |
---|---|
109 | 1 #include <iostream> |
2 #include <SDL.h> | |
3 #include <SDL_opengl.h> | |
4 #include <SDL_image.h> | |
5 #include "polygon.h" | |
6 #include "xml.h" | |
7 #include "sys.h" | |
8 #include "triangle.h" | |
9 #include "vertex.h" | |
10 #include "Span.h" | |
11 #include "SpanC.h" | |
12 #include "scene_graph_pack.h" | |
13 #include "error.h" | |
120 | 14 #include "viewer_types.h" |
109 | 15 using namespace std; |
16 | |
17 //extern int decode(char *cont, char *file_name); | |
18 extern int decode(char *cont, FILE *outfile); | |
19 | |
20 | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
21 Polygon::Polygon(void) |
109 | 22 { |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
23 xyz[0] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
24 xyz[1] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
25 xyz[2] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
26 xyz[3] = 1; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
27 c_xyz[0] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
28 c_xyz[1] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
29 c_xyz[2] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
30 c_xyz[3] = 1; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
31 angle[0] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
32 angle[1] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
33 angle[2] = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
34 angle[3] = 1; |
109 | 35 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
36 for (int i = 0; i < 16; i++) { |
349 | 37 matrix[i] = 0; |
109 | 38 } |
39 } | |
40 | |
138 | 41 void |
42 Polygon::position_init(void) | |
43 { | |
44 xyz[0] = 0; | |
45 xyz[1] = 0; | |
46 xyz[2] = 0; | |
47 xyz[3] = 1; | |
48 c_xyz[0] = 0; | |
49 c_xyz[1] = 0; | |
50 c_xyz[2] = 0; | |
51 c_xyz[3] = 1; | |
52 angle[0] = 0; | |
53 angle[1] = 0; | |
54 angle[2] = 0; | |
55 angle[3] = 1; | |
56 | |
57 for (int i = 0; i < 16; i++) { | |
349 | 58 matrix[i] = 0; |
138 | 59 } |
60 } | |
61 | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
62 #if 0 |
109 | 63 void Polygon::draw(SceneGraphPack *sgp) |
64 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
65 float xyz1[4],xyz2[4],xyz3[4]; |
109 | 66 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
67 /***SceneGraphUpdate***/ |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
68 //sgp_update(); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
69 for (int i = 0; i < sgp->info.size; i++) { |
349 | 70 SceneGraphNode node = sgp->node[i]; |
109 | 71 |
349 | 72 /***draw***/ |
73 int n,nt; | |
74 for(n=0,nt=0; n<node.size*3; n+=9,nt+=6) { | |
75 xyz1[0] = node.vertex[n]; | |
76 xyz1[1] = node.vertex[n+1]; | |
77 xyz1[2] = node.vertex[n+2]*-1; | |
78 xyz1[3] = 1; | |
79 xyz2[0] = node.vertex[n+3]; | |
80 xyz2[1] = node.vertex[n+3+1]; | |
81 xyz2[2] = node.vertex[n+3+2]*-1; | |
82 xyz2[3] = 1; | |
83 xyz3[0] = node.vertex[n+6]; | |
84 xyz3[1] = node.vertex[n+6+1]; | |
85 xyz3[2] = node.vertex[n+6+2]*-1; | |
86 xyz3[3] = 1; | |
109 | 87 |
349 | 88 rotate(xyz1, node.translation); |
89 rotate(xyz2, node.translation); | |
90 rotate(xyz3, node.translation); | |
109 | 91 |
349 | 92 Vertex *ver1 = new Vertex(xyz1[0],xyz1[1],xyz1[2],node.texture[nt],node.texture[nt+1]); |
93 Vertex *ver2 = new Vertex(xyz2[0],xyz2[1],xyz2[2],node.texture[nt+2],node.texture[nt+2+1]); | |
94 Vertex *ver3 = new Vertex(xyz3[0],xyz3[1],xyz3[2],node.texture[nt+4],node.texture[nt+4+1]); | |
109 | 95 |
349 | 96 Triangle *tri = new Triangle(ver1,ver2,ver3); |
97 Span_c *span = new Span_c(); | |
98 span->viewer = viewer; | |
99 span->p = this; | |
100 span->create_span(tri,texture_image); | |
101 delete ver1; | |
102 delete ver2; | |
103 delete ver3; | |
104 delete tri; | |
105 delete span; | |
106 } | |
109 | 107 } |
108 } | |
109 | |
110 | |
111 void Polygon::draw(PolygonPack *pp) | |
112 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
113 for(int n=0; n<pp->info.size; n++) |
109 | 114 { |
349 | 115 Vertex *ver1 = new Vertex(pp->tri[n].ver1.x,pp->tri[n].ver1.y,pp->tri[n].ver1.z,pp->tri[n].ver1.tex_x,pp->tri[n].ver1.tex_y); |
116 Vertex *ver2 = new Vertex(pp->tri[n].ver2.x,pp->tri[n].ver2.y,pp->tri[n].ver2.z,pp->tri[n].ver2.tex_x,pp->tri[n].ver2.tex_y); | |
117 Vertex *ver3 = new Vertex(pp->tri[n].ver3.x,pp->tri[n].ver3.y,pp->tri[n].ver3.z,pp->tri[n].ver3.tex_x,pp->tri[n].ver3.tex_y); | |
109 | 118 |
349 | 119 Triangle *tri = new Triangle(ver1,ver2,ver3); |
120 Span_c *span = new Span_c(); | |
121 span->viewer = viewer; | |
122 span->p = this; | |
123 span->create_span(tri,texture_image); | |
124 delete ver1; | |
125 delete ver2; | |
126 delete ver3; | |
127 delete tri; | |
128 delete span; | |
109 | 129 } |
130 } | |
131 | |
132 void Polygon::draw(SpanPack *sp) | |
133 { | |
134 Span *span; | |
135 | |
136 for (int n = 0; n < sp->info.size; n++) { | |
349 | 137 span = &sp->span[n]; |
109 | 138 |
349 | 139 //int x = span->x; |
140 //int y = span->y; | |
141 float z = span->start_z; | |
142 int end = span->length_x; | |
143 float zpos = span->end_z; | |
144 float tex1 = span->tex_x1; | |
145 float tex2 = span->tex_x2; | |
146 float tey1 = span->tex_y1; | |
147 float tey2 = span->tex_y2; | |
148 Uint32 rgb; | |
149 int tex_xpos; | |
150 int tex_ypos; | |
151 int tex_zpos; | |
152 float tex_x, tex_y, tex_z; | |
109 | 153 |
349 | 154 if (end == 1) { |
155 tex_xpos = (int)((span->tex_height-1) * tex1); | |
156 tex_ypos = (int)((span->tex_width-1) * tey1); | |
157 tex_zpos = (int)z; | |
158 rgb = get_rgb(tex_xpos, tex_ypos); | |
159 //viewer->write_pixel(x, y, zpos, rgb); | |
160 } else { | |
161 for (int j = 0; j < end; j++) { | |
162 tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1); | |
163 tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1); | |
164 tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1); | |
165 if (tex_x > 1) tex_x = 1; | |
166 if (tex_y > 1) tex_y = 1; | |
167 tex_xpos = (int)((span->tex_height-1) * tex_x); | |
168 tex_ypos = (int)((span->tex_width-1) * tex_y); | |
169 rgb = get_rgb(tex_xpos,tex_ypos); | |
170 //viewer->write_pixel(j + x, y, tex_z, rgb); | |
171 } | |
172 } | |
109 | 173 } |
174 } | |
175 | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
176 #endif |
109 | 177 |
178 void Polygon::pickup_coordinate(char *cont) | |
179 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
180 for(int n=0; n<size*3; n+=3) |
109 | 181 { |
349 | 182 cont = pickup_float(cont, coord_xyz+n); |
183 cont = pickup_float(cont, coord_xyz+n+1); | |
184 cont = pickup_float(cont, coord_xyz+n+2); | |
185 | |
186 if (cont == NULL) | |
187 { | |
188 cout << "Analyzing obj data failed coordinate\n"; | |
189 } | |
109 | 190 } |
191 } | |
192 | |
193 void Polygon::pickup_normal(char *cont) | |
194 { | |
228
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
141
diff
changeset
|
195 for (int n = 0; n<size*3; n += 3) |
109 | 196 { |
349 | 197 cont = pickup_float(cont, normal+n); |
198 cont = pickup_float(cont, normal+n+1); | |
199 cont = pickup_float(cont, normal+n+2); | |
200 | |
201 if (cont == NULL) | |
202 { | |
203 cout << "Analyzing obj data failed normal\n"; | |
204 } | |
109 | 205 } |
206 } | |
207 | |
208 void Polygon::pickup_model(char *cont) | |
209 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
210 cont = pickup_float(cont,c_xyz); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
211 cont = pickup_float(cont,c_xyz+1); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
212 cont = pickup_float(cont,c_xyz+2); |
349 | 213 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
214 if (cont == NULL) |
109 | 215 { |
349 | 216 cout << "Analyzing obj data failed model\n"; |
109 | 217 } |
218 } | |
219 | |
220 void Polygon::pickup_texture(char *cont) | |
221 { | |
228
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
141
diff
changeset
|
222 for (int n = 0; n < size*3; n += 3) |
109 | 223 { |
349 | 224 cont = pickup_float(cont, coord_tex+n); |
225 cont = pickup_float(cont, coord_tex+n+1); | |
226 coord_tex[n+2] = 1.0; | |
227 | |
228 if (cont == NULL) | |
229 { | |
230 cout << "Analyzing obj data failed texture\n"; | |
231 } | |
109 | 232 } |
233 } | |
234 | |
235 char *get_pixel(int tx, int ty, SDL_Surface *texture_image) | |
236 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
237 return (char*)texture_image->pixels+(texture_image->format->BytesPerPixel*((texture_image->w)*ty+tx)); |
109 | 238 } |
239 | |
240 unsigned my_ntohl(unsigned u) { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
241 // rr gg bb 00 |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
242 // rr |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
243 // bb gg rr |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
244 //unsigned u1 = ((u&0xff)<<24) + |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
245 // ((u&0xff00)<<8) + |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
246 // ((u&0xff0000)>>8) + |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
247 // ((u&0xff000000)>>24); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
248 unsigned u1; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
249 unsigned b = (u&0xff000000)>>24; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
250 unsigned g = (u&0xff0000)>>16; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
251 unsigned r = (u&0xff00)>>8; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
252 u1 = r + (g<<8) + (b<<16); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
253 //printf("pixel %x->%x\n",u,u1); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
254 return u1; |
109 | 255 } |
256 | |
257 Uint32 Polygon::get_rgb(int tx, int ty) | |
258 { | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
259 SDL_PixelFormat *fmt; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
260 //Uint32 temp, pixel; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
261 Uint8 red, green, blue; |
349 | 262 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
263 fmt = texture_image->format; |
109 | 264 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
265 if (tx<0) tx = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
266 if (texture_image->w-1< tx) tx = texture_image->w-1 ; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
267 if (ty<0) ty = 0; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
268 if (texture_image->h-1< ty) ty = texture_image->h-1 ; |
109 | 269 |
270 | |
271 | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
272 //SDL_LockSurface(texture_image); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
273 char *p = get_pixel(tx,ty,texture_image); |
109 | 274 #if 0 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
275 pixel = my_ntohl(*(Uint32*)p); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
276 //printf("pixel = %d\n", pixel); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
277 //printf("pixel %x bpp = %d ",p, fmt->BytesPerPixel); |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
278 //SDL_UnlockSurface(texture_image); |
349 | 279 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
280 temp = pixel&fmt->Rmask; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
281 temp = temp>>fmt->Rshift; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
282 temp = temp<<fmt->Rloss; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
283 red = (Uint8)temp; |
349 | 284 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
285 temp = pixel&fmt->Gmask; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
286 temp = temp>>fmt->Gshift; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
287 temp = temp<<fmt->Gloss; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
288 green = (Uint8)temp; |
349 | 289 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
290 temp = pixel&fmt->Bmask; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
291 temp = temp>>fmt->Bshift; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
292 temp = temp<<fmt->Bloss; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
293 blue = (Uint8)temp; |
109 | 294 #endif |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
295 blue = (Uint8) p[0]; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
296 green = (Uint8) p[1]; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
297 red = (Uint8) p[2]; |
349 | 298 |
299 //printf("tx = %d ty = %d ", tx,ty); | |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
300 //printf("pixel color => R: %d, G: %d, B: %d\n", red, green, blue); |
123
e9e12e2088bd
delete scene_graph->child (instead use "children")
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
120
diff
changeset
|
301 |
238 | 302 SDL_PixelFormat *pf = NULL; |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
303 //pf = viewer->screen->format; |
109 | 304 |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
305 //cout << SDL_MapRGB(pf, red, green, blue) << endl; |
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
130
diff
changeset
|
306 return SDL_MapRGB(pf, red, green, blue); |
109 | 307 } |