Index: GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.cpp	(revision 643)
+++ GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.cpp	(revision 724)
@@ -10,7 +10,8 @@
 
 RenderTraverser::RenderTraverser(): mFrameID(1), mVisibilityThreshold(0),
-mHierarchyRoot(NULL), mOcclusionQueries(NULL), mCurrentTestIdx(0), mIsQueryMode(false),
+mHierarchyRoot(NULL), mOcclusionQueries(NULL), mCurrentQueryIdx(0), mIsQueryMode(false),
 mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0),
-mRenderTime(0), mNumRenderedGeometry(0), mUseOptimization(true)
+mRenderTime(0), mNumRenderedGeometry(0), mUseOptimization(true),
+mUseArbQueries(false)
 {
 }
@@ -18,6 +19,5 @@
 RenderTraverser::~RenderTraverser()
 {
-	if(mOcclusionQueries) 
-		delete [] mOcclusionQueries;
+	DelQueries();
 }
 
@@ -47,5 +47,5 @@
 
 	mFrameID ++;
-	ResetQueries();
+	
 
 	long endTime = getTime();
@@ -267,11 +267,20 @@
 }
 
-bool RenderTraverser::ResultAvailable(HierarchyNode *node)
-{
-	int result;
-
-	glGetQueryivARB(node->GetOcclusionQuery(),
-					GL_QUERY_RESULT_AVAILABLE_ARB, &result);
-
+bool RenderTraverser::ResultAvailable(HierarchyNode *node) const
+{
+	unsigned int result;
+	if (mUseArbQueries)
+	{
+		glGetQueryObjectuivARB(node->GetOcclusionQuery(),
+							   GL_QUERY_RESULT_AVAILABLE_ARB, &result);
+	}
+	else
+	{
+		
+		glGetOcclusionQueryuivNV(node->GetOcclusionQuery(), 
+								 GL_PIXEL_COUNT_AVAILABLE_NV, &result);
+
+	}
+	
 	return (result == GL_TRUE);
 }
@@ -281,7 +290,5 @@
 	mHierarchyRoot = sceneRoot;
 
-	// not valid anymore for new hierarchy => delete
-	delete [] mOcclusionQueries;
-	mOcclusionQueries = NULL;
+	DelQueries();
 }
 
@@ -291,11 +298,18 @@
 }
 
-int RenderTraverser::GetOcclusionQueryResult(HierarchyNode *node)
+unsigned int RenderTraverser::GetOcclusionQueryResult(HierarchyNode *node) const
 {
 	unsigned int result;
-	
-	glGetQueryObjectuivARB(node->GetOcclusionQuery(), GL_QUERY_RESULT_ARB, &result);
-
-	return (int)result;
+
+	if (mUseArbQueries)
+	{
+		glGetQueryObjectuivARB(node->GetOcclusionQuery(), GL_QUERY_RESULT_ARB, &result);
+	}
+	else
+	{
+		glGetOcclusionQueryuivNV(node->GetOcclusionQuery(), GL_PIXEL_COUNT_NV, &result);
+	}
+
+	return result;
 }
 
@@ -330,9 +344,17 @@
 {
 	// get next available test id
-	unsigned int occlusionQuery = mOcclusionQueries[mCurrentTestIdx++];
+	unsigned int occlusionQuery = mOcclusionQueries[mCurrentQueryIdx ++];
 	
 	node->SetOcclusionQuery(occlusionQuery);
+
 	// do the actual occlusion query for this node
-	glBeginQueryARB(GL_SAMPLES_PASSED_ARB, occlusionQuery);
+	if (mUseArbQueries)
+	{
+		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, occlusionQuery);
+	}
+	else
+	{
+		glBeginOcclusionQueryNV(occlusionQuery);
+	}
 	
 	// if leaf and was visible => will be rendered anyway, thus we
@@ -350,12 +372,29 @@
 	}
 
