Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp	(revision 2856)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp	(revision 2857)
@@ -66,9 +66,9 @@
 	switch (filterType)
 	{
-	case WRAP_NEAREST:
+	case FILTER_NEAREST:
 		filterParam = GL_NEAREST; break;
-	case WRAP_LINEAR:
+	case FILTER_LINEAR:
 		filterParam = GL_LINEAR; break;
-	case WRAP_MIPMAP_LINEAR: 
+	case FILTER_MIPMAP_LINEAR: 
 		filterParam = GL_LINEAR_MIPMAP_LINEAR; break;
 	}
@@ -79,8 +79,8 @@
 	switch (wrapType)
 	{
-	case GL_REPEAT:
-		wrapParam = GL_NEAREST; break;
-	case GL_CLAMP_TO_EDGE:
-		wrapParam = GL_LINEAR; break;
+	case WRAP_REPEAT:
+		wrapParam = GL_REPEAT; break;
+	case WRAP_CLAMP_TO_EDGE:
+		wrapParam = GL_CLAMP_TO_EDGE; break;
 	}
 
@@ -91,4 +91,5 @@
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapParam);
 
+	// print status
 	PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
 }
@@ -124,9 +125,23 @@
 		glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormat, mWidth, mHeight);
 		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthId);
+	}
 
-		PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
-	}
+	// print status
+	PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
 }
 
 
+ColorBufferObject *FrameBufferObject::AddColorBuffer(ColorBufferObject::FORMAT col, 
+													 ColorBufferObject::WRAP_TYPE wrapType, 
+													 ColorBufferObject::FILTER_TYPE filterType, 
+													 bool useMipMap, 
+													 bool useMultiSampling)
+{
+	ColorBufferObject *colorBuf = 
+		new ColorBufferObject(mWidth, mHeight, col, wrapType, filterType, useMipMap, useMultiSampling);
+	mColorBuffers.push_back(colorBuf);
+
+	return colorBuf;
+}
+
 } // namespace
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2856)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2857)
@@ -32,4 +32,5 @@
 #include "Transform3.h"
 #include "SampleGenerator.h"
+#include "FrameBufferObject.h"
 
 
@@ -201,4 +202,6 @@
 static Matrix4x4 matProjectionView = IdentityMatrix();
 
+FrameBufferObject *myfbo = NULL;
+
 
 // function forward declarations
@@ -466,5 +469,5 @@
 	CreateNoiseTex2D();
 
-	// init render traverser
+	// initialize the render traverser
 	ResetTraverser();
 
@@ -476,5 +479,5 @@
 	frameTimer.Start();
 
-
+	// the rendering loop
 	glutMainLoop();
 
@@ -663,4 +666,33 @@
 void InitFBO()
 {
+	// this fbo basicly stores the scene information we get from standard rendering of a frame
+	// we store colors, normals, positions (for the ssao)
+	myfbo = new FrameBufferObject(texWidth, texHeight, true, FrameBufferObject::DEPTH_24);
+
+
+	ColorBufferObject *diffuseBuffer = 
+		myfbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, 
+		                      ColorBufferObject::WRAP_CLAMP_TO_EDGE, 
+							  ColorBufferObject::FILTER_LINEAR, 
+							  false, false);
+
+	ColorBufferObject *mypositionBuffer = 
+		myfbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, 
+		                      ColorBufferObject::WRAP_CLAMP_TO_EDGE, 
+							  ColorBufferObject::FILTER_NEAREST, 
+							  false, false);
+
+
+	ColorBufferObject *mynormalsBuffer = 
+		myfbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, 
+		                      ColorBufferObject::WRAP_CLAMP_TO_EDGE, 
+							  ColorBufferObject::FILTER_NEAREST, 
+							  false, false);
+
+	
+
+
+	////////////////////////
+
 	glGenFramebuffersEXT(1, &fbo);
 	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
@@ -673,9 +705,12 @@
 	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer);
 	
+#if 1
 	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight);
-
+#else
 	int samples = 8;
-	//glEnable(GL_MULTISAMPLE_ARB);
-	//glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA8, texWidth, texHeight);
+	glEnable(GL_MULTISAMPLE_ARB);
+	glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA8, texWidth, texHeight);
+#endif
+
 	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer);
 	
