Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1940)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj	(revision 1949)
@@ -267,4 +267,62 @@
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtGlRenderer\Release"
+				GenerateDebugInformation="FALSE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+				FixedBaseAddress="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release_Qt|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				FavorSizeOrSpeed="1"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;USE_QT;TRY_GLOBAL_LINES"
+				RuntimeLibrary="2"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib QtCore4.lib qtmain.lib cg.lib cgGL.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtInterface.lib"
+				OutputFile="../bin/release/Preprocessor.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtInterface\Release;&quot;$(CG_LIB_PATH)&quot;"
 				GenerateDebugInformation="FALSE"
 				SubSystem="1"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1940)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 1949)
@@ -302,4 +302,53 @@
 				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
+		<Configuration
+			Name="Release_Qt|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="0"
+				FavorSizeOrSpeed="0"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_QT"
+				ExceptionHandling="TRUE"
+				RuntimeLibrary="2"
+				DisableLanguageExtensions="FALSE"
+				ForceConformanceInForLoopScope="FALSE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				BrowseInformation="1"
+				WarningLevel="2"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="../lib/Release/$(ProjectName).lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
 	</Configurations>
 	<References>
@@ -592,4 +641,12 @@
 						Outputs=""/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Release_Qt|Win32">
+					<Tool
+						Name="VCCustomBuildTool"
+						Description=""
+						CommandLine=""
+						Outputs=""/>
+				</FileConfiguration>
 			</File>
 			<File
@@ -644,4 +701,12 @@
 						Outputs=""/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Release_Qt|Win32">
+					<Tool
+						Name="VCCustomBuildTool"
+						Description=""
+						CommandLine=""
+						Outputs=""/>
+				</FileConfiguration>
 			</File>
 			<File
@@ -650,10 +715,4 @@
 			<File
 				RelativePath="..\src\Pvs.h">
-			</File>
-			<File
-				RelativePath=".\QtGlViewer.cpp">
-			</File>
-			<File
-				RelativePath=".\QtGlViewer.h">
 			</File>
 			<File
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 1942)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h	(revision 1949)
@@ -282,5 +282,5 @@
 
   virtual bool RequiresRays() {
-	for (int i=0; i < mDistributions.size(); i++)
+	for (int i=0; i < (int)mDistributions.size(); i++)
 	  if (mDistributions[i]->RequiresRays())
 		return true;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1945)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp	(revision 1949)
@@ -60,6 +60,7 @@
 	glLoadIdentity();
 
-	gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0);
+	//gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0);
 	//gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 0.5, 10.0);
+	glOrtho(-1000, 1000, -1000, 1000, 1, 1000);
 }
 
@@ -92,5 +93,11 @@
 	switch(key)
 	{
-	case ' ':
+	case '2':
+		++ globalLinesRenderer->mMaxDepth;
+		cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl;
+		return;
+	case '1':
+		-- globalLinesRenderer->mMaxDepth;
+		cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl;
 		return;
 	default:
@@ -108,8 +115,9 @@
 }
 */
-GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, GlRenderer *renderer): 
+GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, 
+										 GlRenderer *renderer): 
 mNewBuffer(NULL), 
 mOldBuffer(NULL), 
-mMaxDepth(100), 
+mMaxDepth(0), 
 mRenderer(renderer), 
 mPreprocessor(preprocessor)
@@ -188,5 +196,6 @@
 	AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox();
 	const Vector3 midPoint = bbox.Center();
-	const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0);
+	//const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0);
+	const Vector3 viewPoint = midPoint + Vector3(2, 0, 0);
 
 	cout << "midPoint: " << midPoint << endl;
@@ -200,5 +209,6 @@
 	gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
 
-	glDisable(GL_CULL_FACE);
+	//glDisable(GL_CULL_FACE);
+	glEnable(GL_CULL_FACE);
 	glDisable(GL_LIGHTING);
 	//glEnable(GL_COLOR_MATERIAL);
@@ -214,8 +224,10 @@
 	
 	mNewBuffer = new RenderTexture(texWidth, texHeight, true, true);
