Explorar el Código

Fixed up render system manager
Restored references to render system

Marko Pintera hace 13 años
padre
commit
8417bea53d

+ 7 - 1
CamelotRenderer/CamelotRenderer.cpp

@@ -35,7 +35,13 @@ using namespace CamelotEngine;
 
 int _tmain(int argc, _TCHAR* argv[])
 {
-	const Ogre::String& name = CamelotEngine::gApplication().getRenderSystem()->getName();
+	//const Ogre::String& name = CamelotEngine::gApplication().getRenderSystem()->getName();
+
+	gApplication().startUp();
+
+	int a = 5;
+
+	gApplication().shutDown();
 
 	return 0;
 }

+ 3 - 1
CamelotRenderer/CamelotRenderer.vcxproj

@@ -91,6 +91,7 @@
     <ClInclude Include="CmApplication.h" />
     <ClInclude Include="CmD3D9RenderSystemFactory.h" />
     <ClInclude Include="CmRenderSystemFactory.h" />
+    <ClInclude Include="CmRenderSystemManager.h" />
     <ClInclude Include="OgreAlignedAllocator.h" />
     <ClInclude Include="OgreAxisAlignedBox.h" />
     <ClInclude Include="OgreBitwise.h" />
@@ -99,6 +100,7 @@
     <ClInclude Include="OgreColourValue.h" />
     <ClInclude Include="OgreCommon.h" />
     <ClInclude Include="OgreConfig.h" />
+    <ClInclude Include="OgreConfigOptionMap.h" />
     <ClInclude Include="OgreD3D9Device.h" />
     <ClInclude Include="OgreD3D9DeviceManager.h" />
     <ClInclude Include="OgreD3D9Driver.h" />
@@ -180,7 +182,7 @@
     <ClCompile Include="CamelotRenderer.cpp" />
     <ClCompile Include="CmApplication.cpp" />
     <ClCompile Include="CmD3D9RenderSystemFactory.cpp" />
-    <ClCompile Include="CmRenderSystemFactory.cpp" />
+    <ClCompile Include="CmRenderSystemManager.cpp" />
     <ClCompile Include="OgreAlignedAllocator.cpp" />
     <ClCompile Include="OgreAxisAlignedBox.cpp" />
     <ClCompile Include="OgreColourValue.cpp" />

+ 7 - 1
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -307,6 +307,12 @@
     <ClInclude Include="CmApplication.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="OgreConfigOptionMap.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="CmRenderSystemManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">
@@ -501,7 +507,7 @@
     <ClCompile Include="CmApplication.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="CmRenderSystemFactory.cpp">
+    <ClCompile Include="CmRenderSystemManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>

+ 18 - 0
CamelotRenderer/CmApplication.cpp

