about summary refs log tree commit diff
path: root/src/game/client/mapres_tilemap.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 09:15:34 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 09:15:34 +0000
commit3b1871499c52a41c6fe1e017d6da858b7e70a396 (patch)
tree410cca70987d8789088e25c8a8b5b24eb46a8c06 /src/game/client/mapres_tilemap.cpp
parent1950995bb5137e084b5706275cce1d9d7398fc34 (diff)
downloadzcatch-3b1871499c52a41c6fe1e017d6da858b7e70a396.tar.gz
zcatch-3b1871499c52a41c6fe1e017d6da858b7e70a396.zip
laggometer, smaller gfx fixes
Diffstat (limited to 'src/game/client/mapres_tilemap.cpp')
-rw-r--r--src/game/client/mapres_tilemap.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp
index 52f2a9b1..6476f26d 100644
--- a/src/game/client/mapres_tilemap.cpp
+++ b/src/game/client/mapres_tilemap.cpp
@@ -3,6 +3,8 @@
 #include "mapres_image.h"
 #include "../mapres.h"
 
+#include <baselib/opengl.h>
+
 int tilemap_init()
 {
 	return 0;
@@ -17,6 +19,12 @@ void tilemap_render(float scale, int fg)
 	int start, num;
 	map_get_type(MAPRES_TILEMAP, &start, &num);
 
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+
+
 	// render tilemaps
 	int passed_main = 0;
 	for(int t = 0; t < num; t++)
@@ -34,6 +42,8 @@ void tilemap_render(float scale, int fg)
 			
 			int c = 0;
 			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++)
@@ -41,11 +51,25 @@ void tilemap_render(float scale, int fg)
 					unsigned char d = data[c*2];
 					if(d)
 					{
+						/*
 						gfx_quads_setsubset(
 							(d%16)/16.0f*s+frac,
 							(d/16)/16.0f*s+frac,
 							((d%16)/16.0f+1.0f/16.0f)*s-frac,
 							((d/16)/16.0f+1.0f/16.0f)*s-frac);
+							*/
+						int tx = d%16;
+						int ty = d/16;
+						int px0 = tx*(1024/16);
+						int py0 = ty*(1024/16);
+						int px1 = (tx+1)*(1024/16)-1;
+						int py1 = (ty+1)*(1024/16)-1;
+						gfx_quads_setsubset(
+							nudge + px0/texsize+frac,
+							nudge + py0/texsize+frac,
+							nudge + px1/texsize-frac,
+							nudge + py1/texsize-frac);
+
 						gfx_quads_drawTL(x*scale, y*scale, scale, scale);
 					}
 				}
@@ -53,4 +77,8 @@ void tilemap_render(float scale, int fg)
 			gfx_quads_end();
 		}
 	}
+	
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+	
 }