Mercurial > hg > Game > Cerium
annotate Renderer/Engine/polygon.cc @ 1161:cc1a50cac83d draft
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
author | Yutaka_Kinjyo |
---|---|
date | Thu, 05 May 2011 00:15:43 +0900 |
parents | 786e800abfb4 |
children | b8adf4e95e96 |
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 | |
1130 | 18 |
19 | |
20 Polygon::Polygon() | |
539 | 21 { |
1050 | 22 position_init(); |
539 | 23 } |
24 | |
25 void | |
26 Polygon::position_init(void) | |
27 { | |
1129 | 28 |
539 | 29 xyz[0] = 0; |
30 xyz[1] = 0; | |
31 xyz[2] = 0; | |
32 xyz[3] = 1; | |
33 c_xyz[0] = 0; | |
34 c_xyz[1] = 0; | |
35 c_xyz[2] = 0; | |
36 c_xyz[3] = 1; | |
37 angle[0] = 0; | |
38 angle[1] = 0; | |
39 angle[2] = 0; | |
40 angle[3] = 1; | |
1050 | 41 scale[0] = 1; |
42 scale[1] = 1; | |
43 scale[2] = 1; | |
539 | 44 |
861 | 45 |
539 | 46 } |
47 | |
48 void Polygon::pickup_coordinate(char *cont) | |
49 { | |
860 | 50 |
1128 | 51 // size は頂点の数, count は面の数 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
52 char *tmp_cont = cont; |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
53 int count = size / 3; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
54 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
55 for (int i = 0; i < pp_num; i++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
56 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
57 TrianglePackPtr tri = pp[i].tri; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
58 // TrianglePack の size のチェック |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
59 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
60 pp[i].info.size = tri_size; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
61 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
62 for (int j = 0; j < tri_size; j++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
63 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
64 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
65 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
66 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.z)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
67 |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
68 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
69 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
70 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.z)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
71 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
72 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
73 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
74 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.z)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
75 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
76 if (tmp_cont == NULL) |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
77 { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
78 cout << "Analyzing obj data failed coordinate\n"; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
79 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
80 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
81 count -= 1; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
82 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
83 } |
1128 | 84 |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
85 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
86 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
87 if (count != 0) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
88 printf("miss pickup_coordinate size. diff size = %d\n", count); |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
89 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
90 |
539 | 91 } |
92 | |
93 void Polygon::pickup_normal(char *cont) | |
94 { | |
860 | 95 |
96 | |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
97 // size は頂点の数, count は面の数 |
1128 | 98 char *tmp_cont = cont; |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
99 int count = size / 3; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
100 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
101 for (int i = 0; i < pp_num; i++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
102 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
103 TrianglePackPtr tri = pp[i].tri; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
104 // TrianglePack の size のチェック |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
105 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
106 pp[i].info.size = tri_size; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
107 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
108 for (int j = 0; j < tri_size; j++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
109 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
110 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
111 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
112 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.z)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
113 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
114 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
115 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
116 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.z)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
117 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
118 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
119 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.y)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
120 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.z)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
121 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
122 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
123 if (tmp_cont == NULL) |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
124 { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
125 cout << "Analyzing obj data failed coordinate\n"; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
126 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
127 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
128 count -= 1; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
129 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
130 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
131 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
132 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
133 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
134 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
135 if (count != 0) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
136 printf("miss pickup_normal size. diff size = %d\n", count); |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
137 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
138 |
539 | 139 } |
140 | |
141 void Polygon::pickup_model(char *cont) | |
142 { | |
143 cont = pickup_float(cont,c_xyz); | |
144 cont = pickup_float(cont,c_xyz+1); | |
145 cont = pickup_float(cont,c_xyz+2); | |
146 | |
147 if (cont == NULL) | |
148 { | |
149 cout << "Analyzing obj data failed model\n"; | |
150 } | |
151 } | |
152 | |
153 void Polygon::pickup_texture(char *cont) | |
154 { | |
860 | 155 |
906
becd6fad3ae0
coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents:
861
diff
changeset
|
156 char *tmp_cont = cont; |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
157 int count = size / 3; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
158 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
159 for (int i = 0; i < pp_num; i++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
160 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
161 TrianglePackPtr tri = pp[i].tri; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
162 // TrianglePack の size のチェック |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
163 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
164 pp[i].info.size = tri_size; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
165 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
166 for (int j = 0; j < tri_size; j++) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
167 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
168 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
169 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_y)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
170 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
171 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
172 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_y)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
173 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
174 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_x)); |
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
175 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_y)); |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
176 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
177 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
178 if (tmp_cont == NULL) |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
179 { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
180 cout << "Analyzing obj data failed coordinate\n"; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
181 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
182 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
183 count -= 1; |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
184 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
185 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
186 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
187 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
188 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
189 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
190 if (count != 0) { |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
191 printf("miss pickup_texture size. diff size = %d\n", count); |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
192 } |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
193 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
194 |
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1125
diff
changeset
|
195 |
539 | 196 } |
197 | |
198 char *get_pixel(int tx, int ty, SDL_Surface *texture_image) | |
199 { | |
200 return (char*)texture_image->pixels+(texture_image->format->BytesPerPixel*((texture_image->w)*ty+tx)); | |
201 } | |
202 | |
203 unsigned my_ntohl(unsigned u) { | |
204 // rr gg bb 00 | |
205 // rr | |
206 // bb gg rr | |
207 //unsigned u1 = ((u&0xff)<<24) + | |
208 // ((u&0xff00)<<8) + | |
209 // ((u&0xff0000)>>8) + | |
210 // ((u&0xff000000)>>24); | |
211 unsigned u1; | |
212 unsigned b = (u&0xff000000)>>24; | |
213 unsigned g = (u&0xff0000)>>16; | |
214 unsigned r = (u&0xff00)>>8; | |
215 u1 = r + (g<<8) + (b<<16); | |
216 //printf("pixel %x->%x\n",u,u1); | |
217 return u1; | |
218 } | |
219 | |
220 Uint32 Polygon::get_rgb(int tx, int ty) | |
221 { | |
222 SDL_PixelFormat *fmt; | |
223 //Uint32 temp, pixel; | |
224 Uint8 red, green, blue; | |
225 | |
1130 | 226 fmt = texture_info->texture_image->format; |
539 | 227 |
228 if (tx<0) tx = 0; | |
1130 | 229 if (texture_info->texture_image->w-1< tx) tx = texture_info->texture_image->w-1 ; |
539 | 230 if (ty<0) ty = 0; |
1130 | 231 if (texture_info->texture_image->h-1< ty) ty = texture_info->texture_image->h-1 ; |
539 | 232 |
233 | |
234 //SDL_LockSurface(texture_image); | |
1130 | 235 char *p = get_pixel(tx,ty,texture_info->texture_image); |
539 | 236 blue = (Uint8) p[0]; |
237 green = (Uint8) p[1]; | |
238 red = (Uint8) p[2]; | |
239 | |
240 //printf("tx = %d ty = %d ", tx,ty); | |
241 //printf("pixel color => R: %d, G: %d, B: %d\n", red, green, blue); | |
242 | |
243 SDL_PixelFormat *pf = NULL; | |
244 //pf = viewer->screen->format; | |
245 | |
246 //cout << SDL_MapRGB(pf, red, green, blue) << endl; | |
247 return SDL_MapRGB(pf, red, green, blue); | |
248 } |