Index: src/display3d.c
===================================================================
--- src/display3d.c	(revision 2973)
+++ src/display3d.c	(arbetskopia)
@@ -939,8 +939,8 @@
 	const unsigned short tile = TileNumber_tile(tileNumber);
 
 	/* Used to calculate texture coordinates, which are 0-255 in value */
-	const unsigned int xMult = (256 / (PAGE_WIDTH / TILE_WIDTH));
-	const unsigned int yMult = (256 / (PAGE_HEIGHT / TILE_HEIGHT));
+	const unsigned int xMult = 256 / TILES_IN_PAGE_COLUMN;
+	const unsigned int yMult = 256 / TILES_IN_PAGE_ROW;
 
 	/*
 	 * Points for flipping the texture around if the tile is flipped or rotated
Index: src/texture.c
===================================================================
--- src/texture.c	(revision 2973)
+++ src/texture.c	(arbetskopia)
@@ -49,6 +49,7 @@
 
 static int firstPage; // the last used page before we start adding terrain textures
 int terrainPage; // texture ID of the terrain page
+static int mipmap_max = MIPMAP_MAX, mipmap_levels = MIPMAP_LEVELS;
 
 // Generate a new texture page both in the texture page table, and on the graphics card
 static int newPage(const char *name, int level, int width, int height, int count)
@@ -71,8 +72,11 @@
 	strlcpy(_TEX_PAGE[texPage].name, name, sizeof(_TEX_PAGE[texPage].name));
 
 	pie_SetTexturePage(texPage);
+
+	// Specify first and last mipmap level to be used
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MIPMAP_LEVELS - 1);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmap_levels - 1);
+
 	// debug(LOG_TEXTURE, "newPage: glTexImage2D(page=%d, level=%d) opengl id=%u", texPage, level, _TEX_PAGE[texPage].id);
 	glTexImage2D(GL_TEXTURE_2D, level, wz_texture_compression, width, height, 0,
 	             GL_RGBA, GL_UNSIGNED_BYTE, NULL);
@@ -99,12 +103,30 @@
 	char fullPath[PATH_MAX], partialPath[PATH_MAX], *buffer;
 	unsigned int i, j, k, size;
 	int texPage;
+	GLint glval;
 
 	firstPage = _TEX_INDEX;
 
 	ASSERT(_TEX_INDEX < iV_TEX_MAX, "Too many texture pages used");
 	ASSERT(MIPMAP_MAX == TILE_WIDTH && MIPMAP_MAX == TILE_HEIGHT, "Bad tile sizes");
 
+	//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glval);
+	glval = 1024;
+	debug( LOG_TEXTURE, "Maximum texture size: %dx%d", (int)glval, (int)glval );
+	while (glval < mipmap_max * TILES_IN_PAGE_COLUMN)
+	{
+		mipmap_max /= 2;
+		mipmap_levels--;
+		debug(LOG_ERROR, "Max supported texture size %dx%d is too low - reducing texture detail to %dx%d.",
+		      (int)glval, (int)glval, mipmap_max, mipmap_max);
+		ASSERT(mipmap_levels > 0, "Supported texture size %d is too low to load any mipmap levels!",
+		       (int)glval);
+		if (mipmap_levels == 0)
+		{
+			exit(1);
+		}
+	}
+
 	/* Get and set radar colours */
 
 	sprintf(fullPath, "%s.radar", fileName);
@@ -132,8 +154,8 @@
 
 	/* Now load the actual tiles */
 
-	i = MIPMAP_MAX; // i is used to keep track of the tile dimensions
-	for (j = 0; j < MIPMAP_LEVELS; j++)
+	i = mipmap_max; // i is used to keep track of the tile dimensions
+	for (j = 0; j < mipmap_levels; j++)
 	{
 		int xOffset = 0, yOffset = 0; // offsets into the texture atlas
 		int xSize = 1;
@@ -171,7 +193,7 @@
 			glTexSubImage2D(GL_TEXTURE_2D, j, xOffset, yOffset, tile.width, tile.height,
 			                GL_RGBA, GL_UNSIGNED_BYTE, tile.bmp);
 			free(tile.bmp);
-			if (i == TILE_WIDTH) // dealing with main texture page; so register coordinates
+			if (i == mipmap_max) // dealing with main texture page; so register coordinates
 			{
 				// 256 is an integer hack for GLfloat texture coordinates
 				tileTexInfo[k].uOffset = xOffset / (xSize / 256);
Index: src/texture.h
===================================================================
--- src/texture.h	(revision 2973)
+++ src/texture.h	(arbetskopia)
@@ -31,13 +31,13 @@
 	unsigned int texPage; // Which textpage is the tile in? TileNumber/16 basically;
 } TILE_TEX_INFO;
 
-#define PAGE_WIDTH              2048
-#define PAGE_HEIGHT             2048
-#define TILES_IN_PAGE_COLUMN (PAGE_WIDTH / TILE_WIDTH)
-#define TILES_IN_PAGE_ROW (PAGE_HEIGHT / TILE_HEIGHT)
-#define TILES_IN_PAGE (TILES_IN_PAGE_COLUMN * TILES_IN_PAGE_ROW)
+// these constants are adapted for fitting 256 textures of size 128x128 into a 2048x2048
+// texture page; if such large texture pages are not available, just scaled everything down
+#define TILES_IN_PAGE_COLUMN	16
+#define TILES_IN_PAGE_ROW	16
+#define TILES_IN_PAGE		(TILES_IN_PAGE_COLUMN * TILES_IN_PAGE_ROW)
+#define MAX_TILES		TILES_IN_PAGE
 
-#define MAX_TILES TILES_IN_PAGE
 extern TILE_TEX_INFO	tileTexInfo[MAX_TILES];
 extern int terrainPage;
 
Index: lib/ivis_opengl/screen.c
===================================================================
--- lib/ivis_opengl/screen.c	(revision 2973)
+++ lib/ivis_opengl/screen.c	(arbetskopia)
@@ -63,7 +63,6 @@
 {
 	static int video_flags = 0;
 	int bpp = 0, value;
-	GLint glval;
 
 	/* Store the screen information */
 	screenWidth = width;
@@ -148,14 +147,6 @@
 	{
 		debug( LOG_ERROR, "OpenGL initialization did not give double buffering!" );
 	}
-	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glval);
-	debug( LOG_TEXTURE, "Maximum texture size: %dx%d", (int)glval, (int)glval );
-	if (glval < 2048) // PAGE_WIDTH and PAGE_HEIGHT from src/texture.h
-	{
-		debug( LOG_ERROR, "OpenGL reports a texture size (%d) that is less than required!", (int)glval );
-		debug( LOG_ERROR, "This is either a bug in OpenGL or your graphics card is really old!" );
-		debug( LOG_ERROR, "Trying to run the game anyway..." );
-	}
 	debug(LOG_3D, "OpenGL extensions supported:");
 	if (check_extension("GL_ARB_texture_compression"))
 	{