-	glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+	if (mUseArbQueries)
+	{
+		glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+	}
+	else
+	{
+		glEndOcclusionQueryNV();
+	}
 }
 
 void RenderTraverser::Preprocess()
 {
-	if(!mOcclusionQueries)
+	if (!mOcclusionQueries)
 	{
 		mOcclusionQueries = new unsigned int[mHierarchyRoot->GetNumHierarchyNodes()];
+
+		// generate ids for occlusion test
+		if (mUseArbQueries)
+		{
+			glGenQueriesARB(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
+		}
+		else
+		{
+			glGenOcclusionQueriesNV(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
+		}
 	}
 
@@ -363,7 +402,6 @@
 	calcViewFrustumPlanes(&mClipPlanes, mProjViewMatrix);
 	calcAABNPVertexIndices(mNPVertexIndices, mClipPlanes);
-	// generate ids for occlusion test
-	glGenQueriesARB(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
-	mCurrentTestIdx = 0;
+
+	mCurrentQueryIdx = 0;
 
 	// reset statistics
@@ -375,8 +413,22 @@
 
 
-void RenderTraverser::ResetQueries()
-{
+void RenderTraverser::DelQueries()
+{
+	if (!mOcclusionQueries)
+		return;
+
 	// tell the driver that the occlusion queries won't be needed any more
-	glDeleteQueriesARB(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
+	if (mUseArbQueries)
+	{
+		glDeleteQueriesARB(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
+	}
+	else
+	{
+		glDeleteOcclusionQueriesNV(mHierarchyRoot->GetNumHierarchyNodes(), mOcclusionQueries);
+	}
+
+	delete [] mOcclusionQueries;
+
+	mOcclusionQueries = NULL;
 }
 
@@ -435,4 +487,15 @@
 }
 
+void RenderTraverser::SetUseArbQueries(const bool useArbQueries)
+{
+	DelQueries();
+	mUseArbQueries = useArbQueries;
+}
+
+bool RenderTraverser::GetUseArbQueries() const
+{
+	return mUseArbQueries;
+}
+
 long RenderTraverser::GetRenderTime()
 {
Index: GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.h	(revision 643)
+++ GTP/trunk/App/Demos/Vis/Teapots/RenderTraverser.h	(revision 724)
@@ -58,4 +58,9 @@
 	void SetUseOptimization(bool useOptimization);
 
+	//! if arb queries should be used instead of nv
+	void SetUseArbQueries(const bool useArbQueries);
+	//!	see set
+	bool GetUseArbQueries() const;
+
 protected:
 
@@ -70,5 +75,5 @@
 	
 	//! returns occlusion query result for specified node
-	int GetOcclusionQueryResult(HierarchyNode *node);
+	unsigned int GetOcclusionQueryResult(HierarchyNode *node) const;
 	//! the node is traversed as usual
 	void TraverseNode(HierarchyNode *node);
@@ -76,9 +81,9 @@
 	void PullUpVisibility(HierarchyNode *node);
 	//! is result available from query queue?
-	bool ResultAvailable(HierarchyNode *node);
+	bool ResultAvailable(HierarchyNode *node) const;
 	//! issues occlusion query for specified node
 	void IssueOcclusionQuery(HierarchyNode *node, bool wasVisible);
 	//! resets occlusion queries after a traversal
-	void ResetQueries();
+	void DelQueries();
 	//! does view frustum culling. returns intersect (if intersects view plane)
 	bool InsideViewFrustum(HierarchyNode *node, bool &intersects);
@@ -88,5 +93,9 @@
 	void Switch2GLQueryState();
 
+
 protected:
+
+	/// if arb queries should be instead of nv
+	bool mUseArbQueries;
 
 	// the current clip planes of the view frustum
@@ -95,6 +104,8 @@
 	int mNPVertexIndices[12];
 
+	// the current view point
 	Vector3 mViewpoint;
 	Matrix4x4 mProjViewMatrix;
+	// the root of the scene hierarchy
 	HierarchyNode *mHierarchyRoot;
 	//TraversalStack mTraversalStack;
@@ -105,5 +116,5 @@
 	int mVisibilityThreshold;
 	unsigned int *mOcclusionQueries;
-	int mCurrentTestIdx;
+	int mCurrentQueryIdx;
 	bool mIsQueryMode;
 	
Index: GTP/trunk/App/Demos/Vis/Teapots/occquery.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/Teapots/occquery.cpp	(revision 643)
+++ GTP/trunk/App/Demos/Vis/Teapots/occquery.cpp	(revision 724)
@@ -14,4 +14,7 @@
 #include <math.h>
 #include <time.h>
+
+bool arbQuerySupport = false;
+bool nvQuerySupport = false;
 
 double nearDist = 0.1; // eye near plane distance
@@ -68,4 +71,5 @@
 
 bool useOptimization = true;
+bool useArbQueries = false;
 
 Vector3 amb[2];
@@ -213,4 +217,5 @@
 		"'C'            - recreates the scene hierarchy",
 		"'G'            - enables/disables optimization to take geometry as occluder",
+		"'N'            - triggers NV / ARB queries",
 		"",
 		"'R'            - shows/hides recreation parameters",
@@ -357,11 +362,12 @@
 	
 	char *optstr[2] = {"", ", using optimization"};
-	
+	char *querystr[2] = {"NV", "ARB"};
+
 	float fps = 1000.0;
 	long renderTime = calcRenderTime();
 	if(renderTime) fps = 1000000.0f / (float)calcRenderTime();
 
-	sprintf(msg3, "Threshold: %4d, algorithm rendering time: %ld ms (%3.3f fps)%s", 
-			traverser.GetVisibilityThreshold(), renderTime / 1000, fps, optstr[useOptimization]);
+	sprintf(msg3, "Threshold: %4d, algorithm rendering time: %ld ms (%3.3f fps), queries: %s%s", 
+		traverser.GetVisibilityThreshold(), renderTime / 1000, fps, querystr[useArbQueries], optstr[useOptimization]);
 
 	string str;
@@ -494,4 +500,9 @@
 		traverser.SetUseOptimization(useOptimization);
 		break;
+	case 'n':
+	case 'N':
+		useArbQueries = !useArbQueries;
+		traverser.SetUseArbQueries(useArbQueries);
+		break;
 	case 'c':
 	case 'C':	
@@ -658,12 +669,21 @@
 {
 	GLenum err = glewInit();
-	if(GLEW_OK != err) {
+	if (GLEW_OK != err) 
+	{
 		// problem: glewInit failed, something is seriously wrong
-		fprintf(stderr,"Error: %s\n",glewGetErrorString(err));
+		fprintf(stderr,"Error: %s\n", glewGetErrorString(err));
 		exit(1);
 	}
 
-	if(!GLEW_ARB_occlusion_query) {
-		printf("I require the GL_ARB_occlusion_query OpenGL extension to work.\n");
+	if (GLEW_ARB_occlusion_query) 
+		arbQuerySupport = true;
+	
+	if (GLEW_NV_occlusion_query) 
+		nvQuerySupport = true;
+	
+
+	if  (!arbQuerySupport && !nvQuerySupport)
+	{
+		printf("I require the GL_ARB_occlusion_query or the GL_NV_occlusion_query OpenGL extension to work.\n");
 		exit(1);
 	}
Index: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 723)
+++ GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 724)
@@ -195,5 +195,5 @@
 	//mMyStatsAlgorithmInfo->setTop(top);
 
-	mMyStatsOverlay->show();
+	//mMyStatsOverlay->show();
 
 	if (1)
@@ -204,5 +204,5 @@
 	
 		// show stats overlays
-		showStats(false);
+		showStats(true);
 	}
 
