Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2862)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp	(revision 2877)
@@ -7,5 +7,6 @@
 #include <IL/il.h>
 #include <assert.h>
-#include "RenderTexture.h"
+#include "FrameBufferObject.h"
+
 
 
@@ -16,4 +17,6 @@
 
 
+static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
+
 
 static void PrintGLerror(char *msg)
@@ -48,13 +51,14 @@
 
 
-void GrabDepthBuffer(float *data, RenderTexture *rt)
-{
-	rt->BindDepth();
-	rt->EnableTextureTarget();
-
-	const int texFormat = GL_DEPTH_COMPONENT;
-	glGetTexImage(rt->GetTextureTarget(), 0, texFormat, GL_FLOAT, data);
-
-	rt->DisableTextureTarget();
+//void GrabDepthBuffer(float *data, RenderTexture *rt)
+void GrabDepthBuffer(float *data, GLuint depthTexture)
+{
+	glEnable(GL_TEXTURE_2D);
+	glBindTexture(GL_TEXTURE_2D, depthTexture);
+
+	glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT, data);
+
+	glBindTexture(GL_TEXTURE_2D, 0);
+	glDisable(GL_TEXTURE_2D);
 }
 
@@ -136,56 +140,57 @@
 	orthoCam->SetPosition(pos);
 
-	RenderTexture *depthTexture = new RenderTexture(texWidth, texHeight, true, true);
-
-#ifdef ATI
-	depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32, RenderTexture::RT_COPY_TO_TEXTURE);
-#else
-	depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32);
-#endif
-
-	PrintGLerror("Init");
-
-	depthTexture->BeginCapture();
-	{
-		glViewport(0, 0, texWidth, texHeight);
-		glPushAttrib(GL_VIEWPORT_BIT);
-
-		glClearColor(1, 1, 1, 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_PROJECTION);
-		glPushMatrix();
-
-		glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 
-
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-
-		orthoCam->SetupCameraView();
-
-		mDepth = new float[texHeight * texWidth];
-
-		//renderer->SetCamera(orthoCam);
-		renderer->RenderScene();
-
-		glPopMatrix();
-		glPopMatrix();
-
-		glPopAttrib();
-	}
-	depthTexture->EndCapture();
-
-	GrabDepthBuffer(mDepth, depthTexture);
-	//ExportDepthBuffer(mDepth); PrintGLerror("grab");
-
-	DEL_PTR(depthTexture);
+	FrameBufferObject *fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32, true);
+	fbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false);
+
+	PrintGLerror("here667");
+
+	fbo->Bind();
+
+	glDrawBuffers(1, mrt);
+	
+	glViewport(0, 0, texWidth, texHeight);
+	glPushAttrib(GL_VIEWPORT_BIT);
+
+	glClearColor(1, 1, 1, 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_PROJECTION);
+	glPushMatrix();
+
+
+	glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 
+
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix();
+
+	orthoCam->SetupCameraView();
+
+	mDepth = new float[texHeight * texWidth];
+
+	renderer->RenderScene();
+	
+	glPopMatrix();
+	glMatrixMode(GL_PROJECTION);
+	
+	glPopMatrix();
+
+	glPopAttrib();
+	
+	FrameBufferObject::Release();
+
+	GrabDepthBuffer(mDepth, fbo->GetDepthTex());
+	
+	ExportDepthBuffer(mDepth); 
+	PrintGLerror("grab");
+
+	DEL_PTR(fbo);
 	DEL_PTR(orthoCam);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2875)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2877)
@@ -225,5 +225,5 @@
 DeferredShader *deferredShader = NULL;
 
-GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
+static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h	(revision 2867)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h	(revision 2877)
@@ -65,4 +65,5 @@
 	static void Release();
 	
+	unsigned int GetDepthTex() const { return mDepthTexId; }
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2873)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2877)
@@ -292,12 +292,4 @@
 			</File>
 			<File
-				RelativePath=".\src\RenderTexture.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\src\RenderTexture.h"
-				>
-			</File>
-			<File
 				RelativePath=".\src\SampleGenerator.cpp"
 				>