@@ -1,7 +1,25 @@
 #include "CmApplication.h"
 
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
+
 namespace CamelotEngine
 {
+	Application::Application()
+	{ }
+
+	void Application::startUp()
+	{
+		RenderSystemManager::initialize("D3D9RenderSystem");
+		RenderSystemManager::getActive()->_initialise(true, "Camelot Renderer");
+	}
+
+	void Application::shutDown()
+	{
+		if(RenderSystemManager::getActive() != nullptr)
+			RenderSystemManager::getActive()->shutdown();
+	}
+
 	Application& gApplication()
 	{
 		static Application application;

+ 3 - 16
CamelotRenderer/CmApplication.h

@@ -2,28 +2,15 @@
 
 #include <memory>
 
-#include "CmRenderSystemFactory.h"
-
-namespace Ogre
-{
-	class RenderSystem;
-	typedef std::shared_ptr<Ogre::RenderSystem> RenderSystemPtr;
-}
-
 namespace CamelotEngine
 {
 	class Application
 	{
 		public:
-			Application()
-			{
-				mActiveRenderSystem = RenderSystemManager::create("D3D9RenderSystem");
-			}
-
-			RenderSystemPtr getRenderSystem() { return mActiveRenderSystem; }
+			Application();
 
-		private:
-			RenderSystemPtr mActiveRenderSystem;
+			void startUp();
+			void shutDown();
 	};
 
 	Application& gApplication();

+ 1 - 0
CamelotRenderer/CmD3D9RenderSystemFactory.h

@@ -2,6 +2,7 @@
 
 #include <string>
 #include "CmRenderSystemFactory.h"
+#include "CmRenderSystemManager.h"
 #include "OgreD3D9RenderSystem.h"
 
 namespace CamelotEngine

+ 0 - 28
CamelotRenderer/CmRenderSystemFactory.cpp

@@ -1,28 +0,0 @@
-#include "CmRenderSystemFactory.h"
-
-namespace CamelotEngine
-{
-	RenderSystemPtr RenderSystemManager::create(const std::string& name)
-	{
-		for(auto iter = getAvailableFactories().begin(); iter != getAvailableFactories().end(); ++iter)
-		{
-			if((*iter)->name() == name)
-				return (*iter)->create();
-		}
-
-		return nullptr;
-	}
-
-	void RenderSystemManager::registerRenderSystemFactory(RenderSystemFactoryPtr factory)
-	{
-		assert(factory != nullptr);
-
-		getAvailableFactories().push_back(factory);
-	}
-
-	std::vector<RenderSystemFactoryPtr>& RenderSystemManager::getAvailableFactories()
-	{
-		static std::vector<RenderSystemFactoryPtr> availableFactories;
-		return availableFactories;
-	}
-}

+ 0 - 14
CamelotRenderer/CmRenderSystemFactory.h

@@ -1,9 +1,7 @@
 #pragma once
 
 #include <string>
-#include <vector>
 #include <memory>
-#include <assert.h>
 
 namespace Ogre
 {
@@ -20,16 +18,4 @@ namespace CamelotEngine
 		virtual RenderSystemPtr create() = 0;
 		virtual const std::string& name() const = 0;
 	};
-
-	typedef std::shared_ptr<RenderSystemFactory> RenderSystemFactoryPtr;
-
-	class RenderSystemManager
-	{
-	public:
-		static RenderSystemPtr create(const std::string& name);
-		static void registerRenderSystemFactory(RenderSystemFactoryPtr factory);
-
-	private:
-		static std::vector<RenderSystemFactoryPtr>& getAvailableFactories();
-	};
 }

+ 46 - 0
CamelotRenderer/CmRenderSystemManager.cpp

@@ -0,0 +1,46 @@
+#include "CmRenderSystemManager.h"
+#include "OgreException.h"
+#include "OgreRenderSystem.h"
+
+namespace CamelotEngine
+{
+	RenderSystemPtr RenderSystemManager::mActiveRenderSystem;
+
+	void RenderSystemManager::initialize(const std::string& name)
+	{
+		for(auto iter = getAvailableFactories().begin(); iter != getAvailableFactories().end(); ++iter)
+		{
+			if((*iter)->name() == name)
+			{
+				RenderSystemPtr newRenderSystem = (*iter)->create();
+				if(newRenderSystem != nullptr)
+				{
+					if(mActiveRenderSystem != nullptr)
+						mActiveRenderSystem->shutdown();
+
+					mActiveRenderSystem = newRenderSystem;
+				}				
+			}
+		}
+
+		if(mActiveRenderSystem == nullptr)
+		{
+			OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, 
+				"Cannot initialize render system. Renderer with the name '" + name + "' cannot be found.",
+				"RenderSystemManager::initialize")
+		}
+	}
+
+	void RenderSystemManager::registerRenderSystemFactory(RenderSystemFactoryPtr factory)
+	{
+		assert(factory != nullptr);
+
+		getAvailableFactories().push_back(factory);
+	}
+
+	std::vector<RenderSystemFactoryPtr>& RenderSystemManager::getAvailableFactories()
+	{
+		static std::vector<RenderSystemFactoryPtr> availableFactories;
+		return availableFactories;
+	}
+}

+ 27 - 0
CamelotRenderer/CmRenderSystemManager.h

@@ -0,0 +1,27 @@
+#pragma once
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <assert.h>
+
+#include "CmRenderSystemFactory.h"
+
+namespace CamelotEngine
+{
+	typedef std::shared_ptr<RenderSystemFactory> RenderSystemFactoryPtr;
+
+	class RenderSystemManager
+	{
+	public:
+		static void initialize(const std::string& name);
+		static Ogre::RenderSystem* getActive() { return mActiveRenderSystem.get(); }
+
+		static void registerRenderSystemFactory(RenderSystemFactoryPtr factory);
+	private:
+		static std::vector<RenderSystemFactoryPtr>& getAvailableFactories();
+
+		static RenderSystemPtr mActiveRenderSystem;
+	};
+}
+

+ 63 - 0
CamelotRenderer/OgreConfigOptionMap.h

@@ -0,0 +1,63 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2011 Torus Knot Software Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _ConfigOptionMap_H__
+#define _ConfigOptionMap_H__
+
+#include "OgrePrerequisites.h"
+
+#include "OgreStringVector.h"
+#include "OgreString.h"
+
+
+namespace Ogre {
+	/** \addtogroup Core
+	*  @{
+	*/
+	/** \addtogroup General
+	*  @{
+	*/
+	/** Packages the details of a configuration option.
+        @remarks
+            Used for RenderSystem::getConfigOptions. If immutable is true, this
+            option must be disabled for modifying.
+    */
+    typedef struct _ConfigOption
+    {
+        String name;
+        String currentValue;
+        StringVector possibleValues;
+        bool immutable;
+    } ConfigOption;
+
+    typedef map< String, ConfigOption >::type ConfigOptionMap;
+	/** @} */
+	/** @} */
+}
+
+#endif

+ 8 - 11
CamelotRenderer/OgreD3D9Device.cpp

@@ -33,6 +33,7 @@ THE SOFTWARE.
 #include "OgreD3D9RenderWindow.h"
 #include "OgreHardwareBufferManager.h"
 #include "OgreException.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre
 {
@@ -204,8 +205,7 @@ namespace Ogre
 	{
 		if (mpDevice != NULL)
 		{
-			// TODO PORT - Make sure to call this once rendersystem is active
-			//D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
+			D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
 
 			//// Clean up depth stencil surfaces
 			//renderSystem->_cleanupDepthStencils(mpDevice);	
@@ -243,11 +243,10 @@ namespace Ogre
 
 		// Case we just moved from valid state to lost state.
 		mDeviceLost = true;	
-		
-		// TODO PORT - Make sure to call this once rendersystem is active
-		//D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
-		//
-		//renderSystem->notifyOnDeviceLost(this);
+
+		D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
+
+		renderSystem->notifyOnDeviceLost(this);
 	}	
 
 	//---------------------------------------------------------------------
@@ -371,8 +370,7 @@ namespace Ogre
 		// Lock access to rendering device.
 		D3D9RenderSystem::getResourceManager()->lockDeviceAccess();
 					
-		// TODO PORT - Make sure to call this once rendersystem is active
-		//D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
+		D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
 
 		// Inform all resources that device lost.
 		D3D9RenderSystem::getResourceManager()->notifyOnDeviceLost(mpDevice);
@@ -598,8 +596,7 @@ namespace Ogre
 	//---------------------------------------------------------------------
 	void D3D9Device::clearDeviceStreams()
 	{
-		// TODO PORT - Make sure to call this once rendersystem is active
-		//D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
+		D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
 
 		// Set all texture units to nothing to release texture surfaces
 		for (DWORD stage = 0; stage < mD3D9DeviceCaps.MaxSimultaneousTextures; ++stage)

+ 36 - 41
CamelotRenderer/OgreD3D9DeviceManager.cpp

@@ -32,6 +32,7 @@ THE SOFTWARE.
 #include "OgreD3D9Driver.h"
 #include "OgreD3D9DriverList.h"
 #include "OgreException.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre
 {
@@ -62,23 +63,22 @@ namespace Ogre
 		{
 			mActiveDevice = device;
 
-			// TODO PORT - Make sure to enable once rendersystem is active
-			//D3D9RenderSystem*	renderSystem = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
-			//D3D9DriverList*		driverList	 = renderSystem->getDirect3DDrivers();
-
-			//// Update the active driver member.
-			//for (uint i=0; i < driverList->count(); ++i)
-			//{
-			//	D3D9Driver* currDriver = driverList->item(i);
-			//	if (currDriver->getAdapterNumber() == mActiveDevice->getAdapterNumber())
-			//	{
-			//		renderSystem->mActiveD3DDriver = currDriver;
-			//		break;
-			//	}				
-			//}	
-
-			//// Invalidate active view port.
-			//renderSystem->mActiveViewport = NULL;
+			D3D9RenderSystem* renderSystem = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
+			D3D9DriverList*		driverList	 = renderSystem->getDirect3DDrivers();
+
+			// Update the active driver member.
+			for (uint i=0; i < driverList->count(); ++i)
+			{
+				D3D9Driver* currDriver = driverList->item(i);
+				if (currDriver->getAdapterNumber() == mActiveDevice->getAdapterNumber())
+				{
+					renderSystem->mActiveD3DDriver = currDriver;
+					break;
+				}				
+			}	
+
+			// Invalidate active view port.
+			renderSystem->mActiveViewport = NULL;
 		}						
 	}
 
@@ -155,8 +155,8 @@ namespace Ogre
 	D3D9Device* D3D9DeviceManager::selectDevice(D3D9RenderWindow* renderWindow, D3D9RenderWindowList& renderWindowsGroup)
 	{
 		// TODO PORT - Make sure to enable once rendersystem is active
-		/*
-		D3D9RenderSystem*		renderSystem	 = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
+		
+		D3D9RenderSystem*		renderSystem	 = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
 		D3D9Device*				renderDevice	 = NULL;	
 		IDirect3D9*				direct3D9	     = D3D9RenderSystem::getDirect3D9();
 		UINT					nAdapterOrdinal  = D3DADAPTER_DEFAULT;
@@ -415,37 +415,32 @@ namespace Ogre
 		}				
 
 		return renderDevice;	
-		*/
-		return NULL;
 	}
 
 	//-----------------------------------------------------------------------
 	D3D9Driver* D3D9DeviceManager::findDriver(D3D9RenderWindow* renderWindow)
 	{
-		// TODO PORT - Make sure to enable once rendersystem is active
-		//D3D9RenderSystem*		renderSystem	 = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());		
-		//IDirect3D9*				direct3D9	     = D3D9RenderSystem::getDirect3D9();
-		//UINT					nAdapterOrdinal  = D3DADAPTER_DEFAULT;						
-		//HMONITOR				hRenderWindowMonitor = NULL;			
-		//D3D9DriverList*			driverList = renderSystem->getDirect3DDrivers();
-
-		//// Find the monitor this render window belongs to.
-		//hRenderWindowMonitor = MonitorFromWindow(renderWindow->getWindowHandle(), MONITOR_DEFAULTTONEAREST);
+		D3D9RenderSystem*		renderSystem	 = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());		
+		IDirect3D9*				direct3D9	     = D3D9RenderSystem::getDirect3D9();
+		UINT					nAdapterOrdinal  = D3DADAPTER_DEFAULT;						
+		HMONITOR				hRenderWindowMonitor = NULL;			
+		D3D9DriverList*			driverList = renderSystem->getDirect3DDrivers();
 
+		// Find the monitor this render window belongs to.
+		hRenderWindowMonitor = MonitorFromWindow(renderWindow->getWindowHandle(), MONITOR_DEFAULTTONEAREST);
 
-		//// Find the matching driver using window monitor handle.
-		//for (uint i = 0; i < driverList->count(); ++i)
-		//{
-		//	D3D9Driver* currDriver       = driverList->item(i);
-		//	HMONITOR hCurrAdpaterMonitor = direct3D9->GetAdapterMonitor(currDriver->getAdapterNumber());
 
-		//	if (hCurrAdpaterMonitor == hRenderWindowMonitor)
-		//	{
-		//		return currDriver;				
-		//	}
-		//}
+		// Find the matching driver using window monitor handle.
+		for (uint i = 0; i < driverList->count(); ++i)
+		{
+			D3D9Driver* currDriver       = driverList->item(i);
+			HMONITOR hCurrAdpaterMonitor = direct3D9->GetAdapterMonitor(currDriver->getAdapterNumber());
 
-		return NULL;
+			if (hCurrAdpaterMonitor == hRenderWindowMonitor)
+			{
+				return currDriver;				
+			}
+		}
 	}
 
 	//-----------------------------------------------------------------------

+ 4 - 4
CamelotRenderer/OgreD3D9HLSLProgram.cpp

@@ -30,6 +30,8 @@ THE SOFTWARE.
 #include "OgreStringConverter.h"
 #include "OgreD3D9GpuProgram.h"
 #include "OgreException.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
     //-----------------------------------------------------------------------
@@ -545,10 +547,8 @@ namespace Ogre {
         if (mCompileError || !isRequiredCapabilitiesSupported())
             return false;
 
-		// TODO PORT - Enable this once rendersystem has a singleton, for now just return true
-		//RenderSystem* rs = Root::getSingleton().getRenderSystem();
-		//return rs->getCapabilities()->isShaderProfileSupported(mTarget);
-		return true;
+		RenderSystem* rs = CamelotEngine::RenderSystemManager::getActive();
+		return rs->getCapabilities()->isShaderProfileSupported(mTarget);
     }
     //-----------------------------------------------------------------------
     GpuProgramParametersSharedPtr D3D9HLSLProgram::createParameters(void)

+ 3 - 4
CamelotRenderer/OgreD3D9HardwarePixelBuffer.cpp

@@ -32,6 +32,7 @@ THE SOFTWARE.
 #include "OgreStringConverter.h"
 #include "OgreBitwise.h"
 #include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
 
@@ -972,8 +973,7 @@ void D3D9HardwarePixelBuffer::updateRenderTexture(bool writeGamma, uint fsaa, co
 
 		mRenderTexture = new D3D9RenderTexture(name, this, writeGamma, fsaa);		
 
-		// TODO PORT - Call once I have rendersystem singleton
-		//Root::getSingleton().getRenderSystem()->attachRenderTarget(*mRenderTexture);
+		CamelotEngine::RenderSystemManager::getActive()->attachRenderTarget(*mRenderTexture);
 	}
 }
 //-----------------------------------------------------------------------------    
@@ -981,8 +981,7 @@ void D3D9HardwarePixelBuffer::destroyRenderTexture()
 {
 	if (mRenderTexture != NULL)
 	{
-		// TODO PORT - Call once I have rendersystem singleton
-		//Root::getSingleton().getRenderSystem()->destroyRenderTarget(mRenderTexture->getName());
+		CamelotEngine::RenderSystemManager::getActive()->destroyRenderTarget(mRenderTexture->getName());
 		mRenderTexture = NULL;
 	}
 }

+ 11 - 11
CamelotRenderer/OgreD3D9MultiRenderTarget.cpp

@@ -33,6 +33,7 @@ THE SOFTWARE.
 #include "OgreD3D9RenderSystem.h"
 #include "OgreD3D9Device.h"
 #include "OgreD3D9DeviceManager.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre 
 {
@@ -73,17 +74,16 @@ namespace Ogre
 					"D3D9MultiRenderTarget::bindSurface");
 			}
 
-			// TODO PORT - Not checking capabilities until I can get rendersystem singleton
-			//if (!Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_MRT_DIFFERENT_BIT_DEPTHS)
-			//	&& (PixelUtil::getNumElemBits(mRenderTargets[y]->getFormat()) != 
-			//		PixelUtil::getNumElemBits(buffer->getFormat())))
-			//{
-			//	OGRE_EXCEPT(
-			//		Exception::ERR_INVALIDPARAMS, 
-			//		"MultiRenderTarget surfaces are not of same bit depth and hardware requires it", 
-			//		"D3D9MultiRenderTarget::bindSurface"
-			//	);
-			//}
+			if (!CamelotEngine::RenderSystemManager::getActive()->getCapabilities()->hasCapability(RSC_MRT_DIFFERENT_BIT_DEPTHS)
+				&& (PixelUtil::getNumElemBits(mRenderTargets[y]->getFormat()) != 
+				PixelUtil::getNumElemBits(buffer->getFormat())))
+			{
+				OGRE_EXCEPT(
+					Exception::ERR_INVALIDPARAMS, 
+					"MultiRenderTarget surfaces are not of same bit depth and hardware requires it", 
+					"D3D9MultiRenderTarget::bindSurface"
+					);
+			}
 		}
 
 		mRenderTargets[attachment] = buffer;

