Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 971)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp	(revision 1151)
@@ -25,5 +25,4 @@
 
 //#include <OgreVisibilityTerrainSceneManager.h>
-//#include <OgreVisibilityOctreeSceneManager.h>
 #include <OgreOcclusionCullingSceneManager.h>
 
@@ -40,5 +39,4 @@
 namespace Ogre {
 
-//VisibilityOctreeSceneManagerFactory *visibilityOctreePlugin;
 //VisibilityTerrainSceneManagerFactory *visibilityTerrainPlugin;
 OcclusionCullingSceneManagerFactory *occlusionCullingPlugin;
@@ -52,5 +50,4 @@
 
 	// Create new scene manager
-	//visibilityOctreePlugin = new VisibilityOctreeSceneManagerFactory(visManager);
 	//visibilityTerrainPlugin = new VisibilityTerrainSceneManagerFactory(visManager);
 	occlusionCullingPlugin = new OcclusionCullingSceneManagerFactory(visManager);
@@ -59,5 +56,4 @@
 
 	// Register
-	//Root::getSingleton().addSceneManagerFactory(visibilityOctreePlugin);
 	//Root::getSingleton().addSceneManagerFactory(visibilityTerrainPlugin);
 	Root::getSingleton().addSceneManagerFactory(occlusionCullingPlugin);
@@ -66,5 +62,4 @@
 extern "C" void __declspec(dllexport) dllShutdownPlugin()
 {
-	//Root::getSingleton().removeSceneManagerFactory(visibilityOctreePlugin);
 	//Root::getSingleton().removeSceneManagerFactory(visibilityTerrainPlugin);
 	Root::getSingleton().removeSceneManagerFactory(occlusionCullingPlugin);
@@ -77,7 +72,7 @@
 	//delete heightmapTerrainPageSource;
 
-	// (HACK: crashes on delete!!!! FIX this 
-	//delete visibilityOctreePlugin;
-    //delete visibilityTerrainPlugin;
+	// BUG: crashes on delete!!!! FIX this 
+
+	 //delete visibilityTerrainPlugin;
 	delete occlusionCullingPlugin;
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 1150)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 1151)
@@ -841,5 +841,5 @@
 		sprintf(buf, "snap/i-%02d-", mPass);
 
-		renderer->mSnapPrefix = buf;
+		renderer->SetSnapPrefix(buf);
 	  }
 	  else
@@ -847,8 +847,8 @@
 		sprintf(buf, "snap/r-%02d-", mPass);
 
-		renderer->mSnapPrefix = buf;
+		renderer->SetSnapPrefix(buf);
 	  }
 
-	  renderer->mSnapErrorFrames = true;
+	  renderer->SetSnapErrorFrames(true);
 	}
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1148)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1151)
@@ -1289,8 +1289,8 @@
 	sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs);
 
-	int start = mViewCells.size() * minValid;
-	int end = mViewCells.size() * maxValid;
-
-	for (int i = 0; i < mViewCells.size(); ++ i)
+	int start = (int)(mViewCells.size() * minValid);
+	int end = (int)(mViewCells.size() * maxValid);
+
+	for (int i = 0; i < (int)mViewCells.size(); ++ i)
 	{
 		mViewCells[i]->SetValid(i >= start && i <= end);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1146)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 1151)
@@ -1,2 +1,6 @@
+#include <windows.h>
+#include <stdio.h>
+#include <crtdbg.h>
+
 #include "SamplingPreprocessor.h"
 #include "VssPreprocessor.h"
@@ -19,15 +23,46 @@
 #define USE_EXE_PATH false
 
-#include <crtdbg.h>
 
 using namespace GtpVisibilityPreprocessor;
 
 Preprocessor *preprocessor = NULL;
