On Dec 5, 2007 12:33 AM, Christian Ohm <[EMAIL PROTECTED]> wrote:
> I'll stop working on it for today. With this patch (not cleaned up, your
> patch is included) everything works except gui elements.

This patch is more limited, but does mostly the same thing. I tried to
reimplement the one-pixel border with it, but I notice texture seams
at close zoom. You do no notice them at normal zoom, though. If this
is worse than it used to be, I do not understand why.

  - Per
Index: src/display3d.c
===================================================================
--- src/display3d.c	(revision 2979)
+++ src/display3d.c	(working copy)
@@ -162,7 +162,7 @@
 BOOL	godMode;
 
 static float waterRealValue = 0.0f;
-#define WAVE_SPEED 2.0f
+#define WAVE_SPEED 0.015f
 
 UDWORD	barMode = BAR_FULL; // configured in configuration.c
 
@@ -503,7 +503,7 @@
 	if(!gamePaused())
 	{
 		waterRealValue += (WAVE_SPEED * frameTime2) / GAME_TICKS_PER_SEC;
-		if (waterRealValue >= (256 / TILES_IN_PAGE_ROW) / 2)
+		if (waterRealValue >= (1.0f / TILES_IN_PAGE_ROW) / 2)
 		{
 			waterRealValue = 0.0f;
 		}
@@ -809,7 +809,6 @@
 	pie_SetColourKeyedBlack(TRUE);
 	pie_TranslateTextureEnd();
 
-
 	targetOpenList((BASE_OBJECT*)driveGetDriven());
 
 	/* ---------------------------------------------------------------- */
@@ -939,18 +938,19 @@
 	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 float xMult = (1.0f / (PAGE_WIDTH / TILE_WIDTH));
+	const float yMult = (1.0f / (PAGE_HEIGHT / TILE_HEIGHT));
+	const float one = 1.0f / PAGE_WIDTH;
 
 	/*
 	 * Points for flipping the texture around if the tile is flipped or rotated
 	 * Store the source rect as four points
 	 */
-	Vector2i
-		sP1 = {1, 1},
-		sP2 = {xMult - 1, 1},
-		sP3 = {xMult - 1, yMult - 1},
-		sP4 = {1, yMult - 1},
+	Vector2f
+		sP1 = { one, one },
+		sP2 = { xMult - one, one },
+		sP3 = { xMult - one, yMult - one },
+		sP4 = { one, yMult - one },
 		sPTemp;
 
 	if (texture & TILE_XFLIP)
@@ -4049,23 +4049,23 @@
 	if (terrainType( mapTile(actualX, actualY) ) == TER_WATER)
 	{
 		/* Used to calculate texture coordinates, which are 0-255 in value */
-		const unsigned int
-				xMult = 256 / TILES_IN_PAGE_COLUMN,
-				yMult = 256 / (2 * TILES_IN_PAGE_ROW);
+		const float xMult = 1.0f / TILES_IN_PAGE_COLUMN;
+		const float yMult = 1.0f / (2.0f * TILES_IN_PAGE_ROW);
+		const float one = 1.0f / PAGE_WIDTH;
 		const unsigned int tileNumber = getWaterTileNum();
 		TERRAIN_VERTEX vertices[3];
 
-		tileScreenInfo[i+0][j+0].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + 1;
+		tileScreenInfo[i+0][j+0].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + one;
 		tileScreenInfo[i+0][j+0].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset;
 
-		tileScreenInfo[i+0][j+1].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + (xMult - 1);
+		tileScreenInfo[i+0][j+1].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + (xMult - one);
 		tileScreenInfo[i+0][j+1].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset;
 
-		tileScreenInfo[i+1][j+1].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + (xMult - 1);
-		tileScreenInfo[i+1][j+1].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset + (yMult - 1);
+		tileScreenInfo[i+1][j+1].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + (xMult - one);
+		tileScreenInfo[i+1][j+1].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset + (yMult - one);
 
-		tileScreenInfo[i+1][j+0].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + 1;
-		tileScreenInfo[i+1][j+0].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset + (yMult - 1);
+		tileScreenInfo[i+1][j+0].u = tileTexInfo[TileNumber_tile(tileNumber)].uOffset + one;
+		tileScreenInfo[i+1][j+0].v = tileTexInfo[TileNumber_tile(tileNumber)].vOffset + (yMult - one);
 
 		vertices[0] = tileScreenInfo[i + 0][j + 0];
 		vertices[0].pos.y = tileScreenInfo[i + 0][j + 0].water_height;
Index: src/texture.c
===================================================================
--- src/texture.c	(revision 2979)
+++ src/texture.c	(working copy)
@@ -173,9 +173,8 @@
 			free(tile.bmp);
 			if (i == TILE_WIDTH) // dealing with main texture page; so register coordinates
 			{
-				// 256 is an integer hack for GLfloat texture coordinates
-				tileTexInfo[k].uOffset = xOffset / (xSize / 256);
-				tileTexInfo[k].vOffset = yOffset / (ySize / 256);
+				tileTexInfo[k].uOffset = (float)xOffset / (float)xSize;
+				tileTexInfo[k].vOffset = (float)yOffset / (float)ySize;
 				tileTexInfo[k].texPage = texPage;
 				debug(LOG_TEXTURE, "  texLoad: Registering k=%d i=%d u=%f v=%f xoff=%d yoff=%d xsize=%d ysize=%d tex=%d (%s)",
 				     k, i, tileTexInfo[k].uOffset, tileTexInfo[k].vOffset, xOffset, yOffset, xSize, ySize, texPage, fullPath);
Index: lib/ivis_common/piedef.h
===================================================================
--- lib/ivis_common/piedef.h	(revision 2979)
+++ lib/ivis_common/piedef.h	(working copy)
@@ -124,7 +124,7 @@
 typedef struct
 {
 	Vector3i pos;
-	unsigned int u, v;
+	float u, v;
 	PIELIGHT light, specular;
 	Vector3i screen; //! Screenspace tile coordinates
 	Vector3i water; //! Screenspace water coordinates
Index: lib/ivis_opengl/piematrix.c
===================================================================
--- lib/ivis_opengl/piematrix.c	(revision 2979)
+++ lib/ivis_opengl/piematrix.c	(working copy)
@@ -441,7 +441,6 @@
 void pie_TranslateTextureBegin(const Vector2f offset)
 {
 	glMatrixMode(GL_TEXTURE);
-	glPushMatrix();
 	glTranslatef(offset.x, offset.y, 0.0f);
 	glMatrixMode(GL_MODELVIEW);
 }
@@ -449,7 +448,8 @@
 void pie_TranslateTextureEnd(void)
 {
 	glMatrixMode(GL_TEXTURE);
-	glPopMatrix();
+	glLoadIdentity();
+	glScalef(1.0f/OLD_TEXTURE_SIZE_FIX, 1.0f/OLD_TEXTURE_SIZE_FIX, 1.0f); // FIXME Scaling texture coords to 256x256!
 	glMatrixMode(GL_MODELVIEW);
 }
 
Index: lib/ivis_opengl/piedraw.c
===================================================================
--- lib/ivis_opengl/piedraw.c	(revision 2979)
+++ lib/ivis_opengl/piedraw.c	(working copy)
@@ -985,6 +985,8 @@
 	glColorPointer(COLOUR_COMPONENTS, GL_UNSIGNED_BYTE, 0, aColour);
 	glTexCoordPointer(TEXCOORD_COMPONENTS, GL_FLOAT, 0, aTexCoord);
 	glVertexPointer(VERTEX_COMPONENTS, GL_FLOAT, 0, aVertex);
+	glMatrixMode(GL_TEXTURE);
+	glLoadIdentity();
 }
 
 void pie_DrawTerrainDone(int mapx, int mapy)
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to