+ 328 - 344
CamelotRenderer/OgreD3D9RenderSystem.cpp

@@ -169,110 +169,109 @@ namespace Ogre
 		D3D9DriverList* driverList;
 		D3D9Driver* driver;
 
-		// TODO PORT - I'm not going to use these config options, but I need to find another way to initialize the render system
-//		ConfigOption optDevice;
-//		ConfigOption optVideoMode;
-//		ConfigOption optFullScreen;
-//		ConfigOption optVSync;
-//		ConfigOption optVSyncInterval;
-//		ConfigOption optAA;
-//		ConfigOption optFPUMode;
-//		ConfigOption optNVPerfHUD;
-//		ConfigOption optSRGB;
-//		ConfigOption optResourceCeationPolicy;
-//
-//		driverList = this->getDirect3DDrivers();
-//
-//		optDevice.name = "Rendering Device";
-//		optDevice.currentValue.clear();
-//		optDevice.possibleValues.clear();
-//		optDevice.immutable = false;
-//
-//		optVideoMode.name = "Video Mode";
-//		optVideoMode.currentValue = "800 x 600 @ 32-bit colour";
-//		optVideoMode.immutable = false;
-//
-//		optFullScreen.name = "Full Screen";
-//		optFullScreen.possibleValues.push_back( "Yes" );
-//		optFullScreen.possibleValues.push_back( "No" );
-//		optFullScreen.currentValue = "Yes";
-//		optFullScreen.immutable = false;
-//
-//		optResourceCeationPolicy.name = "Resource Creation Policy";		
-//		optResourceCeationPolicy.possibleValues.push_back( "Create on all devices" );
-//		optResourceCeationPolicy.possibleValues.push_back( "Create on active device" );
-//
-//		if (mResourceManager->getCreationPolicy() == RCP_CREATE_ON_ACTIVE_DEVICE)
-//			optResourceCeationPolicy.currentValue = "Create on active device";			
-//		else if (mResourceManager->getCreationPolicy() == RCP_CREATE_ON_ALL_DEVICES)
-//			optResourceCeationPolicy.currentValue = "Create on all devices";
-//		else
-//			optResourceCeationPolicy.currentValue = "N/A";
-//		optResourceCeationPolicy.immutable = false;
-//
-//		for( unsigned j=0; j < driverList->count(); j++ )
-//		{
-//			driver = driverList->item(j);
-//			optDevice.possibleValues.push_back( driver->DriverDescription() );
-//			// Make first one default
-//			if( j==0 )
-//				optDevice.currentValue = driver->DriverDescription();
-//		}
-//
-//		optVSync.name = "VSync";
-//		optVSync.immutable = false;
-//		optVSync.possibleValues.push_back( "Yes" );
-//		optVSync.possibleValues.push_back( "No" );
-//		optVSync.currentValue = "No";
-//
-//		optVSyncInterval.name = "VSync Interval";
-//		optVSyncInterval.immutable = false;
-//		optVSyncInterval.possibleValues.push_back( "1" );
-//		optVSyncInterval.possibleValues.push_back( "2" );
-//		optVSyncInterval.possibleValues.push_back( "3" );
-//		optVSyncInterval.possibleValues.push_back( "4" );
-//		optVSyncInterval.currentValue = "1";
-//
-//		optAA.name = "FSAA";
-//		optAA.immutable = false;
-//		optAA.possibleValues.push_back( "None" );
-//		optAA.currentValue = "None";
-//
-//		optFPUMode.name = "Floating-point mode";
-//#if OGRE_DOUBLE_PRECISION
-//		optFPUMode.currentValue = "Consistent";
-//#else
-//		optFPUMode.currentValue = "Fastest";
-//#endif
-//		optFPUMode.possibleValues.clear();
-//		optFPUMode.possibleValues.push_back("Fastest");
-//		optFPUMode.possibleValues.push_back("Consistent");
-//		optFPUMode.immutable = false;
-//
-//		optNVPerfHUD.currentValue = "No";
-//		optNVPerfHUD.immutable = false;
-//		optNVPerfHUD.name = "Allow NVPerfHUD";
-//		optNVPerfHUD.possibleValues.push_back( "Yes" );
-//		optNVPerfHUD.possibleValues.push_back( "No" );
-//
-//
-//		// SRGB on auto window
-//		optSRGB.name = "sRGB Gamma Conversion";
-//		optSRGB.possibleValues.push_back("Yes");
-//		optSRGB.possibleValues.push_back("No");
-//		optSRGB.currentValue = "No";
-//		optSRGB.immutable = false;
-//
-//		mOptions[optDevice.name] = optDevice;
-//		mOptions[optVideoMode.name] = optVideoMode;
-//		mOptions[optFullScreen.name] = optFullScreen;
-//		mOptions[optVSync.name] = optVSync;
-//		mOptions[optVSyncInterval.name] = optVSyncInterval;
-//		mOptions[optAA.name] = optAA;
-//		mOptions[optFPUMode.name] = optFPUMode;
-//		mOptions[optNVPerfHUD.name] = optNVPerfHUD;
-//		mOptions[optSRGB.name] = optSRGB;
-//		mOptions[optResourceCeationPolicy.name] = optResourceCeationPolicy;
+		ConfigOption optDevice;
+		ConfigOption optVideoMode;
+		ConfigOption optFullScreen;
+		ConfigOption optVSync;
+		ConfigOption optVSyncInterval;
+		ConfigOption optAA;
+		ConfigOption optFPUMode;
+		ConfigOption optNVPerfHUD;
+		ConfigOption optSRGB;
+		ConfigOption optResourceCeationPolicy;
+
+		driverList = this->getDirect3DDrivers();
+
+		optDevice.name = "Rendering Device";
+		optDevice.currentValue.clear();
+		optDevice.possibleValues.clear();
+		optDevice.immutable = false;
+
+		optVideoMode.name = "Video Mode";
+		optVideoMode.currentValue = "800 x 600 @ 32-bit colour";
+		optVideoMode.immutable = false;
+
+		optFullScreen.name = "Full Screen";
+		optFullScreen.possibleValues.push_back( "Yes" );
+		optFullScreen.possibleValues.push_back( "No" );
+		optFullScreen.currentValue = "Yes";
+		optFullScreen.immutable = false;
+
+		optResourceCeationPolicy.name = "Resource Creation Policy";		
+		optResourceCeationPolicy.possibleValues.push_back( "Create on all devices" );
+		optResourceCeationPolicy.possibleValues.push_back( "Create on active device" );
+
+		if (mResourceManager->getCreationPolicy() == RCP_CREATE_ON_ACTIVE_DEVICE)
+			optResourceCeationPolicy.currentValue = "Create on active device";			
+		else if (mResourceManager->getCreationPolicy() == RCP_CREATE_ON_ALL_DEVICES)
+			optResourceCeationPolicy.currentValue = "Create on all devices";
+		else
+			optResourceCeationPolicy.currentValue = "N/A";
+		optResourceCeationPolicy.immutable = false;
+
+		for( unsigned j=0; j < driverList->count(); j++ )
+		{
+			driver = driverList->item(j);
+			optDevice.possibleValues.push_back( driver->DriverDescription() );
+			// Make first one default
+			if( j==0 )
+				optDevice.currentValue = driver->DriverDescription();
+		}
+
+		optVSync.name = "VSync";
+		optVSync.immutable = false;
+		optVSync.possibleValues.push_back( "Yes" );
+		optVSync.possibleValues.push_back( "No" );
+		optVSync.currentValue = "No";
+
+		optVSyncInterval.name = "VSync Interval";
+		optVSyncInterval.immutable = false;
+		optVSyncInterval.possibleValues.push_back( "1" );
+		optVSyncInterval.possibleValues.push_back( "2" );
+		optVSyncInterval.possibleValues.push_back( "3" );
+		optVSyncInterval.possibleValues.push_back( "4" );
+		optVSyncInterval.currentValue = "1";
+
+		optAA.name = "FSAA";
+		optAA.immutable = false;
+		optAA.possibleValues.push_back( "None" );
+		optAA.currentValue = "None";
+
+		optFPUMode.name = "Floating-point mode";
+#if OGRE_DOUBLE_PRECISION
+		optFPUMode.currentValue = "Consistent";
+#else
+		optFPUMode.currentValue = "Fastest";
+#endif
+		optFPUMode.possibleValues.clear();
+		optFPUMode.possibleValues.push_back("Fastest");
+		optFPUMode.possibleValues.push_back("Consistent");
+		optFPUMode.immutable = false;
+
+		optNVPerfHUD.currentValue = "No";
+		optNVPerfHUD.immutable = false;
+		optNVPerfHUD.name = "Allow NVPerfHUD";
+		optNVPerfHUD.possibleValues.push_back( "Yes" );
+		optNVPerfHUD.possibleValues.push_back( "No" );
+
+
+		// SRGB on auto window
+		optSRGB.name = "sRGB Gamma Conversion";
+		optSRGB.possibleValues.push_back("Yes");
+		optSRGB.possibleValues.push_back("No");
+		optSRGB.currentValue = "No";
+		optSRGB.immutable = false;
+
+		mOptions[optDevice.name] = optDevice;
+		mOptions[optVideoMode.name] = optVideoMode;
+		mOptions[optFullScreen.name] = optFullScreen;
+		mOptions[optVSync.name] = optVSync;
+		mOptions[optVSyncInterval.name] = optVSyncInterval;
+		mOptions[optAA.name] = optAA;
+		mOptions[optFPUMode.name] = optFPUMode;
+		mOptions[optNVPerfHUD.name] = optNVPerfHUD;
+		mOptions[optSRGB.name] = optSRGB;
+		mOptions[optResourceCeationPolicy.name] = optResourceCeationPolicy;
 
 		refreshD3DSettings();
 
