Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/SceneGraph.cpp @ 174:559b48b69b76
getScale()、getTapestry から、span->length に適切なテクスチャの選択に成功
author | gongo@localhost.localdomain |
---|---|
date | Fri, 12 Dec 2008 12:23:20 +0900 |
parents | 56be4a6e5513 |
children | 5d1b82945b0d |
comparison
equal
deleted
inserted
replaced
173:56be4a6e5513 | 174:559b48b69b76 |
---|---|
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; | 326 uint32 *tex_dest; |
327 int scale = 1; | |
327 | 328 |
328 { | 329 { |
329 int t = 0; | 330 int t = 0; |
330 int tex_w = texture_image->w; | 331 int tex_w = texture_image->w; |
331 int tex_h = texture_image->h; | 332 int tex_h = texture_image->h; |
332 Uint32 *tex_src = (Uint32*)texture_image->pixels; | 333 Uint32 *tex_src = (Uint32*)texture_image->pixels; |
333 int scale = 1; | |
334 int scale_cnt; | 334 int scale_cnt; |
335 int cur_w = tex_w; | 335 int cur_w = tex_w; |
336 int cur_h = tex_h; | 336 int cur_h = tex_h; |
337 int all_pixel_num = 0; | 337 int all_pixel_num = 0; |
338 | 338 |
347 * (128, 64) => 64,32 : 32,16: 16,8 | 347 * (128, 64) => 64,32 : 32,16: 16,8 |
348 * scale = 8 | 348 * scale = 8 |
349 */ | 349 */ |
350 while (cur_w % TEXTURE_SPLIT_PIXEL == 0 && | 350 while (cur_w % TEXTURE_SPLIT_PIXEL == 0 && |
351 cur_h % TEXTURE_SPLIT_PIXEL == 0) { | 351 cur_h % TEXTURE_SPLIT_PIXEL == 0) { |
352 printf("(%3d, %3d) = %4d\n", cur_w, cur_h, cur_w*cur_h); | |
353 all_pixel_num += cur_w*cur_h; | 352 all_pixel_num += cur_w*cur_h; |
354 cur_w >>= 1; | 353 cur_w >>= 1; /* cur_w /= 2 */ |
355 cur_h >>= 1; | 354 cur_h >>= 1; |
356 scale <<= 1; | 355 scale <<= 1; /* scale *= 2 */ |
357 } | 356 } |
358 | 357 |
359 scale >>= 1; | 358 scale >>= 1; |
360 scale_cnt = scale; | 359 scale_cnt = scale; |
361 tex_dest | 360 tex_dest |
362 = (uint32*)manager->malloc(sizeof(int)*all_pixel_num); | 361 = (uint32*)manager->malloc(sizeof(int)*all_pixel_num); |
363 | |
364 printf("scale = %d, all = %d\n", scale, all_pixel_num); | |
365 | 362 |
366 int diff = TEXTURE_SPLIT_PIXEL; | 363 int diff = TEXTURE_SPLIT_PIXEL; |
367 int p_diff = 1; | 364 int p_diff = 1; |
368 while (scale_cnt) { | 365 while (scale_cnt) { |
369 for (int y = 0; y < tex_h; y += diff) { | 366 for (int y = 0; y < tex_h; y += diff) { |
374 = tex_src[(x+i) + tex_w*(y+j)]; | 371 = tex_src[(x+i) + tex_w*(y+j)]; |
375 } | 372 } |
376 } | 373 } |
377 } | 374 } |
378 } | 375 } |
379 | 376 |
380 diff <<= 1; | 377 diff <<= 1; |
381 p_diff <<= 1; | 378 p_diff <<= 1; |
382 scale_cnt >>= 1; | 379 scale_cnt >>= 1; |
383 } | 380 } |
384 } | 381 } |
385 | 382 |
386 list[id_count-1].t_w = texture_image->w; | 383 list[id_count-1].t_w = texture_image->w; |
387 list[id_count-1].t_h = texture_image->h; | 384 list[id_count-1].t_h = texture_image->h; |
388 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels; | 385 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels; |
389 list[id_count-1].pixels = tex_dest; | 386 list[id_count-1].pixels = tex_dest; |
387 list[id_count-1].scale_max = scale; | |
390 | 388 |
391 texture_id = id_count-1; | 389 texture_id = id_count-1; |
392 texture_info.t_w = texture_image->w; | 390 texture_info.t_w = texture_image->w; |
393 texture_info.t_h = texture_image->h; | 391 texture_info.t_h = texture_image->h; |
394 texture_info.pixels_orig = (Uint32*)texture_image->pixels; | 392 texture_info.pixels_orig = (Uint32*)texture_image->pixels; |
395 texture_info.pixels = tex_dest; | 393 texture_info.pixels = tex_dest; |
396 | 394 texture_info.scale_max = scale; |
397 if(unlink(image_name)) | 395 |
396 if (unlink(image_name)) | |
398 { | 397 { |
399 cout << "unlink error\n"; | 398 cout << "unlink error\n"; |
400 } | 399 } |
401 | 400 |
402 } else { | 401 } else { |
409 // 微妙に思う、自分で書き換えた感想 by gongo | 408 // 微妙に思う、自分で書き換えた感想 by gongo |
410 texture_info.t_w = list[tex_id].t_w; | 409 texture_info.t_w = list[tex_id].t_w; |
411 texture_info.t_h = list[tex_id].t_h;; | 410 texture_info.t_h = list[tex_id].t_h;; |
412 texture_info.pixels_orig = list[tex_id].pixels_orig; | 411 texture_info.pixels_orig = list[tex_id].pixels_orig; |
413 texture_info.pixels = list[tex_id].pixels; | 412 texture_info.pixels = list[tex_id].pixels; |
413 texture_info.scale_max = list[tex_id].scale_max; | |
414 } | 414 } |
415 } | 415 } |
416 } | 416 } |
417 } | 417 } |
418 | 418 |