-	mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);
-
+	//mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);
+	mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE);
+	
 	mOldBuffer = new RenderTexture(texWidth, texHeight, true, true);
-	mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);
+	//mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);
+	mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE);
 
 	// Setup Cg
@@ -265,5 +277,11 @@
 		glClearColor(0.1, 0.7, 0.2, 1);
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	
+
+		glFrontFace(GL_CCW);
+		glCullFace(GL_BACK);
+		glEnable(GL_CULL_FACE);
+		glShadeModel(GL_FLAT);
+		glEnable(GL_DEPTH_TEST);
+		
 		glMatrixMode(GL_MODELVIEW);
 		glLoadIdentity();
@@ -272,5 +290,4 @@
 				  0, 1, 0);
 
-		glEnable(GL_DEPTH_TEST); 
 	}
 	mNewBuffer->EndCapture();
@@ -282,9 +299,15 @@
 		glMatrixMode(GL_MODELVIEW);
 		glLoadIdentity();
+		
+		glFrontFace(GL_CCW);
+		glCullFace(GL_BACK);
+		glEnable(GL_CULL_FACE);
+		glShadeModel(GL_FLAT);
+		glEnable(GL_DEPTH_TEST);
+		
 		gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z, 
 				  midPoint.x, midPoint.y, midPoint.z, 
 				  0, 1, 0);
 
-		glEnable(GL_DEPTH_TEST); 
 		glClearColor(0.6, 0.2, 0.2, 1);
 	}
@@ -326,14 +349,11 @@
 	mNewBuffer->EndCapture();
 	
-	//mNewBuffer->Bind();
-	mNewBuffer->BindDepth();
-	mNewBuffer->EnableTextureTarget();
-
-
-	//glBindTexture(texture_target,texID);
-	//const int texID = mNewBuffer->GetTextureTarget();
-	//glGetTexImage(texture_target,0,texture_format,GL_FLOAT,data);
-/*
-	for(int l = 0; l < mMaxDepth; ++ l) 
+	//mNewBuffer->BindDepth();
+	//float data[262144];
+	//glGetTexImage(mNewBuffer->GetTextureTarget(), 0, mNewBuffer->texture_format, GL_FLOAT, data);
+	if (mNewBuffer->IsRectangleTexture()) cout << "rect" << endl;
+//else cout << "haga"<<endl;
+
+	for(int i = 0; i < mMaxDepth; ++ i) 
 	{
 		// Peel another layer
@@ -348,25 +368,39 @@
 
 			cgGLBindProgram(sCgDepthPeelingProgram);
+		//	cgGLBindProgram(sCgPassThroughProgram);
 			cgGLEnableProfile(sCgFragmentProfile);
 			cgGLSetTextureParameter(sTextureParam, mOldBuffer->GetDepthTextureID());
 			cgGLEnableTextureParameter(sTextureParam);
 
-			//glColor3f(0,0.0,0.0);
-			DrawGeometry();
+			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+			glMatrixMode(GL_MODELVIEW);
+			glPushMatrix();
+			{ 
+				//glutSolidTorus(0.25, 1, 32, 64);
+				DrawGeometry();
+			}
+			glPopMatrix();
+
 			cgGLDisableTextureParameter(sTextureParam);
+			cgGLDisableProfile(sCgFragmentProfile);
 		}
 		mNewBuffer->EndCapture();
 	}
-*/
+
+	PrintGLerror("display 1");
+
+	//mNewBuffer->Bind();
+	mNewBuffer->BindDepth();
+	mNewBuffer->EnableTextureTarget();
+
 
 	PrintGLerror("display 2");
 	glColor3f(1,1,1);
 	glBegin(GL_QUADS);
-    glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f);
-    glTexCoord2f(1, 0); glVertex3f( 1, -1, -0.5f);
-    glTexCoord2f(1, 1); glVertex3f( 1,  1, -0.5f);
-    glTexCoord2f(0, 1); glVertex3f(-1,  1, -0.5f);
+    glTexCoord2f(0, 0); glVertex3f(-1000, -1000, -0.5f);
+    glTexCoord2f(1, 0); glVertex3f( 1000, -1000, -0.5f);
+    glTexCoord2f(1, 1); glVertex3f( 1000,  1000, -0.5f);
+    glTexCoord2f(0, 1); glVertex3f(-1000,  1000, -0.5f);
     glEnd();
