Index: OGRE/trunk/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h
===================================================================
--- OGRE/trunk/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h	(revision 115)
+++ OGRE/trunk/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h	(revision 657)
@@ -46,4 +46,5 @@
   *
   * @author Lee Sandberg
+  * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
   */
 class _OgreExport HardwareOcclusionQuery
@@ -82,6 +83,6 @@
 	  *				UINT	m_uintNumberOfPixelsVisable;
 	  *				pullOcclusionQuery( &m_dwNumberOfPixelsVisable );
-	  *				You may not get the result directlly after the first pass or frame.
-	  *				Objects not visable must be tested every frame, visable objects may be tested less freqvent.
+	  *				You may not get the result directly after the first pass or frame.
+	  *				Objects not visible must be tested every frame, visible objects may be tested less frequently.
 	  *			
 	  */
@@ -112,8 +113,8 @@
 	  *   
 	  * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver
-	  * if you set it to 0 every hw occlusion test is acctually made. If you set it to 1 only the half of your queries are sent 
-	  * for all visable objects. 2 will result in 25% of all queries to acctualy be sent. 
-	  * New and none visable objects will be tested all the time.
-	  * This functionality is here because this class can keep track on visable and none visable objects for you.
+	  * if you set it to 0 every hardware occlusion test is actually made. If you set it to 1 only the half of your queries are sent 
+	  * for all visible objects. 2 will result in 25% of all queries to actually be sent. 
+	  * New and none visible objects will be tested all the time.
+	  * This functionality is here because this class can keep track on visible and none visible objects for you.
 	  * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
 	  */
Index: OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderSystem.h
===================================================================
--- OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderSystem.h	(revision 316)
+++ OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderSystem.h	(revision 657)
@@ -42,4 +42,5 @@
 #include "OgreGpuProgram.h"
 #include "OgrePlane.h"
+#include "OgreIteratorWrappers.h"
 
 namespace Ogre
@@ -173,5 +174,11 @@
         virtual void setConfigOption(const String &name, const String &value) = 0;
 
-		virtual HardwareOcclusionQuery* createHardwareOcclusionQuery() = 0;
+		/** Create an object for performing hardware occlusion queries. 
+		*/
+		virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0;
+
+		/** Destroy a hardware occlusion query object. 
+		*/
+		virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq);
 
         /** Validates the options set for the rendering system, returning a message if there are problems.
@@ -295,5 +302,6 @@
 				Description: External window handle, for embedding the OGRE context
 				Values: positive integer for W32 (HWND handle)
-				        posint:posint:posint for GLX (display:screen:windowHandle)
+				        poslong:posint:poslong (display*:screen:windowHandle) or
+				        poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX
 				Default: 0 (None)
 				**
@@ -301,5 +309,5 @@
 				Description: Parent window handle, for embedding the OGRE context
 				Values: positive integer for W32 (HWND handle)
-				        posint:posint:posint for GLX (display:screen:windowHandle)
+				        poslong:posint:poslong for GLX (display*:screen:windowHandle)
 				Default: 0 (None)
 				**
@@ -392,4 +400,11 @@
         virtual RenderTarget * detachRenderTarget( const String &name );
 
+		/// Iterator over RenderTargets
+		typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
+
+		/** Returns a specialised MapIterator over all render targets attached to the RenderSystem. */
+		virtual RenderTargetIterator getRenderTargetIterator(void) {
+			return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
+		}
         /** Returns a description of an error code.
         */
@@ -947,4 +962,45 @@
         virtual Real getMaximumDepthInputValue(void) = 0;
 
+		/** Defines a listener on the custom events that this render system 
+			can raise.
+		@see RenderSystem::addListener
+		*/
+		class _OgreExport Listener
+		{
+		public:
+			Listener() {}
+			virtual ~Listener() {}
+
+			/** A rendersystem-specific event occurred.
+			@param eventName The name of the event which has occurred
+			@param parameters A list of parameters that may belong to this event,
+				may be null if there are no parameters
+			*/
+			virtual void eventOccurred(const String& eventName, 
+				const NameValuePairList* parameters = 0) = 0;
+		};
+		/** Adds a listener to the custom events that this render system can raise.
+		@remarks
+			Some render systems have quite specific, internally generated events 
+			that the application may wish to be notified of. Many applications
+			don't have to worry about these events, and can just trust OGRE to 
+			handle them, but if you want to know, you can add a listener here.
+		@par
+			Events are raised very generically by string name. Perhaps the most 
+			common example of a render system specific event is the loss and 
+			restoration of a device in DirectX; which OGRE deals with, but you 
+			may wish to know when it happens. 
+		@see RenderSystem::getRenderSystemEvents
+		*/
+		virtual void addListener(Listener* l);
+		/** Remove a listener to the custom events that this render system can raise.
+		*/
+		virtual void removeListener(Listener* l);
+
+		/** Gets a list of the rendersystem specific events that this rendersystem
+			can raise.
+		@see RenderSystem::addListener
+		*/
+		virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
     protected:
 
@@ -984,4 +1040,18 @@
 
         bool mInvertVertexWinding;
+
+		/// List of names of events this rendersystem may raise
+		StringVector mEventNames;
+
+		/// Internal method for firing a rendersystem event
+		virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
+
+		typedef std::list<Listener*> ListenerList;
+		ListenerList mEventListeners;
+
+		typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList;
+		HardwareOcclusionQueryList mHwOcclusionQueries;
+
+
     };
 }
