comparison TaskManager/Test/test_render/spe/DrawSpan.cpp @ 166:e297ecaf2b4d

fix
author gongo@localhost.localdomain
date Tue, 09 Dec 2008 11:53:51 +0900
parents 246881f0634b
children c8b868871dce
comparison
equal deleted inserted replaced
165:246881f0634b 166:e297ecaf2b4d
6 #include "texture.h" 6 #include "texture.h"
7 #include "viewer_types.h" 7 #include "viewer_types.h"
8 8
9 #define SPAN_PACK_LOAD 0 9 #define SPAN_PACK_LOAD 0
10 #define TEX_LOAD 1 10 #define TEX_LOAD 1
11 #define TILE_INFO_LOAD 2
12 11
13 SchedDefineTask(DrawSpan); 12 SchedDefineTask(DrawSpan);
14 13
15 static const int hashsize = 263; 14 static const int hashsize = 263;
16 15
155 return zRow; 154 return zRow;
156 } 155 }
157 156
158 157
159 char* 158 char*
160 DrawSpan::get_pixel(int tx, int ty, void *texture_image) 159 DrawSpan::get_pixel(int tx, int ty, uint32 *texture_image)
161 { 160 {
162 return (char*)texture_image+(4*((TEXTURE_SPLIT_PIXEL)*ty+tx)); 161 return (char*)(texture_image+((TEXTURE_SPLIT_PIXEL)*ty+tx));
163 } 162 }
164 163
165 Uint32 164 Uint32
166 DrawSpan::get_rgb(int tx, int ty, void *addr) 165 DrawSpan::get_rgb(int tx, int ty, uint32 *addr)
167 { 166 {
168 Uint8 red, green, blue, alpha; 167 Uint8 red, green, blue, alpha;
169 TilePtr tile; 168 TilePtr tile;
170 169
171 /** 170 /**
263 float tex1 = span->tex_x1; 262 float tex1 = span->tex_x1;
264 float tex2 = span->tex_x2; 263 float tex2 = span->tex_x2;
265 float tey1 = span->tex_y1; 264 float tey1 = span->tex_y1;
266 float tey2 = span->tex_y2; 265 float tey2 = span->tex_y2;
267 266
267 /**
268 * Span が持つ 1 pixel 毎の
269 * テクスチャの座標
270 */
268 int tex_xpos; 271 int tex_xpos;
269 int tex_ypos; 272 int tex_ypos;
270 int tex_zpos; 273
271 274 /**
275 * (tex_xpos, tex_ypos) の、ブロック内(上の図参照)での座標と
276 * そのブロックのアドレス(MainMemory)
277 */
272 int tex_localx; 278 int tex_localx;
273 int tex_localy; 279 int tex_localy;
274 uint32 *tex_addr; 280 uint32 *tex_addr;
275 281
276 int x = span->x; 282 int x = span->x;
288 continue; 294 continue;
289 } 295 }
290 296
291 tex_xpos = (int)((span->tex_width-1) * tex1); 297 tex_xpos = (int)((span->tex_width-1) * tex1);
292 tex_ypos = (int)((span->tex_height-1) * tey1); 298 tex_ypos = (int)((span->tex_height-1) * tey1);
293 tex_zpos = (int)z;
294 299
295 if (zpos < zRow[localx + (rangex * localy)]) { 300 if (zpos < zRow[localx + (rangex * localy)]) {
301 tex_addr = getTile(tex_xpos, tex_ypos,
302 span->tex_width, span->tex_addr);
296 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; 303 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
297 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; 304 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
298 tex_addr = getTile(tex_xpos, tex_ypos, 305
299 span->tex_width, span->tex_addr);
300
301 rgb = get_rgb(tex_localx, tex_localy, tex_addr); 306 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
302 307
303 zRow[localx + (rangex * localy)] = zpos; 308 zRow[localx + (rangex * localy)] = zpos;
304 linebuf[localy][localx] = rgb; 309 linebuf[localy][localx] = rgb;
305 } 310 }
324 if (tex_y < 0) tex_y = 0; 329 if (tex_y < 0) tex_y = 0;
325 tex_xpos = (int)((span->tex_width-1) * tex_x); 330 tex_xpos = (int)((span->tex_width-1) * tex_x);
326 tex_ypos = (int)((span->tex_height-1) * tex_y); 331 tex_ypos = (int)((span->tex_height-1) * tex_y);
327 332
328 if (tex_z < zRow[localx + (rangex*localy)]) { 333 if (tex_z < zRow[localx + (rangex*localy)]) {
334 tex_addr = getTile(tex_xpos, tex_ypos,
335 span->tex_width, span->tex_addr);
329 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; 336 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
330 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; 337 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
331 tex_addr = getTile(tex_xpos, tex_ypos,
332 span->tex_width, span->tex_addr);
333 338
334 rgb = get_rgb(tex_localx, tex_localy, tex_addr); 339 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
335 340
336 zRow[localx + (rangex*localy)] = tex_z; 341 zRow[localx + (rangex*localy)] = tex_z;
337 linebuf[localy][localx] = rgb; 342 linebuf[localy][localx] = rgb;