Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/SceneGraph.cpp @ 171:dc68bc5c9e41
Scale-SceneGraph.cpp
author | tkaito@nw0534.st.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 11 Dec 2008 16:33:39 +0900 |
parents | 1f4c3f3238e6 |
children | 56be4a6e5513 |
comparison
equal
deleted
inserted
replaced
170:d1f2ce3bdb2f | 171:dc68bc5c9e41 |
---|---|
321 if (converted != NULL) { | 321 if (converted != NULL) { |
322 SDL_FreeSurface(texture_image); | 322 SDL_FreeSurface(texture_image); |
323 texture_image = converted; | 323 texture_image = converted; |
324 } | 324 } |
325 | 325 |
326 uint32 *tex_dest = (uint32*)manager->malloc(texture_image->w*texture_image->h*4); | 326 int image_tmp = texture_image->w*texture_image->h*4; |
327 int tile_size = image_tmp + image_tmp/2 + image_tmp/4 + image_tmp/8 + image_tmp/16; | |
328 //uint32 *tex_dest = (uint32*)manager->malloc(texture_image->w*texture_image->h*4); | |
329 uint32 *tex_dest = (uint32*)manager->malloc(tile_size); | |
330 | |
327 | 331 |
328 { | 332 { |
329 int t = 0; | 333 int t = 0; |
330 int tex_width = texture_image->w; | 334 int tex_width = texture_image->w; |
331 int tex_height = texture_image->h; | 335 int tex_height = texture_image->h; |
338 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; | 342 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; |
339 } | 343 } |
340 } | 344 } |
341 } | 345 } |
342 } | 346 } |
347 | |
348 // 1 / 2 | |
349 for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*2) { | |
350 for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*2) { | |
351 for (int j = 0; j < TEXTURE_SPLIT_PIXEL*2; j+=2) { | |
352 for (int i = 0; i < TEXTURE_SPLIT_PIXEL*2; i+=2) { | |
353 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; | |
354 } | |
355 } | |
356 } | |
357 } | |
358 | |
359 // 1 / 4 | |
360 for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*4) { | |
361 for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*4) { | |
362 for (int j = 0; j < TEXTURE_SPLIT_PIXEL*4; j+=4) { | |
363 for (int i = 0; i < TEXTURE_SPLIT_PIXEL*4; i+=4) { | |
364 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; | |
365 } | |
366 } | |
367 } | |
368 } | |
369 | |
370 // 1 / 8 | |
371 for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*8) { | |
372 for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*8) { | |
373 for (int j = 0; j < TEXTURE_SPLIT_PIXEL*8; j+=8) { | |
374 for (int i = 0; i < TEXTURE_SPLIT_PIXEL*8; i+=8) { | |
375 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; | |
376 } | |
377 } | |
378 } | |
379 } | |
380 | |
381 // 1 / 16 | |
382 for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*16) { | |
383 for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*16) { | |
384 for (int j = 0; j < TEXTURE_SPLIT_PIXEL*16; j+=16) { | |
385 for (int i = 0; i < TEXTURE_SPLIT_PIXEL*16; i+=16) { | |
386 tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; | |
387 } | |
388 } | |
389 } | |
390 } | |
391 | |
343 } | 392 } |
344 | 393 |
345 list[id_count-1].t_w = texture_image->w; | 394 list[id_count-1].t_w = texture_image->w/2; |
346 list[id_count-1].t_h = texture_image->h; | 395 list[id_count-1].t_h = texture_image->h/2; |
347 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels; | 396 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels; |
348 list[id_count-1].pixels = tex_dest; | 397 list[id_count-1].pixels = tex_dest + image_tmp/4; |
349 | 398 |
350 texture_id = id_count-1; | 399 texture_id = id_count-1; |
351 texture_info.t_w = texture_image->w; | 400 texture_info.t_w = texture_image->w/2; |
352 texture_info.t_h = texture_image->h; | 401 texture_info.t_h = texture_image->h/2; |
353 texture_info.pixels_orig = (Uint32*)texture_image->pixels; | 402 texture_info.pixels_orig = (Uint32*)texture_image->pixels; |
354 texture_info.pixels = tex_dest; | 403 texture_info.pixels = tex_dest + image_tmp/4; |
355 | 404 |
356 printf("[%s] %p\n", filename, tex_dest); | 405 printf("[%s] %p\n", filename, tex_dest); |
357 | 406 |
358 if(unlink(image_name)) | 407 if(unlink(image_name)) |
359 { | 408 { |