Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/task/DrawSpan.cpp @ 161:1f4c3f3238e6 fullHD_omedetou
texture の座標がマイナスになったあと、それを 0 にし忘れてた
author | gongo@localhost.localdomain |
---|---|
date | Mon, 08 Dec 2008 16:37:02 +0900 |
parents | cd5ad7adc5e1 |
children | 38cbb7aecc70 |
comparison
equal
deleted
inserted
replaced
160:d5cca23ed50c | 161:1f4c3f3238e6 |
---|---|
12 | 12 |
13 SchedDefineTask(DrawSpan); | 13 SchedDefineTask(DrawSpan); |
14 | 14 |
15 static const int hashsize = 263; | 15 static const int hashsize = 263; |
16 | 16 |
17 static TilePtr hash_table[hashsize] = {NULL}; | 17 static TilePtr hash_table[hashsize] = {0}; |
18 | 18 |
19 unsigned short PRIME[8] = { | 19 unsigned short PRIME[8] = { |
20 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd, | 20 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd, |
21 }; | 21 }; |
22 | 22 |
121 | 121 |
122 tile = &tileList->tile[tileList->size]; | 122 tile = &tileList->tile[tileList->size]; |
123 tile->texture_addr = addr; | 123 tile->texture_addr = addr; |
124 | 124 |
125 smanager->dma_load(tile->pixel, (uint32)addr, | 125 smanager->dma_load(tile->pixel, (uint32)addr, |
126 sizeof(uint32)*64, TEX_LOAD); | 126 sizeof(uint32)*TEXTURE_BLOCK_SIZE, TEX_LOAD); |
127 | 127 |
128 int index = put(tile->texture_addr, tile); | 128 int index = put(tile->texture_addr, tile); |
129 | 129 |
130 /** | 130 /** |
131 * TODO: | 131 * TODO: |
165 | 165 |
166 TileInfoListPtr tilist = | 166 TileInfoListPtr tilist = |
167 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | 167 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); |
168 TileInfoListPtr next_tilist = | 168 TileInfoListPtr next_tilist = |
169 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | 169 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); |
170 TileInfoPtr tinfo; | |
171 | |
172 | 170 |
173 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); | 171 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); |
174 tileList->init(); | 172 tileList->init(); |
175 | 173 |
176 int render_y = sp->info.y_top; | 174 void *texture_image = global_get(TEXTURE_ID); |
177 void *texture_image = global_get(TEXTURE_ID); | |
178 | |
179 int rangex_start = get_param(0); // Υô x ϰϤλ | 175 int rangex_start = get_param(0); // Υô x ϰϤλ |
180 int rangex_end = get_param(1); // (start <= x <= end) | 176 int rangex_end = get_param(1); // (start <= x <= end) |
181 int rangey = get_param(2); // y ϰ (render_y + rangey - 1) | 177 int rangey = get_param(2); // y ϰ (render_y + rangey - 1) |
182 int rangex = rangex_end - rangex_start + 1; | 178 int rangex = rangex_end - rangex_start + 1; |
183 | 179 |
210 | 206 |
211 smanager->dma_load(tilist, (uint32)span->tilelist, | 207 smanager->dma_load(tilist, (uint32)span->tilelist, |
212 sizeof(TileInfoList), TILE_INFO_LOAD); | 208 sizeof(TileInfoList), TILE_INFO_LOAD); |
213 | 209 |
214 Uint32 rgb = 0x00ff00; | 210 Uint32 rgb = 0x00ff00; |
215 float tex1 = span->tex_x1; | |
216 float tex2 = span->tex_x2; | |
217 float tey1 = span->tex_y1; | |
218 float tey2 = span->tex_y2; | |
219 int tex_xpos; | 211 int tex_xpos; |
220 int tex_ypos; | 212 int tex_ypos; |
221 int tex_zpos; | 213 int tex_zpos; |
222 int x = span->x; | 214 int x = span->x; |
223 int y = span->y; | 215 int y = span->y; |
234 if (x_len == 1) { | 226 if (x_len == 1) { |
235 if (x < rangex_start || rangex_end < x) { | 227 if (x < rangex_start || rangex_end < x) { |
236 continue; | 228 continue; |
237 } | 229 } |
238 | 230 |
239 #if 1 | |
240 tex_xpos = tilist->tileinfo[0].tix; | 231 tex_xpos = tilist->tileinfo[0].tix; |
241 tex_ypos = tilist->tileinfo[0].tiy; | 232 tex_ypos = tilist->tileinfo[0].tiy; |
233 tex_zpos = (int)z; | |
242 texture_image = tilist->tileinfo[0].tile; | 234 texture_image = tilist->tileinfo[0].tile; |
243 #else | |
244 tex_xpos = (int)((span->tex_width-1) * tex1); | |
245 tex_ypos = (int)((span->tex_height-1) * tey1); | |
246 tex_zpos = (int)z; | |
247 #endif | |
248 | 235 |
249 if (zpos < zRow[localx + (rangex * localy)]) { | 236 if (zpos < zRow[localx + (rangex * localy)]) { |
250 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); | 237 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
251 zRow[localx + (rangex * localy)] = zpos; | 238 zRow[localx + (rangex * localy)] = zpos; |
252 linebuf[localy][localx] = rgb; | 239 linebuf[localy][localx] = rgb; |
299 len = cur_x_diff - 1; | 286 len = cur_x_diff - 1; |
300 } else { | 287 } else { |
301 len = max_x - cur_x; | 288 len = max_x - cur_x; |
302 } | 289 } |
303 | 290 |
304 float tex_x, tex_y, tex_z; | |
305 | |
306 for (int j = cur_x; j <= cur_x + len; j++) { | 291 for (int j = cur_x; j <= cur_x + len; j++) { |
307 TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; | 292 TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; |
293 float tex_z | |
294 = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); | |
295 | |
308 localx = getLocalX(x-1+j); | 296 localx = getLocalX(x-1+j); |
309 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); | 297 |
310 | |
311 #if 1 | |
312 tex_xpos = tinfo->tix; | 298 tex_xpos = tinfo->tix; |
313 tex_ypos = tinfo->tiy; | 299 tex_ypos = tinfo->tiy; |
314 texture_image = tinfo->tile; | 300 texture_image = tinfo->tile; |
315 #else | |
316 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); | |
317 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); | |
318 if (tex_x > 1) tex_x = 1; | |
319 if (tex_y > 1) tex_y = 1; | |
320 tex_xpos = (int)((span->tex_width-1) * tex_x); | |
321 tex_ypos = (int)((span->tex_height-1) * tex_y); | |
322 #endif | |
323 | 301 |
324 if (tex_z < zRow[localx + (rangex*localy)]) { | 302 if (tex_z < zRow[localx + (rangex*localy)]) { |
325 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); | 303 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
326 zRow[localx + (rangex*localy)] = tex_z; | 304 zRow[localx + (rangex*localy)] = tex_z; |
327 linebuf[localy][localx] = rgb; | 305 linebuf[localy][localx] = rgb; |