Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 146)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 147)
@@ -170,4 +170,7 @@
 	dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())->
 		SetViewport(mWindow->getViewport(0));
+
+	// reset statistics
+	resetStats();
 } 
 //-----------------------------------------------------------------------
@@ -528,8 +531,11 @@
 		writeFrames();
 		
+		float avgFps = (float)mAvgFps / (float)mFrameCount;
+
 		//-- write out stats for recorded walkthrough
 		std::stringstream d;
 		d << "Algorithm: " << currentAlgorithmCaptions[mCurrentAlgorithm] << "\n"
-		  << "avg. FPS: " << mWindow->getAverageFPS() << "\n"
+		  //<< "avg. FPS: " << mWindow->getAverageFPS() << "\n"
+		  << "avg. FPS: " << avgFps << "\n"
 		  << "best FPS: " << mWindow->getBestFPS() << "\n"
 		  << "worst FPS: " << mWindow->getWorstFPS() << "\n"
@@ -564,6 +570,7 @@
 			mWindow->setDebugText("Replay");
 			
-			// reset, because we measure fps stats during walkthrough
+			// reset, because we measure fps stats during walkthrough (warning: average fps broken)
 			mWindow->resetStatistics();
+			resetStats();
 
 			//-- initialise frame data
@@ -630,4 +637,10 @@
 }
 //-----------------------------------------------------------------------
+void TerrainFrameListener::resetStats()
+{
+	mAvgFps = 0;
+	mFrameCount = 0;
+}
+//-----------------------------------------------------------------------
 void TerrainFrameListener::updateStats()
 {
@@ -635,10 +648,15 @@
 	char str[100];
 	
-	static String currFps = "Current FPS: ";
-	static String avgFps = "Average FPS: ";
-	static String bestFps = "Best FPS: ";
-	static String worstFps = "Worst FPS: ";
-	static String tris = "Triangle Count: ";
-
+	static String currFpsString = "Current FPS: ";
+	static String avgFpsString = "Average FPS: ";
+	static String bestFpsString = "Best FPS: ";
+	static String worstFpsString = "Worst FPS: ";
+	static String trisString = "Triangle Count: ";
+
+	mAvgFps += mWindow->getStatistics().lastFPS;
+	++ mFrameCount;
+	
+	float avgFps = (float)mAvgFps / (float)mFrameCount;
+    
 	// update stats when necessary
     try 
@@ -651,13 +669,14 @@
 		const RenderTarget::FrameStats& stats = mWindow->getStatistics();
 
-		guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
-		guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
-		guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
+		//guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
+		guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps));
+		guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS));
+		guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS)
 			+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
-		guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
+		guiWorst->setCaption(worstFpsString + StringConverter::toString(stats.worstFPS)
 			+" "+StringConverter::toString(stats.worstFrameTime)+" ms");
 
 		OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
-        guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));
+        guiTris->setCaption(trisString + StringConverter::toString(stats.triangleCount));
 
 		OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 146)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 147)
@@ -126,4 +126,6 @@
 protected:
 
+	void resetStats();
+
 	/** Clamp camera to terrain.
 	*/
@@ -228,4 +230,6 @@
 	bool mShowQueryStats;
 
+	unsigned long mAvgFps;
+	unsigned long mFrameCount;
 	//bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
 };
