Index: Myth2Code/hardware/OpenGL/render_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/render_opengl.c	(revision 3667)
+++ Myth2Code/hardware/OpenGL/render_opengl.c	(working copy)
@@ -1100,13 +1100,16 @@
 		initialize_shader_programs_opengl2(FALSE);
 	}
 
-	initialize_preallocated_textures_opengl();
+#if defined(windows) && !defined( __RENDER_32_BIT__)	// Build 243 - PAB - We don't support 565 so I'm just gonna force 555
+	active_screen.encoding= _16bit_555_encoding;
+#endif
+
 	initialize_texture_cache_for_new_map_opengl();
 	initialize_volatile_cmap_texture_opengl();
 
 	{
 		struct bitmap_data *bitmap = initialize_hardware_font(get_interface_font_index(_screen_font_high_resolution_tag));
-		update_preallocated_texture_opengl(_preallocated_font_texture, 0, 0, bitmap->row_addresses[0], bitmap->bytes_per_row);
+        initialize_font_texture_opengl(bitmap);
 	}
 
 	rasterizer_initialized= TRUE;
@@ -1159,10 +1162,10 @@
 	if (rasterizer_initialized)
 	{
 		dispose_hardware_font();
+        dispose_font_texture_opengl();
 		dispose_texture_cache_from_old_map_opengl();
 		dispose_volatile_cmap_shading_table_opengl();
 		dispose_volatile_cmap_texture_opengl();
-		dispose_preallocated_textures_opengl();
 		dispose_cached_bitmaps_opengl();
 		dispose_shader_programs_opengl2();
 
@@ -2672,12 +2675,12 @@
 
 		if (bitmap)
 		{
-			update_preallocated_texture_opengl(_preallocated_font_texture, 0, 0, bitmap->row_addresses[0], bitmap->bytes_per_row);
+            update_font_texture_opengl(bitmap);
 		}
 	}
 
 	set_render_mode_opengl(_shader_basic_texture, _projection_mode_ortho, _depth_mode_none, _blend_mode_alpha);
-	source_preallocated_texture_opengl(_preallocated_font_texture, 0);
+    bind_texture_unit_opengl(0, font_texture_name_opengl);
 
 	submit_fan_opengl(4);
 }
Index: Myth2Code/hardware/OpenGL/utilities_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/utilities_opengl.c	(revision 3667)
+++ Myth2Code/hardware/OpenGL/utilities_opengl.c	(working copy)
@@ -116,24 +116,18 @@
 static TOGLImage converted_image= {0, 0, 0, NULL};
 static long actual_converted_image_pixmap_size = 0; // Build 268 - ALS
 
-static struct preallocated_tex_header preallocated_headers[NUMBER_OF_PREALLOCATED_TEXTURES]=
-{
-	{16, 64, 64, NONE},				// _preallocated_status_bar_textures,  //NOTE: these are unused now
-	{NUMBER_OF_PREALLOCATED_LANDSCAPE_TEXTURES, 64, 64, NONE},// _preallocated_color_map_textures, //NOTE: these are unused now
+/*
 #ifdef __RENDER_32_BIT__
-	{1, 256, 256, kOGLPixel_ARGB32},	// _preallocated_font_texture,
+    static TOGLImage font_tex= {1, 256, 256, kOGLPixel_ARGB32};
 #else
-	{1, 256, 256, kOGLPixel_ARGB16_4444},	// _preallocated_font_texture,
+    static TOGLImage font_tex= {1, 256, 256, kOGLPixel_ARGB16_4444};
 #endif
-	{16, 64, 32, NONE} 				// _preallocated_control_bar_textures  //NOTE: these are unused now
-};
+*/
 
 void bind_texture_unit_opengl(int texture_unit, int texture);
 
 //------------- local prototypes
 
-static struct preallocated_tex_header *get_preallocated_tex_header(int preallocated_header_index);
-
 static void delete_cache_item_opengl(SHADED_TEX_CACHE_ITEM* shaded_item);
 static SHADED_TEX_CACHE_ITEM* new_cache_item_opengl( BITMAP_TEX_CACHE_ITEM** first_level_address,
 	unsigned long bitmap_key, unsigned long shading_table_key, TOGLImagePixelType pixel_type);
@@ -613,347 +607,6 @@
 }
 
 