-	PrintGLerror("display 1");
 
     if (mNewBuffer->IsFloatTexture())
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1946)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1949)
@@ -98,5 +98,5 @@
 	mMixtureDistribution->GenerateSamples(mSamplesPerPass, simpleRays);
 
-	cout << "generated " << simpleRays.size() << " samples in " 
+	cout << "generated " << (int)simpleRays.size() << " samples in " 
 		 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1941)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1949)
@@ -43,4 +43,5 @@
 void DrawGeometry();
 void Run();
+int mMaxDepth;
 protected:
 
@@ -62,5 +63,4 @@
 
 	Preprocessor *mPreprocessor;
-	int mMaxDepth;
 
 	GlRenderer *mRenderer;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/depth_peeling.cg
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/depth_peeling.cg	(revision 1940)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/depth_peeling.cg	(revision 1949)
@@ -1,9 +1,10 @@
 
 float3 main(in float4 col : COL0,
-       in float3 pos : WPOS,
-        uniform samplerRECT depthTex) : COLOR
+	    in float3 pos : WPOS,
+	    uniform sampler2D depthTex) : COLOR
 {
-   float zold = texRECT(depthTex, pos.xy);
-   if(pos.z < (zold + .000001))
+   float zold = tex2D(depthTex, pos.xy / 256.0);
+
+   if(pos.z < (zold + 0.1))
       discard;
    else;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1942)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1949)
@@ -28,5 +28,5 @@
 #include "ObjExporter.h"
 #include "SceneGraph.h"
-//#include "GlobalLinesRenderer.h"
+#include "GlobalLinesRenderer.h"
 
 #include "ViewCellsManager.h"
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1944)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1949)
@@ -25,5 +25,5 @@
 class TransformedMeshInstance;
 class TriangleIntersectable;
-  class BvhNode;
+ class BvhNode;
   
 struct VssRayContainer;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.cpp	(revision 1926)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#ifdef USE_QT
-
-#include <QApplication>
-#include "QtPreprocessorThread.h"
-#include "Camera.h"
-#include "KdTree.h"
-#include "SceneGraph.h"
-#include "Preprocessor.h"
-
-
-namespace GtpVisibilityPreprocessor {
-
-
-QtPreprocessorThread::QtPreprocessorThread(Preprocessor *p,
-										   QObject *parent)
-: PreprocessorThread(p), QThread(parent)															
-{
-	if (p->mQuitOnFinish)
-	{
-		connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void)));
-	}
-}
-
-
-QtPreprocessorThread::~QtPreprocessorThread()
-{
-  cerr << "Preprocessor thread destructor...\n";
-}
-
-
-int
-QtPreprocessorThread::GetCurrentThreadId() const
-{
-  QThread *thread = currentThread();
-  for (int i=0; i < sThreads.size(); i++)
-	if (sThreads[i] == (QtPreprocessorThread *)thread)
-	  return i+1;
-  return 0;
-}
-
-}
-
-#endif
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.h	(revision 1926)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#ifndef __QT_PREPROCESSOR_THREAD_H
-#define __QT_PREPROCESSOR_THREAD_H
-
-#ifdef USE_QT
-
-#include <QThread>
-#include "PreprocessorThread.h"
-
-namespace GtpVisibilityPreprocessor {
-
-class Preprocessor;
-
-class QtPreprocessorThread : public PreprocessorThread, public QThread
-{
-public:
-	QtPreprocessorThread(Preprocessor *p, QObject *parent = 0);
-	~QtPreprocessorThread();
-
-	void InitThread() {
-		PreprocessorThread::InitThread();
-	}
-	void RunThread() {
-		start(QThread::LowPriority);
-	}
-
-	// This function has to be defined by the thread library used...
-	virtual int GetCurrentThreadId() const;
-
-protected:
-	void run() {
-		Main();
-	}
-};
-
-}
-
-#endif
-#endif
