Fix some problems introduced in r1286: 1. flickering water edges 2. transparent water was not correctly drawn

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1363 4a71c877-e1ca-e34f-864e-861f7616d084
master
Gerard Krol 2007-04-05 14:32:13 +00:00
parent b8c4065e15
commit 7d6382905d
3 changed files with 30 additions and 4 deletions

View File

@ -156,6 +156,7 @@ extern SDWORD pieStateCount;
/***************************************************************************/
extern void pie_SetDefaultStates(void);//Sets all states
extern void pie_SetDepthBufferStatus(DEPTH_MODE depthMode);
extern void pie_SetDepthOffset(float offset);
extern void pie_SetGammaValue(float val);
//renderer capability
extern void pie_SetFogCap(FOG_CAP val);

View File

@ -75,6 +75,21 @@ void pie_SetDepthBufferStatus(DEPTH_MODE depthMode) {
}
}
/// Set the depth (z) offset
/// Negative values are closer to the screen
void pie_SetDepthOffset(float offset)
{
if(offset == 0.0f)
{
glDisable (GL_POLYGON_OFFSET_FILL);
}
else
{
glPolygonOffset(offset, offset);
glEnable (GL_POLYGON_OFFSET_FILL);
}
}
/// Set the OpenGL fog start and end
void pie_UpdateFogDistance(float begin, float end)
{

View File

@ -952,7 +952,18 @@ static void drawTiles(iView *camera, iView *player)
continue;
}
drawTerrainTile(i,j, FALSE);
drawTerrainWaterTile(i,j);
if(tileScreenInfo[i][j].bWater)
{
// add the (possibly) transparent water to the bucket sort
bucketAddTypeToList(RENDER_WATERTILE, &tileIJ[i][j]);
// check if we need to draw a water edge
if((mapTile(playerXTile + j, playerZTile + i)->texture & TILE_NUMMASK) != WaterTileID) {
// the edge is in front of the water (which is drawn at z-index -1)
pie_SetDepthOffset(-2.0);
drawTerrainTile(i,j, TRUE);
pie_SetDepthOffset(0.0);
}
}
}
}
}
@ -4974,6 +4985,7 @@ void drawTerrainWaterTile(UDWORD i, UDWORD j)
aVrts[2].light = tileScreenInfo[i+1][j+1].wlight;
aVrts[2].light.byte.a = WATER_ALPHA_LEVEL;
pie_SetDepthOffset(-1.0);
pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
memcpy(&aVrts[1],&aVrts[2],sizeof(PIEVERTEX));
@ -4987,9 +4999,7 @@ void drawTerrainWaterTile(UDWORD i, UDWORD j)
pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
if( (psTile->texture & TILE_NUMMASK) != WaterTileID) {
drawTerrainTile(i,j, TRUE);
}
pie_SetDepthOffset(0.0);
}
}