-/************************************************************************************/
-/* preallocated texture code								*/
-/************************************************************************************/
-
-// Build 344 - ALS - separated this into a function
-static boolean initialize_preallocated_texture_header(
-	struct preallocated_tex_header *header)
-{
-	int bitmap_index;
-	short bytes_per_pixel;
-
-	if (header->common.format==NONE)
-	{
-#ifdef __RENDER_32_BIT__
-		header->common.format= kOGLPixel_RGB32;
-#else
-		switch (active_screen.encoding)
-		{
-			case _16bit_555_encoding:
-			case _16bit_565_encoding:
-				header->common.format= kOGLPixel_RGB16;
-				break;
-
-			default:
-				halt();
-				break;
-		}
-#endif
-	}
-	bytes_per_pixel= get_bytes_per_pixel_from_format(header->common.format);
-
-	header->common.textures = (struct preallocated_texture_data *)malloc(header->common.count*sizeof(struct preallocated_texture_data));
-	if (!header->common.textures)
-	{
-		error_message(_error_out_of_memory, __FILE__, __LINE__, "couldn't allocate preallocated textures");
-		return FALSE;
-	}
-
-	header->common.texture_buffer = malloc(bytes_per_pixel*header->common.width*header->common.height);
-	if (!header->common.texture_buffer)
-	{
-		error_message(_error_out_of_memory, __FILE__, __LINE__, "couldn't allocate preallocated texture buffer");
-		return FALSE;
-	}
-
-	header->common.next_free_index = 0;
-
-	header->texture_info.width= header->common.width;
-	header->texture_info.height= header->common.height;
-	header->texture_info.rowBytes= header->common.width*bytes_per_pixel;
-
-	// header->texture_info.pixmap= header->common.texture_buffer;
-	// yig: we don't allocate a temp pixmap anymore; we use header->common.texture_buffer
-	// FOLLOWUP: we can't do this because control and status bar re-use the common.texture_buffer
-	if (header->common.count == 1)
-	{
-		header->texture_info.pixmap = header->common.texture_buffer;
-	}
-	else
-	{
-		header->texture_info.pixmap= malloc(header->texture_info.height*header->texture_info.rowBytes);
-
-		if (!header->texture_info.pixmap)
-		{
-			error_message(_error_out_of_memory, __FILE__, __LINE__ , "couldn't allocate memory for temp pixmap");
-			return FALSE;
-		}
-	}
-
-	memset(header->texture_info.pixmap, 0, header->texture_info.height*header->texture_info.rowBytes);
-	for (bitmap_index = 0; bitmap_index < header->common.count; bitmap_index++)
-	{
-		TOGLError error;
-
-		header->common.textures[bitmap_index].identifier= NONE;
-
-		error = new_texture_opengl(
-			(TOGLImagePixelType)header->common.format,
-			&header->texture_info,
-			header->common.count == 1 ? GL_TRUE : GL_FALSE,
-			// GL_TRUE, // preallocated textures have a pixmap that stays valid.
-			// FOLLOWUP: this is not always true.  status bar and control bar textures require a temp buffer
-			//           to be passed into here.
-			(gl_client_texture**)&header->common.textures[bitmap_index].address);
-
-		while (error != kOGLNoErr && texture_cache && texture_cache->shaded_head)
-		{
-			delete_cache_item_opengl(NULL);
-			
-			error = new_texture_opengl(
-				(TOGLImagePixelType)header->common.format,
-				&header->texture_info,
-				header->common.count == 1 ? GL_TRUE : GL_FALSE,
-				// GL_TRUE, // preallocated textures have a pixmap that stays valid.
-				// FOLLOWUP: this is not true.  status bar and control bar textures require a temp buffer
-				//           to be passed into here.
-				(gl_client_texture**)&header->common.textures[bitmap_index].address);
-		}
-		assert(error == kOGLNoErr);
-
-		assert( header->common.textures[bitmap_index].address && GL_TRUE == glIsTexture( ((gl_client_texture*)header->common.textures[bitmap_index].address)->name ) );
-
-	}
-
-	// yig: as above, we now use header->common.texture_buffer
-	// FOLLOWUP: we can't.  see comments above.
-	if (header->common.count != 1)
-	{
-		free_and_clear(&header->texture_info.pixmap);
-	}
-
-	return TRUE;
-}
-// Build 344 - ALS - end change
-
-void initialize_preallocated_textures_opengl(
-	void)
-{
-#if defined(windows) && !defined( __RENDER_32_BIT__)	// Build 243 - PAB - We don't support 565 so I'm just gonna force 555
-	active_screen.encoding= _16bit_555_encoding;
-#endif
-
-	initialize_preallocated_texture_header(get_preallocated_tex_header(_preallocated_font_texture));
-}
-
-void dispose_preallocated_textures_opengl(
-	void)
-{
-	short header_index;
-
-	for (header_index = 0; header_index < NUMBER_OF_PREALLOCATED_TEXTURES; header_index++)
-	{
-		struct preallocated_tex_header *header = get_preallocated_tex_header(header_index);
-
-		if (header->common.texture_buffer)
-		{
-			free(header->common.texture_buffer);
-		}
-
-		if (header->common.textures)
-		{
-			int bitmap_index;
-
-			for (bitmap_index = 0; bitmap_index < header->common.count; bitmap_index++)
-			{
-				if (header->common.textures[bitmap_index].address)
-				{
-					delete_texture_opengl((gl_client_texture**) &header->common.textures[bitmap_index].address);
-					header->common.textures[bitmap_index].address= 0;
-				}
-				header->common.textures[bitmap_index].identifier= NONE;
-			}
-
-			free(header->common.textures);
-		}
-
-		header->common.next_free_index = 0;
-	}
-
-	GL_ASSERT() ;
-
-	return;
-}
-
-int update_preallocated_texture_opengl(
-	int preallocated_header_index,
-	int bitmap_index, // will choose next_free_index if NONE
-	int identifier,
-	void *source_buffer,
-	int bytes_per_row) // no slop if zero
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-	short bytes_per_pixel= get_bytes_per_pixel_from_format(header->common.format);
-	int actual_bytes_per_row= header->common.width*bytes_per_pixel;
-	TOGLError error;
-
-	if (bitmap_index == NONE)
-	{
-		bitmap_index = header->common.next_free_index++;
-
-		if (header->common.next_free_index == header->common.count)
-		{
-			header->common.next_free_index = 0;
-		}
-	}
-
-	assert(bitmap_index>=0 && bitmap_index<header->common.count);
-
-	assert(identifier!=NONE);
-	header->common.textures[bitmap_index].identifier = identifier;
-
-	assert(source_buffer);
-
-	if (bytes_per_row)
-	{
-		if (preallocated_header_index== _preallocated_font_texture)
-		{
-#ifdef __RENDER_32_BIT__
-			// Convert font data from 8-bit intensity to 8888
-			pixel32 *dest_row_base32= (pixel32 *)header->common.texture_buffer;
-			int dest_bytes_per_row32= (actual_bytes_per_row>>2);
-
-			pixel8 *source_row_base8= (pixel8 *)source_buffer;
-			int source_bytes_per_row8= bytes_per_row;
-			int x, y;
-
-			for (y= 0; y<header->common.height; ++y)
-			{
-				pixel32 *texture= dest_row_base32;
-				pixel8 *source= source_row_base8;
-
-				for (x= 0; x<header->common.width; ++x)
-				{
-					short p= (*source++);
-					*texture++ = (p<<24)|0x00ffffff;
-				}
-				dest_row_base32+= dest_bytes_per_row32;
-				source_row_base8+= source_bytes_per_row8;
-			}
-#else
-			// Convert font data from 8-bit intensity to 4444
-			pixel16 *dest_row_base16= (pixel16 *)header->common.texture_buffer;
-			int dest_bytes_per_row16= (actual_bytes_per_row>>1);
-
-			pixel8 *source_row_base8= (pixel8 *)source_buffer;
-			int source_bytes_per_row8= bytes_per_row;
-			int x, y;
-
-			for (y= 0; y<header->common.height; ++y)
-			{
-				pixel16 *texture= dest_row_base16;
-				pixel8 *source= source_row_base8;
-
-				for (x= 0; x<header->common.width; ++x)
-				{
-					short p= (*source++) >> 4;
-					*texture++ = (p<<12)|0x0fff;
-				}
-				dest_row_base16+= dest_bytes_per_row16;
-				source_row_base8+= source_bytes_per_row8;
-			}
-#endif
-		}
-		else
-		{
-			pixel8 *texture_buffer_row_base= (pixel8 *)header->common.texture_buffer;
-			pixel8 *source_buffer_row_base= (pixel8 *)source_buffer;
-			int y;
-
-			assert(header->common.texture_buffer);
-
-			for (y= 0; y<header->common.height; ++y)
-			{
-				memcpy(texture_buffer_row_base, source_buffer_row_base, actual_bytes_per_row);
-
-				texture_buffer_row_base+= actual_bytes_per_row;
-				source_buffer_row_base+= bytes_per_row;
-			}
-		}
-		source_buffer= header->common.texture_buffer;
-	}
-
-	header->texture_info.pixmap= source_buffer;
-	assert(header->texture_info.pixmap!= NULL);
-
-	assert(header->common.textures[bitmap_index].address);
-
-	error = update_texture_opengl(
-		(TOGLImagePixelType)header->common.format,
-		&header->texture_info,
-		(gl_client_texture*)header->common.textures[bitmap_index].address);
-
-	assert(error == kOGLNoErr);
-
-	return bitmap_index;
-}
-
-void source_preallocated_texture_opengl(
-	int preallocated_header_index,
-	int bitmap_index)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-
-	assert(bitmap_index>=0 && bitmap_index<header->common.count);
-
-	assert(header->common.texture_buffer);
-	header->texture_info.pixmap= header->common.texture_buffer;
-
-	assert(header->common.textures[bitmap_index].address);
-	if (header->common.textures[bitmap_index].address)
-	{
-		// QASetPtr(gDrawContext, kQATag_Texture, (TQATexture *)header->common.textures[bitmap_index].address);
-		bind_texture_opengl( (gl_client_texture*)header->common.textures[bitmap_index].address ) ;
-	}
-
-	GL_ASSERT() ;
-
-	return;
-}
-
-void flush_preallocated_textures_opengl(
-	int preallocated_header_index)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-	int bitmap_index;
-
-	for (bitmap_index = 0; bitmap_index < header->common.count; bitmap_index++)
-	{
-		header->common.textures[bitmap_index].identifier= NONE;
-	}
-	header->common.next_free_index = 0;
-
-	return;
-}
-
-void flush_some_preallocated_textures_opengl(
-	int preallocated_header_index,
-	int num_to_clear)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-	int bitmap_index;
-	
-	// clear the first num_to_clear textures, then slide the num_to_clear .. count textures down
-	for( bitmap_index = 0 ; bitmap_index < header->common.count - num_to_clear ; bitmap_index ++ )
-	{
-		// also need to swap the texture pointer
-		unsigned long temp												= header->common.textures[bitmap_index].address ;
-		header->common.textures[bitmap_index].address					= header->common.textures[bitmap_index + num_to_clear].address ;
-		header->common.textures[bitmap_index + num_to_clear].address	= temp ;
-		
-		header->common.textures[bitmap_index].identifier				= header->common.textures[bitmap_index + num_to_clear].identifier ;
-		header->common.textures[bitmap_index + num_to_clear].identifier	= NONE ;
-	}
-	
-	header->common.next_free_index = header->common.count - num_to_clear ;
-	if( header->common.next_free_index >= header->common.count )
-		header->common.next_free_index = 0 ;
-	
-	return;
-}
-
 //////////////////////////////////////////////////////////////////////////
 // Build 314 - DRB - begin new volatile maps code
 //////////////////////////////////////////////////////////////////////////
@@ -1139,6 +792,107 @@
 // end new volatile maps code
 //////////////////////////////////////////////////////////////////////////
 
+
+gl_client_texture *font_texture = NULL;
+void *font_pixmap = NULL;
+int font_texture_name_opengl;
+
+void initialize_font_texture_opengl(struct bitmap_data *bitmap)
+{
+	int bpp;
+	TOGLImagePixelType pixel_type;
+	TOGLImage image = {0};
+
+	if(gl_prefs.Use32BitTextures)
+	{
+		bpp = 4;
+		pixel_type = kOGLPixel_ARGB32;
+	}
+	else
+	{
+		bpp = 2;
+		pixel_type = kOGLPixel_ARGB16_4444;
+	}
+
+	image.width = bitmap->width;
+	image.height = bitmap->height;
+	image.rowBytes = image.width * bpp;
+	image.pixmap = malloc(image.height * image.rowBytes);
+	new_texture_opengl(pixel_type, &image, TRUE, &font_texture);
+	font_pixmap = image.pixmap;
+	font_texture_name_opengl = font_texture->name;
+}
+
+void dispose_font_texture_opengl(void)
+{
+	delete_texture_opengl(&font_texture);
+	if(font_pixmap)
+	{
+		free(font_pixmap);
+		font_pixmap = 0;
+	}
+}
+
+void update_font_texture_opengl(struct bitmap_data *bitmap)
+{
+	int width = bitmap->width;
+    int height = bitmap->height;
+
+    if (gl_prefs.Use32BitTextures)
+    {
+        // Convert font data from 8-bit intensity to 8888
+	    pixel32 *dest_row= (pixel32 *)font_texture->data.pixmap;
+	    int dest_stride= (font_texture->data.rowBytes>>2);
+
+	    pixel8 *source_row= (pixel8 *)bitmap->row_addresses[0];
+	    int source_stride= bitmap->bytes_per_row;
+	    int x, y;
+
+	    for (y= 0; y<height; ++y)
+	    {
+		    pixel32 *texture= dest_row;
+		    pixel8 *source= source_row;
+
+		    for (x= 0; x<width; ++x)
+		    {
+			    pixel32 p= source[x];
+			    texture[x] = (p<<24)|0x00ffffff;
+		    }
+		    dest_row+= dest_stride;
+		    source_row+= source_stride;
+	    }
+
+        update_texture_opengl(kOGLPixel_ARGB32, &font_texture->data, font_texture);
+    }
+    else
+    {
+	    // Convert font data from 8-bit intensity to 4444
+	    pixel16 *dest_row= (pixel16 *)font_texture->data.pixmap;
+	    int dest_stride= (font_texture->data.rowBytes>>1);
+
+	    pixel8 *source_row= (pixel8 *)bitmap->row_addresses[0];
+	    int source_stride= bitmap->bytes_per_row;
+	    int x, y;
+
+	    for (y= 0; y<height; ++y)
+	    {
+		    pixel16 *texture= dest_row;
+		    pixel8 *source= source_row;
+
+		    for (x= 0; x<width; ++x)
+		    {
+			    pixel16 p= source[x] >> 4;
+			    texture[x] = (p<<12)|0x0fff;
+		    }
+		    dest_row+= dest_stride;
+		    source_row+= source_stride;
+	    }
+
+        update_texture_opengl(kOGLPixel_ARGB16_4444, &font_texture->data, font_texture);
+    }
+}
+
+
 void clear_opengl_backbuffer(void)
 {
 	glClearColor(0, 0, 0, 0);
@@ -1686,69 +1440,7 @@
 }
 #endif
 
