Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2677)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2679)
@@ -28,8 +28,8 @@
 -preprocessor=gvs \
 -gvs_epsilon=0.0001 \
--gvs_total_samples=1000000 \
--gvs_samples_per_pass=1000000 \
+-gvs_total_samples=100000 \
+-gvs_samples_per_pass=100000 \
 -gvs_initial_samples=16 \
--gvs_max_viewcells=20 \
+-gvs_max_viewcells=1 \
 -gvs_min_contribution=50 \
 -gvs_per_viewcell=true \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2678)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2679)
@@ -30,4 +30,35 @@
 
 #include <QVBoxLayout>
+static GLint cubeArray[][3] = {
+    {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0},
+    {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1},
+    {0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1},
+    {0, 1, 0}, {0, 1, 1}, {1, 1, 1}, {1, 1, 0},
+    {0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1},
+    {1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}
+};
+
+static GLint cubeTextureArray[][2] = {
+    {0, 0}, {1, 0}, {1, 1}, {0, 1},
+    {0, 0}, {0, 1}, {1, 1}, {1, 0},
+    {0, 0}, {1, 0}, {1, 1}, {0, 1},
+    {1, 0}, {0, 0}, {0, 1}, {1, 1},
+    {0, 0}, {1, 0}, {1, 1}, {0, 1},
+    {1, 0}, {0, 0}, {0, 1}, {1, 1}
+};
+
+static GLint faceArray[][2] = {
+    {1, -1}, {1, 1}, {-1, 1}, {-1, -1}
+};
+
+static GLubyte colorArray[][4] = {
+    {170, 202, 0, 255},
+    {120, 143, 0, 255},
+    {83, 102, 0, 255},
+    {120, 143, 0, 255}
+};
+
+
+
 
 namespace GtpVisibilityPreprocessor 
@@ -68,4 +99,64 @@
 }
 #endif
+
+
+void QtGlRendererBuffer::dummyBuffer()
+{ 
+	//QGLPixelBuffer *dummy = new QGLPixelBuffer(QSize(256, 256), format(), this);
+    
+	// set up the pbuffer context
+    makeCurrent();
+    
+	glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    glVertexPointer(3, GL_INT, 0, cubeArray);
+    glTexCoordPointer(2, GL_INT, 0, cubeTextureArray);
+    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorArray);
+
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    glEnable(GL_BLEND);
+    glEnable(GL_TEXTURE_2D);
+    glEnable(GL_DEPTH_TEST);
+
+    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+
+    glViewport(0, 0, size().width(), size().height());
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(-1, 1, -1, 1, -99, 99);
+    glTranslatef(-0.5f, -0.5f, 0.0f);
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+
+   
+	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
+
+	// draw cube background
+	glPushMatrix();
+	glLoadIdentity();
+	glTranslatef(0.5f, 0.5f, -2.0f);
+	glDisable(GL_TEXTURE_2D);
+	glEnableClientState(GL_COLOR_ARRAY);
+	glVertexPointer(2, GL_INT, 0, faceArray);
+	glDrawArrays(GL_QUADS, 0, 4);
+	glVertexPointer(3, GL_INT, 0, cubeArray);
+	glDisableClientState(GL_COLOR_ARRAY);
+	glEnable(GL_TEXTURE_2D);
+	glPopMatrix();
+
+	// draw cube
+	glTranslatef(0.5f, 0.5f, 0.5f);
+	glRotatef(3.0f, 1.0f, 1.0f, 1.0f);
+	glTranslatef(-0.5f, -0.5f, -0.5f);
+	glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
+	glDrawArrays(GL_QUADS, 0, 24);
+
+	QImage im = toImage();
+	QString qstr("test.png");
+
+	im.save(qstr, "PNG");
+
+	doneCurrent();
+}
 
 
@@ -99,4 +190,5 @@
 	//mUseVbos = false;
 	
+	//makeCurrent();
 	MakeLive();
 	glViewport(0, 0, w, h);
@@ -109,10 +201,7 @@
 
 	InitGL();
-	
-	//mydynamicTexture = generateDynamicTexture();
-    // bind the dynamic texture to the pbuffer - this is a no-op under X11
-	//bindToDynamicTexture(mydynamicTexture);
-
-	DoneLive();
+
+	//doneCurrent();
+	//DoneLive();
 }
 
@@ -275,5 +364,5 @@
 			char filename[256];
 			//sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels);
