Mercurial > hg > Game > Cerium
annotate Renderer/Engine/polygon.cc @ 1087:20f09564c586 draft
fix (not yet tested)
author | root@localhost.localdomain |
---|---|
date | Fri, 17 Dec 2010 18:34:29 +0900 |
parents | 9ce0480cde63 |
children | b733c7903d07 |
rev | line source |
---|---|
539 | 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" | |
1050 | 7 #include "matrix_calc.h" |
539 | 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" | |
14 #include "viewer_types.h" | |
15 using namespace std; | |
16 | |
17 | |
18 Polygon::Polygon(void) | |
19 { | |
1050 | 20 position_init(); |
539 | 21 } |
22 | |
23 void | |
24 Polygon::position_init(void) | |
25 { | |
26 xyz[0] = 0; | |
27 xyz[1] = 0; | |
28 xyz[2] = 0; | |
29 xyz[3] = 1; | |
30 c_xyz[0] = 0; | |
31 c_xyz[1] = 0; | |
32 c_xyz[2] = 0; | |
33 c_xyz[3] = 1; | |
34 angle[0] = 0; | |
35 angle[1] = 0; | |
36 angle[2] = 0; | |
37 angle[3] = 1; | |
1050 | 38 scale[0] = 1; |
39 scale[1] = 1; | |
40 scale[2] = 1; | |
539 | 41 |
861 | 42 |
43 #if !SPE_CREATE_POLYGON | |
44 | |
539 | 45 for (int i = 0; i < 16; i++) { |
46 matrix[i] = 0; | |
47 } | |
861 | 48 |
49 #endif | |
50 | |
539 | 51 } |
52 | |
53 void Polygon::pickup_coordinate(char *cont) | |
54 { | |
860 | 55 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
56 char *tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
57 int bound = 8; // coord_vertex size is 8byte. |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
58 int offset = 0; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
59 |
539 | 60 for(int n=0; n<size*3; n+=3) |
61 { | |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
62 tmp_cont = pickup_float(tmp_cont, coord_xyz+n); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
63 tmp_cont = pickup_float(tmp_cont, coord_xyz+n+1); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
64 tmp_cont = pickup_float(tmp_cont, coord_xyz+n+2); |
539 | 65 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
66 if (tmp_cont == NULL) |
539 | 67 { |
68 cout << "Analyzing obj data failed coordinate\n"; | |
69 } | |
70 } | |
860 | 71 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
72 tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
73 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
74 for(int n=0; n<size; n++) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
75 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
76 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
77 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
78 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+2); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
79 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
80 if (tmp_cont == NULL) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
81 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
82 cout << "Analyzing obj data failed coordinate\n"; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
83 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
84 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
85 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
86 #if SPE_CREATE_POLYGON_CHECK |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
87 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
88 for (int i = 0; i < size; i++) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
89 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
90 if (*(coord_xyz+i*3) != *(coord_pack+i*bound+offset)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
91 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
92 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
93 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
94 if (*(coord_xyz+i*3+1) != *(coord_pack+i*bound+offset+1)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
95 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
96 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
97 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
98 if (*(coord_xyz+i*3+2) != *(coord_pack+i*bound+offset+2)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
99 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
100 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
101 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
102 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
103 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
104 #endif |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
105 |
539 | 106 } |
107 | |
108 void Polygon::pickup_normal(char *cont) | |
109 { | |
860 | 110 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
111 char *tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
112 int bound = 8; // coord_pack size is 8byte. |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
113 int offset = 5; // coord_pack (xyz(3) + tex_x,tex_y(2) + n_xyz(3)) |
860 | 114 |
539 | 115 for (int n = 0; n<size*3; n += 3) |
116 { | |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
117 tmp_cont = pickup_float(tmp_cont, normal+n); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
118 tmp_cont = pickup_float(tmp_cont, normal+n+1); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
119 tmp_cont = pickup_float(tmp_cont, normal+n+2); |
539 | 120 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
121 if (tmp_cont == NULL) |
539 | 122 { |
123 cout << "Analyzing obj data failed normal\n"; | |
124 } | |
125 } | |
860 | 126 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
127 tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
128 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
129 for(int n=0; n<size; n++) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
130 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
131 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
132 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
133 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+2); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
134 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
135 if (tmp_cont == NULL) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
136 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
137 cout << "Analyzing obj data failed coordinate\n"; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
138 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
139 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
140 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
141 #if SPE_CREATE_POLYGON_CHECK |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
142 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
143 for (int i = 0; i < size; i++) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
144 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
145 if (*(normal+i*3) != *(coord_pack+i*bound+offset)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
146 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
147 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
148 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
149 if (*(normal+i*3+1) != *(coord_pack+i*bound+offset+1)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
150 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
151 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
152 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
153 if (*(normal+i*3+2) != *(coord_pack+i*bound+offset+2)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
154 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
155 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
156 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
157 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
158 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
159 #endif |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
160 |
539 | 161 } |
162 | |
163 void Polygon::pickup_model(char *cont) | |
164 { | |
165 cont = pickup_float(cont,c_xyz); | |
166 cont = pickup_float(cont,c_xyz+1); | |
167 cont = pickup_float(cont,c_xyz+2); | |
168 | |
169 if (cont == NULL) | |
170 { | |
171 cout << "Analyzing obj data failed model\n"; | |
172 } | |
173 } | |
174 | |
175 void Polygon::pickup_texture(char *cont) | |
176 { | |
860 | 177 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
178 char *tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
179 int bound = 8; // coord_pack size is 8byte. |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
180 int offset = 3; // coord_pack (xyz(3) + tex_x,tex_y(2) + n_xyz(3)) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
181 |
539 | 182 for (int n = 0; n < size*3; n += 3) |
183 { | |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
184 tmp_cont = pickup_float(tmp_cont, coord_tex+n); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
185 tmp_cont = pickup_float(tmp_cont, coord_tex+n+1); |
539 | 186 coord_tex[n+2] = 1.0; |
187 | |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
188 if (tmp_cont == NULL) |
539 | 189 { |
190 cout << "Analyzing obj data failed texture\n"; | |
191 } | |
192 } | |
860 | 193 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
194 tmp_cont = cont; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
195 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
196 for(int n=0; n<size; n++) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
197 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
198 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
199 tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
200 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
201 if (tmp_cont == NULL) |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
202 { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
203 cout << "Analyzing obj data failed coordinate\n"; |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
204 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
205 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
206 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
207 #if SPE_CREATE_POLYGON_CHECK |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
208 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
209 for (int i = 0; i < size; i++) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
210 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
211 if (*(coord_tex+i*3) != *(coord_pack+i*bound+offset)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
212 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
213 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
214 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
215 if (*(coord_tex+i*3+1) != *(coord_pack+i*bound+offset+1)) { |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
216 printf("hoge\n"); |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
217 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
218 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
219 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
220 } |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
221 |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
222 #endif |
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
223 |
539 | 224 } |
225 | |
226 char *get_pixel(int tx, int ty, SDL_Surface *texture_image) | |
227 { | |
228 return (char*)texture_image->pixels+(texture_image->format->BytesPerPixel*((texture_image->w)*ty+tx)); | |
229 } | |
230 | |
231 unsigned my_ntohl(unsigned u) { | |
232 // rr gg bb 00 | |
233 // rr | |
234 // bb gg rr | |
235 //unsigned u1 = ((u&0xff)<<24) + | |
236 // ((u&0xff00)<<8) + | |
237 // ((u&0xff0000)>>8) + | |
238 // ((u&0xff000000)>>24); | |
239 unsigned u1; | |
240 unsigned b = (u&0xff000000)>>24; | |
241 unsigned g = (u&0xff0000)>>16; | |
242 unsigned r = (u&0xff00)>>8; | |
243 u1 = r + (g<<8) + (b<<16); | |
244 //printf("pixel %x->%x\n",u,u1); | |
245 return u1; | |
246 } | |
247 | |
248 Uint32 Polygon::get_rgb(int tx, int ty) | |
249 { | |
250 SDL_PixelFormat *fmt; | |
251 //Uint32 temp, pixel; | |
252 Uint8 red, green, blue; | |
253 | |
1055 | 254 fmt = texture_info.texture_image->format; |
539 | 255 |
256 if (tx<0) tx = 0; | |
1055 | 257 if (texture_info.texture_image->w-1< tx) tx = texture_info.texture_image->w-1 ; |
539 | 258 if (ty<0) ty = 0; |
1055 | 259 if (texture_info.texture_image->h-1< ty) ty = texture_info.texture_image->h-1 ; |
539 | 260 |
261 | |
262 | |
263 //SDL_LockSurface(texture_image); | |
1055 | 264 char *p = get_pixel(tx,ty,texture_info.texture_image); |
539 | 265 blue = (Uint8) p[0]; |
266 green = (Uint8) p[1]; | |
267 red = (Uint8) p[2]; | |
268 | |
269 //printf("tx = %d ty = %d ", tx,ty); | |
270 //printf("pixel color => R: %d, G: %d, B: %d\n", red, green, blue); | |
271 | |
272 SDL_PixelFormat *pf = NULL; | |
273 //pf = viewer->screen->format; | |
274 | |
275 //cout << SDL_MapRGB(pf, red, green, blue) << endl; | |
276 return SDL_MapRGB(pf, red, green, blue); | |
277 } |