@@ -280,216 +279,212 @@ namespace Ogre
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::refreshD3DSettings()
 	{
-		// TODO PORT - I'm not going to use these config options, but I need to find another way to initialize the render system
-		//ConfigOption* optVideoMode;
-		//D3D9Driver* driver = 0;
-		//D3D9VideoMode* videoMode;
-
-		//ConfigOptionMap::iterator opt = mOptions.find( "Rendering Device" );
-		//if( opt != mOptions.end() )
-		//{
-		//	for( unsigned j=0; j < getDirect3DDrivers()->count(); j++ )
-		//	{
-		//		D3D9Driver* curDriver = getDirect3DDrivers()->item(j);
-		//		if( curDriver->DriverDescription() == opt->second.currentValue )
-		//		{
-		//			driver = curDriver;
-		//			break;
-		//		}
-		//	}
-
-		//	if (driver)
-		//	{
-		//		opt = mOptions.find( "Video Mode" );
-		//		optVideoMode = &opt->second;
-		//		optVideoMode->possibleValues.clear();
-		//		// get vide modes for this device
-		//		for( unsigned k=0; k < driver->getVideoModeList()->count(); k++ )
-		//		{
-		//			videoMode = driver->getVideoModeList()->item( k );
-		//			optVideoMode->possibleValues.push_back( videoMode->getDescription() );
-		//		}
-
-		//		// Reset video mode to default if previous doesn't avail in new possible values
-		//		StringVector::const_iterator itValue =
-		//			std::find(optVideoMode->possibleValues.begin(),
-		//			optVideoMode->possibleValues.end(),
-		//			optVideoMode->currentValue);
-		//		if (itValue == optVideoMode->possibleValues.end())
-		//		{
-		//			optVideoMode->currentValue = "800 x 600 @ 32-bit colour";
-		//		}
-
-		//		// Also refresh FSAA options
-		//		refreshFSAAOptions();
-		//	}
-		//}
+		ConfigOption* optVideoMode;
+		D3D9Driver* driver = 0;
+		D3D9VideoMode* videoMode;
+
+		ConfigOptionMap::iterator opt = mOptions.find( "Rendering Device" );
+		if( opt != mOptions.end() )
+		{
+			for( unsigned j=0; j < getDirect3DDrivers()->count(); j++ )
+			{
+				D3D9Driver* curDriver = getDirect3DDrivers()->item(j);
+				if( curDriver->DriverDescription() == opt->second.currentValue )
+				{
+					driver = curDriver;
+					break;
+				}
+			}
+
+			if (driver)
+			{
+				opt = mOptions.find( "Video Mode" );
+				optVideoMode = &opt->second;
+				optVideoMode->possibleValues.clear();
+				// get vide modes for this device
+				for( unsigned k=0; k < driver->getVideoModeList()->count(); k++ )
+				{
+					videoMode = driver->getVideoModeList()->item( k );
+					optVideoMode->possibleValues.push_back( videoMode->getDescription() );
+				}
+
+				// Reset video mode to default if previous doesn't avail in new possible values
+				StringVector::const_iterator itValue =
+					std::find(optVideoMode->possibleValues.begin(),
+					optVideoMode->possibleValues.end(),
+					optVideoMode->currentValue);
+				if (itValue == optVideoMode->possibleValues.end())
+				{
+					optVideoMode->currentValue = "800 x 600 @ 32-bit colour";
+				}
+
+				// Also refresh FSAA options
+				refreshFSAAOptions();
+			}
+		}
 
 	}
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setConfigOption( const String &name, const String &value )
 	{
-		// TODO PORT - I'm not going to use these config options, but I need to find another way to initialize the render system
-		//bool viewModeChanged = false;
-
-		//// Find option
-		//ConfigOptionMap::iterator it = mOptions.find( name );
-
-		//// Update
-		//if( it != mOptions.end() )
-		//	it->second.currentValue = value;
-		//else
-		//{
-		//	StringUtil::StrStreamType str;
-		//	str << "Option named '" << name << "' does not exist.";
-		//	OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, str.str(), "D3D9RenderSystem::setConfigOption" );
-		//}
-
-		//// Refresh other options if D3DDriver changed
-		//if( name == "Rendering Device" )
-		//	refreshD3DSettings();
-
-		//if( name == "Full Screen" )
-		//{
-		//	// Video mode is applicable
-		//	it = mOptions.find( "Video Mode" );
-		//	if (it->second.currentValue.empty())
-		//	{
-		//		it->second.currentValue = "800 x 600 @ 32-bit colour";
-		//		viewModeChanged = true;
-		//	}
-		//}
-
-		//if( name == "FSAA" )
-		//{
-		//	StringVector values = StringUtil::split(value, " ", 1);
-		//	mFSAASamples = StringConverter::parseUnsignedInt(values[0]);
-		//	if (values.size() > 1)
-		//		mFSAAHint = values[1];
-
-		//}
-
-		//if( name == "VSync" )
-		//{
-		//	if (value == "Yes")
-		//		mVSync = true;
-		//	else
-		//		mVSync = false;
-		//}
-
-		//if( name == "VSync Interval" )
-		//{
-		//	mVSyncInterval = StringConverter::parseUnsignedInt(value);
-		//}
-
-		//if( name == "Allow NVPerfHUD" )
-		//{
-		//	if (value == "Yes")
-		//		mUseNVPerfHUD = true;
-		//	else
-		//		mUseNVPerfHUD = false;
-		//}
-
-		//if (viewModeChanged || name == "Video Mode")
-		//{
-		//	refreshFSAAOptions();
-		//}
-
-		//if (name == "Resource Creation Policy")
-		//{
-		//	if (value == "Create on active device")
-		//		mResourceManager->setCreationPolicy(RCP_CREATE_ON_ACTIVE_DEVICE);
-		//	else if (value == "Create on all devices")
-		//		mResourceManager->setCreationPolicy(RCP_CREATE_ON_ALL_DEVICES);		
-		//}
+		bool viewModeChanged = false;
+
+		// Find option
+		ConfigOptionMap::iterator it = mOptions.find( name );
+
+		// Update
+		if( it != mOptions.end() )
+			it->second.currentValue = value;
+		else
+		{
+			StringUtil::StrStreamType str;
+			str << "Option named '" << name << "' does not exist.";
+			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, str.str(), "D3D9RenderSystem::setConfigOption" );
+		}
+
+		// Refresh other options if D3DDriver changed
+		if( name == "Rendering Device" )
+			refreshD3DSettings();
+
+		if( name == "Full Screen" )
+		{
+			// Video mode is applicable
+			it = mOptions.find( "Video Mode" );
+			if (it->second.currentValue.empty())
+			{
+				it->second.currentValue = "800 x 600 @ 32-bit colour";
+				viewModeChanged = true;
+			}
+		}
+
+		if( name == "FSAA" )
+		{
+			StringVector values = StringUtil::split(value, " ", 1);
+			mFSAASamples = StringConverter::parseUnsignedInt(values[0]);
+			if (values.size() > 1)
+				mFSAAHint = values[1];
+
+		}
+
+		if( name == "VSync" )
+		{
+			if (value == "Yes")
+				mVSync = true;
+			else
+				mVSync = false;
+		}
+
+		if( name == "VSync Interval" )
+		{
+			mVSyncInterval = StringConverter::parseUnsignedInt(value);
+		}
+
+		if( name == "Allow NVPerfHUD" )
+		{
+			if (value == "Yes")
+				mUseNVPerfHUD = true;
+			else
+				mUseNVPerfHUD = false;
+		}
+
+		if (viewModeChanged || name == "Video Mode")
+		{
+			refreshFSAAOptions();
+		}
+
+		if (name == "Resource Creation Policy")
+		{
+			if (value == "Create on active device")
+				mResourceManager->setCreationPolicy(RCP_CREATE_ON_ACTIVE_DEVICE);
+			else if (value == "Create on all devices")
+				mResourceManager->setCreationPolicy(RCP_CREATE_ON_ALL_DEVICES);		
+		}
 	}
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::refreshFSAAOptions()
 	{
-		// TODO PORT - I'm not going to use these config options, but I need to find another way to initialize the render system
-		//ConfigOptionMap::iterator it = mOptions.find( "FSAA" );
-		//ConfigOption* optFSAA = &it->second;
-		//optFSAA->possibleValues.clear();
-		//optFSAA->possibleValues.push_back("0");
-
-		//it = mOptions.find("Rendering Device");
-		//D3D9Driver *driver = getDirect3DDrivers()->item(it->second.currentValue);
-		//if (driver)
-		//{
-		//	it = mOptions.find("Video Mode");
-		//	D3D9VideoMode *videoMode = driver->getVideoModeList()->item(it->second.currentValue);
-		//	if (videoMode)
-		//	{
-		//		DWORD numLevels = 0;
-		//		bool bOK;
-
-		//		for (unsigned int n = 2; n < 25; n++)
-		//		{
-		//			bOK = this->_checkMultiSampleQuality(
-		//				(D3DMULTISAMPLE_TYPE)n, 
-		//				&numLevels, 
-		//				videoMode->getFormat(), 
-		//				driver->getAdapterNumber(),
-		//				D3DDEVTYPE_HAL,
-		//				TRUE);
-		//			if (bOK)
-		//			{
-		//				optFSAA->possibleValues.push_back(StringConverter::toString(n));
-		//				if (n >= 8)
-		//					optFSAA->possibleValues.push_back(StringConverter::toString(n) + " [Quality]");
-		//			}
-		//		}
-
-		//	}
-		//}
-
-		//// Reset FSAA to none if previous doesn't avail in new possible values
-		//StringVector::const_iterator itValue =
-		//	std::find(optFSAA->possibleValues.begin(),
-		//	optFSAA->possibleValues.end(),
-		//	optFSAA->currentValue);
-		//if (itValue == optFSAA->possibleValues.end())
-		//{
-		//	optFSAA->currentValue = "0";
-		//}
+		ConfigOptionMap::iterator it = mOptions.find( "FSAA" );
+		ConfigOption* optFSAA = &it->second;
+		optFSAA->possibleValues.clear();
+		optFSAA->possibleValues.push_back("0");
+
+		it = mOptions.find("Rendering Device");
+		D3D9Driver *driver = getDirect3DDrivers()->item(it->second.currentValue);
+		if (driver)
+		{
+			it = mOptions.find("Video Mode");
+			D3D9VideoMode *videoMode = driver->getVideoModeList()->item(it->second.currentValue);
+			if (videoMode)
+			{
+				DWORD numLevels = 0;
+				bool bOK;
+
+				for (unsigned int n = 2; n < 25; n++)
+				{
+					bOK = this->_checkMultiSampleQuality(
+						(D3DMULTISAMPLE_TYPE)n, 
+						&numLevels, 
+						videoMode->getFormat(), 
+						driver->getAdapterNumber(),
+						D3DDEVTYPE_HAL,
+						TRUE);
+					if (bOK)
+					{
+						optFSAA->possibleValues.push_back(StringConverter::toString(n));
+						if (n >= 8)
+							optFSAA->possibleValues.push_back(StringConverter::toString(n) + " [Quality]");
+					}
+				}
+
+			}
+		}
+
+		// Reset FSAA to none if previous doesn't avail in new possible values
+		StringVector::const_iterator itValue =
+			std::find(optFSAA->possibleValues.begin(),
+			optFSAA->possibleValues.end(),
+			optFSAA->currentValue);
+		if (itValue == optFSAA->possibleValues.end())
+		{
+			optFSAA->currentValue = "0";
+		}
 
 	}
 	//---------------------------------------------------------------------
 	String D3D9RenderSystem::validateConfigOptions()
 	{
-		// TODO PORT - I'm not going to use these config options, but I need to find another way to initialize the render system
-		//ConfigOptionMap::iterator it;
-
-		//// check if video mode is selected
-		//it = mOptions.find( "Video Mode" );
-		//if (it->second.currentValue.empty())
-		//	return "A video mode must be selected.";
-
-		//it = mOptions.find( "Rendering Device" );
-		//bool foundDriver = false;
-		//D3D9DriverList* driverList = getDirect3DDrivers();
-		//for( ushort j=0; j < driverList->count(); j++ )
-		//{
-		//	if( driverList->item(j)->DriverDescription() == it->second.currentValue )
-		//	{
-		//		foundDriver = true;
-		//		break;
-		//	}
-		//}
-
-		//if (!foundDriver)
-		//{
-		//	// Just pick the first driver
-		//	setConfigOption("Rendering Device", driverList->item(0)->DriverDescription());
-		//	return "Your DirectX driver name has changed since the last time you ran OGRE; "
-		//		"the 'Rendering Device' has been changed.";
-		//}
-
-		//it = mOptions.find( "VSync" );
-		//if( it->second.currentValue == "Yes" )
-		//	mVSync = true;
-		//else
-		//	mVSync = false;
+		ConfigOptionMap::iterator it;
+
+		// check if video mode is selected
+		it = mOptions.find( "Video Mode" );
+		if (it->second.currentValue.empty())
+			return "A video mode must be selected.";
+
+		it = mOptions.find( "Rendering Device" );
+		bool foundDriver = false;
+		D3D9DriverList* driverList = getDirect3DDrivers();
+		for( ushort j=0; j < driverList->count(); j++ )
+		{
+			if( driverList->item(j)->DriverDescription() == it->second.currentValue )
+			{
+				foundDriver = true;
+				break;
+			}
+		}
+
+		if (!foundDriver)
+		{
+			// Just pick the first driver
+			setConfigOption("Rendering Device", driverList->item(0)->DriverDescription());
+			return "Your DirectX driver name has changed since the last time you ran OGRE; "
+				"the 'Rendering Device' has been changed.";
+		}
+
+		it = mOptions.find( "VSync" );
+		if( it->second.currentValue == "Yes" )
+			mVSync = true;
+		else
+			mVSync = false;
 
 		return StringUtil::BLANK;
 	}