-			sprintf(filename, "error-frame-%04d-%04d.png", mFrame, pixelCount);
+			sprintf(filename, "error-frame-%04d-%08d.png", mFrame, pixelCount);
 			QImage im = toImage();
 			string str = mSnapPrefix + filename;
@@ -305,5 +394,5 @@
 
 			im = toImage();
-			sprintf(filename, "error-frame-%04d-%04d-%0.5f-pvs.png", mFrame, viewcell->GetId(), pErrorPixels);
+			sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount);
 			str = mSnapPrefix + filename;
 			qstr = str.c_str();
@@ -316,5 +405,5 @@
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
-	DoneLive();
+	//DoneLive();
 
 	return pErrorPixels;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2678)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2679)
@@ -76,5 +76,5 @@
 
 	unsigned int mydynamicTexture;
-
+void dummyBuffer();
 public:
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj	(revision 2676)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj	(revision 2679)
@@ -212,4 +212,8 @@
 			>
 			<File
+				RelativePath=".\glwidget.cpp"
+				>
+			</File>
+			<File
 				RelativePath="LogReader.cpp"
 				>
@@ -241,4 +245,8 @@
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
 			>
+			<File
+				RelativePath=".\glwidget.h"
+				>
+			</File>
 			<File
 				RelativePath="LogReader.h"
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2678)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2679)
@@ -1022,9 +1022,9 @@
 GlRendererBuffer::EvalPvsStat()
 {
-	MakeLive();
+	//MakeLive();
 	
 	GlRenderer::EvalPvsStat();
 	
-	DoneLive();
+	//DoneLive();
 	// mRenderingFinished.wakeAll();
 }
@@ -1033,9 +1033,9 @@
 void GlRendererBuffer::EvalPvsStat(const SimpleRayContainer &viewPoints)
 {
-	MakeLive();
+	//MakeLive();
 
 	GlRenderer::EvalPvsStat(viewPoints);
   
-	DoneLive();
+	//DoneLive();
 }
 