-GlRenderWidget *renderWidget = NULL;
+GlRendererWidget *rendererWidget = NULL;
+
+// DLL function signature
+typedef GlRendererWidget *(*importFunction)();
+
+int LoadMyDll()
+{
+	importFunction LoadRenderWidget;
+	
+    // Load DLL file
+	HINSTANCE hinstLib = LoadLibrary("QtRenderer.dll");
+	
+	if (hinstLib == NULL) 
+	{
+		cout << "ERROR: unable to load DLL\n";
+		return 1;
+	}
+
+	// Get function pointer
+    LoadRenderWidget = (importFunction)GetProcAddress(hinstLib, "LoadRenderWidget");
+	
+	if (LoadRenderWidget == NULL) 
+	{
+		cout << "ERROR: unable to find DLL function\n";
+		return 1;
+	}
+
+	// load the render window
+    rendererWidget = LoadRenderWidget();
+
+	return 0;
+}
+
 
 
 void Cleanup()
 {
-	DEL_PTR(renderWidget);
+	DEL_PTR(rendererWidget);
 	DEL_PTR(preprocessor);
 
@@ -40,11 +75,13 @@
 void DisplayWidget()
 {
+	if (!rendererWidget)
+		LoadMyDll();
+
 	// note matt: capsulate qt dependent code as good as possible
-	renderWidget = 
-		new GlRenderWidget(preprocessor->mSceneGraph, 
+	/*new GlRendererWidget(preprocessor->mSceneGraph, 
 						   preprocessor->mViewCellsManager, 
 						   preprocessor->mKdTree);
-
-	renderWidget->Show();
+*/
+	rendererWidget->Show();
 
 #if QT_ENABLED
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1146)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 1151)
@@ -78,35 +78,11 @@
 
 public:
-  ObjectContainer mObjects;
-   
-  Vector3 mViewPoint;
-  Vector3 mViewDirection;
-
-  int timerId;
-  bool mUseFalseColors;
-  bool mUseForcedColors;
-
-  HaltonSequence halton;
-  
-  int mFrame;
-  bool mWireFrame;
-  
-  bool mDetectEmptyViewSpace;
-  bool mSnapErrorFrames;
-
-  bool mUseGlLists;
-  
-  string mSnapPrefix;
-
-  KdTree *mKdTree;
-
-  //QWaitCondition mRenderingFinished;
-  
-  vector<OcclusionQuery *> mOcclusionQueries;
-  
+
   GlRenderer(SceneGraph *sceneGraph,
 			 ViewCellsManager *viewcells,
 			 KdTree *tree);
   
+  GlRenderer() {}
+
   virtual ~GlRenderer();
 
@@ -140,4 +116,39 @@
 
   int GetId(int r, int g, int b) const;
+
+  inline const bool GetSnapErrorFrames() { return mSnapErrorFrames; }
+  inline const string GetSnapPrefix() { return mSnapPrefix; }
+
+  inline void SetSnapErrorFrames(bool snapframes) { mSnapErrorFrames = snapframes; }
+  inline void SetSnapPrefix(const string &pref) { mSnapPrefix = pref; }
+
+protected:
+
+
+  vector<OcclusionQuery *> mOcclusionQueries;
+
+  ObjectContainer mObjects;
+   
+  Vector3 mViewPoint;
+  Vector3 mViewDirection;
+
+  int timerId;
+  bool mUseFalseColors;
+  bool mUseForcedColors;
+
+  HaltonSequence halton;
+  
+  int mFrame;
+  bool mWireFrame;
+  
+  bool mDetectEmptyViewSpace;
+  bool mSnapErrorFrames;
+
+  bool mUseGlLists;
+  
+  string mSnapPrefix;
+
+  KdTree *mKdTree;
+
 };
 