Index: OGRE/trunk/ogre_changes/OgreMain/include/OgreFrustum.h
===================================================================
--- OGRE/trunk/ogre_changes/OgreMain/include/OgreFrustum.h	(revision 61)
+++ OGRE/trunk/ogre_changes/OgreMain/include/OgreFrustum.h	(revision 657)
@@ -445,4 +445,7 @@
 		/** Disables any custom near clip plane. */
 		virtual void disableCustomNearClipPlane(void);
+		/** Is a custom near clip plane in use? */
+		virtual bool isCustomNearClipPlaneEnabled(void) const 
+		{ return mObliqueDepthProjection; }
 		
 
Index: OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h
===================================================================
--- OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h	(revision 343)
+++ OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h	(revision 657)
@@ -316,11 +316,12 @@
         }
 
-        /** Clears this group of renderables. 
-        @remarks
-            Doesn't delete any priority groups, just empties them. Saves on 
+       /** Clears this group of renderables. 
+        @param destroy
+            If false, doesn't delete any priority groups, just empties them. Saves on 
             memory deallocations since the chances are rougly the same kinds of 
-            renderables are going to be sent to the queue again next time.
-        */
-        void clear(void)
+            renderables are going to be sent to the queue again next time. If
+			true, completely destroys.
+        */
+        void clear(bool destroy = false)
         {
             PriorityMap::iterator i, iend;
@@ -328,8 +329,15 @@
             for (i = mPriorityGroups.begin(); i != iend; ++i)
             {
-                i->second->clear();
-            }
-
-        }
+				if (destroy)
+					delete i->second;
+				else
+					i->second->clear();
+            }
+
+			if (destroy)
+				mPriorityGroups.clear();
+
+        }
+
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE	
 		void clear(int passes)
Index: OGRE/trunk/ogre_changes/OgreMain/include/OgreSceneManager.h
===================================================================
--- OGRE/trunk/ogre_changes/OgreMain/include/OgreSceneManager.h	(revision 316)
+++ OGRE/trunk/ogre_changes/OgreMain/include/OgreSceneManager.h	(revision 657)
@@ -271,7 +271,4 @@
         */
         virtual void initRenderQueue(void);
-        /** Retrieves the internal render queue. */
-        virtual RenderQueue* getRenderQueue(void);
-
         /** Internal method for setting up the renderstate for a rendering pass.
             @param
@@ -282,5 +279,4 @@
         */
         virtual Pass* setPass(Pass* pass);
-
         /// A pass designed to let us render shadow colour on white for texture shadows
         Pass* mShadowCasterPlainBlackPass;
@@ -429,4 +425,6 @@
         virtual void createShadowTextures(unsigned short size, unsigned short count, 
 			PixelFormat fmt);
+        /// Internal method for destroying shadow textures (texture-based shadows)
+        virtual void destroyShadowTextures(void);
         /// Internal method for preparing shadow textures ready for use in a regular render
         virtual void prepareShadowTextures(Camera* cam, Viewport* vp);
@@ -582,4 +580,10 @@
 
         /** Removes (and destroys) all cameras from the scene.
+            @remarks
+                Some cameras are internal created to dealing with texture shadow,
+                their aren't supposed to destroy outside. So, while you are using
+                texture shadow, don't call this method, or you can set the shadow
+                technique other than texture-based, which will destroy all internal
+                created shadow cameras and textures.
         */
         virtual void removeAllCameras(void);
@@ -1025,4 +1029,10 @@
             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 
+		/** Return whether a key plane is enabled */
+		virtual bool isSkyPlaneEnabled(void) const { return mSkyPlaneEnabled; }
+
+		/** Get the sky plane node, if enabled. */
+		virtual SceneNode* getSkyPlaneNode(void) { return mSkyPlaneNode; }		
+
         /** Enables / disables a 'sky box' i.e. a 6-sided box at constant
             distance from the camera representing the sky.
@@ -1070,4 +1080,10 @@
             bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY,
             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+
+		/** Return whether a skybox is enabled */
+		virtual bool isSkyBoxEnabled(void) const { return mSkyBoxEnabled; }
+
+		/** Get the skybox node, if enabled. */
+		virtual SceneNode* getSkyBoxNode(void) const { return mSkyBoxNode; }
 
         /** Enables / disables a 'sky dome' i.e. an illusion of a curved sky.
@@ -1132,4 +1148,10 @@
             int xsegments = 16, int ysegments = 16, int ysegments_keep = -1,
             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+
+		/** Return whether a skydome is enabled */
+		virtual bool isSkyDomeEnabled(void) const { return mSkyDomeEnabled; }
+
+		/** Get the sky dome node, if enabled. */
+		virtual SceneNode* getSkyDomeNode(void) { return mSkyDomeNode; }		
 
         /** Sets the fogging mode applied to the scene.
@@ -1340,4 +1362,16 @@
             const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix, 
             bool doBeginEndFrame = false) ;
+
+        /** Retrieves the internal render queue, for advanced users only.
+        @remarks
+            The render queue is mainly used internally to manage the scene object 
+			rendering queue, it also exports some methods to allow advanced users 
+			to configure the behavior of rendering process.
+            Most methods provided by RenderQueue are supposed to be used 
+			internally only, you should reference to the RenderQueue API for 
+			more information. Do not access this directly unless you know what 
+			you are doing.
+        */
+        virtual RenderQueue* getRenderQueue(void);
 
         /** Registers a new RenderQueueListener which will be notified when render queues