@@ -1476,91 +1476,92 @@
 GlRenderer::EvalPvsStat()
 {
-  mPvsStat.Reset();
-  halton.Reset();
-
-  SetupProjection(GetWidth(), GetHeight());
-
-  cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl;
-  
-  for (int i=0; i < mPvsStatFrames; i++) {
-	float err;
-	// set frame id for saving the error buffer
-	mFrame = i;
-
-	//	cerr<<"RV"<<endl;
-	RandomViewPoint();
-	//	cerr<<"RV2"<<endl;
-
- 	if (mPvsErrorBuffer[i].mError == 1.0f) {
-	  // check if the view point is valid
-	  if (!ValidViewPoint()) {
-		mPvsErrorBuffer[i].mError = -1.0f;
-	  }
-
-	  // manualy corrected view point
-	  if (mFrame == 5105)
-		mPvsErrorBuffer[i].mError = -1.0f;
-	}
-
-
-	if (mPvsErrorBuffer[i].mError > 0.0f) {
-		int pvsSize;
-
-		float error = GetPixelError(pvsSize);
-
-		mPvsErrorBuffer[i].mError = error;
-		mPvsErrorBuffer[i].mPvsSize = pvsSize;
-
-		//cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")";
-	}
-
-	err = mPvsErrorBuffer[i].mError;
-	
-	if (err >= 0.0f) {
-	  if (err > mPvsStat.maxError)
-		mPvsStat.maxError = err;
-	  mPvsStat.sumError += err;
-	  mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize;
-	  
-	  if (err == 0.0f)
-		mPvsStat.errorFreeFrames++;
-	  mPvsStat.frames++;
-	}
-  }
-  
-  glFinish();
-
-  static bool first = true;
-  if (first) {
-	
-
-	bool exportRandomViewCells;
-	Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells",
-											  exportRandomViewCells);
-	
-	if (0 && exportRandomViewCells)
-	  {
-		char buff[512];
-		Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
-		string filename(buff);
-
-		string viewCellPointsFile;
-		
-		if (strstr(filename.c_str(), ".obj"))
-		  viewCellPointsFile = ReplaceSuffix(filename, ".obj", ".vc");
-		else if (strstr(filename.c_str(), ".dat"))
-		  viewCellPointsFile = ReplaceSuffix(filename, ".dat", ".vc");
-		else if (strstr(filename.c_str(), ".x3d"))
-		  viewCellPointsFile = ReplaceSuffix(filename, ".x3d", ".vc");
-		
-		
-		cout << "exporting random view cells" << endl;
-		preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile);
-		cout << "finished" << endl;
-	  }
-	first = false;
-  }
-
-  cout<<endl<<flush;
+	mPvsStat.Reset();
+	halton.Reset();
+
+	SetupProjection(GetWidth(), GetHeight());
+
+	cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl;
+
+	for (int i=0; i < mPvsStatFrames; i++) {
+		float err;
+		// set frame id for saving the error buffer
+		mFrame = i;
+
+		//	cerr<<"RV"<<endl;
+		RandomViewPoint();
+		//	cerr<<"RV2"<<endl;
+
+		if (mPvsErrorBuffer[i].mError == 1.0f) {
+			// check if the view point is valid
+			if (!ValidViewPoint()) {
+				mPvsErrorBuffer[i].mError = -1.0f;
+			}
+
+			// manualy corrected view point
+			if (mFrame == 5105)
+				mPvsErrorBuffer[i].mError = -1.0f;
+		}
+
+
+		if (mPvsErrorBuffer[i].mError > 0.0f) 
+		{
+			int pvsSize;
+
+			float error = GetPixelError(pvsSize);
+
+			mPvsErrorBuffer[i].mError = error;
+			mPvsErrorBuffer[i].mPvsSize = pvsSize;
+
+			//cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")";
+		}
+
+		err = mPvsErrorBuffer[i].mError;
+
+		if (err >= 0.0f) {
+			if (err > mPvsStat.maxError)
+				mPvsStat.maxError = err;
+			mPvsStat.sumError += err;
+			mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize;
+
+			if (err == 0.0f)
+				mPvsStat.errorFreeFrames++;
+			mPvsStat.frames++;
+		}
+	}
+
+	glFinish();
+
+	static bool first = true;
+	if (first) {
+
+
+		bool exportRandomViewCells;
+		Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells",
+			exportRandomViewCells);
+
+		if (0 && exportRandomViewCells)
+		{
+			char buff[512];
+			Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
+			string filename(buff);
+
+			string viewCellPointsFile;
+
+			if (strstr(filename.c_str(), ".obj"))
+				viewCellPointsFile = ReplaceSuffix(filename, ".obj", ".vc");
+			else if (strstr(filename.c_str(), ".dat"))
+				viewCellPointsFile = ReplaceSuffix(filename, ".dat", ".vc");
+			else if (strstr(filename.c_str(), ".x3d"))
+				viewCellPointsFile = ReplaceSuffix(filename, ".x3d", ".vc");
+
+
+			cout << "exporting random view cells" << endl;
+			preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile);
+			cout << "finished" << endl;
+		}
+		first = false;
+	}
+
+	cout<<endl<<flush;
 }
 
@@ -1580,5 +1581,5 @@
 	for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i) 
 	{
-		if ((i % 10) == 99)
+		if ((i % 100) == 99)
 			cout << "processed " << i << " view points " << endl;
 
@@ -1603,4 +1604,5 @@
 
 			const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight();
+
 			if (0 && (pixelError > 0) && (pvsSize > 0)) 
 			{
@@ -1623,5 +1625,5 @@
 				mPvsStat.maxError = err;
 
-				cout << "new max error: " << mPvsStat.maxError * GetWidth()*GetHeight()  << endl;
+				cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl;
 			}
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2677)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2679)
@@ -34,4 +34,5 @@
 	#include "QtGlRenderer.h"
 	#include <QGLWidget>
+#include "glwidget.h"
 
 #else
@@ -292,4 +293,8 @@
 	// create a qt application first (must be created before any opengl widget ...)
 	QApplication *app = new QApplication(argc, NULL);
+
+	//Dummy dummy(1024, 1024);
+	//dummy.dummyBuffer();
+
 	pt = new QtPreprocessorThread(preprocessor);	
 
@@ -314,10 +319,13 @@
 		// renderer must be initialised
 		// $$matt
-		preprocessor->renderer = 
+		QtGlRendererBuffer *glbuf = 
 			new QtGlRendererBuffer(1024, 1024,
-			preprocessor->mSceneGraph,
-			preprocessor->mViewCellsManager,
-			preprocessor->mKdTree);
-
+								   preprocessor->mSceneGraph,
+								   preprocessor->mViewCellsManager,
+								   preprocessor->mKdTree);
+
+		preprocessor->renderer = glbuf;
+			
+		//glbuf->dummyBuffer();
 	}
 
