Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp	(revision 2858)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp	(revision 2858)
@@ -0,0 +1,9 @@
+#include "DeferredShader.h"
+
+using namespace std;
+
+
+namespace CHCDemoEngine
+{
+
+} // namespace
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h	(revision 2858)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h	(revision 2858)
@@ -0,0 +1,27 @@
+#ifndef _DeferredShader_H__
+#define _DeferredShader_H__
+
+#include "common.h"
+
+namespace CHCDemoEngine 
+{ 
+
+class FrameBufferObject;
+
+/** This class implements a deferred shading algorithm.
+*/
+class DeferredShader
+{
+public:
+	/** constructor requesting an opengl occlusion query.
+	*/
+	DeferredShader();
+
+	/** The algorithm renders the scene given an fbo.
+		The fbo must have color buffer, position buffer, normal buffer.
+	*/
+	void Render(FrameBufferObject *fbo);
+};
+
+} // namespace 
+#endif // _DeferredShader_H__
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h	(revision 2858)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h	(revision 2858)
@@ -0,0 +1,27 @@
+#ifndef _DeferredShader_H__
+#define _DeferredShader_H__
+
+#include "common.h"
+
+namespace CHCDemoEngine 
+{ 
+
+class FrameBufferObject;
+
+/** This class implements a deferred shading algorithm.
+*/
+class DeferredShader
+{
+public:
+	/** constructor requesting an opengl occlusion query.
+	*/
+	DeferredShader();
+
+	/** The algorithm renders the scene given an fbo.
+		The fbo must have color buffer, position buffer, normal buffer.
+	*/
+	void Render(FrameBufferObject *fbo);
+};
+
+} // namespace 
+#endif // _DeferredShader_H__
Index: /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp	(revision 2858)
+++ /GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp	(revision 2858)
@@ -0,0 +1,80 @@
+#include "DeferredShader.h"
+#include "glInterface.h"
+
+
+using namespace std;
+
+
+namespace CHCDemoEngine
+{
+
+void DeferredShader::Render(FrameBufferObject *fbo)
+{
+	glPushAttrib(GL_VIEWPORT_BIT);
+	glViewport(0, 0, fbo->GetWidth(), fbo->GetHeight());
+
+	glDisable(GL_ALPHA_TEST);
+	glDisable(GL_TEXTURE_2D);
+	glDisable(GL_LIGHTING);
+	
+	glMatrixMode(GL_PROJECTION);
+	glPushMatrix();
+	glLoadIdentity();
+
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix();
+	glLoadIdentity();
+
+	const float offs = 0.5f;
+	
+	glOrtho(-offs, offs, -offs, offs, 0, 1);
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	cgGLEnableProfile(RenderState::sCgFragmentProfile);
+
+	cgGLBindProgram(sCgDeferredProgram);
+
+	cgGLSetTextureParameter(sPositionsTexParam, positionsTex);
+	cgGLEnableTextureParameter(sPositionsTexParam);
+
+	cgGLSetTextureParameter(sColorsTexParam, colorsTex);
+	cgGLEnableTextureParameter(sColorsTexParam);
+
+	cgGLSetTextureParameter(sNormalsTexParam, normalsTex);
+	cgGLEnableTextureParameter(sNormalsTexParam);
+	
+	glColor3f(1.0f, 1.0f, 1.0f);
+
+	glBegin(GL_QUADS);
+
+	float offs2 = 0.5f;
+
+	glTexCoord2f(0, 0); glVertex3f(-offs2, -offs2, -0.5f);
+	glTexCoord2f(1, 0); glVertex3f( offs2, -offs2, -0.5f);
+	glTexCoord2f(1, 1); glVertex3f( offs2,  offs2, -0.5f);
+	glTexCoord2f(0, 1); glVertex3f(-offs2,  offs2, -0.5f);
+
+	glEnd();
+
+	cgGLDisableTextureParameter(sColorsTexParam);
+	cgGLDisableTextureParameter(sPositionsTexParam);
+	cgGLDisableTextureParameter(sNormalsTexParam);
+
+	cgGLDisableProfile(RenderState::sCgFragmentProfile);
+	
+	glEnable(GL_LIGHTING);
+	glDisable(GL_TEXTURE_2D);
+	
+	glMatrixMode(GL_PROJECTION);
+	glPopMatrix();
+
+	glMatrixMode(GL_MODELVIEW);
+	glPopMatrix();
+
+	glPopAttrib();
+
+	PrintGLerror("deferred shading");
+}
+
+
+} // namespace
