From: Latif Khalifa Date: Sun, 3 Jul 2011 03:09:16 +0000 (+0000) Subject: Avoid terrain flicker as the patches come in. X-Git-Tag: 2.8~426 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=02b53d01d858f6f8129230e53490079ffd962252;p=radegast%2Fradegast.git Avoid terrain flicker as the patches come in. git-svn-id: https://radegast.googlecode.com/svn/trunk@936 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- diff --git a/Radegast/GUI/Rendering/Rendering.cs b/Radegast/GUI/Rendering/Rendering.cs index cff8108..2ae1782 100644 --- a/Radegast/GUI/Rendering/Rendering.cs +++ b/Radegast/GUI/Rendering/Rendering.cs @@ -1113,26 +1113,38 @@ namespace Radegast.Rendering private void ResetTerrain() { + ResetTerrain(true); + } + + private void ResetTerrain(bool removeImage) + { if (terrainImage != null) { terrainImage.Dispose(); terrainImage = null; } - terrainTexture = -1; - - if (terrainVBO == -1) + if (terrainVBO != -1) { GL.DeleteBuffers(1, ref terrainVBO); terrainVBO = -1; } - if (terrainIndexVBO == -1) + if (terrainIndexVBO != -1) { GL.DeleteBuffers(1, ref terrainIndexVBO); terrainIndexVBO = -1; } + if (removeImage) + { + if (terrainTexture != -1) + { + GL.DeleteTexture(terrainTexture); + terrainTexture = -1; + } + } + fetchingTerrainTexture = false; TerrainModified = true; } @@ -1165,10 +1177,8 @@ namespace Radegast.Rendering TerrainModified = false; } - void CheckTerrainTexture() + void UpdateTerrainTexture() { - if (terrainTexture != -1) return; - if (!fetchingTerrainTexture) { fetchingTerrainTexture = true; @@ -1184,11 +1194,6 @@ namespace Radegast.Rendering fetchingTerrainTexture = false; }); } - else if (terrainImage != null) - { - terrainTexture = GLLoadImage(terrainImage, false); - } - } private void RenderTerrain() @@ -1199,11 +1204,22 @@ namespace Radegast.Rendering if (TerrainModified) { - ResetTerrain(); + ResetTerrain(false); UpdateTerrain(); + UpdateTerrainTexture(); } - CheckTerrainTexture(); + if (terrainImage != null) + { + if (terrainTexture != -1) + { + GL.DeleteTexture(terrainTexture); + } + + terrainTexture = GLLoadImage(terrainImage, false); + terrainImage.Dispose(); + terrainImage = null; + } if (terrainTexture == -1) {