Index: /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 26)
+++ /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h	(revision 28)
@@ -40,5 +40,4 @@
 		~OcclusionCullingSceneManager();
 	
-
 		enum {RENDER_CULL_FRUSTUM, RENDER_STOP_AND_WAIT, RENDER_COHERENT, NUM_RENDERMODES};
 		
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 26)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 28)
@@ -27,6 +27,6 @@
 	OcclusionCullingSceneManager::~OcclusionCullingSceneManager()
 	{		
-		delete mHalfBoundingBox[0];
-		delete mHalfBoundingBox[1];
+		if(mHalfBoundingBox[0]) delete mHalfBoundingBox[0];
+		if(mHalfBoundingBox[1]) delete mHalfBoundingBox[1];
 
 		deleteQueries();
Index: /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 18)
+++ /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 28)
@@ -6,4 +6,15 @@
 */
 
+#pragma warning (push)
+#pragma warning( disable : 4267 )
+
+#include <OgreNoMemoryMacros.h>
+#include <CEGUI/CEGUI.h>
+#include <../CEGUIRenderer/include/OgreCEGUIRenderer.h>
+#include <../CEGUIRenderer/include/OgreCEGUIResourceProvider.h>
+#include <../CEGUIRenderer/include/OgreCEGUITexture.h>
+#include <OgreMemoryMacros.h>
+#pragma warning (pop)
+/*
 #include <CEGUI/CEGUIImageset.h>
 #include <CEGUI/CEGUISystem.h>
@@ -21,5 +32,5 @@
 #include "OgreCEGUIRenderer.h"
 #include "OgreCEGUIResourceProvider.h"
-
+*/
 #include "Ogre.h"
 #include "TestCullingApplication.h"
Index: /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 27)
+++ /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 28)
@@ -7,4 +7,21 @@
 #include "OgreOcclusionCullingSceneManager.h"
 
+Real timeDelay = 0;
+#define KEY_PRESSED(_key,_timeDelay, _macro) \
+{ \
+    if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \
+{ \
+    timeDelay = _timeDelay; \
+    _macro ; \
+} \
+}
+
+String mAlgorithmTypeCaptions[OcclusionCullingSceneManager::NUM_RENDERMODES] = 
+{
+    "Cull Frustum", 
+	"Stop and Wait", 
+	"Coherent Occlusion Culling"
+};
+
 class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
 {
@@ -13,5 +30,5 @@
     MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer,
 					   SceneNode* shipNode)
-        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode),  mShutdownRequested(false)
+        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode)//,  mShutdownRequested(false)
     {
 
@@ -28,13 +45,18 @@
 		mAlgorithmType = OcclusionCullingSceneManager::RENDER_COHERENT;
 
-		//mMyOverlay = OverlayManager::getSingleton().getByName("scripts/MyPanel");
-		mMyOverlay = OverlayManager::getSingleton().getByName("Core/MyPanel");
-
-		//mDebugOverlay->hide();
-		//mMyOverlay->show();
 		// Register this so that we get mouse events.
         mEventProcessor->addMouseListener(this);
         mEventProcessor->addMouseMotionListener(this);
 		mEventProcessor->addKeyListener(this);
+
+		// show overlay
+        Overlay* pOver = OverlayManager::getSingleton().getByName("Example/ShadowsOverlay");    
+        mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/ShadowTechniqueInfo");
+        //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo");
+        //mInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/Info");
+
+		mAlgorithmInfo->setCaption("Algorithm: " + mAlgorithmTypeCaptions[mAlgorithmType]);
+        //mMaterialInfo->setCaption("Current: " + mAtheneMaterials[mCurrentAtheneMaterial]);
+        pOver->show();
     } // MouseQueryListener
 
@@ -43,51 +65,12 @@
     }
 
-	void myShowOverlay(bool show)
-	{
-		if (mDebugOverlay)
-        {
-            if (show)
-            {
-                mDebugOverlay->show();
-            }
-            else
-            {
-                mDebugOverlay->hide();
-            }
-        }
-		if(mMyOverlay)
-		{
-			mMyOverlay->show();
-		}
+   bool frameEnded(const FrameEvent& evt)
+    {
+        if (timeDelay >= 0) 
+            timeDelay -= evt.timeSinceLastFrame;
 
-	}
-    bool frameStarted(const FrameEvent &evt)
-    {
-	/*    Real MoveFactor = 80.0 * evt.timeSinceLastFrame;
- 
-		mInputDevice->capture();
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_UP))
-		{
-			mAlgorithmType = (mAlgorithmType + 1) % OcclusionCullingSceneManager::NUM_RENDERMODES;
-			//mShipNode->translate(0.0, MoveFactor, 0.0);
-		}
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
-			mShipNode->translate(0.0, -MoveFactor, 0.0);
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
-			mShipNode->translate(-MoveFactor, 0.0, 0.0);
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
-			mShipNode->translate(MoveFactor, 0.0, 0.0);		
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE))
-			return false;*/
-
-		if(mInputDevice->isKeyDown(Ogre::KC_L))
-			myShowOverlay(false);
-
-		return ExampleFrameListener::frameStarted(evt);
+        KEY_PRESSED(KC_O, 1, changeAlgorithm());
+      
+        return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt);        
     }
 
@@ -108,5 +91,5 @@
     // This is when the mouse is clicked, held and dragged.
     virtual void mouseDragged (MouseEvent *e);
-
+/*
     void keyPressed(KeyEvent* e)
     {
@@ -134,5 +117,5 @@
 	}
 
-	  bool frameEnded(const FrameEvent& evt)
+    bool frameEnded(const FrameEvent& evt)
     {
         if (mShutdownRequested)
@@ -141,7 +124,11 @@
             return ExampleFrameListener::frameEnded(evt);
     }
+*/
+	 void changeAlgorithm()
+    {
+        mAlgorithmType = ++mAlgorithmType % OcclusionCullingSceneManager::NUM_RENDERMODES;
+        mAlgorithmInfo->setCaption("Algorithm: " + mAlgorithmTypeCaptions[mAlgorithmType]);
+    }
 
-	void setAlgorithmType(int type) { mAlgorithmType = type; }
-	int getAlgorithmType() { return mAlgorithmType; }
 
 protected:
@@ -151,7 +138,7 @@
     CEGUI::Renderer *mGUIRenderer;     // cegui renderer
 	SceneNode* mShipNode;
-	bool mShutdownRequested;
+//	bool mShutdownRequested;
 	int mAlgorithmType;
-	Overlay *mMyOverlay;
+	OverlayElement *mAlgorithmInfo;
 };
 