@@ -500,15 +495,15 @@ namespace Ogre
 
 		// Init using current settings
 		mActiveD3DDriver = NULL;
-		//ConfigOptionMap::iterator opt = mOptions.find( "Rendering Device" );
-		//for( uint j=0; j < getDirect3DDrivers()->count(); j++ )
-		//{
-		//	if( getDirect3DDrivers()->item(j)->DriverDescription() == opt->second.currentValue )
-		//	{
-		//		mActiveD3DDriver = getDirect3DDrivers()->item(j);
-		//		break;
-		//	}
-		//}
+		ConfigOptionMap::iterator opt = mOptions.find( "Rendering Device" );
+		for( uint j=0; j < getDirect3DDrivers()->count(); j++ )
+		{
+			if( getDirect3DDrivers()->item(j)->DriverDescription() == opt->second.currentValue )
+			{
+				mActiveD3DDriver = getDirect3DDrivers()->item(j);
+				break;
+			}
+		}
 
 		if( !mActiveD3DDriver )
 			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Problems finding requested Direct3D driver!", "D3D9RenderSystem::initialise" );
@@ -537,39 +532,30 @@ namespace Ogre
 		
 		if( autoCreateWindow )
 		{
-			//bool fullScreen;
-			//opt = mOptions.find( "Full Screen" );
-			//if( opt == mOptions.end() )
-			//	OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find full screen option!", "D3D9RenderSystem::initialise" );
-			//fullScreen = opt->second.currentValue == "Yes";
-			// TODO PORT - Not loading fullscreen from options, assume its false
-			bool fullScreen = false;
-
+			bool fullScreen;
+			opt = mOptions.find( "Full Screen" );
+			if( opt == mOptions.end() )
+				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find full screen option!", "D3D9RenderSystem::initialise" );
+			fullScreen = opt->second.currentValue == "Yes";
 
 			D3D9VideoMode* videoMode = NULL;
 			unsigned int width, height;
 			String temp;
 
-			// TODO - Not loading video mode from the list, instead we assume 800x600 @ 32-bit
-			//opt = mOptions.find( "Video Mode" );
-			//if( opt == mOptions.end() )
-			//	OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find Video Mode option!", "D3D9RenderSystem::initialise" );
-
-			//// The string we are manipulating looks like this :width x height @ colourDepth
-			//// Pull out the colour depth by getting what comes after the @ and a space
-			//String colourDepth = opt->second.currentValue.substr(opt->second.currentValue.rfind('@')+1);
-			//// Now we know that the width starts a 0, so if we can find the end we can parse that out
-			//String::size_type widthEnd = opt->second.currentValue.find(' ');
-			//// we know that the height starts 3 characters after the width and goes until the next space
-			//String::size_type heightEnd = opt->second.currentValue.find(' ', widthEnd+3);
-			//// Now we can parse out the values
-			//width = StringConverter::parseInt(opt->second.currentValue.substr(0, widthEnd));
-			//height = StringConverter::parseInt(opt->second.currentValue.substr(widthEnd+3, heightEnd));
-
-			width = 800;
-			height = 600;
-			String colourDepth = "32-bit";
-			String resValue = "800 x 600 @ 32-bit";
+			opt = mOptions.find( "Video Mode" );
+			if( opt == mOptions.end() )
+				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find Video Mode option!", "D3D9RenderSystem::initialise" );
+
+			// The string we are manipulating looks like this :width x height @ colourDepth
+			// Pull out the colour depth by getting what comes after the @ and a space
+			String colourDepth = opt->second.currentValue.substr(opt->second.currentValue.rfind('@')+1);
+			// Now we know that the width starts a 0, so if we can find the end we can parse that out
+			String::size_type widthEnd = opt->second.currentValue.find(' ');
+			// we know that the height starts 3 characters after the width and goes until the next space
+			String::size_type heightEnd = opt->second.currentValue.find(' ', widthEnd+3);
+			// Now we can parse out the values
+			width = StringConverter::parseInt(opt->second.currentValue.substr(0, widthEnd));
+			height = StringConverter::parseInt(opt->second.currentValue.substr(widthEnd+3, heightEnd));
 
 			for( unsigned j=0; j < mActiveD3DDriver->getVideoModeList()->count(); j++ )
 			{
@@ -578,7 +564,7 @@ namespace Ogre
 				// In full screen we only want to allow supported resolutions, so temp and opt->second.currentValue need to 
 				// match exactly, but in windowed mode we can allow for arbitrary window sized, so we only need
 				// to match the colour values
-				if(fullScreen && (temp == resValue) ||
+				if(fullScreen && (temp == opt->second.currentValue) ||
 					!fullScreen && (temp.substr(temp.rfind('@')+1) == colourDepth))
 				{
 					videoMode = mActiveD3DDriver->getVideoModeList()->item(j);
@@ -591,13 +577,11 @@ namespace Ogre
 
 			// sRGB window option
 			bool hwGamma = false;
-			// TODO PORT - Not loading this from config so assume false for now
-			//opt = mOptions.find( "sRGB Gamma Conversion" );
-			//if( opt == mOptions.end() )
-			//	OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find sRGB option!", "D3D9RenderSystem::initialise" );
-			//hwGamma = opt->second.currentValue == "Yes";
 
-			
+			opt = mOptions.find( "sRGB Gamma Conversion" );
+			if( opt == mOptions.end() )
+				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find sRGB option!", "D3D9RenderSystem::initialise" );
+			hwGamma = opt->second.currentValue == "Yes";
 
 			NameValuePairList miscParams;
 			miscParams["colourDepth"] = StringConverter::toString(videoMode->getColourDepth());

+ 3 - 0
CamelotRenderer/OgreD3D9RenderSystem.h

@@ -31,6 +31,7 @@ THE SOFTWARE.
 #include "OgreD3D9Prerequisites.h"
 #include "OgreString.h"
 #include "OgreStringConverter.h"
+#include "OgreConfigOptionMap.h"
 #include "OgreRenderSystem.h"
 #include "OgreRenderSystemCapabilities.h"
 #include "OgreD3D9Mappings.h"
@@ -53,6 +54,8 @@ namespace Ogre
 	private:
 		/// Direct3D
 		IDirect3D9*	 mpD3D;		
+		// Stored options
+		ConfigOptionMap mOptions;
 		size_t mFSAASamples;
 		String mFSAAHint;
 

+ 6 - 8
CamelotRenderer/OgreD3D9RenderWindow.cpp

@@ -34,6 +34,7 @@ THE SOFTWARE.
 #include "OgreStringConverter.h"
 #include "OgreWindowEventUtilities.h"
 #include "OgreD3D9DeviceManager.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre
 {
@@ -601,14 +602,11 @@ namespace Ogre
 			// 16-bit depth, software stencil
 			presentParams->AutoDepthStencilFormat	= D3DFMT_D16;
 
-		// TODO PORT - Enable this once I have RenderSystem singleton set up. For now set no FSAA
-		//D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
-		//
-		//rsys->determineFSAASettings(mDevice->getD3D9Device(),
-		//	mFSAA, mFSAAHint, presentParams->BackBufferFormat, mIsFullScreen, 
-		//	&mFSAAType, &mFSAAQuality);
-		mFSAAType = D3DMULTISAMPLE_NONE;
-		mFSAAQuality = 0;
+		D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
+
+		rsys->determineFSAASettings(mDevice->getD3D9Device(),
+			mFSAA, mFSAAHint, presentParams->BackBufferFormat, mIsFullScreen, 
+			&mFSAAType, &mFSAAQuality);
 
 		presentParams->MultiSampleType = mFSAAType;
 		presentParams->MultiSampleQuality = (mFSAAQuality == 0) ? 0 : mFSAAQuality;

+ 7 - 12
CamelotRenderer/OgreD3D9Texture.cpp

@@ -36,6 +36,7 @@ THE SOFTWARE.
 #include "OgreD3D9Device.h"
 #include "OgreD3D9DeviceManager.h"
 #include "OgreD3D9ResourceManager.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre 
 {
@@ -976,12 +977,9 @@ namespace Ogre
 		// Check FSAA level
 		if (mUsage & TU_RENDERTARGET)
 		{
-			// TODO PORT - Enable when rendersystem is active, for now set to no FSAA
-			//D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
-			//rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
-			//	&mFSAAType, &mFSAAQuality);
-			mFSAAType = D3DMULTISAMPLE_NONE;
-			mFSAAQuality = 0;
+			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
+			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
+				&mFSAAType, &mFSAAQuality);
 		}
 		else
 		{
@@ -1139,12 +1137,9 @@ namespace Ogre
 		// Check FSAA level
 		if (mUsage & TU_RENDERTARGET)
 		{
-			// TODO PORT - Enable when rendersystem is active, for now set to no FSAA
-			//D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
-			//rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
-			//	&mFSAAType, &mFSAAQuality);
-			mFSAAType = D3DMULTISAMPLE_NONE;
-			mFSAAQuality = 0;
+			D3D9RenderSystem* rsys = static_cast<D3D9RenderSystem*>(CamelotEngine::RenderSystemManager::getActive());
+			rsys->determineFSAASettings(d3d9Device, mFSAA, mFSAAHint, d3dPF, false, 
+				&mFSAAType, &mFSAAQuality);
 		}
 		else
 		{

+ 4 - 5
CamelotRenderer/OgreD3D9TextureManager.cpp

@@ -31,6 +31,7 @@ THE SOFTWARE.
 #include "OgreStringConverter.h"
 #include "OgreD3D9Mappings.h"
 #include "OgreD3D9RenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre 
 {
@@ -94,11 +95,9 @@ namespace Ogre
         if (!preciseFormatOnly)
             format = getNativeFormat(ttype, format, usage);
 
-		// TODO PORT - Enable once rendersystem singleton is active, for now assume its true
-        //D3D9RenderSystem* rs = static_cast<D3D9RenderSystem*>(
-        //    Root::getSingleton().getRenderSystem());
+        D3D9RenderSystem* rs = static_cast<D3D9RenderSystem*>(
+            CamelotEngine::RenderSystemManager::getActive());
 
-        //return rs->_checkTextureFilteringSupported(ttype, format, usage);
-		return true;
+        return rs->_checkTextureFilteringSupported(ttype, format, usage);
     }
 }

+ 7 - 6
CamelotRenderer/OgreFrustum.cpp

@@ -35,6 +35,8 @@ THE SOFTWARE.
 #include "OgreHardwareBufferManager.h"
 #include "OgreHardwareVertexBuffer.h"
 #include "OgreHardwareIndexBuffer.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
 
@@ -531,12 +533,11 @@ namespace Ogre {
         mProjMatrix = mProjMatrix * Quaternion(Degree(mOrientationMode * 90.f), Vector3::UNIT_Z);
 #endif
 
-		// TODO PORT - IMPORTANT - After I have render system ported make sure to enable this
-		//RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
-		//// API specific
-		//renderSystem->_convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
-		//// API specific for Gpu Programs
-		//renderSystem->_convertProjectionMatrix(mProjMatrix, mProjMatrixRSDepth, true);
+		RenderSystem* renderSystem = CamelotEngine::RenderSystemManager::getActive();
+		// API specific
+		renderSystem->_convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
+		// API specific for Gpu Programs
+		renderSystem->_convertProjectionMatrix(mProjMatrix, mProjMatrixRSDepth, true);
 
 
 		// Calculate bounding box (local)

+ 5 - 6
CamelotRenderer/OgreGpuProgram.cpp

@@ -32,6 +32,8 @@ THE SOFTWARE.
 #include "OgreRenderSystemCapabilities.h"
 #include "OgreStringConverter.h"
 #include "OgreException.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre
 {
@@ -121,7 +123,7 @@ namespace Ogre
     //-----------------------------------------------------------------------------
     bool GpuProgram::isRequiredCapabilitiesSupported(void) const
     {
-		// TODO PORT- Enable once I port rendersystem. Right now just assume everything is supported and return true
+		// TODO PORT- I dont think I'll be using these capabilities
 		return true;
 
 		//const RenderSystemCapabilities* caps = 
@@ -149,11 +151,8 @@ namespace Ogre
         if (mCompileError || !isRequiredCapabilitiesSupported())
             return false;
 
-		// TODO PORT - Enable this once I have ported the render system, for now just return true
-		//RenderSystem* rs = Root::getSingleton().getRenderSystem();
-		//return rs->getCapabilities()->isShaderProfileSupported(mSyntaxCode);
-
-        return true;
+		RenderSystem* rs = CamelotEngine::RenderSystemManager::getActive();
+		return rs->getCapabilities()->isShaderProfileSupported(mSyntaxCode);
     }
 	//---------------------------------------------------------------------
 	void GpuProgram::createParameterMappingStructures(bool recreateIfExists) const

+ 7 - 7
CamelotRenderer/OgreHardwareVertexBuffer.cpp

@@ -32,6 +32,8 @@ THE SOFTWARE.
 #include "OgreStringConverter.h"
 #include "OgreHardwareBufferManager.h"
 #include "OgreDefaultHardwareBufferManager.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
 
@@ -186,13 +188,11 @@ namespace Ogre {
 	VertexElementType VertexElement::getBestColourVertexElementType(void)
 	{
 		// Use the current render system to determine if possible
-		// TODO PORT - Requires singleton to render system and I don't have that yet, but I will once port is complete
-		//if (Root::getSingletonPtr() && Root::getSingletonPtr()->getRenderSystem())
-		//{
-		//	return Root::getSingleton().getRenderSystem()->getColourVertexElementType();
-		//}
-		//else
-		// END PORT
+		if (CamelotEngine::RenderSystemManager::getActive())
+		{
+			return CamelotEngine::RenderSystemManager::getActive()->getColourVertexElementType();
+		}
+		else
 		{
 			// We can't know the specific type right now, so pick a type
 			// based on platform

+ 2 - 2
CamelotRenderer/OgreRenderSystem.h

@@ -31,6 +31,8 @@ THE SOFTWARE.
 // Precompiler options
 #include "OgrePrerequisites.h"
 
+#include <memory>
+
 #include "OgreString.h"
 
 #include "OgreTextureUnitState.h"
@@ -1306,8 +1308,6 @@ namespace Ogre
 		*/
 		virtual unsigned int getDisplayMonitorCount() const = 0;
 	protected:
-
-
 		/** The render targets. */
 		RenderTargetMap mRenderTargets;
 		/** The render targets, ordered by priority. */

+ 3 - 3
CamelotRenderer/OgreRenderTarget.cpp

@@ -30,6 +30,8 @@ THE SOFTWARE.
 
 #include "OgreViewport.h"
 #include "OgreException.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
 
@@ -238,9 +240,7 @@ namespace Ogre {
 		if (swap)
 		{
 			// Swap buffers
-			// TODO PORT - Make sure to enable this line and disable next line, once render system is ported
-    	    //swapBuffers(Root::getSingleton().getRenderSystem()->getWaitForVerticalBlank());
-			swapBuffers(false);
+    	    swapBuffers(CamelotEngine::RenderSystemManager::getActive()->getWaitForVerticalBlank());
 		}
     }
 	

+ 5 - 3
CamelotRenderer/OgreVertexIndexData.cpp

@@ -33,6 +33,8 @@ THE SOFTWARE.
 #include "OgreVector3.h"
 #include "OgreAxisAlignedBox.h"
 #include "OgreException.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
 
@@ -150,9 +152,9 @@ namespace Ogre {
 
         // Upfront, lets check whether we have vertex program capability
         bool useVertexPrograms = false;
-		// TODO PORT - Don't have access to render system yet, but will after the port is done. For now assume we always can use vertex programs.
-		//RenderSystem* rend = Root::getSingleton().getRenderSystem();
-        //if (rend && rend->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM))
+
+		RenderSystem* rend = CamelotEngine::RenderSystemManager::getActive();
+        if (rend && rend->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM))
         {
             useVertexPrograms = true;
         }

+ 23 - 24
CamelotRenderer/OgreViewport.cpp

@@ -30,7 +30,8 @@ THE SOFTWARE.
 #include "OgreException.h"
 #include "OgreRenderTarget.h"
 #include "OgreMath.h"
-//#include "OgreRenderWindow.h"
+#include "OgreRenderSystem.h"
+#include "CmRenderSystemManager.h"
 
 namespace Ogre {
     OrientationMode Viewport::mDefaultOrientationMode = OR_DEGREE_0;
@@ -168,15 +169,14 @@ namespace Ogre {
             setDefaultOrientationMode(orientationMode);
         }
 
-		// TODO PORT - Enable this once I port rendersystem
-	//// Update the render system config
- //       RenderSystem* rs = Root::getSingleton().getRenderSystem();
- //       if(mOrientationMode == OR_LANDSCAPELEFT)
- //           rs->setConfigOption("Orientation", "Landscape Left");
- //       else if(mOrientationMode == OR_LANDSCAPERIGHT)
- //           rs->setConfigOption("Orientation", "Landscape Right");
- //       else if(mOrientationMode == OR_PORTRAIT)
- //           rs->setConfigOption("Orientation", "Portrait");
+		// Update the render system config
+        RenderSystem* rs = CamelotEngine::RenderSystemManager::getActive();
+        if(mOrientationMode == OR_LANDSCAPELEFT)
+            rs->setConfigOption("Orientation", "Landscape Left");
+        else if(mOrientationMode == OR_LANDSCAPERIGHT)
+            rs->setConfigOption("Orientation", "Landscape Right");
+        else if(mOrientationMode == OR_PORTRAIT)
+            rs->setConfigOption("Orientation", "Portrait");
     }
     //---------------------------------------------------------------------
     OrientationMode Viewport::getOrientationMode() const
@@ -238,20 +238,19 @@ namespace Ogre {
 	void Viewport::clear(unsigned int buffers, const ColourValue& col,  
 						 Real depth, unsigned short stencil)
 	{
-		// TODO PORT - Enable this once I port rendersystem
-		//RenderSystem* rs = Root::getSingleton().getRenderSystem();
-		//if (rs)
-		//{
-		//	Viewport* currentvp = rs->_getViewport();
-		//	if (currentvp && currentvp == this)
-		//		rs->clearFrameBuffer(buffers, col, depth, stencil);
-		//	else if (currentvp)
-		//	{
-		//		rs->_setViewport(this);
-		//		rs->clearFrameBuffer(buffers, col, depth, stencil);
-		//		rs->_setViewport(currentvp);
-		//	}
-		//}
+		RenderSystem* rs = CamelotEngine::RenderSystemManager::getActive();
+		if (rs)
+		{
+			Viewport* currentvp = rs->_getViewport();
+			if (currentvp && currentvp == this)
+				rs->clearFrameBuffer(buffers, col, depth, stencil);
+			else if (currentvp)
+			{
+				rs->_setViewport(this);
+				rs->clearFrameBuffer(buffers, col, depth, stencil);
+				rs->_setViewport(currentvp);
+			}
+		}
 	}
     //---------------------------------------------------------------------
     void Viewport::getActualDimensions(int &left, int&top, int &width, int &height) const