I'll stop working on it for today. With this patch (not cleaned up, your
patch is included) everything works except gui elements.
The change in lib/ivis_opengl/piedraw.c is just a quick fix, but I don't
want to track it down further (I guess the texcoords should be divided
by 256 directly when loading the pie), and a similar change is needed
for the gui graphics.
--
The root of all superstition is that men observe when a thing hits,
but not when it misses.
-- Francis Bacon
diff -r 6f78a7c219db Makefile.am
--- a/Makefile.am Tue Dec 04 21:25:25 2007 +0100
+++ b/Makefile.am Wed Dec 05 00:26:37 2007 +0100
@@ -1,4 +1,4 @@ SUBDIRS = build_tools win32 lib src data
-SUBDIRS = build_tools win32 lib src data po doc icons nsis
+SUBDIRS = build_tools win32 lib src data doc icons nsis
dist_doc_DATA = AUTHORS ChangeLog COPYING COPYING.README
diff -r 6f78a7c219db configure.ac
--- a/configure.ac Tue Dec 04 21:25:25 2007 +0100
+++ b/configure.ac Wed Dec 05 00:26:37 2007 +0100
@@ -34,7 +34,7 @@ AC_GNU_SOURCE
AC_GNU_SOURCE
# Check for gettext
-AM_GNU_GETTEXT([external])
+#AM_GNU_GETTEXT([external])
# Check for compiler
diff -r 6f78a7c219db lib/ivis_common/piedef.h
--- a/lib/ivis_common/piedef.h Tue Dec 04 21:25:25 2007 +0100
+++ b/lib/ivis_common/piedef.h Wed Dec 05 00:26:37 2007 +0100
@@ -56,9 +56,6 @@
#define INTERFACE_DEPTH (MAX_Z - 1.0f)
#define BUTTON_DEPTH 2000 // will be stretched to 16000
-#define OLD_TEXTURE_SIZE_FIX 256.0f
-
-
#define pie_MAX_POLY_SIZE 16
//Effects
@@ -124,7 +121,7 @@ typedef struct
typedef struct
{
Vector3i pos;
- unsigned int u, v;
+ float u, v;
PIELIGHT light, specular;
Vector3i screen; //! Screenspace tile coordinates
Vector3i water; //! Screenspace water coordinates
diff -r 6f78a7c219db lib/ivis_common/piefunc.h
--- a/lib/ivis_common/piefunc.h Tue Dec 04 21:25:25 2007 +0100
+++ b/lib/ivis_common/piefunc.h Wed Dec 05 00:26:37 2007 +0100
@@ -35,7 +35,7 @@
extern UBYTE pie_ByteScale(UBYTE a, UBYTE b) WZ_DECL_CONST;
extern void pie_TransColouredTriangle(CLIP_VERTEX *vrt, UDWORD rgb);
-extern void pie_DrawSkybox(float scale, int u, int v, int w, int h);
+extern void pie_DrawSkybox(float scale, float u, float v, float w, float h);
extern void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider);
extern void pie_DrawViewingWindow( Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour);
diff -r 6f78a7c219db lib/ivis_opengl/piedraw.c
--- a/lib/ivis_opengl/piedraw.c Tue Dec 04 21:25:25 2007 +0100
+++ b/lib/ivis_opengl/piedraw.c Wed Dec 05 00:26:37 2007 +0100
@@ -435,8 +435,8 @@ static void pie_Draw3DShape2(iIMDShape *
pieVrts[n].x = scrPoints[*index].x;
pieVrts[n].y = scrPoints[*index].y;
pieVrts[n].z = scrPoints[*index].z;
- pieVrts[n].u = pPolys->texCoord[n].x;
- pieVrts[n].v = pPolys->texCoord[n].y;
+ pieVrts[n].u = pPolys->texCoord[n].x / 256;
+ pieVrts[n].v = pPolys->texCoord[n].y / 256;
pieVrts[n].light.argb = colour.argb;
pieVrts[n].specular.argb = specular.argb;
}
diff -r 6f78a7c219db lib/ivis_opengl/piefunc.c
--- a/lib/ivis_opengl/piefunc.c Tue Dec 04 21:25:25 2007 +0100
+++ b/lib/ivis_opengl/piefunc.c Wed Dec 05 00:26:37 2007 +0100
@@ -129,7 +129,7 @@ void pie_TransColouredTriangle(CLIP_VERT
/* ---------------------------------------------------------------------------------- */
-void pie_DrawSkybox(float scale, int u, int v, int w, int h)
+void pie_DrawSkybox(float scale, float u, float v, float w, float h)
{
const float r = 1.0f; // just because it is shorter than 1.0f
diff -r 6f78a7c219db lib/ivis_opengl/screen.c
--- a/lib/ivis_opengl/screen.c Tue Dec 04 21:25:25 2007 +0100
+++ b/lib/ivis_opengl/screen.c Wed Dec 05 00:26:37 2007 +0100
@@ -181,7 +181,7 @@ BOOL screenInitialise(
glOrtho(0, width, height, 0, 1, -1);
glMatrixMode(GL_TEXTURE);
- glScalef(1.0f/OLD_TEXTURE_SIZE_FIX, 1.0f/OLD_TEXTURE_SIZE_FIX, 1.0f); // FIXME Scaling texture coords to 256x256!
+ glScalef(1.0f, 1.0f, 1.0f); // FIXME Scaling texture coords to 256x256!
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -295,11 +295,11 @@ void screen_Upload(const char *newBackDr
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
- glTexCoord2f(255, 0);
+ glTexCoord2f(1, 0);
glVertex2f(screenWidth, 0);
- glTexCoord2f(0, 255);
+ glTexCoord2f(0, 1);
glVertex2f(0, screenHeight);
- glTexCoord2f(255, 255);
+ glTexCoord2f(1, 1);
glVertex2f(screenWidth, screenHeight);
glEnd();
}
diff -r 6f78a7c219db src/display3d.c
--- a/src/display3d.c Tue Dec 04 21:25:25 2007 +0100
+++ b/src/display3d.c Wed Dec 05 00:26:37 2007 +0100
@@ -939,18 +939,19 @@ static void flipsAndRots(unsigned int ti
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 = 0.00f;
/*
* 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)
@@ -3734,7 +3735,7 @@ static void renderSurroundings(void)
wind = 0.0f;
}
}
- pie_DrawSkybox(skybox_scale, 0, 128, 256, 128);
+ pie_DrawSkybox(skybox_scale, 0, 0.5, 1, 0.5);
// Load Saved State
pie_MatEnd();
@@ -4049,23 +4050,23 @@ static void drawTerrainWaterTile(UDWORD
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 = 0.00f;
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+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+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 + 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;
diff -r 6f78a7c219db src/texture.c
--- a/src/texture.c Tue Dec 04 21:25:25 2007 +0100
+++ b/src/texture.c Wed Dec 05 00:26:37 2007 +0100
@@ -173,9 +173,8 @@ void texLoad(const char *fileName)
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);
diff -r 6f78a7c219db tools/pietoaster/pie_types.h
--- a/tools/pietoaster/pie_types.h Tue Dec 04 21:25:25 2007 +0100
+++ b/tools/pietoaster/pie_types.h Wed Dec 05 00:26:37 2007 +0100
@@ -56,9 +56,6 @@ typedef iV_Image iTexture;
#define LONG_TEST (1<<14)
#define INTERFACE_DEPTH (MAX_Z - 1.0f)
#define BUTTON_DEPTH 2000 // will be stretched to 16000
-
-#define OLD_TEXTURE_SIZE_FIX 256.0f
-
#define pie_MAX_POLY_SIZE 16
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev