about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2007-07-22 11:46:25 +0000
committerJoel de Vahl <joel@stalverk80.se>2007-07-22 11:46:25 +0000
commit2165a728c25d804128933408cd8753c333be9ed3 (patch)
tree569fb839b90d58f1f87bc40811a150131e64b61e /src/game/client
parent14745012f3ca67ce5296496c8cf4c39c67e368a0 (diff)
downloadzcatch-2165a728c25d804128933408cd8753c333be9ed3.tar.gz
zcatch-2165a728c25d804128933408cd8753c333be9ed3.zip
Discarded work on mipmaps.
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/mapres_image.cpp82
-rw-r--r--src/game/client/mapres_tilemap.cpp1
2 files changed, 81 insertions, 2 deletions
diff --git a/src/game/client/mapres_image.cpp b/src/game/client/mapres_image.cpp
index eca7882f..ab624949 100644
--- a/src/game/client/mapres_image.cpp
+++ b/src/game/client/mapres_image.cpp
@@ -5,7 +5,84 @@
 
 static int map_textures[64] = {0};
 static int count = 0;
+/*
+static void calc_mipmaps(void *data_in, unsigned width, unsigned height, void *data_out)
+{
+	unsigned char *src = (unsigned char*)data_in;
+	unsigned char *dst = (unsigned char*)data_out;
+	unsigned mip_w = width;
+	unsigned mip_h = height;
+	unsigned prev_w;
+	unsigned prev_h;
+
+	// Highest level - no mod
+	for(unsigned x = 0; x < mip_w; x++)
+	{
+		for(unsigned y = 0; y < mip_h; y++)
+		{
+			unsigned i = (y * mip_w + x)<<2;
+			for(unsigned j = 0; j < 4; j++)
+				dst[i+j] = src[i+j];
+		}
+	}
+
+	src = dst;
+	dst += mip_w * mip_h * 4;
+	prev_w = mip_w;
+	prev_h = mip_h;
+	mip_w = mip_w>>1;
+	mip_h = mip_h>>1;
+
+	while(mip_w > 0 && mip_h > 0)
+	{
+		for(unsigned x = 0; x < mip_w; x++)
+		{
+			for(unsigned y = 0; y < mip_h; y++)
+			{
+				unsigned i = (y * mip_w + x)<<2;
+
+				unsigned r = 0;
+				unsigned g = 0;
+				unsigned b = 0;
+				unsigned a = 0;
 
+
+				r += src[(((y<<1) * prev_w + (x<<1))<<2)];
+				g += src[(((y<<1) * prev_w + (x<<1))<<2)+1];
+				b += src[(((y<<1) * prev_w + (x<<1))<<2)+2];
+				a += src[(((y<<1) * prev_w + (x<<1))<<2)+3];
+
+				r += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)];
+				g += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+1];
+				b += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+2];
+				a += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+3];
+
+				r += src[((((y+1)<<1) * prev_w + (x<<1))<<2)];
+				g += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+1];
+				b += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+2];
+				a += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+3];
+
+				r += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)];
+				g += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+1];
+				b += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+2];
+				a += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+3];
+
+				dst[i]   = r>>2;
+				dst[i+1] = g>>2;
+				dst[i+2] = b>>2;
+				dst[i+3] = a>>2;
+			}
+		}
+
+		src = dst;
+		dst = dst + mip_w*mip_h*4;
+		prev_w = mip_w;
+		prev_h = mip_h;
+		mip_w = mip_w>>1;
+		mip_h = mip_h>>1;
+	}
+}
+*/
 extern int DEBUGTEST_MAPIMAGE;
 
 int img_init()
@@ -22,13 +99,16 @@ int img_init()
 		}
 	}
 
+	//void *data_res = (void*)mem_alloc(1024*1024*4*2, 16);
 	for(int i = 0; i < count; i++)
 	{
 		mapres_image *img = (mapres_image *)map_get_item(start+i, 0, 0);
 		void *data = map_get_data(img->image_data);
+		//calc_mipmaps(data, img->width, img->height, data_res);
 		map_textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data);
 	}
-	
+
+	//mem_free(data_res);
 	return count;
 }
 
diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp
index 6476f26d..dfc7a7f8 100644
--- a/src/game/client/mapres_tilemap.cpp
+++ b/src/game/client/mapres_tilemap.cpp
@@ -44,7 +44,6 @@ void tilemap_render(float scale, int fg)
 			float frac = (1.0f/1024.0f);//2.0f; //2.0f;
 			float texsize = 1024.0f;
 			float nudge = 0.5f/texsize;
-			const float s = 1.0f;
 			for(int y = 0; y < tmap->height; y++)
 				for(int x = 0; x < tmap->width; x++, c++)
 				{