-void get_preallocated_texture_dimensions_opengl(
-	short preallocated_header_index,
-	short *width,
-	short *height,
-	short *count)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
 
-	if (width)
-	{
-		*width= header->common.width;
-	}
-	if (height)
-	{
-		*height= header->common.height;
-	}
-	if (count)
-	{
-		*count= header->common.count;
-	}
-
-	return;
-}
-
-int find_preallocated_texture_by_identifier_opengl(
-	int preallocated_header_index,
-	int identifier)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-	int result_index= NONE;
-	int bitmap_index;
-
-	assert(identifier!=NONE);
-
-	for (bitmap_index= 0; bitmap_index<header->common.count; ++bitmap_index)
-	{
-		if (header->common.textures[bitmap_index].identifier==identifier)
-		{
-			result_index= bitmap_index;
-
-			break;
-		}
-	}
-
-	return result_index;
-}
-
-static struct preallocated_tex_header *get_preallocated_tex_header(
-	int preallocated_header_index)
-{
-	assert(preallocated_header_index>=0 && preallocated_header_index<NUMBER_OF_PREALLOCATED_TEXTURES);
-
-	return (preallocated_headers + preallocated_header_index);
-}
-
-void *get_preallocated_texture_buffer_opengl(
-	int preallocated_header_index)
-{
-	struct preallocated_tex_header *header= get_preallocated_tex_header(preallocated_header_index);
-
-	return header->common.texture_buffer;
-}
-
 TOGLError new_texture_opengl(TOGLImagePixelType pixtype, TOGLImage *texinfo, GLboolean pixmapMythStorage, gl_client_texture **outTex)
 {
 	// errors are OutOfMemory unless raveUpdateTexture() returns otherwise
Index: Myth2Code/hardware/OpenGL/utilities_opengl.h
===================================================================
--- Myth2Code/hardware/OpenGL/utilities_opengl.h	(revision 3667)
+++ Myth2Code/hardware/OpenGL/utilities_opengl.h	(working copy)
@@ -87,13 +87,12 @@
 
 struct bitmap_data *initialize_opengl_render_bitmap(rectangle2d *bounds);
 
-void initialize_preallocated_textures_opengl(void);
-void dispose_preallocated_textures_opengl(void);
-void source_preallocated_texture_opengl(int preallocated_header_index, int bitmap_index);
-int update_preallocated_texture_opengl(int preallocated_header_index, int bitmap_index,
-	int identifier, void *buffer, int bytes_per_row);
-void flush_preallocated_textures_opengl(int preallocated_header_index);
-void flush_some_preallocated_textures_opengl(int preallocated_header_index, int num_to_clear);
+// New font texture management code
+extern int font_texture_name_opengl;
+void initialize_font_texture_opengl(struct bitmap_data *bitmap);
+void dispose_font_texture_opengl(void);
+void update_font_texture_opengl(struct bitmap_data *bitmap);
+// end new volatile maps code
 
 // Build 314 - DRB - begin new volatile maps code
 extern int volatile_cmap_texture_name_opengl;
@@ -104,10 +103,6 @@
 void update_volatile_cmap_texture_opengl(struct render_surface_list *surfaces);
 // end new volatile maps code
 
-void get_preallocated_texture_dimensions_opengl(short preallocated_header_index, short *width, short *height, short *count);
-int find_preallocated_texture_by_identifier_opengl(int preallocated_header_index, int identifier);
-void *get_preallocated_texture_buffer_opengl(int preallocated_header_index);
-
 void toggle_filtering_effects_opengl(boolean enabled);
 void bind_texture_unit_opengl(int texture_unit, int texture);
 void bind_texture_unit_for_update_opengl(int texture_unit, int texture); // use this if you intend to call glTexImage, etc.