@@ -147,6 +158,6 @@
 {
 
-//Q_OBJECT
 public:
+
 GlRendererBuffer(SceneGraph *sceneGraph,
 				 ViewCellsManager *viewcells,
@@ -259,17 +270,15 @@
 /** Abstract class for implmenenting a gl render widget.
 */
-class GlRenderWidget
+class GlRendererWidget: public GlRenderer
 {
 public:
 	
-	GlRenderWidget(SceneGraph *sceneGraph, ViewCellsManager *vcm, KdTree *kdTree):
-	  mSceneGraph(sceneGraph), mViewCellsManager(vcm), mKdTree(kdTree)
-	{
-	}
-
-	
-	GlRenderWidget() {}
-
-    virtual ~GlRenderWidget() {}
+	GlRendererWidget(SceneGraph *sceneGraph, ViewCellsManager *vcm, KdTree *kdTree):
+	  GlRenderer(sceneGraph, vcm, kdTree)
+	{}
+
+    GlRendererWidget() {}
+
+    virtual ~GlRendererWidget() {}
 
 	//virtual void Create() {}
@@ -285,4 +294,6 @@
 };
 
+//extern GlRendererWidget *rendererWidget;
+
 };
 
Index: /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.cpp	(revision 1148)
+++ /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.cpp	(revision 1151)
@@ -30,6 +30,7 @@
 //static vector<OcclusionQuery *> sQueries;
 
-GlRendererWidget *rendererWidget = NULL;
-GlDebuggerWidget *debuggerWidget = NULL;
+QtGlRendererWidget *rendererWidget = NULL;
+QtGlDebuggerWidget *debuggerWidget = NULL;
+
 
 static inline bool ilt(Intersectable *obj1, Intersectable *obj2)
@@ -909,5 +910,5 @@
 
 void
-GlRendererWidget::SetupProjection(const int w, const int h, const float angle)
+QtGlRendererWidget::SetupProjection(const int w, const int h, const float angle)
 {
   if (!mTopView)
@@ -923,5 +924,5 @@
 
 void
-GlRendererWidget::RenderPvs()
+QtGlRendererWidget::RenderPvs()
 {
   SetupCamera();
@@ -984,5 +985,5 @@
 
 float
-GlRendererWidget::RenderErrors()
+QtGlRendererWidget::RenderErrors()
 {
   float pErrorPixels = -1.0f;
@@ -1110,5 +1111,5 @@
 
 void
-GlRendererWidget::mousePressEvent(QMouseEvent *e)
+QtGlRendererWidget::mousePressEvent(QMouseEvent *e)
 {
   int x = e->pos().x();
@@ -1121,5 +1122,5 @@
 
 void
-GlRendererWidget::mouseMoveEvent(QMouseEvent *e)
+QtGlRendererWidget::mouseMoveEvent(QMouseEvent *e)
 {
   float MOVE_SENSITIVITY = Magnitude(mSceneGraph->GetBox().Diagonal())*1e-3;
@@ -1149,12 +1150,12 @@
 
 void
-GlRendererWidget::mouseReleaseEvent(QMouseEvent *)
-{
-
-
-}
-
-void
-GlRendererWidget::resizeGL(int w, int h)
+QtGlRendererWidget::mouseReleaseEvent(QMouseEvent *)
+{
+
+
+}
+
+void
+QtGlRendererWidget::resizeGL(int w, int h)
 {
   SetupProjection(w, h);
@@ -1163,5 +1164,5 @@
 
 void
-GlRendererWidget::paintGL()
+QtGlRendererWidget::paintGL()
 {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1189,5 +1190,5 @@
 
 void
-GlRendererWidget::SetupCamera()
+QtGlRendererWidget::SetupCamera()
 {
   if (!mTopView)
@@ -1227,5 +1228,5 @@
 
 void
-GlRendererWidget::keyPressEvent ( QKeyEvent * e )
+QtGlRendererWidget::keyPressEvent ( QKeyEvent * e )
 {
   switch (e->key()) {
@@ -1253,5 +1254,5 @@
   
 
-GlRendererWidget::GlRendererWidget(SceneGraph *sceneGraph,
+QtGlRendererWidget::QtGlRendererWidget(SceneGraph *sceneGraph,
 								   ViewCellsManager *viewcells,
 								   KdTree *tree,
@@ -1261,5 +1262,5 @@
 								   )
   :
-  GlRenderer(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f)
+  GlRendererWidget(sceneGraph, viewcells, tree), QGLWidget(parent, shareWidget, f)
 {
   mTopView = false;
@@ -1286,5 +1287,5 @@
   mPvsSize = 0;
   mRenderError = 0.0f;
-  mControlWidget = new RendererControlWidget(NULL);
+  mControlWidget = new QtRendererControlWidget(NULL);
   
   connect(mControlWidget, SIGNAL(SetViewCellGranularity(int)), this, SLOT(SetViewCellGranularity(int)));
@@ -1313,5 +1314,5 @@
 
 void
-GlRendererWidget::RenderInfo()
+QtGlRendererWidget::RenderInfo()
 {
   QString s;
@@ -1438,5 +1439,5 @@
 
 void
-GlRendererWidget::SetViewCellGranularity(int number)
+QtGlRendererWidget::SetViewCellGranularity(int number)
 {
   if (mViewCellsManager) 
@@ -1448,5 +1449,5 @@
 
 void
-GlRendererWidget::SetVisibilityFilterSize(int number)
+QtGlRendererWidget::SetVisibilityFilterSize(int number)
 {
   if (mViewCellsManager) 
@@ -1456,5 +1457,5 @@
 
 void
-GlRendererWidget::SetSpatialFilterSize(int number)
+QtGlRendererWidget::SetSpatialFilterSize(int number)
 {
   mSpatialFilterSize = 1e-3*number;
@@ -1463,5 +1464,5 @@
 
 void
-GlRendererWidget::SetSceneCut(int number)
+QtGlRendererWidget::SetSceneCut(int number)
 {
   // assume the cut plane can only be aligned with xz plane
@@ -1478,5 +1479,5 @@
 
 void
-GlRendererWidget::SetTopDistance(int number)
+QtGlRendererWidget::SetTopDistance(int number)
 {
   mTopDistance = number/1000.0f;
@@ -1485,5 +1486,5 @@
 
 void
-GlRendererWidget::RenderViewCells()
+QtGlRendererWidget::RenderViewCells()
 {
   mUseFalseColors = true;
@@ -1543,9 +1544,9 @@
 
 /***********************************************************************/
-/*                     GlDebuggerWidget implementation				   */
+/*                     QtGlDebuggerWidget implementation				   */
 /***********************************************************************/
 
 
-GlDebuggerWidget::GlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent)
+QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent)
       : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf)
 {
@@ -1557,5 +1558,5 @@
 
 
-GlDebuggerWidget::~GlDebuggerWidget()
+QtGlDebuggerWidget::~QtGlDebuggerWidget()
 {
  mRenderBuffer->releaseFromDynamicTexture();
@@ -1567,5 +1568,5 @@
 
 
-RendererControlWidget::RendererControlWidget(QWidget * parent, Qt::WFlags f):
+QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f):
   QWidget(parent, f)
 {
@@ -1730,12 +1731,12 @@
 
 void
-RendererControlWidget::FocusNextPvsErrorFrame(void)
-{
-  
-  
-}
-
-void
-RendererControlWidget::UpdatePvsErrorItem(int row,
+QtRendererControlWidget::FocusNextPvsErrorFrame(void)
+{
+  
+  
+}
+
+void
+QtRendererControlWidget::UpdatePvsErrorItem(int row,
 										  GlRendererBuffer::PvsErrorEntry &pvsErrorEntry)
 {
@@ -1753,5 +1754,5 @@
 
 
-void GlDebuggerWidget::initializeGL()
+void QtGlDebuggerWidget::initializeGL()
 {
 	glMatrixMode(GL_PROJECTION);
@@ -1770,5 +1771,5 @@
 
 
-void GlDebuggerWidget::resizeGL(int w, int h)
+void QtGlDebuggerWidget::resizeGL(int w, int h)
 {
 	glViewport(0, 0, w, h);
@@ -1776,5 +1777,5 @@
 
 
-void GlDebuggerWidget::paintGL()
+void QtGlDebuggerWidget::paintGL()
 {
 	// draw a spinning cube into the pbuffer..
@@ -1809,5 +1810,5 @@
 
 
-void GlDebuggerWidget::initPbuffer()
+void QtGlDebuggerWidget::initPbuffer()
 {
 	// set up the pbuffer context
@@ -1833,5 +1834,5 @@
 }
 
-void GlDebuggerWidget::initCommon()
+void QtGlDebuggerWidget::initCommon()
 {
 	glEnable(GL_TEXTURE_2D);
Index: /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.h	(revision 1150)
+++ /GTP/trunk/Lib/Vis/QtRenderer/QtGlRenderer.h	(revision 1151)
@@ -126,5 +126,5 @@
 
 
-class __declspec(dllexport) RendererControlWidget : public QWidget
+class __declspec(dllexport) QtRendererControlWidget : public QWidget
 {
   Q_OBJECT
@@ -133,5 +133,5 @@
   QListWidget *mPvsErrorWidget;
 
-  RendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
+  QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
 
   public slots:
@@ -163,5 +163,5 @@
 };
 
-class __declspec(dllexport) GlRendererWidget : public QGLWidget, public GlRenderer
+class __declspec(dllexport) QtGlRendererWidget : public QGLWidget, public GlRendererWidget
 {
   Q_OBJECT
@@ -191,7 +191,7 @@
   float mRenderError;
 
-  RendererControlWidget *mControlWidget;
-  
-  GlRendererWidget(SceneGraph *sceneGraph,
+  QtRendererControlWidget *mControlWidget;
+  
+  QtGlRendererWidget(SceneGraph *sceneGraph,
 				   ViewCellsManager *viewcells,
 				   KdTree *tree,
@@ -199,4 +199,5 @@
 				   );
 
+  QtGlRendererWidget() {};
 
   virtual void SetupCamera();
@@ -305,12 +306,10 @@
 
 
-extern GlRendererWidget *rendererWidget;
-
-class GlDebuggerWidget : public QGLWidget
+class QtGlDebuggerWidget : public QGLWidget
 {
 	Q_OBJECT
 public:
-    GlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
-    ~GlDebuggerWidget();
+    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
+    ~QtGlDebuggerWidget();
     void initializeGL();
     void resizeGL(int w, int h);
@@ -335,5 +334,5 @@
 };
 
-extern GlDebuggerWidget *debuggerWidget;
+extern QtGlDebuggerWidget *debuggerWidget;
 
 };
Index: /GTP/trunk/Lib/Vis/QtRenderer/QtRendererDll.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/QtRenderer/QtRendererDll.cpp	(revision 1151)
+++ /GTP/trunk/Lib/Vis/QtRenderer/QtRendererDll.cpp	(revision 1151)
@@ -0,0 +1,29 @@
+#include "QtGlRenderer.h"
+
+
+namespace GtpVisibilityPreprocessor {
+
+
+//QtGlRendererWidget *rendererWidget = NULL;
+//QtGlDebuggerWidget *debuggerWidget = NULL;
+
+//-----------------------------------------------------------------------
+extern "C" GlRendererWidget *__declspec(dllexport) LoadRenderWidget(void)
+{
+	return new QtGlRendererWidget();
+}
+
+/*//-----------------------------------------------------------------------
+extern "C" void __declspec(dllexport) dllShutdownPlugin()
+{
+	delete rendererWidget;
+}*/
+//-----------------------------------------------------------------------
+extern "C" void __declspec(dllexport) dllStopPlugin()
+{
+	//delete rendererWidget;
+}
+
+
+
+} 
Index: /GTP/trunk/Lib/Vis/QtRenderer/QtRenderer.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/QtRenderer/QtRenderer.vcproj	(revision 1150)
+++ /GTP/trunk/Lib/Vis/QtRenderer/QtRenderer.vcproj	(revision 1151)
@@ -126,4 +126,7 @@
 				RelativePath=".\QtGlRenderer.cpp">
 			</File>
+			<File
+				RelativePath=".\QtRendererDll.cpp">
+			</File>
 		</Filter>
 		<Filter