@@ -1111,4 +1146,5 @@
 
 
+// the main rendering loop
 void Display() 
 {	
@@ -1166,9 +1202,11 @@
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
-		state.SetRenderType(RenderState::DEPTH_PASS);
-		glDisable(GL_LIGHTING);
-
 		cgGLDisableProfile(RenderState::sCgFragmentProfile);
 		cgGLDisableProfile(RenderState::sCgVertexProfile);
+
+		state.SetRenderType(RenderState::DEPTH_PASS);
+
+		// the scene is rendered withouth any shading	
+		glDisable(GL_LIGHTING);
 	
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1219,30 +1257,15 @@
 	SetupEyeView();
 
-
-	/*state.Reset();
-	state.SetState(RenderState::RENDER);
-	
+	// actually render the scene geometry using one of the specified algorithms
+	traverser->RenderScene();
+
+
+
+	/////////
+	//-- do the rest of the rendering
+
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_NORMAL_ARRAY);
 
-	for (int i = 0; i < loader->mSceneEntities.size(); ++ i)
-	{
-		SceneEntity *ent = loader->mSceneEntities[i];
-
-		ent->UpdateLODs(camera);
-		ent->Render(&state);
-	}*/
-
-	// actually render the scene geometry using one of the specified algorithms
-	traverser->RenderScene();
-
-
-
-	/////////
-	//-- do the rest of the rendering
-
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glEnableClientState(GL_NORMAL_ARRAY);
-
 
 	// reset depth pass and render visible objects
@@ -1264,7 +1287,8 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 
+
 	if (renderType == RenderState::DEFERRED) 
 	{
-		glPopAttrib();
+		//glPopAttrib();
 		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
@@ -1296,5 +1320,5 @@
 	}
 
-	glFlush();
+	//glFlush();
 
 	const bool restart = true;
@@ -1303,4 +1327,5 @@
 	DisplayStats();
 
+	// flip textures for temporal smoothing
 	isFirstTexture = !isFirstTexture;
 
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h	(revision 2856)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h	(revision 2857)
@@ -17,6 +17,6 @@
 
 	enum FORMAT { BUFFER_UBYTE, BUFFER_FLOAT_16, BUFFER_FLOAT_32 };
-	enum FILTER_TYPE { GL_REPEAT, GL_CLAMP_TO_EDGE };
-	enum WRAP_TYPE { WRAP_NEAREST, WRAP_LINEAR, WRAP_MIPMAP_LINEAR };
+	enum WRAP_TYPE{ WRAP_REPEAT, WRAP_CLAMP_TO_EDGE };
+	enum FILTER_TYPE { FILTER_NEAREST, FILTER_LINEAR, FILTER_MIPMAP_LINEAR };
 
 	ColorBufferObject(int w, int h, 
@@ -48,6 +48,6 @@
 	*/
 	ColorBufferObject *AddColorBuffer(ColorBufferObject::FORMAT col, 
-		                              int wrapType, 
-									  int filterType, 
+		                              ColorBufferObject::WRAP_TYPE wrapType, 
+									  ColorBufferObject::FILTER_TYPE filterType, 
 									  bool useMipMap, 
 									  bool useMultiSampling);
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2854)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 2857)
@@ -216,4 +216,12 @@
 			</File>
 			<File
+				RelativePath=".\src\DeferredShader.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\DeferredShader.h"
+				>
+			</File>
+			<File
 				RelativePath=".\src\Environment.cpp"
 				>
@@ -221,4 +229,12 @@
 			<File
 				RelativePath=".\src\Environment.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\FrameBufferObject.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\FrameBufferObject.h"
 				>
 			</File>
@@ -515,8 +531,4 @@
 				</File>
 				<File
-					RelativePath=".\src\FrameBufferObject.h"
-					>
-				</File>
-				<File
 					RelativePath=".\src\Geometry.h"
 					>
@@ -618,8 +630,4 @@
 				<File
 					RelativePath=".\src\chcdemo.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\src\FrameBufferObject.cpp"
 					>
 				</File>
