Fix problems updating texture size. Also see bug #10456.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2984 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-12-06 18:26:16 +00:00
parent 299d7bfcfb
commit 411b172dac
2 changed files with 9 additions and 4 deletions

View File

@ -940,7 +940,7 @@ static void flipsAndRots(unsigned int tileNumber, unsigned int i, unsigned int j
/* Used to calculate texture coordinates, which are 0-255 in value */ /* Used to calculate texture coordinates, which are 0-255 in value */
const float xMult = 1.0f / TILES_IN_PAGE_COLUMN; const float xMult = 1.0f / TILES_IN_PAGE_COLUMN;
const float yMult = 1.0f / TILES_IN_PAGE_ROW; const float yMult = 1.0f / TILES_IN_PAGE_ROW;
const float one = 1.0f / (TILES_IN_PAGE_COLUMN * getTextureSize()); const float one = 1.0f / (TILES_IN_PAGE_COLUMN * (float)getTextureSize());
/* /*
* Points for flipping the texture around if the tile is flipped or rotated * Points for flipping the texture around if the tile is flipped or rotated
@ -4051,7 +4051,7 @@ static void drawTerrainWaterTile(UDWORD i, UDWORD j)
/* Used to calculate texture coordinates, which are 0-255 in value */ /* Used to calculate texture coordinates, which are 0-255 in value */
const float xMult = 1.0f / TILES_IN_PAGE_COLUMN; const float xMult = 1.0f / TILES_IN_PAGE_COLUMN;
const float yMult = 1.0f / (2.0f * TILES_IN_PAGE_ROW); const float yMult = 1.0f / (2.0f * TILES_IN_PAGE_ROW);
const float one = 1.0f / (TILES_IN_PAGE_COLUMN * getTextureSize()); const float one = 1.0f / (TILES_IN_PAGE_COLUMN * (float)getTextureSize());
const unsigned int tileNumber = getWaterTileNum(); const unsigned int tileNumber = getWaterTileNum();
TERRAIN_VERTEX vertices[3]; TERRAIN_VERTEX vertices[3];

View File

@ -49,8 +49,7 @@ TILE_TEX_INFO tileTexInfo[MAX_TILES];
static int firstPage; // the last used page before we start adding terrain textures static int firstPage; // the last used page before we start adding terrain textures
int terrainPage; // texture ID of the terrain page int terrainPage; // texture ID of the terrain page
static int mipmap_max = MIPMAP_MAX, mipmap_levels = MIPMAP_LEVELS; static int mipmap_max, mipmap_levels, mipmap_user_requested = MIPMAP_MAX;
static int mipmap_user_requested = MIPMAP_MAX;
void setTextureSize(int texSize) void setTextureSize(int texSize)
{ {
@ -60,6 +59,7 @@ void setTextureSize(int texSize)
return; return;
} }
mipmap_user_requested = texSize; mipmap_user_requested = texSize;
debug(LOG_3D, "texture size set to %d", texSize);
} }
int getTextureSize() int getTextureSize()
@ -126,6 +126,10 @@ void texLoad(const char *fileName)
ASSERT(_TEX_INDEX < iV_TEX_MAX, "Too many texture pages used"); ASSERT(_TEX_INDEX < iV_TEX_MAX, "Too many texture pages used");
ASSERT(MIPMAP_MAX == TILE_WIDTH && MIPMAP_MAX == TILE_HEIGHT, "Bad tile sizes"); ASSERT(MIPMAP_MAX == TILE_WIDTH && MIPMAP_MAX == TILE_HEIGHT, "Bad tile sizes");
// reset defaults
mipmap_max = MIPMAP_MAX;
mipmap_levels = MIPMAP_LEVELS;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glval); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glval);
while (glval < mipmap_max * TILES_IN_PAGE_COLUMN) while (glval < mipmap_max * TILES_IN_PAGE_COLUMN)
@ -145,6 +149,7 @@ void texLoad(const char *fileName)
{ {
mipmap_max /= 2; mipmap_max /= 2;
mipmap_levels--; mipmap_levels--;
debug(LOG_3D, "Downgrading texture quality to %d due to user setting %d", mipmap_max, mipmap_user_requested);
} }
mipmap_user_requested = mipmap_max; // reduce to lowest possible mipmap_user_requested = mipmap_max; // reduce to lowest possible