diff Renderer/Engine/SceneGraph.cc @ 1047:f87218eed9fc draft

broken texure ( h/w != 2^n ) protection
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 08 Dec 2010 05:38:45 +0900
parents a9581a9df440
children 91500a6c4def
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Wed Dec 08 02:41:36 2010 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Wed Dec 08 05:38:45 2010 +0900
@@ -483,6 +483,8 @@
                 int tex_w = texture_image->w;
                 int tex_h = texture_image->h;
                 int all_pixel_num = 0;
+		int nw = tex_w;
+		int nh = tex_h;
 
                 /**
                  * テクスチャの w or h が 8 pixel で分割できる間、
@@ -495,6 +497,9 @@
                  *  (128, 64) => 64,32 : 32,16: 16,8
                  *     scale = 8
                  */
+		//if (tex_w!=power_of_two(tex_w)) nw = tex_w = power_of_two(tex_w)/2;
+		//if (tex_h!=power_of_two(tex_h)) nh = tex_h = power_of_two(tex_h)/2;
+
                 while (tex_w % TEXTURE_SPLIT_PIXEL == 0 &&
                        tex_h % TEXTURE_SPLIT_PIXEL == 0) {
                     all_pixel_num += tex_w*tex_h;
@@ -504,13 +509,14 @@
                 }
 
                 scale >>= 1;
+		// scale==0 means broken texture
 
                 tapestry = makeTapestry(manager, texture_image->w, texture_image->h,
                                         (uint32*)texture_image->pixels,
                                         all_pixel_num, scale);
 
-                list[id].t_w = texture_image->w;
-                list[id].t_h = texture_image->h;
+                list[id].t_w = nw;
+                list[id].t_h = nh;
                 list[id].pixels_orig = (Uint32*)texture_image->pixels;
                 list[id].pixels = tapestry;
                 list[id].scale_max = scale;