Index: Myth2Code/hardware/OpenGL/render_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/render_opengl.c	(revision 3769)
+++ Myth2Code/hardware/OpenGL/render_opengl.c	(working copy)
@@ -50,7 +50,7 @@
 //#define CAPTURE_VIDEO
 //#define CAPTURE_FPS 30
 
-//#define USE_FLOAT
+#define USE_FLOAT
 
 #ifdef USE_FLOAT
 
@@ -2128,7 +2128,7 @@
 
 	prepare_to_render_new_frame(view, surfaces);
 
-#if 0
+#if 1
 	lod_bias_debug();
 #endif
 
@@ -2357,23 +2357,39 @@
 	{
 		GLcolor a = COLOR_ONE - ConvertColor(rectangle->transparency);
 
-		GLposition l = ConvertPosition(real_left);
-		GLposition r = ConvertPosition(real_right);
-		GLposition t = ConvertPosition(real_top);
-		GLposition b = ConvertPosition(real_bottom);
-		GLposition z = ConvertPosition(rectangle->z);
+		float u_texel = 1.0f/bitmap->hardware_width;
+		float v_texel = 1.0f/bitmap->hardware_height;
 
-		float u_scale = (TEXTURE_ONE*(float)(bitmap->width-1))/(bitmap->hardware_width*width);
-		float v_scale = (TEXTURE_ONE*(float)(bitmap->height-1))/(bitmap->hardware_height*height);
+		float u_halft = 0.5*u_texel;
+		float v_halft = 0.5*v_texel;
 
-		GLtexcoord u0t = u0*u_scale;
-		GLtexcoord u1t = u1*u_scale;
-		GLtexcoord v0t = v0*v_scale;
-		GLtexcoord v1t = v1*v_scale;
+		float x_halfp = (0.5*width)/bitmap->width;
+		float y_halfp = (0.5*height)/bitmap->height;
 
 		// if we're using premultiplied alpha, we need to premultiply the vertex color too.
 		GLcolor c = blend == _blend_mode_premultiplied_alpha ? a : COLOR_ONE;
 
+		GLposition l, r, t, b, z;
+		GLtexcoord u0t, u1t, v0t, v1t;
+		float u_scale = u_texel*bitmap->width/width;
+		float v_scale = v_texel*bitmap->height/height;
+
+		if(key_down(_key_space))
+		{
+			u_halft = v_halft = x_halfp = y_halfp = 0;
+		}
+
+		l = ConvertPosition(real_left - x_halfp);
+		r = ConvertPosition(real_right + x_halfp);
+		t = ConvertPosition(real_top - y_halfp);
+		b = ConvertPosition(real_bottom + y_halfp);
+		z = ConvertPosition(rectangle->z);
+
+		u0t = TEXTURE_ONE*(u_scale*u0 - u_halft);
+		u1t = TEXTURE_ONE*(u_scale*u1 + u_halft);
+		v0t = TEXTURE_ONE*(v_scale*v0 - v_halft);
+		v1t = TEXTURE_ONE*(v_scale*v1 + v_halft);
+
 		SetTexture(0, l, t, z, c, c, c, a, u0t, v0t);
 		SetTexture(1, l, b, z, c, c, c, a, u0t, v1t);
 		SetTexture(2, r, b, z, c, c, c, a, u1t, v1t);
Index: Myth2Code/hardware/OpenGL/utilities_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/utilities_opengl.c	(revision 3768)
+++ Myth2Code/hardware/OpenGL/utilities_opengl.c	(working copy)
@@ -1638,31 +1638,45 @@
 	if (tex->data.mipLevels <= 1 && enough_mem == tex->data.width)
 	{
 		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texinfo->width, texinfo->height, format, type, texinfo->pixmap);
+		//glTexImage2D(GL_TEXTURE_2D, 0, internalformat, texinfo->width, texinfo->height, 0, format, type, texinfo->pixmap);
 		GL_DEBUG("glTexSubImage2D");
 	}
 	// sending texture data for the first time
 	else
 	{
+		byte *pixels = (byte*)tex->data.pixmap;
+		int width = tex->data.width;
+		int height = tex->data.height;
+
+		int min_filter = tex->data.mipLevels > 1 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
 		// Texture parameters are per-texture name, so we set our initial values here.
 		// Build 359 - ALS - use GL_CLAMP_TO_EDGE to avoid visible border lines
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-		// Build 359 - ALS - end change
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 5);
+		// Build 359 - ALS - end change	
 
+		set_apple_client_storage(TRUE);	
+
+		if(min_filter != GL_LINEAR_MIPMAP_LINEAR)
 		{
-			int min_filter = tex->data.mipLevels > 1 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+			glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, type, pixels);
 		}
+		else if(min_filter == GL_LINEAR_MIPMAP_LINEAR)
+		{
+			int i, hw, hh;
 
-		set_apple_client_storage(TRUE);
+			if(tex->data.mipLevels < 1)
+				tex->data.mipLevels = 1; // TEMP HACK
 
-		{
-			int i;
-			byte *pixels = (byte*)tex->data.pixmap;
-			int width = tex->data.width;
-			int height = tex->data.height;
-			if(tex->data.mipLevels < 1) tex->data.mipLevels = 1; // TEMP HACK
+			//hh = 1; while(hh < texinfo->height) hh<<=1;
+			//hw = 1; while(hw < texinfo->width) hw<<=1;
+			//glTexImage2D(GL_TEXTURE_2D, 0, internalformat, hw, hh, 0, format, type, NULL);
+			//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, pixels);
+
 			for(i = 0; i < tex->data.mipLevels; ++i)
 			{
 #if 0 // Mipmap Coloring
@@ -1681,6 +1695,20 @@
 				width = MAX(1, width/2);
 				height = MAX(1, height/2);
 			}
+	
+			if(1)
+			{
+				typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
+				static PFNGLGENERATEMIPMAPPROC glGenerateMipmap = (void*)NONE;
+				if(glGenerateMipmap == (void*)NONE)
+				{
+					glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)wglGetProcAddress("glGenerateMipmap");
+				}
+				if(glGenerateMipmap != (void*)NONE && glGenerateMipmap != NULL)
+				{
+					glGenerateMipmap(GL_TEXTURE_2D);
+				}
+			}
 		}
 	}
 	
