comparison Renderer/Engine/task/DrawSpan.cc @ 619:0decff4e867b

RenewTask removal
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 15 Nov 2009 02:02:30 +0900
parents f21603a335aa
children 5b178db5988a
comparison
equal deleted inserted replaced
618:360032cc500e 619:0decff4e867b
9 #include "global_alloc.h" 9 #include "global_alloc.h"
10 #include "SchedTask.h" 10 #include "SchedTask.h"
11 #include "Tapestry.h" 11 #include "Tapestry.h"
12 #include "SpanPack.h" 12 #include "SpanPack.h"
13 13
14 #define BIGENDIAN 1
14 15
15 SchedDefineTask(DrawSpan); 16 SchedDefineTask(DrawSpan);
16 17
17 #define TEX_LOAD1 0 18 #define TEX_LOAD1 0
18 #define TEX_LOAD2 1 19 #define TEX_LOAD2 1
172 float normal_x, float normal_y, float normal_z, TilePtr tile) 173 float normal_x, float normal_y, float normal_z, TilePtr tile)
173 { 174 {
174 175
175 int color = get_rgb(tex_x, tex_y, tile); 176 int color = get_rgb(tex_x, tex_y, tile);
176 /*下位4bitを抽出*/ 177 /*下位4bitを抽出*/
178 #if BIGENDIAN
177 int alpha = color & 0x000000ff; 179 int alpha = color & 0x000000ff;
180 #else
181 int alpha = color & 0xff000000;
182 #endif
178 /*完全に透けているか判断*/ 183 /*完全に透けているか判断*/
179 int flag = (alpha != 0); 184 int flag = (alpha != 0);
180 185
181 color = infinity_light_calc(color,normal_x,normal_y,normal_z); 186 color = infinity_light_calc(color,normal_x,normal_y,normal_z);
182 187
359 // 光のベクトル,きめうちしちゃった。どうにかする 364 // 光のベクトル,きめうちしちゃった。どうにかする
360 float light_vector[4] = {0,0,-1,0}; 365 float light_vector[4] = {0,0,-1,0};
361 float inner_product; 366 float inner_product;
362 367
363 // 引数で受け取った color の rgb 情報の抜き出し 368 // 引数で受け取った color の rgb 情報の抜き出し
369 #if BIGENDIAN
364 rgb[0] = (color & 0xff000000) >> 24; 370 rgb[0] = (color & 0xff000000) >> 24;
365 rgb[1] = (color & 0x00ff0000) >> 16; 371 rgb[1] = (color & 0x00ff0000) >> 16;
366 rgb[2] = (color & 0x0000ff00) >> 8; 372 rgb[2] = (color & 0x0000ff00) >> 8;
367 rgb[3] = (color & 0x000000ff); 373 rgb[3] = (color & 0x000000ff);
374 #else
375 rgb[3] = (color & 0xff000000) >> 24;
376 rgb[2] = (color & 0x00ff0000) >> 16;
377 rgb[1] = (color & 0x0000ff00) >> 8;
378 rgb[0] = (color & 0x000000ff);
379 #endif
368 380
369 // 法線ベクトルと光源ベクトルとの内積をとる 381 // 法線ベクトルと光源ベクトルとの内積をとる
370 inner_product = innerProduct(normal_vector,light_vector); 382 inner_product = innerProduct(normal_vector,light_vector);
371 // 内積がマイナスの場合は色がない。 383 // 内積がマイナスの場合は色がない。
372 flag = (inner_product > 0); 384 flag = (inner_product > 0);
375 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag); 387 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag);
376 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag); 388 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag);
377 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); 389 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag);
378 390
379 //計算した rgb を light_rgb にまとめる。 391 //計算した rgb を light_rgb にまとめる。
392 #if BIGENDIAN
380 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); 393 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]);
394 #else
395 light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]);
396 #endif
381 397
382 return light_rgb; 398 return light_rgb;
383 } 399 }
384 400
385 401
399 int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = { 415 int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = {
400 &drawDot1, &drawLine1 416 &drawDot1, &drawLine1
401 }; 417 };
402 418
403 // uint32 display = smanager->get_param(0); 419 // uint32 display = smanager->get_param(0);
404 int screen_width = smanager->get_param(1); 420 // int screen_width = smanager->get_param(1);
405 int rangex_start = smanager->get_param(2); 421 int rangex_start = smanager->get_param(2);
406 int rangex_end = smanager->get_param(3); 422 int rangex_end = smanager->get_param(3);
407 423
408 // このタスクが担当する x の範囲 424 // このタスクが担当する x の範囲
409 int rangex = rangex_end - rangex_start + 1; 425 int rangex = rangex_end - rangex_start + 1;