Marko Pintera 13 лет назад
Родитель
Сommit
a884d33548
48 измененных файлов с 484 добавлено и 1027 удалено
  1. 2 1
      CamelotClient/CamelotClient.cpp
  2. 33 88
      CamelotD3D9Renderer/Source/CmD3D9Device.cpp
  3. 1 3
      CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp
  4. 4 13
      CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp
  5. 3 8
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp
  6. 4 12
      CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp
  7. 1 3
      CamelotD3D9Renderer/Source/CmD3D9HardwareOcclusionQuery.cpp
  8. 29 59
      CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp
  9. 4 12
      CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp
  10. 2 9
      CamelotD3D9Renderer/Source/CmD3D9MultiRenderTarget.cpp
  11. 113 168
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  12. 34 67
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  13. 1 3
      CamelotD3D9Renderer/Source/CmD3D9VertexDeclaration.cpp
  14. 1 1
      CamelotD3D9Renderer/Source/CmD3D9VideoModeList.cpp
  15. 8 11
      CamelotGLRenderer/Source/CmGLFrameBufferObject.cpp
  16. 2 2
      CamelotGLRenderer/Source/CmGLGpuProgram.cpp
  17. 8 12
      CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp
  18. 2 3
      CamelotGLRenderer/Source/CmGLHardwareOcclusionQuery.cpp
  19. 12 21
      CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp
  20. 6 11
      CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp
  21. 10 18
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  22. 1 1
      CamelotGLRenderer/Source/CmGLRenderTexture.cpp
  23. 6 11
      CamelotGLRenderer/Source/CmGLTexture.cpp
  24. 12 12
      CamelotGLRenderer/Source/CmWin32GLSupport.cpp
  25. 5 5
      CamelotGLRenderer/Source/CmWin32RenderTexture.cpp
  26. 8 13
      CamelotGLRenderer/Source/CmWin32Window.cpp
  27. 1 1
      CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp
  28. 2 3
      CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgram.cpp
  29. 2 3
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp
  30. 4 4
      CamelotGLRenderer/Source/atifs/src/ATI_FS_GLGpuProgram.cpp
  31. 2 3
      CamelotGLRenderer/Source/win32/CmWin32Context.cpp
  32. 1 2
      CamelotRenderer/Source/CmApplication.cpp
  33. 3 5
      CamelotRenderer/Source/CmFrustum.cpp
  34. 4 6
      CamelotRenderer/Source/CmGpuProgramManager.cpp
  35. 22 33
      CamelotRenderer/Source/CmGpuProgramParams.cpp
  36. 11 17
      CamelotRenderer/Source/CmHardwarePixelBuffer.cpp
  37. 5 9
      CamelotRenderer/Source/CmHardwareVertexBuffer.cpp
  38. 7 10
      CamelotRenderer/Source/CmRenderSystem.cpp
  39. 2 3
      CamelotRenderer/Source/CmRenderSystemManager.cpp
  40. 4 4
      CamelotRenderer/Source/CmRenderTarget.cpp
  41. 4 6
      CamelotRenderer/Source/CmRenderTexture.cpp
  42. 2 3
      CamelotRenderer/Source/CmTexture.cpp
  43. 8 10
      CamelotRenderer/Source/CmVertexIndexData.cpp
  44. 0 1
      CamelotRenderer/TODO.txt
  45. 49 221
      CamelotUtility/Include/CmException.h
  46. 4 8
      CamelotUtility/Source/CmDynLib.cpp
  47. 27 94
      CamelotUtility/Source/CmException.cpp
  48. 8 14
      CamelotUtility/Source/CmPixelUtil.cpp

+ 2 - 1
CamelotClient/CamelotClient.cpp

@@ -9,7 +9,8 @@ using namespace CamelotEngine;
 
 
 int _tmain(int argc, _TCHAR* argv[])
 int _tmain(int argc, _TCHAR* argv[])
 {
 {
-	gApplication().startUp("RenderSystemD3D9.dll");
+	gApplication().startUp("CamelotGLRenderer.dll");
+	//gApplication().startUp("CamelotD3D9Renderer.dll");
 
 
 	int a = 5;
 	int a = 5;
 
 

+ 33 - 88
CamelotD3D9Renderer/Source/CmD3D9Device.cpp

@@ -74,9 +74,8 @@ namespace CamelotEngine
 
 
 		if (it == mMapRenderWindowToResoruces.end())
 		if (it == mMapRenderWindowToResoruces.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Render window was not attached to this device !!", 
-				"D3D9Device::getRenderWindowIterator" );
+			CM_EXCEPT(RenderingAPIException, 
+				"Render window was not attached to this device !!");
 		}
 		}
 
 
 		return it;
 		return it;
@@ -155,9 +154,7 @@ namespace CamelotEngine
 				hr = itPrimary->second->swapChain->GetPresentParameters(&currentPresentParams);
 				hr = itPrimary->second->swapChain->GetPresentParameters(&currentPresentParams);
 				if (FAILED(hr))
 				if (FAILED(hr))
 				{
 				{
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-						"GetPresentParameters failed", 
-						"D3D9RenderWindow::acquire");
+					CM_EXCEPT(RenderingAPIException, "GetPresentParameters failed");
 				}
 				}
 				
 				
 				// Desired parameters are different then current parameters.
 				// Desired parameters are different then current parameters.
@@ -276,9 +273,8 @@ namespace CamelotEngine
 	{
 	{
 		if (index >= mMapRenderWindowToResoruces.size())
 		if (index >= mMapRenderWindowToResoruces.size())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Index of render window is out of bounds!", 
-				"D3D9RenderWindow::getRenderWindow");
+			CM_EXCEPT(RenderingAPIException, 
+				"Index of render window is out of bounds!");
 		}
 		}
 		
 		
 		RenderWindowToResorucesIterator it = mMapRenderWindowToResoruces.begin();
 		RenderWindowToResorucesIterator it = mMapRenderWindowToResoruces.begin();
@@ -409,9 +405,7 @@ namespace CamelotEngine
 		}
 		}
 		else if (FAILED(hr))
 		else if (FAILED(hr))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot reset device!", 
-				"D3D9RenderWindow::reset");
+			CM_EXCEPT(RenderingAPIException, "Cannot reset device!");
 		}
 		}
 
 
 		mDeviceLost = false;
 		mDeviceLost = false;
@@ -473,9 +467,7 @@ namespace CamelotEngine
 	{
 	{
 		if (mD3D9DeviceCapsValid == false)
 		if (mD3D9DeviceCapsValid == false)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Device caps are invalid!", 
-				"D3D9Device::getD3D9DeviceCaps" );
+			CM_EXCEPT(RenderingAPIException, "Device caps are invalid!");
 		}
 		}
 
 
 		return mD3D9DeviceCaps;
 		return mD3D9DeviceCaps;
@@ -486,9 +478,7 @@ namespace CamelotEngine
 	{		
 	{		
 		if (mPresentationParams == NULL || mPresentationParamsCount == 0)
 		if (mPresentationParams == NULL || mPresentationParamsCount == 0)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Presentation parameters are invalid!", 
-				"D3D9Device::getBackBufferFormat" );
+			CM_EXCEPT(RenderingAPIException, "Presentation parameters are invalid!");
 		}
 		}
 
 
 		return mPresentationParams[0].BackBufferFormat;
 		return mPresentationParams[0].BackBufferFormat;
@@ -598,7 +588,7 @@ namespace CamelotEngine
 			if( hr != S_OK )
 			if( hr != S_OK )
 			{
 			{
 				String str = "Unable to disable texture '" + toString((unsigned int)stage) + "' in D3D9";
 				String str = "Unable to disable texture '" + toString((unsigned int)stage) + "' in D3D9";
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9Device::clearDeviceStreams" );
+				CM_EXCEPT(RenderingAPIException, str);
 			}
 			}
 		
 		
 			mpDevice->GetTextureStageState(static_cast<DWORD>(stage), D3DTSS_COLOROP, &dwCurValue);
 			mpDevice->GetTextureStageState(static_cast<DWORD>(stage), D3DTSS_COLOROP, &dwCurValue);
@@ -609,7 +599,7 @@ namespace CamelotEngine
 				if( hr != S_OK )
 				if( hr != S_OK )
 				{
 				{
 					String str = "Unable to disable texture '" + toString((unsigned)stage) + "' in D3D9";
 					String str = "Unable to disable texture '" + toString((unsigned)stage) + "' in D3D9";
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9Device::clearDeviceStreams" );
+					CM_EXCEPT(RenderingAPIException, str);
 				}
 				}
 			}			
 			}			
 		
 		
@@ -694,9 +684,7 @@ namespace CamelotEngine
 
 
 			if ( FAILED( hr ) )
 			if ( FAILED( hr ) )
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Cannot create device!", 
-					"D3D9Device::createD3D9Device" );
+				CM_EXCEPT(RenderingAPIException, "Cannot create device!");
 			}
 			}
 		}
 		}
 
 
@@ -704,18 +692,14 @@ namespace CamelotEngine
 		hr = mpDevice->GetDeviceCaps(&mD3D9DeviceCaps);
 		hr = mpDevice->GetDeviceCaps(&mD3D9DeviceCaps);
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot get device caps!", 
-				"D3D9Device::createD3D9Device" );
+			CM_EXCEPT(RenderingAPIException, "Cannot get device caps!");
 		}
 		}
 
 
 		// Get current creation parameters caps.
 		// Get current creation parameters caps.
 		hr = mpDevice->GetCreationParameters(&mCreationParams);
 		hr = mpDevice->GetCreationParameters(&mCreationParams);
 		if ( FAILED(hr) )
 		if ( FAILED(hr) )
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Error Get Creation Parameters", 
-				"D3D9Device:createD3D9Device" );
+			CM_EXCEPT(RenderingAPIException, "Error Get Creation Parameters");
 		}
 		}
 
 
 		mD3D9DeviceCapsValid = true;
 		mD3D9DeviceCapsValid = true;
@@ -980,9 +964,7 @@ namespace CamelotEngine
 		}
 		}
 		else if( FAILED(hr) )
 		else if( FAILED(hr) )
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Error Presenting surfaces", 
-				"D3D9Device::present" );
+			CM_EXCEPT(RenderingAPIException, "Error Presenting surfaces");
 		}
 		}
 		else
 		else
 		{
 		{
@@ -1017,9 +999,7 @@ namespace CamelotEngine
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Unable to create an additional swap chain",
-					"D3D9RenderWindow::acquireRenderWindowResources");
+				CM_EXCEPT(RenderingAPIException, "Unable to create an additional swap chain");
 			}
 			}
 		}
 		}
 		else
 		else
@@ -1029,9 +1009,7 @@ namespace CamelotEngine
 				&renderWindowResources->swapChain);
 				&renderWindowResources->swapChain);
 			if (FAILED(hr)) 
 			if (FAILED(hr)) 
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Unable to get the swap chain",
-					"D3D9RenderWindow::acquireRenderWindowResources");
+				CM_EXCEPT(RenderingAPIException, "Unable to get the swap chain");
 			}
 			}
 		}
 		}
 
 
@@ -1073,9 +1051,7 @@ namespace CamelotEngine
 
 
 				if (FAILED(hr)) 
 				if (FAILED(hr)) 
 				{
 				{
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-						"Unable to create a depth buffer for the swap chain",
-						"D3D9RenderWindow::acquireRenderWindowResources");
+					CM_EXCEPT(RenderingAPIException, "Unable to create a depth buffer for the swap chain");
 				}
 				}
 
 
 				if (isSwapChainWindow(renderWindow) == false)
 				if (isSwapChainWindow(renderWindow) == false)
@@ -1095,9 +1071,7 @@ namespace CamelotEngine
 		
 		
 		if (FAILED(hr)) 
 		if (FAILED(hr)) 
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Unable to apply render state: D3DRS_SPECULARENABLE <- TRUE",
-				"D3D9Device::setupDeviceStates");
+			CM_EXCEPT(RenderingAPIException, "Unable to apply render state: D3DRS_SPECULARENABLE <- TRUE");
 		}		
 		}		
 	}
 	}
 
 
@@ -1208,9 +1182,7 @@ namespace CamelotEngine
 			(dst.top < 0) || (dst.bottom > renderWindow->getHeight()) ||
 			(dst.top < 0) || (dst.bottom > renderWindow->getHeight()) ||
 			(dst.front != 0) || (dst.back != 1))
 			(dst.front != 0) || (dst.back != 1))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-				"Invalid box.",
-				"D3D9Device::copyContentsToMemory" );
+			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 		}
 		}
 
 
 		HRESULT hr;
 		HRESULT hr;
@@ -1232,9 +1204,7 @@ namespace CamelotEngine
 
 
 			if (FAILED(hr = mpDevice->GetDisplayMode(0, &dm)))
 			if (FAILED(hr = mpDevice->GetDisplayMode(0, &dm)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't get display mode: TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't get display mode: TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			desc.Width = dm.Width;
 			desc.Width = dm.Width;
@@ -1246,18 +1216,14 @@ namespace CamelotEngine
 				&pTempSurf,
 				&pTempSurf,
 				0)))
 				0)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't create offscreen buffer: TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't create offscreen buffer: TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			if (FAILED(hr = swapChain ? resources->swapChain->GetFrontBufferData(pTempSurf) :
 			if (FAILED(hr = swapChain ? resources->swapChain->GetFrontBufferData(pTempSurf) :
 				mpDevice->GetFrontBufferData(0, pTempSurf)))
 				mpDevice->GetFrontBufferData(0, pTempSurf)))
 			{
 			{
 				SAFE_RELEASE(pTempSurf);
 				SAFE_RELEASE(pTempSurf);
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't get front buffer: TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't get front buffer: TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			if(renderWindow->isFullScreen())
 			if(renderWindow->isFullScreen())
@@ -1280,9 +1246,7 @@ namespace CamelotEngine
 				if (FAILED(hr))
 				if (FAILED(hr))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't lock rect:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't lock rect:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				} 
 				} 
 			}
 			}
 			else
 			else
@@ -1308,9 +1272,7 @@ namespace CamelotEngine
 				if (FAILED(hr = pTempSurf->LockRect(&lockedRect, &srcRect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK)))
 				if (FAILED(hr = pTempSurf->LockRect(&lockedRect, &srcRect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK)))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't lock rect:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't lock rect:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				} 
 				} 
 			}
 			}
 		}
 		}
@@ -1320,16 +1282,12 @@ namespace CamelotEngine
 			if(FAILED(hr = swapChain? resources->swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pSurf) :
 			if(FAILED(hr = swapChain? resources->swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pSurf) :
 				mpDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurf)))
 				mpDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurf)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't get back buffer:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't get back buffer:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			if(FAILED(hr = pSurf->GetDesc(&desc)))
 			if(FAILED(hr = pSurf->GetDesc(&desc)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't get description:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't get description:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			if (FAILED(hr = mpDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height,
 			if (FAILED(hr = mpDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height,
@@ -1338,9 +1296,7 @@ namespace CamelotEngine
 				&pTempSurf,
 				&pTempSurf,
 				0)))
 				0)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't create offscreen surface:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't create offscreen surface:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 
 
 			if (desc.MultiSampleType == D3DMULTISAMPLE_NONE)
 			if (desc.MultiSampleType == D3DMULTISAMPLE_NONE)
@@ -1348,9 +1304,7 @@ namespace CamelotEngine
 				if (FAILED(hr = mpDevice->GetRenderTargetData(pSurf, pTempSurf)))
 				if (FAILED(hr = mpDevice->GetRenderTargetData(pSurf, pTempSurf)))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't get render target data:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't get render target data:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				}
 				}
 			}
 			}
 			else
 			else
@@ -1366,26 +1320,20 @@ namespace CamelotEngine
 					0)))
 					0)))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't create render target:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't create render target:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				}
 				}
 
 
 				if (FAILED(hr = mpDevice->StretchRect(pSurf, 0, pStretchSurf, 0, D3DTEXF_NONE)))
 				if (FAILED(hr = mpDevice->StretchRect(pSurf, 0, pStretchSurf, 0, D3DTEXF_NONE)))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pStretchSurf);
 					SAFE_RELEASE(pStretchSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't stretch rect:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't stretch rect:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				}
 				}
 				if (FAILED(hr = mpDevice->GetRenderTargetData(pStretchSurf, pTempSurf)))
 				if (FAILED(hr = mpDevice->GetRenderTargetData(pStretchSurf, pTempSurf)))
 				{
 				{
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pTempSurf);
 					SAFE_RELEASE(pStretchSurf);
 					SAFE_RELEASE(pStretchSurf);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-						"Can't get render target data:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-						"D3D9Device::copyContentsToMemory");
+					CM_EXCEPT(RenderingAPIException, "Can't get render target data:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 				}
 				}
 				SAFE_RELEASE(pStretchSurf);
 				SAFE_RELEASE(pStretchSurf);
 			}
 			}
@@ -1408,9 +1356,7 @@ namespace CamelotEngine
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				SAFE_RELEASE(pTempSurf);
 				SAFE_RELEASE(pTempSurf);
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-					"Can't lock rect:  TODO PORT NO ERROR", // TODO PORT - Translate HR to error
-					"D3D9Device::copyContentsToMemory");
+				CM_EXCEPT(RenderingAPIException, "Can't lock rect:  TODO PORT NO ERROR"); // TODO PORT - Translate HR to error
 			}
 			}
 		}
 		}
 
 
@@ -1419,8 +1365,7 @@ namespace CamelotEngine
 		if (format == PF_UNKNOWN)
 		if (format == PF_UNKNOWN)
 		{
 		{
 			SAFE_RELEASE(pTempSurf);
 			SAFE_RELEASE(pTempSurf);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
-				"Unsupported format", "D3D9Device::copyContentsToMemory");
+			CM_EXCEPT(RenderingAPIException, "Unsupported format");
 		}
 		}
 
 
 		PixelData src(dst.getWidth(), dst.getHeight(), 1, format, lockedRect.pBits);
 		PixelData src(dst.getWidth(), dst.getHeight(), 1, format, lockedRect.pBits);

+ 1 - 3
CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp

@@ -87,9 +87,7 @@ namespace CamelotEngine
 	{	
 	{	
 		if (mActiveDevice == NULL)
 		if (mActiveDevice == NULL)
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"Current active device is NULL !!!", 
-				"D3D9RenderSystem::getActiveDevice" );
+			CM_EXCEPT(InvalidParametersException, "Current active device is NULL !!!" );
 		}
 		}
 
 
 		return mActiveDevice;		
 		return mActiveDevice;		

+ 4 - 13
CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp

@@ -146,8 +146,7 @@ namespace CamelotEngine {
 			message += static_cast<const char*>(errors->GetBufferPointer());
 			message += static_cast<const char*>(errors->GetBufferPointer());
 
 
 			errors->Release();
 			errors->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, message,
-				"D3D9GpuProgram::loadFromSource");
+			CM_EXCEPT(RenderingAPIException, message);
 		}
 		}
 	
 	
 		loadFromMicrocode(d3d9Device, microcode);		
 		loadFromMicrocode(d3d9Device, microcode);		
@@ -196,19 +195,14 @@ namespace CamelotEngine {
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Cannot create D3D9 vertex shader from microcode",
-					"D3D9GpuVertexProgram::loadFromMicrocode");
-	            
+				CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 vertex shader from microcode");
 			}
 			}
 
 
 			mMapDeviceToVertexShader[d3d9Device] = pVertexShader;
 			mMapDeviceToVertexShader[d3d9Device] = pVertexShader;
 		}
 		}
 		else
 		else
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Specified D3D9 vertex shader is not supported!",
-				"D3D9GpuVertexProgram::loadFromMicrocode");
+			CM_EXCEPT(RenderingAPIException, "Specified D3D9 vertex shader is not supported!");
 
 
 			// TODO LOG PORT - Log this error somewhere
 			// TODO LOG PORT - Log this error somewhere
 			//LogManager::getSingleton().logMessage(
 			//LogManager::getSingleton().logMessage(
@@ -307,10 +301,7 @@ namespace CamelotEngine {
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Cannot create D3D9 pixel shader from microcode.",
-					"D3D9GpuFragmentProgram::loadFromMicrocode");
-	            
+				CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 pixel shader from microcode.");
 			}
 			}
 
 
 			mMapDeviceToPixelShader[d3d9Device] = pPixelShader;
 			mMapDeviceToPixelShader[d3d9Device] = pPixelShader;

+ 3 - 8
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -258,8 +258,7 @@ namespace CamelotEngine {
 				errors->Release();
 				errors->Release();
 			}
 			}
 
 
-            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, message,
-                "D3D9HLSLProgram::loadFromSource");
+            CM_EXCEPT(RenderingAPIException, message);
         }
         }
 
 
 
 
@@ -301,9 +300,7 @@ namespace CamelotEngine {
 
 
         if (FAILED(hr))
         if (FAILED(hr))
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-                "Cannot retrieve constant descriptions from HLSL program.", 
-                "D3D9HLSLProgram::buildParameterNameMap");
+			CM_EXCEPT(InternalErrorException, "Cannot retrieve constant descriptions from HLSL program.");
         }
         }
         // Iterate over the constants
         // Iterate over the constants
         for (unsigned int i = 0; i < desc.Constants; ++i)
         for (unsigned int i = 0; i < desc.Constants; ++i)
@@ -328,9 +325,7 @@ namespace CamelotEngine {
         HRESULT hr = mpConstTable->GetConstantDesc(hConstant, &desc, &numParams);
         HRESULT hr = mpConstTable->GetConstantDesc(hConstant, &desc, &numParams);
         if (FAILED(hr))
         if (FAILED(hr))
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-                "Cannot retrieve constant description from HLSL program.", 
-                "D3D9HLSLProgram::processParamElement");
+            CM_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
         }
         }
 
 
         String paramName = desc.Name;
         String paramName = desc.Name;

+ 4 - 12
CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp

@@ -264,18 +264,14 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot create D3D9 Index buffer: " + msg, 
-				"D3D9HardwareIndexBuffer::createBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 Index buffer: " + msg);
 		}
 		}
 
 
 		hr = bufferResources->mBuffer->GetDesc(&mBufferDesc);
 		hr = bufferResources->mBuffer->GetDesc(&mBufferDesc);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot get D3D9 Index buffer desc: " + msg, 
-				"D3D9HardwareIndexBuffer::createBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot get D3D9 Index buffer desc: " + msg);
 		}		
 		}		
 	}
 	}
 
 
@@ -325,9 +321,7 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot lock D3D9 vertex buffer: " + msg, 
-				"D3D9HardwareIndexBuffer::updateBufferResources");
+			CM_EXCEPT(RenderingAPIException, "Cannot lock D3D9 vertex buffer: " + msg);
 		}
 		}
 
 
 		memcpy(dstBytes, systemMemoryBuffer + bufferResources->mLockOffset, bufferResources->mLockLength);
 		memcpy(dstBytes, systemMemoryBuffer + bufferResources->mLockOffset, bufferResources->mLockLength);
@@ -337,9 +331,7 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot unlock D3D9 vertex buffer: " + msg, 
-				"D3D9HardwareIndexBuffer::updateBufferResources");
+			CM_EXCEPT(RenderingAPIException, "Cannot unlock D3D9 vertex buffer: " + msg);
 		}
 		}
 
 
 		bufferResources->mOutOfDate = false;
 		bufferResources->mOutOfDate = false;

+ 1 - 3
CamelotD3D9Renderer/Source/CmD3D9HardwareOcclusionQuery.cpp

@@ -97,9 +97,7 @@ namespace CamelotEngine {
 		
 		
 		if (it == mMapDeviceToQuery.end())
 		if (it == mMapDeviceToQuery.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"End occlusion called without matching begin call !!", 
-				"D3D9HardwareOcclusionQuery::endOcclusionQuery" );
+			CM_EXCEPT(RenderingAPIException, "End occlusion called without matching begin call !!" );
 		}
 		}
 
 
 		IDirect3DQuery9* pOccQuery = mMapDeviceToQuery[pCurDevice];
 		IDirect3DQuery9* pOccQuery = mMapDeviceToQuery[pCurDevice];

+ 29 - 59
CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp

@@ -87,8 +87,7 @@ void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *sur
 
 
 	D3DSURFACE_DESC desc;
 	D3DSURFACE_DESC desc;
 	if(surface->GetDesc(&desc) != D3D_OK)
 	if(surface->GetDesc(&desc) != D3D_OK)
-		OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get surface information",
-		 "D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer");
+		CM_EXCEPT(RenderingAPIException, "Could not get surface information");
 
 
 	mWidth = desc.Width;
 	mWidth = desc.Width;
 	mHeight = desc.Height;
 	mHeight = desc.Height;
@@ -149,8 +148,7 @@ void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volu
 	
 	
 	D3DVOLUME_DESC desc;
 	D3DVOLUME_DESC desc;
 	if(volume->GetDesc(&desc) != D3D_OK)
 	if(volume->GetDesc(&desc) != D3D_OK)
-		OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get volume information",
-		 "D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer");
+		CM_EXCEPT(RenderingAPIException, "Could not get volume information");
 	mWidth = desc.Width;
 	mWidth = desc.Width;
 	mHeight = desc.Height;
 	mHeight = desc.Height;
 	mDepth = desc.Depth;
 	mDepth = desc.Depth;
@@ -254,8 +252,7 @@ void fromD3DLock(PixelData &rval, const D3DLOCKED_RECT &lrect)
 	}
 	}
 	else
 	else
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"Invalid pixel format", "fromD3DLock");
+		CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 	}
 	}
 
 
 	rval.data = lrect.pBits;
 	rval.data = lrect.pBits;
@@ -277,8 +274,7 @@ void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
 	}
 	}
 	else
 	else
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"Invalid pixel format", "fromD3DLock");
+		CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 	}
 	}
 	rval.data = lbox.pBits;
 	rval.data = lbox.pBits;
 }
 }
@@ -336,8 +332,7 @@ PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions opti
 
 
 	// Check for misuse
 	// Check for misuse
 	if(mUsage & TU_RENDERTARGET)
 	if(mUsage & TU_RENDERTARGET)
-		OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.",
-		 	"D3D9HardwarePixelBuffer::lockImpl");		
+		CM_EXCEPT(RenderingAPIException, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.");		
 	// Set locking flags according to options
 	// Set locking flags according to options
 	DWORD flags = 0;
 	DWORD flags = 0;
 	switch(options)
 	switch(options)
@@ -357,8 +352,7 @@ PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions opti
 
 
 	if (mMapDeviceToBufferResources.size() == 0)
 	if (mMapDeviceToBufferResources.size() == 0)
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "There are no resources attached to this pixel buffer !!",
-			"D3D9HardwarePixelBuffer::lockImpl");	
+		CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
 	}
 	}
 	
 	
 	mLockedBox = lockBox;
 	mLockedBox = lockBox;
@@ -399,8 +393,7 @@ CamelotEngine::PixelData D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bu
 			hr = bufferResources->surface->LockRect(&lrect, &prect, flags);
 			hr = bufferResources->surface->LockRect(&lrect, &prect, flags);
 		}
 		}
 		if (FAILED(hr))		
 		if (FAILED(hr))		
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Surface locking failed",
-			"D3D9HardwarePixelBuffer::lockImpl");
+			CM_EXCEPT(RenderingAPIException, "Surface locking failed");
 		fromD3DLock(rval, lrect);
 		fromD3DLock(rval, lrect);
 	} 
 	} 
 	else if(bufferResources->volume) 
 	else if(bufferResources->volume) 
@@ -410,8 +403,7 @@ CamelotEngine::PixelData D3D9HardwarePixelBuffer::lockBuffer(BufferResources* bu
 		D3DLOCKED_BOX lbox; // Filled in by D3D
 		D3DLOCKED_BOX lbox; // Filled in by D3D
 
 
 		if(bufferResources->volume->LockBox(&lbox, &pbox, flags) != D3D_OK)
 		if(bufferResources->volume->LockBox(&lbox, &pbox, flags) != D3D_OK)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Volume locking failed",
-			"D3D9HardwarePixelBuffer::lockImpl");
+			CM_EXCEPT(RenderingAPIException, "Volume locking failed");
 		fromD3DLock(rval, lbox);
 		fromD3DLock(rval, lbox);
 	}
 	}
 
 
@@ -426,8 +418,7 @@ void D3D9HardwarePixelBuffer::unlockImpl(void)
 
 
 	if (mMapDeviceToBufferResources.size() == 0)
 	if (mMapDeviceToBufferResources.size() == 0)
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "There are no resources attached to this pixel buffer !!",
-			"D3D9HardwarePixelBuffer::lockImpl");	
+		CM_EXCEPT(RenderingAPIException, "There are no resources attached to this pixel buffer !!");	
 	}
 	}
 
 
 	DeviceToBufferResourcesIterator it;
 	DeviceToBufferResourcesIterator it;
@@ -484,8 +475,7 @@ void D3D9HardwarePixelBuffer::blit(const HardwarePixelBufferPtr &rsrc,
 
 
 		if (srcBufferResources == NULL)
 		if (srcBufferResources == NULL)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "There are no matching resources attached to the source pixel buffer !!",
-				"D3D9HardwarePixelBuffer::blit");	
+			CM_EXCEPT(RenderingAPIException, "There are no matching resources attached to the source pixel buffer !!");	
 		}
 		}
 
 
 		blit(it->first, rsrc, srcBox, dstBox, srcBufferResources, dstBufferResources);
 		blit(it->first, rsrc, srcBox, dstBox, srcBufferResources, dstBufferResources);
@@ -509,8 +499,7 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 
 
 		D3DSURFACE_DESC srcDesc;
 		D3DSURFACE_DESC srcDesc;
 		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
 		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get surface information",
-			"D3D9HardwarePixelBuffer::blit");
+			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
 
 
 		// If we're blitting from a RTT, try GetRenderTargetData
 		// If we're blitting from a RTT, try GetRenderTargetData
 		// if we're going to try to use GetRenderTargetData, need to use system mem pool
 		// if we're going to try to use GetRenderTargetData, need to use system mem pool
@@ -531,14 +520,12 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 				&tmptex
 				&tmptex
 				) != D3D_OK)
 				) != D3D_OK)
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Create temporary texture failed",
-					"D3D9HardwarePixelBuffer::blit");
+				CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
 			}
 			}
 			if(tmptex->GetSurfaceLevel(0, &tmpsurface) != D3D_OK)
 			if(tmptex->GetSurfaceLevel(0, &tmpsurface) != D3D_OK)
 			{
 			{
 				tmptex->Release();
 				tmptex->Release();
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get surface level failed",
-					"D3D9HardwarePixelBuffer::blit");
+				CM_EXCEPT(RenderingAPIException, "Get surface level failed");
 			}
 			}
 			if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, tmpsurface) == D3D_OK)
 			if(d3d9Device->GetRenderTargetData(srcBufferResources->surface, tmpsurface) == D3D_OK)
 			{
 			{
@@ -551,8 +538,7 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 				{
 				{
 					tmpsurface->Release();
 					tmpsurface->Release();
 					tmptex->Release();
 					tmptex->Release();
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadSurfaceFromSurface failed",
-						"D3D9HardwarePixelBuffer::blit");
+					CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
 				}
 				}
 				tmpsurface->Release();
 				tmpsurface->Release();
 				tmptex->Release();
 				tmptex->Release();
@@ -569,8 +555,7 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 			srcBufferResources->surface, NULL, &dsrcRect,
 			srcBufferResources->surface, NULL, &dsrcRect,
 			D3DX_DEFAULT, 0) != D3D_OK)
 			D3DX_DEFAULT, 0) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadSurfaceFromSurface failed",
-				"D3D9HardwarePixelBuffer::blit");
+			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
 		}
 		}
 	}
 	}
 	else if(dstBufferResources->volume && srcBufferResources->volume)
 	else if(dstBufferResources->volume && srcBufferResources->volume)
@@ -585,8 +570,7 @@ void D3D9HardwarePixelBuffer::blit(IDirect3DDevice9* d3d9Device,
 			srcBufferResources->volume, NULL, &dsrcBox,
 			srcBufferResources->volume, NULL, &dsrcBox,
 			D3DX_DEFAULT, 0) != D3D_OK)
 			D3DX_DEFAULT, 0) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadVolumeFromVolume failed",
-				"D3D9HardwarePixelBuffer::blit");
+			CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
 		}
 		}
 	}
 	}
 	else
 	else
@@ -659,8 +643,7 @@ void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &ds
 			static_cast<UINT>(rowWidth),
 			static_cast<UINT>(rowWidth),
 			NULL, &srcRect, D3DX_DEFAULT, 0) != D3D_OK)
 			NULL, &srcRect, D3DX_DEFAULT, 0) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadSurfaceFromMemory failed",
-				"D3D9HardwarePixelBuffer::blitFromMemory");
+			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
 		}
 		}
 	}
 	}
 	else if (dstBufferResources->volume)
 	else if (dstBufferResources->volume)
@@ -694,8 +677,7 @@ void D3D9HardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &ds
 			static_cast<UINT>(rowWidth), static_cast<UINT>(sliceWidth),
 			static_cast<UINT>(rowWidth), static_cast<UINT>(sliceWidth),
 			NULL, &srcBox, D3DX_DEFAULT, 0) != D3D_OK)
 			NULL, &srcBox, D3DX_DEFAULT, 0) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadSurfaceFromMemory failed",
-				"D3D9HardwarePixelBuffer::blitFromMemory");
+			CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromMemory failed");
 		}
 		}
 	}
 	}
 
 
@@ -738,8 +720,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 
 
 		D3DSURFACE_DESC srcDesc;
 		D3DSURFACE_DESC srcDesc;
 		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
 		if(srcBufferResources->surface->GetDesc(&srcDesc) != D3D_OK)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get surface information",
-			"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
 
 
 		D3DPOOL temppool = D3DPOOL_SCRATCH;
 		D3DPOOL temppool = D3DPOOL_SCRATCH;
 		// if we're going to try to use GetRenderTargetData, need to use system mem pool
 		// if we're going to try to use GetRenderTargetData, need to use system mem pool
@@ -761,14 +742,12 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 			&tmp
 			&tmp
 			) != D3D_OK)
 			) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Create temporary texture failed",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
 		}
 		}
 		if(tmp->GetSurfaceLevel(0, &surface) != D3D_OK)
 		if(tmp->GetSurfaceLevel(0, &surface) != D3D_OK)
 		{
 		{
 			tmp->Release();
 			tmp->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get surface level failed",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Get surface level failed");
 		}
 		}
 		// Copy texture to this temp surface
 		// Copy texture to this temp surface
 		RECT destRect, srcRect;
 		RECT destRect, srcRect;
@@ -778,8 +757,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 		// Get the real temp surface format
 		// Get the real temp surface format
 		D3DSURFACE_DESC dstDesc;
 		D3DSURFACE_DESC dstDesc;
 		if(surface->GetDesc(&dstDesc) != D3D_OK)
 		if(surface->GetDesc(&dstDesc) != D3D_OK)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get surface information",
-			"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Could not get surface information");
 		tmpFormat = D3D9Mappings::_getPF(dstDesc.Format);
 		tmpFormat = D3D9Mappings::_getPF(dstDesc.Format);
 
 
 		// Use fast GetRenderTargetData if we are in its usage conditions
 		// Use fast GetRenderTargetData if we are in its usage conditions
@@ -800,8 +778,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 			{
 			{
 				surface->Release();
 				surface->Release();
 				tmp->Release();
 				tmp->Release();
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadSurfaceFromSurface failed",
-					"D3D9HardwarePixelBuffer::blitToMemory");
+				CM_EXCEPT(RenderingAPIException, "D3DXLoadSurfaceFromSurface failed");
 			}
 			}
 		}
 		}
 
 
@@ -811,8 +788,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 		{
 		{
 			surface->Release();
 			surface->Release();
 			tmp->Release();
 			tmp->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "surface->LockRect",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "surface->LockRect");
 		}
 		}
 		// Copy it
 		// Copy it
 		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
 		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
@@ -838,14 +814,12 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 			&tmp
 			&tmp
 			) != D3D_OK)
 			) != D3D_OK)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Create temporary texture failed",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Create temporary texture failed");
 		}
 		}
 		if(tmp->GetVolumeLevel(0, &surface) != D3D_OK)
 		if(tmp->GetVolumeLevel(0, &surface) != D3D_OK)
 		{
 		{
 			tmp->Release();
 			tmp->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get volume level failed",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "Get volume level failed");
 		}
 		}
 		// Volume
 		// Volume
 		D3DBOX ddestBox, dsrcBox;
 		D3DBOX ddestBox, dsrcBox;
@@ -859,8 +833,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 		{
 		{
 			surface->Release();
 			surface->Release();
 			tmp->Release();
 			tmp->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3DXLoadVolumeFromVolume failed",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "D3DXLoadVolumeFromVolume failed");
 		}
 		}
 		// Lock temp surface and copy it to memory
 		// Lock temp surface and copy it to memory
 		D3DLOCKED_BOX lbox; // Filled in by D3D
 		D3DLOCKED_BOX lbox; // Filled in by D3D
@@ -868,8 +841,7 @@ void D3D9HardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &d
 		{
 		{
 			surface->Release();
 			surface->Release();
 			tmp->Release();
 			tmp->Release();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "surface->LockBox",
-				"D3D9HardwarePixelBuffer::blitToMemory");
+			CM_EXCEPT(RenderingAPIException, "surface->LockBox");
 		}
 		}
 		// Copy it
 		// Copy it
 		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
 		PixelData locked(dst.getWidth(), dst.getHeight(), dst.getDepth(), tmpFormat);
@@ -898,9 +870,7 @@ void D3D9HardwarePixelBuffer::_genMipmaps(IDirect3DBaseTexture9* mipTex)
 		// Software mipmaps
 		// Software mipmaps
 		if( D3DXFilterTexture( mipTex, NULL, D3DX_DEFAULT, D3DX_DEFAULT ) != D3D_OK )
 		if( D3DXFilterTexture( mipTex, NULL, D3DX_DEFAULT, D3DX_DEFAULT ) != D3D_OK )
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, 
-			"Failed to filter texture (generate mipmaps)",
-			 "D3D9HardwarePixelBuffer::_genMipmaps" );
+			CM_EXCEPT(RenderingAPIException, "Failed to filter texture (generate mipmaps)");
 		}
 		}
 	}
 	}
 
 

+ 4 - 12
CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp

@@ -263,18 +263,14 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot restore D3D9 vertex buffer: " + msg, 
-				"D3D9HardwareVertexBuffer::createBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot restore D3D9 vertex buffer: " + msg);
 		}
 		}
 
 
 		hr = bufferResources->mBuffer->GetDesc(&mBufferDesc);
 		hr = bufferResources->mBuffer->GetDesc(&mBufferDesc);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot get D3D9 Vertex buffer desc: " + msg, 
-				"D3D9HardwareVertexBuffer::createBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot get D3D9 Vertex buffer desc: " + msg);
 		}		
 		}		
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
@@ -324,9 +320,7 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot lock D3D9 vertex buffer: " + msg, 
-				"D3D9HardwareVertexBuffer::updateBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot lock D3D9 vertex buffer: " + msg);
 		}
 		}
 
 
 		memcpy(dstBytes, systemMemoryBuffer + bufferResources->mLockOffset, bufferResources->mLockLength);
 		memcpy(dstBytes, systemMemoryBuffer + bufferResources->mLockOffset, bufferResources->mLockLength);
@@ -336,9 +330,7 @@ namespace CamelotEngine {
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"Cannot unlock D3D9 vertex buffer: " + msg, 
-				"D3D9HardwareVertexBuffer::updateBuffer");
+			CM_EXCEPT(RenderingAPIException, "Cannot unlock D3D9 vertex buffer: " + msg);
 		}
 		}
 
 
 		bufferResources->mOutOfDate = false;
 		bufferResources->mOutOfDate = false;

+ 2 - 9
CamelotD3D9Renderer/Source/CmD3D9MultiRenderTarget.cpp

@@ -67,21 +67,14 @@ namespace CamelotEngine
 			if (mRenderTargets[y]->getWidth() != buffer->getWidth() ||
 			if (mRenderTargets[y]->getWidth() != buffer->getWidth() ||
 				mRenderTargets[y]->getHeight() != buffer->getHeight())
 				mRenderTargets[y]->getHeight() != buffer->getHeight())
 			{
 			{
-				OGRE_EXCEPT(
-					Exception::ERR_INVALIDPARAMS, 
-					"MultiRenderTarget surfaces are not of same size", 
-					"D3D9MultiRenderTarget::bindSurface");
+				CM_EXCEPT(InvalidParametersException, "MultiRenderTarget surfaces are not of same size");
 			}
 			}
 
 
 			if (!CamelotEngine::RenderSystemManager::getActive()->getCapabilities()->hasCapability(RSC_MRT_DIFFERENT_BIT_DEPTHS)
 			if (!CamelotEngine::RenderSystemManager::getActive()->getCapabilities()->hasCapability(RSC_MRT_DIFFERENT_BIT_DEPTHS)
 				&& (PixelUtil::getNumElemBits(mRenderTargets[y]->getFormat()) != 
 				&& (PixelUtil::getNumElemBits(mRenderTargets[y]->getFormat()) != 
 				PixelUtil::getNumElemBits(buffer->getFormat())))
 				PixelUtil::getNumElemBits(buffer->getFormat())))
 			{
 			{
-				OGRE_EXCEPT(
-					Exception::ERR_INVALIDPARAMS, 
-					"MultiRenderTarget surfaces are not of same bit depth and hardware requires it", 
-					"D3D9MultiRenderTarget::bindSurface"
-					);
+				CM_EXCEPT(InvalidParametersException, "MultiRenderTarget surfaces are not of same bit depth and hardware requires it");
 			}
 			}
 		}
 		}
 
 

+ 113 - 168
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -80,7 +80,7 @@ namespace CamelotEngine
 
 
 		// Create our Direct3D object
 		// Create our Direct3D object
 		if( NULL == (mpD3D = Direct3DCreate9(D3D_SDK_VERSION)) )
 		if( NULL == (mpD3D = Direct3DCreate9(D3D_SDK_VERSION)) )
-			OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Failed to create Direct3D9 object", "D3D9RenderSystem::D3D9RenderSystem" );
+			CM_EXCEPT(InternalErrorException, "Failed to create Direct3D9 object");
 
 
 		// set config options defaults
 		// set config options defaults
 		initConfigOptions();
 		initConfigOptions();
@@ -333,7 +333,7 @@ namespace CamelotEngine
 		{
 		{
 			StringUtil::StrStreamType str;
 			StringUtil::StrStreamType str;
 			str << "Option named '" << name << "' does not exist.";
 			str << "Option named '" << name << "' does not exist.";
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, str.str(), "D3D9RenderSystem::setConfigOption" );
+			CM_EXCEPT(InvalidParametersException, str.str() );
 		}
 		}
 
 
 		// Refresh other options if D3DDriver changed
 		// Refresh other options if D3DDriver changed
@@ -500,7 +500,7 @@ namespace CamelotEngine
 		}
 		}
 
 
 		if( !mActiveD3DDriver )
 		if( !mActiveD3DDriver )
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Problems finding requested Direct3D driver!", "D3D9RenderSystem::initialise" );
+			CM_EXCEPT(InvalidParametersException, "Problems finding requested Direct3D driver!" );
 
 
 		// get driver version
 		// get driver version
 		mDriverVersion.major = HIWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.HighPart);
 		mDriverVersion.major = HIWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.HighPart);
@@ -528,7 +528,7 @@ namespace CamelotEngine
 			bool fullScreen;
 			bool fullScreen;
 			opt = mOptions.find( "Full Screen" );
 			opt = mOptions.find( "Full Screen" );
 			if( opt == mOptions.end() )
 			if( opt == mOptions.end() )
-				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find full screen option!", "D3D9RenderSystem::initialise" );
+				CM_EXCEPT(InternalErrorException, "Can't find full screen option!");
 			fullScreen = opt->second.currentValue == "Yes";
 			fullScreen = opt->second.currentValue == "Yes";
 
 
 			D3D9VideoMode* videoMode = NULL;
 			D3D9VideoMode* videoMode = NULL;
@@ -537,7 +537,7 @@ namespace CamelotEngine
 
 
 			opt = mOptions.find( "Video Mode" );
 			opt = mOptions.find( "Video Mode" );
 			if( opt == mOptions.end() )
 			if( opt == mOptions.end() )
-				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find Video Mode option!", "D3D9RenderSystem::initialise" );
+				CM_EXCEPT(InternalErrorException, "Can't find Video Mode option!");
 
 
 			// The string we are manipulating looks like this :width x height @ colourDepth
 			// 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
 			// Pull out the colour depth by getting what comes after the @ and a space
@@ -566,14 +566,14 @@ namespace CamelotEngine
 			}
 			}
 
 
 			if( !videoMode )
 			if( !videoMode )
-				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find requested video mode.", "D3D9RenderSystem::initialise" );
+				CM_EXCEPT(InternalErrorException, "Can't find requested video mode.");
 
 
 			// sRGB window option
 			// sRGB window option
 			bool hwGamma = false;
 			bool hwGamma = false;
 
 
 			opt = mOptions.find( "sRGB Gamma Conversion" );
 			opt = mOptions.find( "sRGB Gamma Conversion" );
 			if( opt == mOptions.end() )
 			if( opt == mOptions.end() )
-				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Can't find sRGB option!", "D3D9RenderSystem::initialise" );
+				CM_EXCEPT(InternalErrorException, "Can't find sRGB option!");
 			hwGamma = opt->second.currentValue == "Yes";
 			hwGamma = opt->second.currentValue == "Yes";
 
 
 			NameValuePairList miscParams;
 			NameValuePairList miscParams;
@@ -658,7 +658,7 @@ namespace CamelotEngine
 		{
 		{
 			msg = "A render target of the same name '" + name + "' already "
 			msg = "A render target of the same name '" + name + "' already "
 				"exists.  You cannot create a new window with this name.";
 				"exists.  You cannot create a new window with this name.";
-			OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, msg, "D3D9RenderSystem::_createRenderWindow" );
+			CM_EXCEPT(InternalErrorException, msg);
 		}
 		}
 				
 				
 		D3D9RenderWindow* renderWindow = new D3D9RenderWindow(mhInstance);
 		D3D9RenderWindow* renderWindow = new D3D9RenderWindow(mhInstance);
@@ -1306,9 +1306,8 @@ namespace CamelotEngine
 	{
 	{
 		if (caps->getRenderSystemName() != getName())
 		if (caps->getRenderSystemName() != getName())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Trying to initialize D3D9RenderSystem from RenderSystemCapabilities that do not support Direct3D9",
-				"D3D9RenderSystem::initialiseFromRenderSystemCapabilities");
+			CM_EXCEPT(InvalidParametersException, 
+				"Trying to initialize D3D9RenderSystem from RenderSystemCapabilities that do not support Direct3D9");
 		}
 		}
 
 
 		if (caps->isShaderProfileSupported("hlsl"))
 		if (caps->isShaderProfileSupported("hlsl"))
@@ -1513,24 +1512,21 @@ namespace CamelotEngine
 	{
 	{
 		HRESULT hr = __SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( r, g, b, 1.0f ) );
 		HRESULT hr = __SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( r, g, b, 1.0f ) );
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, 
-			"Failed to set render stat D3DRS_AMBIENT", "D3D9RenderSystem::setAmbientLight" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set render stat D3DRS_AMBIENT");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setShadingType( ShadeOptions so )
 	void D3D9RenderSystem::setShadingType( ShadeOptions so )
 	{
 	{
 		HRESULT hr = __SetRenderState( D3DRS_SHADEMODE, D3D9Mappings::get(so) );
 		HRESULT hr = __SetRenderState( D3DRS_SHADEMODE, D3D9Mappings::get(so) );
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-			"Failed to set render stat D3DRS_SHADEMODE", "D3D9RenderSystem::setShadingType" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set render stat D3DRS_SHADEMODE");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setLightingEnabled( bool enabled )
 	void D3D9RenderSystem::setLightingEnabled( bool enabled )
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = __SetRenderState( D3DRS_LIGHTING, enabled ) ) )
 		if( FAILED( hr = __SetRenderState( D3DRS_LIGHTING, enabled ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-			"Failed to set render state D3DRS_LIGHTING", "D3D9RenderSystem::setLightingEnabled" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set render state D3DRS_LIGHTING");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setViewMatrix( const Matrix4 &m )
 	void D3D9RenderSystem::_setViewMatrix( const Matrix4 &m )
@@ -1546,7 +1542,7 @@ namespace CamelotEngine
 
 
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_VIEW, &mDxViewMat ) ) )
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_VIEW, &mDxViewMat ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Cannot set D3D9 view matrix", "D3D9RenderSystem::_setViewMatrix" );
+			CM_EXCEPT(RenderingAPIException, "Cannot set D3D9 view matrix");
 
 
 		// also mark clip planes dirty
 		// also mark clip planes dirty
 		if (!mClipPlanes.empty())
 		if (!mClipPlanes.empty())
@@ -1569,7 +1565,7 @@ namespace CamelotEngine
 
 
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_PROJECTION, &mDxProjMat ) ) )
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_PROJECTION, &mDxProjMat ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Cannot set D3D9 projection matrix", "D3D9RenderSystem::_setProjectionMatrix" );
+			CM_EXCEPT(RenderingAPIException, "Cannot set D3D9 projection matrix");
 
 
 		// also mark clip planes dirty
 		// also mark clip planes dirty
 		if (!mClipPlanes.empty())
 		if (!mClipPlanes.empty())
@@ -1584,7 +1580,7 @@ namespace CamelotEngine
 
 
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_WORLD, &mDxWorldMat ) ) )
 		if( FAILED( hr = getActiveD3D9Device()->SetTransform( D3DTS_WORLD, &mDxWorldMat ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Cannot set D3D9 world matrix", "D3D9RenderSystem::_setWorldMatrix" );
+			CM_EXCEPT(RenderingAPIException, "Cannot set D3D9 world matrix");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setSurfaceParams( const Color &ambient, const Color &diffuse,
 	void D3D9RenderSystem::_setSurfaceParams( const Color &ambient, const Color &diffuse,
@@ -1601,7 +1597,7 @@ namespace CamelotEngine
 
 
 		HRESULT hr = getActiveD3D9Device()->SetMaterial( &material );
 		HRESULT hr = getActiveD3D9Device()->SetMaterial( &material );
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting D3D material", "D3D9RenderSystem::_setSurfaceParams" );
+			CM_EXCEPT(RenderingAPIException, "Error setting D3D material");
 
 
 
 
 		if(tracking != TVC_NONE) 
 		if(tracking != TVC_NONE) 
@@ -1670,7 +1666,7 @@ namespace CamelotEngine
 				if( hr != S_OK )
 				if( hr != S_OK )
 				{
 				{
 					String str = "Unable to set texture in D3D9";
 					String str = "Unable to set texture in D3D9";
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setTexture" );
+					CM_EXCEPT(RenderingAPIException, str);
 				}
 				}
 
 
 				// set stage desc.
 				// set stage desc.
@@ -1696,7 +1692,7 @@ namespace CamelotEngine
 				if( hr != S_OK )
 				if( hr != S_OK )
 				{
 				{
 					String str = "Unable to disable texture '" + toString(stage) + "' in D3D9";
 					String str = "Unable to disable texture '" + toString(stage) + "' in D3D9";
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setTexture" );
+					CM_EXCEPT(RenderingAPIException, str);
 				}
 				}
 			}
 			}
 
 
@@ -1704,7 +1700,7 @@ namespace CamelotEngine
 			if( hr != S_OK )
 			if( hr != S_OK )
 			{
 			{
 				String str = "Unable to disable texture '" + toString(stage) + "' in D3D9";
 				String str = "Unable to disable texture '" + toString(stage) + "' in D3D9";
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setTexture" );
+				CM_EXCEPT(RenderingAPIException, str);
 			}
 			}
 
 
 			// set stage desc. to defaults
 			// set stage desc. to defaults
@@ -1727,7 +1723,7 @@ namespace CamelotEngine
 				{
 				{
 					String str = "Unable to disable vertex texture '" 
 					String str = "Unable to disable vertex texture '" 
 						+ toString(stage) + "' in D3D9";
 						+ toString(stage) + "' in D3D9";
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setVertexTexture" );
+					CM_EXCEPT(RenderingAPIException, str);
 				}
 				}
 			}
 			}
 
 
@@ -1745,7 +1741,7 @@ namespace CamelotEngine
 				if( hr != S_OK )
 				if( hr != S_OK )
 				{
 				{
 					String str = "Unable to set vertex texture in D3D9";
 					String str = "Unable to set vertex texture in D3D9";
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setVertexTexture" );
+					CM_EXCEPT(RenderingAPIException, str);
 				}
 				}
 
 
 				// set stage desc.
 				// set stage desc.
@@ -1776,7 +1772,7 @@ namespace CamelotEngine
 
 
 		hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXCOORDINDEX, D3D9Mappings::get(mTexStageDesc[stage].autoTexCoordType, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) | index );
 		hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXCOORDINDEX, D3D9Mappings::get(mTexStageDesc[stage].autoTexCoordType, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) | index );
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture coord. set index", "D3D9RenderSystem::_setTextureCoordSet" );
+			CM_EXCEPT(RenderingAPIException, "Unable to set texture coord. set index");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setTextureCoordCalculation( size_t stage, TexCoordCalcMethod m,
 	void D3D9RenderSystem::_setTextureCoordCalculation( size_t stage, TexCoordCalcMethod m,
@@ -1789,7 +1785,7 @@ namespace CamelotEngine
 
 
 		hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXCOORDINDEX, D3D9Mappings::get(m, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) | mTexStageDesc[stage].coordIndex );
 		hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXCOORDINDEX, D3D9Mappings::get(m, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) | mTexStageDesc[stage].coordIndex );
 		if(FAILED(hr))
 		if(FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture auto tex.coord. generation mode", "D3D9RenderSystem::_setTextureCoordCalculation" );
+			CM_EXCEPT(RenderingAPIException, "Unable to set texture auto tex.coord. generation mode");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setTextureMipmapBias(size_t unit, float bias)
 	void D3D9RenderSystem::_setTextureMipmapBias(size_t unit, float bias)
@@ -1800,8 +1796,7 @@ namespace CamelotEngine
 			HRESULT hr = __SetSamplerState(static_cast<DWORD>(unit), D3DSAMP_MIPMAPLODBIAS, 
 			HRESULT hr = __SetSamplerState(static_cast<DWORD>(unit), D3DSAMP_MIPMAPLODBIAS, 
 				*(DWORD*)&bias);
 				*(DWORD*)&bias);
 			if(FAILED(hr))
 			if(FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture mipmap bias", 
-				"D3D9RenderSystem::_setTextureMipmapBias" );
+				CM_EXCEPT(RenderingAPIException, "Unable to set texture mipmap bias");
 
 
 		}
 		}
 	}
 	}
@@ -1819,7 +1814,7 @@ namespace CamelotEngine
 		{
 		{
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
 			if( FAILED( hr ) )
 			if( FAILED( hr ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to disable texture coordinate transform", "D3D9RenderSystem::_setTextureMatrix" );
+				CM_EXCEPT(RenderingAPIException, "Unable to disable texture coordinate transform");
 			return;
 			return;
 		}
 		}
 
 
@@ -1994,18 +1989,18 @@ namespace CamelotEngine
 
 
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, texCoordDim );
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, texCoordDim );
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture coord. dimension", "D3D9RenderSystem::_setTextureMatrix" );
+				CM_EXCEPT(RenderingAPIException, "Unable to set texture coord. dimension");
 
 
 			hr = getActiveD3D9Device()->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + stage), &d3dMat );
 			hr = getActiveD3D9Device()->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + stage), &d3dMat );
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture matrix", "D3D9RenderSystem::_setTextureMatrix" );
+				CM_EXCEPT(RenderingAPIException, "Unable to set texture matrix");
 		}
 		}
 		else
 		else
 		{
 		{
 			// disable all of this
 			// disable all of this
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
 			hr = __SetTextureStageState( static_cast<DWORD>(stage), D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
 			if( FAILED( hr ) )
 			if( FAILED( hr ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to disable texture coordinate transform", "D3D9RenderSystem::_setTextureMatrix" );
+				CM_EXCEPT(RenderingAPIException, "Unable to disable texture coordinate transform");
 
 
 			// Needless to sets texture transform here, it's never used at all
 			// Needless to sets texture transform here, it's never used at all
 		}
 		}
@@ -2016,11 +2011,11 @@ namespace CamelotEngine
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSU, D3D9Mappings::get(uvw.u, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSU, D3D9Mappings::get(uvw.u, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for U", "D3D9RenderSystem::_setTextureAddressingMode" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set texture addressing mode for U" );
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSV, D3D9Mappings::get(uvw.v, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSV, D3D9Mappings::get(uvw.v, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for V", "D3D9RenderSystem::_setTextureAddressingMode" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set texture addressing mode for V");
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSW, D3D9Mappings::get(uvw.w, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_ADDRESSW, D3D9Mappings::get(uvw.w, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps()) ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for W", "D3D9RenderSystem::_setTextureAddressingMode" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set texture addressing mode for W");
 	}
 	}
 	//-----------------------------------------------------------------------------
 	//-----------------------------------------------------------------------------
 	void D3D9RenderSystem::_setTextureBorderColour(size_t stage,
 	void D3D9RenderSystem::_setTextureBorderColour(size_t stage,
@@ -2028,7 +2023,7 @@ namespace CamelotEngine
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_BORDERCOLOR, colour.getAsARGB()) ) )
 		if( FAILED( hr = __SetSamplerState( static_cast<DWORD>(stage), D3DSAMP_BORDERCOLOR, colour.getAsARGB()) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture border colour", "D3D9RenderSystem::_setTextureBorderColour" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set texture border colour");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
 	void D3D9RenderSystem::_setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
@@ -2037,24 +2032,24 @@ namespace CamelotEngine
 		if( sourceFactor == SBF_ONE && destFactor == SBF_ZERO)
 		if( sourceFactor == SBF_ONE && destFactor == SBF_ZERO)
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha blending option");
 		}
 		}
 		else
 		else
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha blending option");
 			if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set separate alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set separate alpha blending option");
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set source blend", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set source blend");
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set destination blend", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set destination blend");
 		}
 		}
 
 
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(op))))
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(op))))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set scene blending operation option", "D3D9RenderSystem::_setSceneBlendingOperation" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set scene blending operation option");
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(op))))
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(op))))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set scene blending operation option", "D3D9RenderSystem::_setSceneBlendingOperation" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set scene blending operation option");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
 	void D3D9RenderSystem::_setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
@@ -2065,28 +2060,28 @@ namespace CamelotEngine
 			sourceFactorAlpha == SBF_ONE && destFactorAlpha == SBF_ZERO)
 			sourceFactorAlpha == SBF_ONE && destFactorAlpha == SBF_ZERO)
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha blending option");
 		}
 		}
 		else
 		else
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha blending option", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha blending option");
 			if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE)))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set separate alpha blending option", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set separate alpha blending option");
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set source blend", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set source blend");
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set destination blend", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set destination blend");
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLENDALPHA, D3D9Mappings::get(sourceFactorAlpha) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLENDALPHA, D3D9Mappings::get(sourceFactorAlpha) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha source blend", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha source blend");
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLENDALPHA, D3D9Mappings::get(destFactorAlpha) ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLENDALPHA, D3D9Mappings::get(destFactorAlpha) ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha destination blend", "D3D9RenderSystem::_setSeperateSceneBlending" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set alpha destination blend");
 		}
 		}
 
 
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(op))))
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(op))))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set scene blending operation option", "D3D9RenderSystem::_setSceneBlendingOperation" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set scene blending operation option");
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(alphaOp))))
 		if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(alphaOp))))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha scene blending operation option", "D3D9RenderSystem::_setSceneBlendingOperation" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set alpha scene blending operation option");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage )
 	void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage )
@@ -2098,22 +2093,20 @@ namespace CamelotEngine
 		if (func != CMPF_ALWAYS_PASS)
 		if (func != CMPF_ALWAYS_PASS)
 		{
 		{
 			if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE,  TRUE ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE,  TRUE ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to enable alpha testing", 
-				"D3D9RenderSystem::_setAlphaRejectSettings" );
+				CM_EXCEPT(RenderingAPIException, "Failed to enable alpha testing");
 
 
 			a2c = alphaToCoverage;
 			a2c = alphaToCoverage;
 		}
 		}
 		else
 		else
 		{
 		{
 			if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE,  FALSE ) ) )
 			if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE,  FALSE ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to disable alpha testing", 
-				"D3D9RenderSystem::_setAlphaRejectSettings" );
+				CM_EXCEPT(RenderingAPIException, "Failed to disable alpha testing");
 		}
 		}
 		// Set always just be sure
 		// Set always just be sure
 		if( FAILED( hr = __SetRenderState( D3DRS_ALPHAFUNC, D3D9Mappings::get(func) ) ) )
 		if( FAILED( hr = __SetRenderState( D3DRS_ALPHAFUNC, D3D9Mappings::get(func) ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha reject function", "D3D9RenderSystem::_setAlphaRejectSettings" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set alpha reject function");
 		if( FAILED( hr = __SetRenderState( D3DRS_ALPHAREF, value ) ) )
 		if( FAILED( hr = __SetRenderState( D3DRS_ALPHAREF, value ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set render state D3DRS_ALPHAREF", "D3D9RenderSystem::_setAlphaRejectSettings" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set render state D3DRS_ALPHAREF");
 
 
 		// Alpha to coverage
 		// Alpha to coverage
 		if (getCapabilities()->hasCapability(RSC_ALPHA_TO_COVERAGE))
 		if (getCapabilities()->hasCapability(RSC_ALPHA_TO_COVERAGE))
@@ -2124,12 +2117,12 @@ namespace CamelotEngine
 				if (a2c)
 				if (a2c)
 				{
 				{
 					if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y,  (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C') ) ) )
 					if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y,  (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C') ) ) )
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" );
+						CM_EXCEPT(RenderingAPIException, "Failed to set alpha to coverage option");
 				}
 				}
 				else
 				else
 				{
 				{
 					if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y,  D3DFMT_UNKNOWN ) ) )
 					if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y,  D3DFMT_UNKNOWN ) ) )
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" );
+						CM_EXCEPT(RenderingAPIException, "Failed to set alpha to coverage option");
 				}
 				}
 
 
 			}
 			}
@@ -2138,13 +2131,13 @@ namespace CamelotEngine
 				if (a2c)
 				if (a2c)
 				{
 				{
 					if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE,  MAKEFOURCC('A','2','M','1') ) ) )
 					if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE,  MAKEFOURCC('A','2','M','1') ) ) )
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" );
+						CM_EXCEPT(RenderingAPIException, "Failed to set alpha to coverage option");
 				}
 				}
 				else
 				else
 				{
 				{
 					// discovered this through trial and error, seems to work
 					// discovered this through trial and error, seems to work
 					if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE,  MAKEFOURCC('A','2','M','0') ) ) )
 					if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE,  MAKEFOURCC('A','2','M','0') ) ) )
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" );
+						CM_EXCEPT(RenderingAPIException, "Failed to set alpha to coverage option");
 				}
 				}
 			}
 			}
 			// no hacks available for any other vendors?
 			// no hacks available for any other vendors?
@@ -2162,7 +2155,7 @@ namespace CamelotEngine
 
 
 		if( FAILED (hr = __SetRenderState(D3DRS_CULLMODE, 
 		if( FAILED (hr = __SetRenderState(D3DRS_CULLMODE, 
 			D3D9Mappings::get(mode, flip))) )
 			D3D9Mappings::get(mode, flip))) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set culling mode", "D3D9RenderSystem::_setCullingMode" );
+			CM_EXCEPT(RenderingAPIException, "Failed to set culling mode");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setDepthBufferParams( bool depthTest, bool depthWrite, CompareFunction depthFunction )
 	void D3D9RenderSystem::_setDepthBufferParams( bool depthTest, bool depthWrite, CompareFunction depthFunction )
@@ -2188,7 +2181,7 @@ namespace CamelotEngine
 			hr = __SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
 			hr = __SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
 
 
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting depth buffer test state", "D3D9RenderSystem::_setDepthBufferCheckEnabled" );
+			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer test state");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setDepthBufferWriteEnabled( bool enabled )
 	void D3D9RenderSystem::_setDepthBufferWriteEnabled( bool enabled )
@@ -2196,14 +2189,14 @@ namespace CamelotEngine
 		HRESULT hr;
 		HRESULT hr;
 
 
 		if( FAILED( hr = __SetRenderState( D3DRS_ZWRITEENABLE, enabled ) ) )
 		if( FAILED( hr = __SetRenderState( D3DRS_ZWRITEENABLE, enabled ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting depth buffer write state", "D3D9RenderSystem::_setDepthBufferWriteEnabled" );
+			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer write state");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setDepthBufferFunction( CompareFunction func )
 	void D3D9RenderSystem::_setDepthBufferFunction( CompareFunction func )
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = __SetRenderState( D3DRS_ZFUNC, D3D9Mappings::get(func) ) ) )
 		if( FAILED( hr = __SetRenderState( D3DRS_ZFUNC, D3D9Mappings::get(func) ) ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting depth buffer test function", "D3D9RenderSystem::_setDepthBufferFunction" );
+			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer test function");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setDepthBias(float constantBias, float slopeScaleBias)
 	void D3D9RenderSystem::_setDepthBias(float constantBias, float slopeScaleBias)
@@ -2217,8 +2210,7 @@ namespace CamelotEngine
 			constantBias = -constantBias / 250000.0f;
 			constantBias = -constantBias / 250000.0f;
 			HRESULT hr = __SetRenderState(D3DRS_DEPTHBIAS, FLOAT2DWORD(constantBias));
 			HRESULT hr = __SetRenderState(D3DRS_DEPTHBIAS, FLOAT2DWORD(constantBias));
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting constant depth bias", 
-				"D3D9RenderSystem::_setDepthBias");
+				CM_EXCEPT(RenderingAPIException, "Error setting constant depth bias");
 		}
 		}
 
 
 		if ((mDeviceManager->getActiveDevice()->getD3D9DeviceCaps().RasterCaps & D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS) != 0)
 		if ((mDeviceManager->getActiveDevice()->getD3D9DeviceCaps().RasterCaps & D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS) != 0)
@@ -2227,8 +2219,7 @@ namespace CamelotEngine
 			slopeScaleBias = -slopeScaleBias;
 			slopeScaleBias = -slopeScaleBias;
 			HRESULT hr = __SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, FLOAT2DWORD(slopeScaleBias));
 			HRESULT hr = __SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, FLOAT2DWORD(slopeScaleBias));
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting slope scale depth bias", 
-				"D3D9RenderSystem::_setDepthBias");
+				CM_EXCEPT(RenderingAPIException, "Error setting slope scale depth bias");
 		}
 		}
 
 
 
 
@@ -2248,8 +2239,7 @@ namespace CamelotEngine
 			val |= D3DCOLORWRITEENABLE_ALPHA;
 			val |= D3DCOLORWRITEENABLE_ALPHA;
 		HRESULT hr = __SetRenderState(D3DRS_COLORWRITEENABLE, val); 
 		HRESULT hr = __SetRenderState(D3DRS_COLORWRITEENABLE, val); 
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting colour write enable flags", 
-			"D3D9RenderSystem::_setColourBufferWriteEnabled");
+			CM_EXCEPT(RenderingAPIException, "Error setting colour write enable flags");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setFog( FogMode mode, const Color& colour, float densitiy, float start, float end )
 	void D3D9RenderSystem::_setFog( FogMode mode, const Color& colour, float densitiy, float start, float end )
@@ -2289,14 +2279,14 @@ namespace CamelotEngine
 		}
 		}
 
 
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting render state", "D3D9RenderSystem::_setFog" );
+			CM_EXCEPT(RenderingAPIException, "Error setting render state");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setPolygonMode(PolygonMode level)
 	void D3D9RenderSystem::_setPolygonMode(PolygonMode level)
 	{
 	{
 		HRESULT hr = __SetRenderState(D3DRS_FILLMODE, D3D9Mappings::get(level));
 		HRESULT hr = __SetRenderState(D3DRS_FILLMODE, D3D9Mappings::get(level));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting polygon mode.", "D3D9RenderSystem::setPolygonMode");
+			CM_EXCEPT(RenderingAPIException, "Error setting polygon mode.");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setStencilCheckEnabled(bool enabled)
 	void D3D9RenderSystem::setStencilCheckEnabled(bool enabled)
@@ -2304,8 +2294,7 @@ namespace CamelotEngine
 		// Allow stencilling
 		// Allow stencilling
 		HRESULT hr = __SetRenderState(D3DRS_STENCILENABLE, enabled);
 		HRESULT hr = __SetRenderState(D3DRS_STENCILENABLE, enabled);
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error enabling / disabling stencilling.",
-			"D3D9RenderSystem::setStencilCheckEnabled");
+			CM_EXCEPT(RenderingAPIException, "Error enabling / disabling stencilling.");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::setStencilBufferParams(CompareFunction func, 
 	void D3D9RenderSystem::setStencilBufferParams(CompareFunction func, 
@@ -2320,12 +2309,10 @@ namespace CamelotEngine
 		if (twoSidedOperation)
 		if (twoSidedOperation)
 		{
 		{
 			if (!mCurrentCapabilities->hasCapability(RSC_TWO_SIDED_STENCIL))
 			if (!mCurrentCapabilities->hasCapability(RSC_TWO_SIDED_STENCIL))
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "2-sided stencils are not supported",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(InvalidParametersException, "2-sided stencils are not supported");
 			hr = __SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
 			hr = __SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting 2-sided stencil mode.",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(RenderingAPIException, "Error setting 2-sided stencil mode.");
 			// NB: We should always treat CCW as front face for consistent with default
 			// NB: We should always treat CCW as front face for consistent with default
 			// culling mode. Therefore, we must take care with two-sided stencil settings.
 			// culling mode. Therefore, we must take care with two-sided stencil settings.
 			flip = (mInvertVertexWinding && mActiveRenderTarget->requiresTextureFlipping()) ||
 			flip = (mInvertVertexWinding && mActiveRenderTarget->requiresTextureFlipping()) ||
@@ -2335,65 +2322,55 @@ namespace CamelotEngine
 			// fail op
 			// fail op
 			hr = __SetRenderState(D3DRS_CCW_STENCILFAIL, D3D9Mappings::get(stencilFailOp, !flip));
 			hr = __SetRenderState(D3DRS_CCW_STENCILFAIL, D3D9Mappings::get(stencilFailOp, !flip));
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil fail operation (2-sided).",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(RenderingAPIException, "Error setting stencil fail operation (2-sided).");
 
 
 			// depth fail op
 			// depth fail op
 			hr = __SetRenderState(D3DRS_CCW_STENCILZFAIL, D3D9Mappings::get(depthFailOp, !flip));
 			hr = __SetRenderState(D3DRS_CCW_STENCILZFAIL, D3D9Mappings::get(depthFailOp, !flip));
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil depth fail operation (2-sided).",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(RenderingAPIException, "Error setting stencil depth fail operation (2-sided).");
 
 
 			// pass op
 			// pass op
 			hr = __SetRenderState(D3DRS_CCW_STENCILPASS, D3D9Mappings::get(passOp, !flip));
 			hr = __SetRenderState(D3DRS_CCW_STENCILPASS, D3D9Mappings::get(passOp, !flip));
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil pass operation (2-sided).",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(RenderingAPIException, "Error setting stencil pass operation (2-sided).");
 		}
 		}
 		else
 		else
 		{
 		{
 			hr = __SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
 			hr = __SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
 			if (FAILED(hr))
 			if (FAILED(hr))
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting 1-sided stencil mode.",
-				"D3D9RenderSystem::setStencilBufferParams");
+				CM_EXCEPT(RenderingAPIException, "Error setting 1-sided stencil mode.");
 			flip = false;
 			flip = false;
 		}
 		}
 
 
 		// func
 		// func
 		hr = __SetRenderState(D3DRS_STENCILFUNC, D3D9Mappings::get(func));
 		hr = __SetRenderState(D3DRS_STENCILFUNC, D3D9Mappings::get(func));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil buffer test function.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil buffer test function.");
 
 
 		// reference value
 		// reference value
 		hr = __SetRenderState(D3DRS_STENCILREF, refValue);
 		hr = __SetRenderState(D3DRS_STENCILREF, refValue);
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil buffer reference value.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil buffer reference value.");
 
 
 		// mask
 		// mask
 		hr = __SetRenderState(D3DRS_STENCILMASK, mask);
 		hr = __SetRenderState(D3DRS_STENCILMASK, mask);
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil buffer mask.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil buffer mask.");
 
 
 		// fail op
 		// fail op
 		hr = __SetRenderState(D3DRS_STENCILFAIL, D3D9Mappings::get(stencilFailOp, flip));
 		hr = __SetRenderState(D3DRS_STENCILFAIL, D3D9Mappings::get(stencilFailOp, flip));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil fail operation.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil fail operation.");
 
 
 		// depth fail op
 		// depth fail op
 		hr = __SetRenderState(D3DRS_STENCILZFAIL, D3D9Mappings::get(depthFailOp, flip));
 		hr = __SetRenderState(D3DRS_STENCILZFAIL, D3D9Mappings::get(depthFailOp, flip));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil depth fail operation.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil depth fail operation.");
 
 
 		// pass op
 		// pass op
 		hr = __SetRenderState(D3DRS_STENCILPASS, D3D9Mappings::get(passOp, flip));
 		hr = __SetRenderState(D3DRS_STENCILPASS, D3D9Mappings::get(passOp, flip));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error setting stencil pass operation.",
-			"D3D9RenderSystem::setStencilBufferParams");
+			CM_EXCEPT(RenderingAPIException, "Error setting stencil pass operation.");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setTextureUnitFiltering(size_t unit, FilterType ftype, 
 	void D3D9RenderSystem::_setTextureUnitFiltering(size_t unit, FilterType ftype, 
@@ -2404,7 +2381,7 @@ namespace CamelotEngine
 		hr = __SetSamplerState( static_cast<DWORD>(unit), D3D9Mappings::get(ftype), 
 		hr = __SetSamplerState( static_cast<DWORD>(unit), D3D9Mappings::get(ftype), 
 			D3D9Mappings::get(ftype, filter, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps(), texType));
 			D3D9Mappings::get(ftype, filter, mDeviceManager->getActiveDevice()->getD3D9DeviceCaps(), texType));
 		if (FAILED(hr))
 		if (FAILED(hr))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture filter ", "D3D9RenderSystem::_setTextureUnitFiltering");
+			CM_EXCEPT(RenderingAPIException, "Failed to set texture filter ");
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	DWORD D3D9RenderSystem::_getCurrentAnisotropy(size_t unit)
 	DWORD D3D9RenderSystem::_getCurrentAnisotropy(size_t unit)
@@ -2525,14 +2502,14 @@ namespace CamelotEngine
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				String msg = DXGetErrorDescription(hr);
 				String msg = DXGetErrorDescription(hr);
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setRenderTarget : " + msg, "D3D9RenderSystem::_setViewport" );
+				CM_EXCEPT(RenderingAPIException, "Failed to setRenderTarget : " + msg);
 			}
 			}
 		}
 		}
 		hr = getActiveD3D9Device()->SetDepthStencilSurface(pDepth);
 		hr = getActiveD3D9Device()->SetDepthStencilSurface(pDepth);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to setDepthStencil : " + msg, "D3D9RenderSystem::_setViewport" );
+			CM_EXCEPT(RenderingAPIException, "Failed to setDepthStencil : " + msg);
 		}
 		}
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
@@ -2569,7 +2546,7 @@ namespace CamelotEngine
 			d3dvp.MaxZ = 1.0f;
 			d3dvp.MaxZ = 1.0f;
 
 
 			if( FAILED( hr = getActiveD3D9Device()->SetViewport( &d3dvp ) ) )
 			if( FAILED( hr = getActiveD3D9Device()->SetViewport( &d3dvp ) ) )
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set viewport.", "D3D9RenderSystem::_setViewport" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set viewport.");
 
 
 			// Set sRGB write mode
 			// Set sRGB write mode
 			__SetRenderState(D3DRS_SRGBWRITEENABLE, target->isHardwareGammaEnabled());
 			__SetRenderState(D3DRS_SRGBWRITEENABLE, target->isHardwareGammaEnabled());
@@ -2581,12 +2558,12 @@ namespace CamelotEngine
 		HRESULT hr;
 		HRESULT hr;
 
 
 		if( !mActiveViewport )
 		if( !mActiveViewport )
-			OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Cannot begin frame - no viewport selected.", "D3D9RenderSystem::_beginFrame" );
+			CM_EXCEPT(InternalErrorException, "Cannot begin frame - no viewport selected.");
 
 
 		if( FAILED( hr = getActiveD3D9Device()->BeginScene() ) )
 		if( FAILED( hr = getActiveD3D9Device()->BeginScene() ) )
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error beginning frame :" + msg, "D3D9RenderSystem::_beginFrame" );
+			CM_EXCEPT(RenderingAPIException, "Error beginning frame :" + msg);
 		}
 		}
 
 
 		mLastVertexSourceCount = 0;
 		mLastVertexSourceCount = 0;
@@ -2602,7 +2579,7 @@ namespace CamelotEngine
 	{
 	{
 		HRESULT hr;
 		HRESULT hr;
 		if( FAILED( hr = getActiveD3D9Device()->EndScene() ) )
 		if( FAILED( hr = getActiveD3D9Device()->EndScene() ) )
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error ending frame", "D3D9RenderSystem::_endFrame" );
+			CM_EXCEPT(RenderingAPIException, "Error ending frame");
 
 
 		mDeviceManager->destroyInactiveRenderDevices();
 		mDeviceManager->destroyInactiveRenderDevices();
 	}
 	}
@@ -2704,8 +2681,7 @@ namespace CamelotEngine
 
 
 		if (FAILED(hr = getActiveD3D9Device()->SetVertexDeclaration(d3ddecl->getD3DVertexDeclaration())))
 		if (FAILED(hr = getActiveD3D9Device()->SetVertexDeclaration(d3ddecl->getD3DVertexDeclaration())))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set D3D9 vertex declaration", 
-				"D3D9RenderSystem::setVertexDeclaration");
+			CM_EXCEPT(RenderingAPIException, "Unable to set D3D9 vertex declaration");
 		}
 		}
 
 
 	}
 	}
@@ -2727,8 +2703,7 @@ namespace CamelotEngine
 				hr = getActiveD3D9Device()->SetStreamSource(static_cast<UINT>(source), NULL, 0, 0);
 				hr = getActiveD3D9Device()->SetStreamSource(static_cast<UINT>(source), NULL, 0, 0);
 				if (FAILED(hr))
 				if (FAILED(hr))
 				{
 				{
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to reset unused D3D9 stream source", 
-						"D3D9RenderSystem::setVertexBufferBinding");
+					CM_EXCEPT(RenderingAPIException, "Unable to reset unused D3D9 stream source");
 				}
 				}
 			}
 			}
 
 
@@ -2742,8 +2717,7 @@ namespace CamelotEngine
 				);
 				);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set D3D9 stream source for buffer binding", 
-					"D3D9RenderSystem::setVertexBufferBinding");
+				CM_EXCEPT(RenderingAPIException, "Unable to set D3D9 stream source for buffer binding");
 			}
 			}
 
 
 
 
@@ -2756,8 +2730,7 @@ namespace CamelotEngine
 			hr = getActiveD3D9Device()->SetStreamSource(static_cast<UINT>(unused), NULL, 0, 0);
 			hr = getActiveD3D9Device()->SetStreamSource(static_cast<UINT>(unused), NULL, 0, 0);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to reset unused D3D9 stream source", 
-					"D3D9RenderSystem::setVertexBufferBinding");
+				CM_EXCEPT(RenderingAPIException, "Unable to reset unused D3D9 stream source");
 			}
 			}
 
 
 		}
 		}
@@ -2829,7 +2802,7 @@ namespace CamelotEngine
 			hr = getActiveD3D9Device()->SetIndices( d3dIdxBuf->getD3DIndexBuffer() );
 			hr = getActiveD3D9Device()->SetIndices( d3dIdxBuf->getD3DIndexBuffer() );
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set index buffer", "D3D9RenderSystem::_render" );
+				CM_EXCEPT(RenderingAPIException, "Failed to set index buffer");
 			}
 			}
 
 
 			do
 			do
@@ -2878,7 +2851,7 @@ namespace CamelotEngine
 		if( FAILED( hr ) )
 		if( FAILED( hr ) )
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to DrawPrimitive : " + msg, "D3D9RenderSystem::_render" );
+			CM_EXCEPT(RenderingAPIException, "Failed to DrawPrimitive : " + msg);
 		}
 		}
 
 
 	}
 	}
@@ -2899,7 +2872,7 @@ namespace CamelotEngine
 				static_cast<D3D9GpuVertexProgram*>(prg)->getVertexShader());
 				static_cast<D3D9GpuVertexProgram*>(prg)->getVertexShader());
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error calling SetVertexShader", "D3D9RenderSystem::bindGpuProgram");
+				CM_EXCEPT(RenderingAPIException, "Error calling SetVertexShader");
 			}
 			}
 			break;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
@@ -2907,7 +2880,7 @@ namespace CamelotEngine
 				static_cast<D3D9GpuFragmentProgram*>(prg)->getPixelShader());
 				static_cast<D3D9GpuFragmentProgram*>(prg)->getPixelShader());
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error calling SetPixelShader", "D3D9RenderSystem::bindGpuProgram");
+				CM_EXCEPT(RenderingAPIException, "Error calling SetPixelShader");
 			}
 			}
 			break;
 			break;
 		};
 		};
@@ -2933,8 +2906,7 @@ namespace CamelotEngine
 			hr = getActiveD3D9Device()->SetVertexShader(NULL);
 			hr = getActiveD3D9Device()->SetVertexShader(NULL);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error resetting SetVertexShader to NULL", 
-					"D3D9RenderSystem::unbindGpuProgram");
+				CM_EXCEPT(RenderingAPIException, "Error resetting SetVertexShader to NULL");
 			}
 			}
 			break;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
@@ -2942,8 +2914,7 @@ namespace CamelotEngine
 			hr = getActiveD3D9Device()->SetPixelShader(NULL);
 			hr = getActiveD3D9Device()->SetPixelShader(NULL);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error resetting SetPixelShader to NULL", 
-					"D3D9RenderSystem::unbindGpuProgram");
+				CM_EXCEPT(RenderingAPIException, "Error resetting SetPixelShader to NULL");
 			}
 			}
 			break;
 			break;
 		};
 		};
@@ -2991,9 +2962,7 @@ namespace CamelotEngine
 						if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantF(
 						if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantF(
 							(UINT)logicalIndex, pFloat, (UINT)slotCount)))
 							(UINT)logicalIndex, pFloat, (UINT)slotCount)))
 							{
 							{
-								OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-									"Unable to upload vertex shader float parameters", 
-									"D3D9RenderSystem::bindGpuProgramParameters");
+								CM_EXCEPT(RenderingAPIException, "Unable to upload vertex shader float parameters");
 							}
 							}
 						}
 						}
 
 
@@ -3018,9 +2987,7 @@ namespace CamelotEngine
 						if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantI(
 						if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantI(
 							static_cast<UINT>(logicalIndex), pInt, static_cast<UINT>(slotCount))))
 							static_cast<UINT>(logicalIndex), pInt, static_cast<UINT>(slotCount))))
 							{
 							{
-								OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-									"Unable to upload vertex shader int parameters", 
-									"D3D9RenderSystem::bindGpuProgramParameters");
+								CM_EXCEPT(RenderingAPIException, "Unable to upload vertex shader int parameters");
 							}
 							}
 						}
 						}
 					}
 					}
@@ -3047,9 +3014,7 @@ namespace CamelotEngine
 						if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantF(
 						if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantF(
 							static_cast<UINT>(logicalIndex), pFloat, static_cast<UINT>(slotCount))))
 							static_cast<UINT>(logicalIndex), pFloat, static_cast<UINT>(slotCount))))
 							{
 							{
-								OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-									"Unable to upload pixel shader float parameters", 
-									"D3D9RenderSystem::bindGpuProgramParameters");
+								CM_EXCEPT(RenderingAPIException, "Unable to upload pixel shader float parameters");
 							}
 							}
 						}
 						}
 					}
 					}
@@ -3073,9 +3038,7 @@ namespace CamelotEngine
 						if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantI(
 						if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantI(
 							static_cast<UINT>(logicalIndex), pInt, static_cast<UINT>(slotCount))))
 							static_cast<UINT>(logicalIndex), pInt, static_cast<UINT>(slotCount))))
 							{
 							{
-								OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-									"Unable to upload pixel shader int parameters", 
-									"D3D9RenderSystem::bindGpuProgramParameters");
+								CM_EXCEPT(RenderingAPIException, "Unable to upload pixel shader int parameters");
 							}
 							}
 						}
 						}
 
 
@@ -3106,9 +3069,7 @@ namespace CamelotEngine
 				if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantF(
 				if (FAILED(hr = getActiveD3D9Device()->SetVertexShaderConstantF(
 					static_cast<UINT>(logicalIndex), pFloat, 1)))
 					static_cast<UINT>(logicalIndex), pFloat, 1)))
 				{
 				{
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-						"Unable to upload vertex shader multi pass parameters", 
-						"D3D9RenderSystem::bindGpuProgramMultiPassParameters");
+					CM_EXCEPT(RenderingAPIException, "Unable to upload vertex shader multi pass parameters");
 				}
 				}
 			}
 			}
 			break;
 			break;
@@ -3122,9 +3083,7 @@ namespace CamelotEngine
 				if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantF(
 				if (FAILED(hr = getActiveD3D9Device()->SetPixelShaderConstantF(
 					static_cast<UINT>(logicalIndex), pFloat, 1)))
 					static_cast<UINT>(logicalIndex), pFloat, 1)))
 				{
 				{
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-						"Unable to upload pixel shader multi pass parameters", 
-						"D3D9RenderSystem::bindGpuProgramMultiPassParameters");
+					CM_EXCEPT(RenderingAPIException, "Unable to upload pixel shader multi pass parameters");
 				}
 				}
 			}
 			}
 			break;
 			break;
@@ -3164,8 +3123,7 @@ namespace CamelotEngine
 			hr = getActiveD3D9Device()->SetClipPlane(static_cast<DWORD>(i), dx9ClipPlane);
 			hr = getActiveD3D9Device()->SetClipPlane(static_cast<DWORD>(i), dx9ClipPlane);
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set clip plane", 
-					"D3D9RenderSystem::setClipPlanes");
+				CM_EXCEPT(RenderingAPIException, "Unable to set clip plane");
 			}
 			}
 
 
 			mask |= (1 << i);
 			mask |= (1 << i);
@@ -3174,8 +3132,7 @@ namespace CamelotEngine
 		hr = __SetRenderState(D3DRS_CLIPPLANEENABLE, mask);
 		hr = __SetRenderState(D3DRS_CLIPPLANEENABLE, mask);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set render state for clip planes", 
-				"D3D9RenderSystem::setClipPlanes");
+			CM_EXCEPT(RenderingAPIException, "Unable to set render state for clip planes");
 		}
 		}
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
@@ -3187,8 +3144,7 @@ namespace CamelotEngine
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to enable scissor rendering state; " + getErrorDescription(hr), 
-					"D3D9RenderSystem::setScissorTest");
+				CM_EXCEPT(RenderingAPIException, "Unable to enable scissor rendering state; " + getErrorDescription(hr));
 			}
 			}
 			RECT rect;
 			RECT rect;
 			rect.left = static_cast<LONG>(left);
 			rect.left = static_cast<LONG>(left);
@@ -3197,16 +3153,14 @@ namespace CamelotEngine
 			rect.right = static_cast<LONG>(right);
 			rect.right = static_cast<LONG>(right);
 			if (FAILED(hr = getActiveD3D9Device()->SetScissorRect(&rect)))
 			if (FAILED(hr = getActiveD3D9Device()->SetScissorRect(&rect)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set scissor rectangle; " + getErrorDescription(hr), 
-					"D3D9RenderSystem::setScissorTest");
+				CM_EXCEPT(RenderingAPIException, "Unable to set scissor rectangle; " + getErrorDescription(hr));
 			}
 			}
 		}
 		}
 		else
 		else
 		{
 		{
 			if (FAILED(hr = __SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE)))
 			if (FAILED(hr = __SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE)))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to disable scissor rendering state; " + getErrorDescription(hr), 
-					"D3D9RenderSystem::setScissorTest");
+				CM_EXCEPT(RenderingAPIException, "Unable to disable scissor rendering state; " + getErrorDescription(hr));
 			}
 			}
 		}
 		}
 	}
 	}
@@ -3238,8 +3192,7 @@ namespace CamelotEngine
 			stencil ) ) )
 			stencil ) ) )
 		{
 		{
 			String msg = DXGetErrorDescription(hr);
 			String msg = DXGetErrorDescription(hr);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error clearing frame buffer : " 
-				+ msg, "D3D9RenderSystem::clearFrameBuffer" );
+			CM_EXCEPT(RenderingAPIException, "Error clearing frame buffer : " + msg);
 		}
 		}
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
@@ -3391,9 +3344,7 @@ namespace CamelotEngine
 
 
 		if (pDirect3D9 == NULL)
 		if (pDirect3D9 == NULL)
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"Direct3D9 interface is NULL !!!", 
-				"D3D9RenderSystem::getDirect3D9" );
+			CM_EXCEPT(InvalidParametersException, "Direct3D9 interface is NULL !!!");
 		}
 		}
 
 
 		return pDirect3D9;
 		return pDirect3D9;
@@ -3413,9 +3364,7 @@ namespace CamelotEngine
 			return msD3D9RenderSystem->mDeviceManager->getDeviceCount();
 			return msD3D9RenderSystem->mDeviceManager->getDeviceCount();
 		}
 		}
 
 
-		OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-			"Invalid resource creation policy !!!", 
-			"D3D9RenderSystem::getResourceCreationDeviceCount" );
+		CM_EXCEPT(InvalidParametersException, "Invalid resource creation policy !!!" );
 
 
 		return 0;
 		return 0;
 	}
 	}
@@ -3436,9 +3385,7 @@ namespace CamelotEngine
 		}
 		}
 		else
 		else
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"Invalid resource creation policy !!!", 
-				"D3D9RenderSystem::getResourceCreationDevice" );
+			CM_EXCEPT(InvalidParametersException, "Invalid resource creation policy !!!" );
 		}
 		}
 
 
 		return d3d9Device;
 		return d3d9Device;
@@ -3454,9 +3401,7 @@ namespace CamelotEngine
 
 
 		if (d3d9Device == NULL)
 		if (d3d9Device == NULL)
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"Current d3d9 device is NULL !!!", 
-				"D3D9RenderSystem::getActiveD3D9Device" );
+			CM_EXCEPT(InvalidParametersException, "Current d3d9 device is NULL !!!" );
 		}
 		}
 
 
 		return d3d9Device;
 		return d3d9Device;
@@ -3570,7 +3515,7 @@ namespace CamelotEngine
 			if(FAILED(hr))
 			if(FAILED(hr))
 			{
 			{
 				String msg = DXGetErrorDescription(hr);
 				String msg = DXGetErrorDescription(hr);
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error CreateDepthStencilSurface : " + msg, "D3D9RenderSystem::_getDepthStencilFor" );
+				CM_EXCEPT(InvalidParametersException, "Error CreateDepthStencilSurface : " + msg);
 			}
 			}
 			/// And cache it
 			/// And cache it
 			ZBufferRef zb;
 			ZBufferRef zb;

+ 34 - 67
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -80,9 +80,8 @@ namespace CamelotEngine
 		if (target->getUsage() != getUsage() ||
 		if (target->getUsage() != getUsage() ||
 			target->getTextureType() != getTextureType())
 			target->getTextureType() != getTextureType())
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-					"Src. and dest. textures must be of same type and must have the same usage !!!", 
-					"D3D9Texture::copyToTexture" );
+			CM_EXCEPT(InvalidParametersException, 
+					"Src. and dest. textures must be of same type and must have the same usage !!!");
 		}
 		}
 
 
         HRESULT hr;
         HRESULT hr;
@@ -109,7 +108,7 @@ namespace CamelotEngine
 				if( FAILED( hr = srcTextureResource->pNormTex->GetSurfaceLevel(0, &pSrcSurface) ) )
 				if( FAILED( hr = srcTextureResource->pNormTex->GetSurfaceLevel(0, &pSrcSurface) ) )
 				{
 				{
 					String msg = DXGetErrorDescription(hr);
 					String msg = DXGetErrorDescription(hr);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+					CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg);
 				}
 				}
 
 
 				// get our target surface
 				// get our target surface
@@ -118,7 +117,7 @@ namespace CamelotEngine
 				{
 				{
 					String msg = DXGetErrorDescription(hr);
 					String msg = DXGetErrorDescription(hr);
 					SAFE_RELEASE(pSrcSurface);
 					SAFE_RELEASE(pSrcSurface);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+					CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg );
 				}
 				}
 
 
 				// do the blit, it's called StretchRect in D3D9 :)
 				// do the blit, it's called StretchRect in D3D9 :)
@@ -127,7 +126,7 @@ namespace CamelotEngine
 					String msg = DXGetErrorDescription(hr);
 					String msg = DXGetErrorDescription(hr);
 					SAFE_RELEASE(pSrcSurface);
 					SAFE_RELEASE(pSrcSurface);
 					SAFE_RELEASE(pDstSurface);
 					SAFE_RELEASE(pDstSurface);
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+					CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg);
 				}
 				}
 
 
 				// release temp. surfaces
 				// release temp. surfaces
@@ -146,7 +145,7 @@ namespace CamelotEngine
 					if( FAILED( hr =srcTextureResource->pCubeTex->GetCubeMapSurface((D3DCUBEMAP_FACES)face, 0, &pSrcSurface) ) )
 					if( FAILED( hr =srcTextureResource->pCubeTex->GetCubeMapSurface((D3DCUBEMAP_FACES)face, 0, &pSrcSurface) ) )
 					{
 					{
 						String msg = DXGetErrorDescription(hr);
 						String msg = DXGetErrorDescription(hr);
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+						CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg);
 					}
 					}
 
 
 					// get our target surface
 					// get our target surface
@@ -155,7 +154,7 @@ namespace CamelotEngine
 					{
 					{
 						String msg = DXGetErrorDescription(hr);
 						String msg = DXGetErrorDescription(hr);
 						SAFE_RELEASE(pSrcSurface);
 						SAFE_RELEASE(pSrcSurface);
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+						CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg);
 					}
 					}
 
 
 					// do the blit, it's called StretchRect in D3D9 :)
 					// do the blit, it's called StretchRect in D3D9 :)
@@ -164,7 +163,7 @@ namespace CamelotEngine
 						String msg = DXGetErrorDescription(hr);
 						String msg = DXGetErrorDescription(hr);
 						SAFE_RELEASE(pSrcSurface);
 						SAFE_RELEASE(pSrcSurface);
 						SAFE_RELEASE(pDstSurface);
 						SAFE_RELEASE(pDstSurface);
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Couldn't blit : " + msg, "D3D9Texture::copyToTexture" );
+						CM_EXCEPT(RenderingAPIException, "Couldn't blit : " + msg);
 					}
 					}
 
 
 					// release temp. surfaces
 					// release temp. surfaces
@@ -174,9 +173,7 @@ namespace CamelotEngine
 			}
 			}
 			else
 			else
 			{
 			{
-				OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED, 
-					"Copy to texture is implemented only for 2D and cube textures !!!", 
-					"D3D9Texture::copyToTexture" );
+				CM_EXCEPT(NotImplementedException, "Copy to texture is implemented only for 2D and cube textures !!!");
 			}
 			}
 
 
 			++it;
 			++it;
@@ -932,7 +929,7 @@ namespace CamelotEngine
 			break;
 			break;
 		default:
 		default:
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Unknown texture type", "D3D9Texture::createInternalResources" );
+			CM_EXCEPT(InternalErrorException, "Unknown texture type");
 		}
 		}
 	}
 	}
 
 
@@ -1039,8 +1036,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error creating texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createNormTex" );
+			CM_EXCEPT(RenderingAPIException, "Error creating texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 		
 		
 		// set the base texture we'll use in the render system
 		// set the base texture we'll use in the render system
@@ -1048,8 +1044,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get base texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createNormTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get base texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 		
 		
 		// set final tex. attributes from tex. description
 		// set final tex. attributes from tex. description
@@ -1059,8 +1054,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get texture description: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createNormTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
 		if (mFSAAType)
 		if (mFSAAType)
@@ -1074,9 +1068,7 @@ namespace CamelotEngine
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Unable to create AA render target: " + String(DXGetErrorDescription(hr)), 
-					"D3D9Texture::_createNormTex");
+				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 
 
 		}
 		}
@@ -1090,8 +1082,7 @@ namespace CamelotEngine
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			if(FAILED(hr))
 			if(FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not set best autogen filter type: "  + String(DXGetErrorDescription(hr)), 
-					"D3D9Texture::_createNormTex" );
+				CM_EXCEPT(RenderingAPIException, "Could not set best autogen filter type: "  + String(DXGetErrorDescription(hr)));
 			}
 			}
 		}
 		}
 
 
@@ -1196,8 +1187,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error creating texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createCubeTex" );
+			CM_EXCEPT(RenderingAPIException, "Error creating texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
 		// set the base texture we'll use in the render system
 		// set the base texture we'll use in the render system
@@ -1205,8 +1195,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get base texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createCubeTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get base texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 		
 		
 		// set final tex. attributes from tex. description
 		// set final tex. attributes from tex. description
@@ -1216,8 +1205,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get texture description: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createCubeTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
 		if (mFSAAType)
 		if (mFSAAType)
@@ -1231,9 +1219,7 @@ namespace CamelotEngine
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-					"Unable to create AA render target: " + String(DXGetErrorDescription(hr)), 
-					"D3D9Texture::_createCubeTex");
+				CM_EXCEPT(RenderingAPIException, "Unable to create AA render target: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 		}
 		}
 
 
@@ -1246,8 +1232,7 @@ namespace CamelotEngine
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			if(FAILED(hr))
 			if(FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not set best autogen filter type: " + String(DXGetErrorDescription(hr)), 
-					"D3D9Texture::_createCubeTex" );
+				CM_EXCEPT(RenderingAPIException, "Could not set best autogen filter type: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 		}
 		}
 
 
@@ -1260,8 +1245,7 @@ namespace CamelotEngine
 
 
 		if (mUsage & TU_RENDERTARGET)
 		if (mUsage & TU_RENDERTARGET)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "D3D9 Volume texture can not be created as render target !!", 
-				"D3D9Texture::_createVolumeTex" );
+			CM_EXCEPT(RenderingAPIException, "D3D9 Volume texture can not be created as render target !!");
 		}
 		}
 
 
 		// determine which D3D9 pixel format we'll use
 		// determine which D3D9 pixel format we'll use
@@ -1348,8 +1332,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error creating texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createVolumeTex" );
+			CM_EXCEPT(RenderingAPIException, "Error creating texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 
 
 		// set the base texture we'll use in the render system
 		// set the base texture we'll use in the render system
@@ -1357,8 +1340,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get base texture: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createVolumeTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get base texture: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 		
 		
 		// set final tex. attributes from tex. description
 		// set final tex. attributes from tex. description
@@ -1368,8 +1350,7 @@ namespace CamelotEngine
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
 			freeInternalResources();
 			freeInternalResources();
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't get texture description: " + String(DXGetErrorDescription(hr)), 
-				"D3D9Texture::_createVolumeTex" );
+			CM_EXCEPT(RenderingAPIException, "Can't get texture description: " + String(DXGetErrorDescription(hr)));
 		}
 		}
 		_setFinalAttributes(d3d9Device, textureResources,
 		_setFinalAttributes(d3d9Device, textureResources,
 			desc.Width, desc.Height, desc.Depth, D3D9Mappings::_getPF(desc.Format));
 			desc.Width, desc.Height, desc.Depth, D3D9Mappings::_getPF(desc.Format));
@@ -1380,8 +1361,7 @@ namespace CamelotEngine
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			hr = textureResources->pBaseTex->SetAutoGenFilterType(_getBestFilterMethod(d3d9Device));
 			if(FAILED(hr))
 			if(FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not set best autogen filter type: " + String(DXGetErrorDescription(hr)), 
-					"D3D9Texture::_createCubeTex" );
+				CM_EXCEPT(RenderingAPIException, "Could not set best autogen filter type: " + String(DXGetErrorDescription(hr)));
 			}
 			}
 		}
 		}
 	}
 	}
@@ -1457,9 +1437,7 @@ namespace CamelotEngine
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"GetDirect3D failed !!!", 				
-				"D3D9Texture::_canUseDynamicTextures" );
+			CM_EXCEPT(InvalidParametersException, "GetDirect3D failed !!!");
 		}
 		}
 		if (pD3D != NULL)
 		if (pD3D != NULL)
 			pD3D->Release();
 			pD3D->Release();
@@ -1496,9 +1474,7 @@ namespace CamelotEngine
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"GetDirect3D failed !!!", 
-				"D3D9Texture::_canUseDynamicTextures" );
+			CM_EXCEPT(InvalidParametersException, "GetDirect3D failed !!!" );
 		}
 		}
 		if (pD3D != NULL)
 		if (pD3D != NULL)
 			pD3D->Release();
 			pD3D->Release();
@@ -1540,9 +1516,7 @@ namespace CamelotEngine
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		hr = d3d9Device->GetDirect3D(&pD3D);
 		if (FAILED(hr))
 		if (FAILED(hr))
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
-				"GetDirect3D failed !!!", 
-				"D3D9Texture::_canUseDynamicTextures" );
+			CM_EXCEPT(InvalidParametersException, "GetDirect3D failed !!!");
 		}
 		}
 		if (pD3D != NULL)
 		if (pD3D != NULL)
 			pD3D->Release();
 			pD3D->Release();
@@ -1650,8 +1624,7 @@ namespace CamelotEngine
 			for(mip=0; mip<=mNumMipmaps; ++mip)
 			for(mip=0; mip<=mNumMipmaps; ++mip)
 			{
 			{
 				if(textureResources->pNormTex->GetSurfaceLevel(static_cast<UINT>(mip), &surface) != D3D_OK)
 				if(textureResources->pNormTex->GetSurfaceLevel(static_cast<UINT>(mip), &surface) != D3D_OK)
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get surface level failed",
-		 				"D3D9Texture::_createSurfaceList");
+					CM_EXCEPT(RenderingAPIException, "Get surface level failed");
 
 
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 								
 								
@@ -1675,8 +1648,7 @@ namespace CamelotEngine
 				for(mip=0; mip<=mNumMipmaps; ++mip)
 				for(mip=0; mip<=mNumMipmaps; ++mip)
 				{
 				{
 					if(textureResources->pCubeTex->GetCubeMapSurface((D3DCUBEMAP_FACES)face, static_cast<UINT>(mip), &surface) != D3D_OK)
 					if(textureResources->pCubeTex->GetCubeMapSurface((D3DCUBEMAP_FACES)face, static_cast<UINT>(mip), &surface) != D3D_OK)
-						OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get cubemap surface failed",
-		 				"D3D9Texture::getBuffer");
+						CM_EXCEPT(RenderingAPIException, "Get cubemap surface failed");
 
 
 					D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(face, mip);
 					D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(face, mip);
 					
 					
@@ -1699,8 +1671,7 @@ namespace CamelotEngine
 			for(mip=0; mip<=mNumMipmaps; ++mip)
 			for(mip=0; mip<=mNumMipmaps; ++mip)
 			{
 			{
 				if(textureResources->pVolumeTex->GetVolumeLevel(static_cast<UINT>(mip), &volume) != D3D_OK)
 				if(textureResources->pVolumeTex->GetVolumeLevel(static_cast<UINT>(mip), &volume) != D3D_OK)
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Get volume level failed",
-		 				"D3D9Texture::getBuffer");	
+					CM_EXCEPT(RenderingAPIException, "Get volume level failed");	
 						
 						
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 				D3D9HardwarePixelBuffer* currPixelBuffer = GETLEVEL(0, mip);
 
 
@@ -1721,11 +1692,9 @@ namespace CamelotEngine
 	HardwarePixelBufferPtr D3D9Texture::getBuffer(size_t face, size_t mipmap) 
 	HardwarePixelBufferPtr D3D9Texture::getBuffer(size_t face, size_t mipmap) 
 	{
 	{
 		if(face >= getNumFaces())
 		if(face >= getNumFaces())
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "A three dimensional cube has six faces",
-					"D3D9Texture::getBuffer");
+			CM_EXCEPT(InvalidParametersException, "A three dimensional cube has six faces");
 		if(mipmap > mNumMipmaps)
 		if(mipmap > mNumMipmaps)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Mipmap index out of range",
-					"D3D9Texture::getBuffer");
+			CM_EXCEPT(InvalidParametersException, "Mipmap index out of range");
 		size_t idx = face*(mNumMipmaps+1) + mipmap;
 		size_t idx = face*(mNumMipmaps+1) + mipmap;
 
 
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
@@ -1964,9 +1933,7 @@ namespace CamelotEngine
 
 
 					if (FAILED(hr))
 					if (FAILED(hr))
 					{
 					{
-						OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-							"Unable to copy AA buffer to final buffer: " + String(DXGetErrorDescription(hr)), 
-							"D3D9RenderTexture::swapBuffers");
+						CM_EXCEPT(InternalErrorException, "Unable to copy AA buffer to final buffer: " + String(DXGetErrorDescription(hr)));
 					}
 					}
 				}								
 				}								
 			}																		
 			}																		

+ 1 - 3
CamelotD3D9Renderer/Source/CmD3D9VertexDeclaration.cpp

@@ -155,9 +155,7 @@ namespace CamelotEngine {
 
 
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-					"Cannot create D3D9 vertex declaration: ", 
-					"Direct3D9VertexDeclaration::getD3DVertexDeclaration");
+				CM_EXCEPT(InternalErrorException, "Cannot create D3D9 vertex declaration: ");
 			}
 			}
 
 
 			delete [] d3delems;
 			delete [] d3delems;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9VideoModeList.cpp

@@ -34,7 +34,7 @@ namespace CamelotEngine
 	D3D9VideoModeList::D3D9VideoModeList( D3D9Driver* pDriver )
 	D3D9VideoModeList::D3D9VideoModeList( D3D9Driver* pDriver )
 	{
 	{
 		if( NULL == pDriver )
 		if( NULL == pDriver )
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "pDriver parameter is NULL", "D3D9VideoModeList::D3D9VideoModeList" );
+			CM_EXCEPT(InvalidParametersException, "pDriver parameter is NULL");
 
 
 		mpDriver = pDriver;
 		mpDriver = pDriver;
 		enumerate();
 		enumerate();

+ 8 - 11
CamelotGLRenderer/Source/CmGLFrameBufferObject.cpp

@@ -109,9 +109,8 @@ namespace CamelotEngine {
         /// First buffer must be bound
         /// First buffer must be bound
         if(!mColour[0].buffer)
         if(!mColour[0].buffer)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-            "Attachment 0 must have surface attached",
-		 	"GLFrameBufferObject::initialise");
+			CM_EXCEPT(InvalidParametersException, 
+            "Attachment 0 must have surface attached");
         }
         }
 
 
 		// If we're doing multisampling, then we need another FBO which contains a
 		// If we're doing multisampling, then we need another FBO which contains a
@@ -142,13 +141,13 @@ namespace CamelotEngine {
                     ss << ". It must be of the same as the size of surface 0, ";
                     ss << ". It must be of the same as the size of surface 0, ";
                     ss << width << "x" << height;
                     ss << width << "x" << height;
                     ss << ".";
                     ss << ".";
-                    OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, ss.str(), "GLFrameBufferObject::initialise");
+                    CM_EXCEPT(InvalidParametersException, ss.str());
                 }
                 }
                 if(mColour[x].buffer->getGLFormat() != format)
                 if(mColour[x].buffer->getGLFormat() != format)
                 {
                 {
                     StringStream ss;
                     StringStream ss;
                     ss << "Attachment " << x << " has incompatible format.";
                     ss << "Attachment " << x << " has incompatible format.";
-                    OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, ss.str(), "GLFrameBufferObject::initialise");
+                    CM_EXCEPT(InvalidParametersException, ss.str());
                 }
                 }
 	            mColour[x].buffer->bindToFramebuffer(GL_COLOR_ATTACHMENT0_EXT+x, mColour[x].zoffset);
 	            mColour[x].buffer->bindToFramebuffer(GL_COLOR_ATTACHMENT0_EXT+x, mColour[x].zoffset);
             }
             }
@@ -269,13 +268,11 @@ namespace CamelotEngine {
             // All is good
             // All is good
             break;
             break;
         case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
         case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-            "All framebuffer formats with this texture internal format unsupported",
-		 	"GLFrameBufferObject::initialise");
+            CM_EXCEPT(InvalidParametersException, 
+            "All framebuffer formats with this texture internal format unsupported");
         default:
         default:
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-            "Framebuffer incomplete or other FBO status error",
-		 	"GLFrameBufferObject::initialise");
+            CM_EXCEPT(InvalidParametersException, 
+            "Framebuffer incomplete or other FBO status error");
         }
         }
         
         
     }
     }

+ 2 - 2
CamelotGLRenderer/Source/CmGLGpuProgram.cpp

@@ -228,8 +228,8 @@ void GLArbGpuProgram::loadFromSource(void)
 		String errPosStr = toString(errPos);
 		String errPosStr = toString(errPos);
         char* errStr = (char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
         char* errStr = (char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
         // XXX New exception code?
         // XXX New exception code?
-        OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-            "Cannot load GL vertex program.  Line " + errPosStr + ":\n" + errStr, "");
+		CM_EXCEPT(InternalErrorException, 
+            "Cannot load GL vertex program.  Line " + errPosStr + ":\n" + errStr);
     }
     }
     glBindProgramARB(mProgramType, 0);
     glBindProgramARB(mProgramType, 0);
 }
 }

+ 8 - 12
CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp

@@ -40,9 +40,8 @@ namespace CamelotEngine {
 
 
         if (!mBufferId)
         if (!mBufferId)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-                "Cannot create GL index buffer", 
-                "GLHardwareIndexBuffer::GLHardwareIndexBuffer");
+			CM_EXCEPT(InternalErrorException, 
+                "Cannot create GL index buffer");
         }
         }
 
 
         glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId);
         glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId);
@@ -66,9 +65,8 @@ namespace CamelotEngine {
 
 
         if(mIsLocked)
         if(mIsLocked)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-                "Invalid attempt to lock an index buffer that has already been locked",
-                    "GLHardwareIndexBuffer::lock");
+            CM_EXCEPT(InternalErrorException, 
+                "Invalid attempt to lock an index buffer that has already been locked");
         }
         }
 
 
         
         
@@ -117,9 +115,8 @@ namespace CamelotEngine {
 
 
 			if(pBuffer == 0)
 			if(pBuffer == 0)
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-					"Index Buffer: Out of memory", 
-					"GLHardwareIndexBuffer::lock");
+				CM_EXCEPT(InternalErrorException, 
+					"Index Buffer: Out of memory");
 			}
 			}
 
 
 			// return offsetted
 			// return offsetted
@@ -157,9 +154,8 @@ namespace CamelotEngine {
 
 
 			if(!glUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB ))
 			if(!glUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB ))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-					"Buffer data corrupted, please reload", 
-					"GLHardwareIndexBuffer::unlock");
+				CM_EXCEPT(InternalErrorException, 
+					"Buffer data corrupted, please reload");
 			}
 			}
 		}
 		}
 
 

+ 2 - 3
CamelotGLRenderer/Source/CmGLHardwareOcclusionQuery.cpp

@@ -59,9 +59,8 @@ GLHardwareOcclusionQuery::GLHardwareOcclusionQuery()
 	}
 	}
 	else
 	else
     {
     {
-        OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, 
-                    "Cannot allocate a Hardware query. This video card doesn't supports it, sorry.", 
-                    "GLHardwareOcclusionQuery::GLHardwareOcclusionQuery" );
+		CM_EXCEPT(InternalErrorException, 
+                    "Cannot allocate a Hardware query. This video card doesn't supports it, sorry.");
     }
     }
 	
 	
 }
 }

+ 12 - 21
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -100,8 +100,7 @@ void GLHardwarePixelBuffer::unlockImpl(void)
 void GLHardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 void GLHardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 {
 {
 	if(!mBuffer.contains(dstBox))
 	if(!mBuffer.contains(dstBox))
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "destination box out of range",
-		 "GLHardwarePixelBuffer::blitFromMemory");
+		CM_EXCEPT(InvalidParametersException, "destination box out of range");
 	PixelData scaled;
 	PixelData scaled;
 	
 	
 	if(src.getWidth() != dstBox.getWidth() ||
 	if(src.getWidth() != dstBox.getWidth() ||
@@ -137,8 +136,7 @@ void GLHardwarePixelBuffer::blitFromMemory(const PixelData &src, const Box &dstB
 void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 {
 {
 	if(!mBuffer.contains(srcBox))
 	if(!mBuffer.contains(srcBox))
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "source box out of range",
-		 "GLHardwarePixelBuffer::blitToMemory");
+		CM_EXCEPT(InvalidParametersException, "source box out of range");
 	if(srcBox.left == 0 && srcBox.right == getWidth() &&
 	if(srcBox.left == 0 && srcBox.right == getWidth() &&
 	   srcBox.top == 0 && srcBox.bottom == getHeight() &&
 	   srcBox.top == 0 && srcBox.bottom == getHeight() &&
 	   srcBox.front == 0 && srcBox.back == getDepth() &&
 	   srcBox.front == 0 && srcBox.back == getDepth() &&
@@ -175,21 +173,18 @@ void GLHardwarePixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GLHardwarePixelBuffer::upload(const PixelData &data, const Box &dest)
 void GLHardwarePixelBuffer::upload(const PixelData &data, const Box &dest)
 {
 {
-    OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-		"Upload not possible for this pixelbuffer type",
-        "GLHardwarePixelBuffer::upload");
+    CM_EXCEPT(RenderingAPIException, 
+		"Upload not possible for this pixelbuffer type");
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
 void GLHardwarePixelBuffer::download(const PixelData &data)
 void GLHardwarePixelBuffer::download(const PixelData &data)
 {
 {
-    OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Download not possible for this pixelbuffer type",
-        "GLHardwarePixelBuffer::download");
+    CM_EXCEPT(RenderingAPIException, "Download not possible for this pixelbuffer type");
 }
 }
 //-----------------------------------------------------------------------------  
 //-----------------------------------------------------------------------------  
 void GLHardwarePixelBuffer::bindToFramebuffer(GLenum attachment, size_t zoffset)
 void GLHardwarePixelBuffer::bindToFramebuffer(GLenum attachment, size_t zoffset)
 {
 {
-    OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Framebuffer bind not possible for this pixelbuffer type",
-        "GLHardwarePixelBuffer::bindToFramebuffer");
+    CM_EXCEPT(RenderingAPIException, "Framebuffer bind not possible for this pixelbuffer type");
 }
 }
 //********* GLTextureBuffer
 //********* GLTextureBuffer
 GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint id, 
 GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint id, 
@@ -294,9 +289,8 @@ void GLTextureBuffer::upload(const PixelData &data, const Box &dest)
 	if(PixelUtil::isCompressed(data.format))
 	if(PixelUtil::isCompressed(data.format))
 	{
 	{
 		if(data.format != mFormat || !data.isConsecutive())
 		if(data.format != mFormat || !data.isConsecutive())
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"Compressed images must be consecutive, in the source format",
-		 	"GLTextureBuffer::upload");
+			CM_EXCEPT(InvalidParametersException, 
+			"Compressed images must be consecutive, in the source format");
 		GLenum format = GLPixelUtil::getClosestGLInternalFormat(mFormat);
 		GLenum format = GLPixelUtil::getClosestGLInternalFormat(mFormat);
 		// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
 		// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
 		// for compressed formats
 		// for compressed formats
@@ -467,15 +461,13 @@ void GLTextureBuffer::download(const PixelData &data)
 	if(data.getWidth() != getWidth() ||
 	if(data.getWidth() != getWidth() ||
 		data.getHeight() != getHeight() ||
 		data.getHeight() != getHeight() ||
 		data.getDepth() != getDepth())
 		data.getDepth() != getDepth())
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "only download of entire buffer is supported by GL",
-		 	"GLTextureBuffer::download");
+		CM_EXCEPT(InvalidParametersException, "only download of entire buffer is supported by GL");
 	glBindTexture( mTarget, mTextureID );
 	glBindTexture( mTarget, mTextureID );
 	if(PixelUtil::isCompressed(data.format))
 	if(PixelUtil::isCompressed(data.format))
 	{
 	{
 		if(data.format != mFormat || !data.isConsecutive())
 		if(data.format != mFormat || !data.isConsecutive())
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"Compressed images must be consecutive, in the source format",
-		 	"GLTextureBuffer::download");
+			CM_EXCEPT(InvalidParametersException, 
+			"Compressed images must be consecutive, in the source format");
 		// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
 		// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
 		// for compressed formate
 		// for compressed formate
 		glGetCompressedTexImageARB(mFaceTarget, mLevel, data.data);
 		glGetCompressedTexImageARB(mFaceTarget, mLevel, data.data);
@@ -794,8 +786,7 @@ void GLTextureBuffer::blitFromMemory(const PixelData &src_orig, const Box &dstBo
         return;
         return;
     }
     }
     if(!mBuffer.contains(dstBox))
     if(!mBuffer.contains(dstBox))
-        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "destination box out of range",
-                    "GLTextureBuffer::blitFromMemory");
+        CM_EXCEPT(InvalidParametersException, "destination box out of range");
     /// For scoped deletion of conversion buffer
     /// For scoped deletion of conversion buffer
 	void* data = NULL;
 	void* data = NULL;
     PixelData src;
     PixelData src;

+ 6 - 11
CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp

@@ -40,9 +40,8 @@ namespace CamelotEngine {
 
 
         if (!mBufferId)
         if (!mBufferId)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-                "Cannot create GL vertex buffer", 
-                "GLHardwareVertexBuffer::GLHardwareVertexBuffer");
+            CM_EXCEPT(InternalErrorException, 
+                "Cannot create GL vertex buffer");
         }
         }
 
 
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
@@ -66,9 +65,8 @@ namespace CamelotEngine {
 
 
         if(mIsLocked)
         if(mIsLocked)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
-                "Invalid attempt to lock an index buffer that has already been locked",
-                "GLHardwareVertexBuffer::lock");
+			CM_EXCEPT(InternalErrorException,
+                "Invalid attempt to lock an index buffer that has already been locked");
         }
         }
 
 
 
 
@@ -121,8 +119,7 @@ namespace CamelotEngine {
 
 
 			if(pBuffer == 0)
 			if(pBuffer == 0)
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-					"Vertex Buffer: Out of memory", "GLHardwareVertexBuffer::lock");
+				CM_EXCEPT(InternalErrorException, "Vertex Buffer: Out of memory");
 			}
 			}
 
 
 			// return offsetted
 			// return offsetted
@@ -159,9 +156,7 @@ namespace CamelotEngine {
 
 
 			if(!glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ))
 			if(!glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ))
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-					"Buffer data corrupted, please reload", 
-					"GLHardwareVertexBuffer::unlock");
+				CM_EXCEPT(InternalErrorException, "Buffer data corrupted, please reload");
 			}
 			}
 		}
 		}
 
 

+ 10 - 18
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -601,9 +601,8 @@ namespace CamelotEngine {
 	{
 	{
 		if(caps->getRenderSystemName() != getName())
 		if(caps->getRenderSystemName() != getName())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Trying to initialize GLRenderSystem from RenderSystemCapabilities that do not support OpenGL",
-				"GLRenderSystem::initialiseFromRenderSystemCapabilities");
+			CM_EXCEPT(InvalidParametersException, 
+				"Trying to initialize GLRenderSystem from RenderSystemCapabilities that do not support OpenGL");
 		}
 		}
 
 
 		// set texture the number of texture units
 		// set texture the number of texture units
@@ -938,10 +937,8 @@ namespace CamelotEngine {
 	{
 	{
 		if (mRenderTargets.find(name) != mRenderTargets.end())
 		if (mRenderTargets.find(name) != mRenderTargets.end())
 		{
 		{
-			OGRE_EXCEPT(
-				Exception::ERR_INVALIDPARAMS, 
-				"Window with name '" + name + "' already exists",
-				"GLRenderSystem::_createRenderWindow" );
+			CM_EXCEPT(InvalidParametersException, 
+				"Window with name '" + name + "' already exists");
 		}
 		}
 
 
 		// Create the window
 		// Create the window
@@ -1765,9 +1762,8 @@ namespace CamelotEngine {
 	void GLRenderSystem::_beginFrame(void)
 	void GLRenderSystem::_beginFrame(void)
 	{
 	{
 		if (!mActiveViewport)
 		if (!mActiveViewport)
-			OGRE_EXCEPT(Exception::ERR_INVALID_STATE, 
-			"Cannot begin frame - no viewport selected.",
-			"GLRenderSystem::_beginFrame");
+			CM_EXCEPT(InvalidStateException, 
+			"Cannot begin frame - no viewport selected.");
 
 
 		// Activate the viewport clipping
 		// Activate the viewport clipping
 		glEnable(GL_SCISSOR_TEST);
 		glEnable(GL_SCISSOR_TEST);
@@ -2065,8 +2061,7 @@ namespace CamelotEngine {
 		if (twoSidedOperation)
 		if (twoSidedOperation)
 		{
 		{
 			if (!mCurrentCapabilities->hasCapability(RSC_TWO_SIDED_STENCIL))
 			if (!mCurrentCapabilities->hasCapability(RSC_TWO_SIDED_STENCIL))
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "2-sided stencils are not supported",
-				"GLRenderSystem::setStencilBufferParams");
+				CM_EXCEPT(InvalidParametersException, "2-sided stencils are not supported");
 
 
 			// NB: We should always treat CCW as front face for consistent with default
 			// NB: We should always treat CCW as front face for consistent with default
 			// culling mode. Therefore, we must take care with two-sided stencil settings.
 			// culling mode. Therefore, we must take care with two-sided stencil settings.
@@ -2733,8 +2728,7 @@ namespace CamelotEngine {
 
 
 			if (i >= 6/*GL_MAX_CLIP_PLANES*/)
 			if (i >= 6/*GL_MAX_CLIP_PLANES*/)
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set clip plane", 
-					"GLRenderSystem::setClipPlanes");
+				CM_EXCEPT(RenderingAPIException, "Unable to set clip plane");
 			}
 			}
 
 
 			clipPlane[0] = plane.normal.x;
 			clipPlane[0] = plane.normal.x;
@@ -3101,10 +3095,8 @@ namespace CamelotEngine {
 		// This is only valid once we've created the main context
 		// This is only valid once we've created the main context
 		if (!mMainContext)
 		if (!mMainContext)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Cannot register a background thread before the main context "
-				"has been created.", 
-				"GLRenderSystem::registerThread");
+			CM_EXCEPT(InvalidParametersException, 
+				"Cannot register a background thread before the main context has been created.");
 		}
 		}
 
 
 		// Create a new context for this thread. Cloning from the main context
 		// Create a new context for this thread. Cloning from the main context

+ 1 - 1
CamelotGLRenderer/Source/CmGLRenderTexture.cpp

@@ -40,7 +40,7 @@ template<> GLRTTManager* Singleton<GLRTTManager>::ms_Singleton = 0;
     }
     }
     MultiRenderTarget* GLRTTManager::createMultiRenderTarget(const String & name)
     MultiRenderTarget* GLRTTManager::createMultiRenderTarget(const String & name)
     {
     {
-    	OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "MultiRenderTarget can only be used with GL_EXT_framebuffer_object extension", "GLRTTManager::createMultiRenderTarget");
+    	CM_EXCEPT(NotImplementedException, "MultiRenderTarget can only be used with GL_EXT_framebuffer_object extension");
     }
     }
     PixelFormat GLRTTManager::getSupportedAlternative(PixelFormat format)
     PixelFormat GLRTTManager::getSupportedAlternative(PixelFormat format)
     {
     {

+ 6 - 11
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -86,9 +86,8 @@ namespace CamelotEngine {
 	void GLTexture::createInternalResourcesImpl(void)
 	void GLTexture::createInternalResourcesImpl(void)
     {
     {
 		if (!GLEW_VERSION_1_2 && mTextureType == TEX_TYPE_3D)
 		if (!GLEW_VERSION_1_2 && mTextureType == TEX_TYPE_3D)
-			OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, 
-				"3D Textures not supported before OpenGL 1.2", 
-				"GLTexture::createInternalResourcesImpl");
+			CM_EXCEPT(NotImplementedException, 
+				"3D Textures not supported before OpenGL 1.2");
 
 
 		// Convert to nearest power-of-two size if required
 		// Convert to nearest power-of-two size if required
         mWidth = GLPixelUtil::optionalPO2(mWidth);      
         mWidth = GLPixelUtil::optionalPO2(mWidth);      
@@ -386,13 +385,11 @@ namespace CamelotEngine {
                 /// Check for error
                 /// Check for error
                 if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0)
                 if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0)
                 {
                 {
-                    OGRE_EXCEPT(
-                        Exception::ERR_RENDERINGAPI_ERROR, 
+					CM_EXCEPT(RenderingAPIException, 
                         "Zero sized texture surface on texture face "
                         "Zero sized texture surface on texture face "
 						+ toString(face) 
 						+ toString(face) 
 						+ " mipmap "+toString(mip)
 						+ " mipmap "+toString(mip)
-						+ ". Probably, the GL driver refused to create the texture.", 
-                            "GLTexture::_createSurfaceList");
+						+ ". Probably, the GL driver refused to create the texture.");
                 }
                 }
 			}
 			}
 		}
 		}
@@ -402,11 +399,9 @@ namespace CamelotEngine {
 	HardwarePixelBufferPtr GLTexture::getBuffer(size_t face, size_t mipmap)
 	HardwarePixelBufferPtr GLTexture::getBuffer(size_t face, size_t mipmap)
 	{
 	{
 		if(face >= getNumFaces())
 		if(face >= getNumFaces())
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Face index out of range",
-					"GLTexture::getBuffer");
+			CM_EXCEPT(InvalidParametersException, "Face index out of range");
 		if(mipmap > mNumMipmaps)
 		if(mipmap > mNumMipmaps)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Mipmap index out of range",
-					"GLTexture::getBuffer");
+			CM_EXCEPT(InvalidParametersException, "Mipmap index out of range");
 		unsigned int idx = face*(mNumMipmaps+1) + mipmap;
 		unsigned int idx = face*(mNumMipmaps+1) + mipmap;
 		assert(idx < mSurfaceList.size());
 		assert(idx < mSurfaceList.size());
 		return mSurfaceList[idx];
 		return mSurfaceList[idx];

+ 12 - 12
CamelotGLRenderer/Source/CmWin32GLSupport.cpp

@@ -150,14 +150,14 @@ namespace CamelotEngine {
 		ConfigOptionMap::iterator moptColourDepth = mOptions.find("Colour Depth");
 		ConfigOptionMap::iterator moptColourDepth = mOptions.find("Colour Depth");
 		ConfigOptionMap::iterator moptDisplayFrequency = mOptions.find("Display Frequency");
 		ConfigOptionMap::iterator moptDisplayFrequency = mOptions.find("Display Frequency");
 		if(optVideoMode == mOptions.end() || moptColourDepth == mOptions.end() || moptDisplayFrequency == mOptions.end())
 		if(optVideoMode == mOptions.end() || moptColourDepth == mOptions.end() || moptDisplayFrequency == mOptions.end())
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find mOptions!", "Win32GLSupport::refreshConfig");
+			CM_EXCEPT(InvalidParametersException, "Can't find mOptions!");
 		ConfigOption* optColourDepth = &moptColourDepth->second;
 		ConfigOption* optColourDepth = &moptColourDepth->second;
 		ConfigOption* optDisplayFrequency = &moptDisplayFrequency->second;
 		ConfigOption* optDisplayFrequency = &moptDisplayFrequency->second;
 
 
 		const String& val = optVideoMode->second.currentValue;
 		const String& val = optVideoMode->second.currentValue;
 		String::size_type pos = val.find('x');
 		String::size_type pos = val.find('x');
 		if (pos == String::npos)
 		if (pos == String::npos)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid Video Mode provided", "Win32GLSupport::refreshConfig");
+			CM_EXCEPT(InvalidParametersException, "Invalid Video Mode provided");
 		DWORD width = parseUnsignedInt(val.substr(0, pos));
 		DWORD width = parseUnsignedInt(val.substr(0, pos));
 		DWORD height = parseUnsignedInt(val.substr(pos+1, String::npos));
 		DWORD height = parseUnsignedInt(val.substr(pos+1, String::npos));
 
 
@@ -190,7 +190,7 @@ namespace CamelotEngine {
 		{
 		{
             StringUtil::StrStreamType str;
             StringUtil::StrStreamType str;
             str << "Option named '" << name << "' does not exist.";
             str << "Option named '" << name << "' does not exist.";
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, str.str(), "Win32GLSupport::setConfigOption" );
+			CM_EXCEPT(InvalidParametersException, str.str());
 		}
 		}
 
 
 		if( name == "Video Mode" )
 		if( name == "Video Mode" )
@@ -225,16 +225,16 @@ namespace CamelotEngine {
         {
         {
             ConfigOptionMap::iterator opt = mOptions.find("Full Screen");
             ConfigOptionMap::iterator opt = mOptions.find("Full Screen");
             if (opt == mOptions.end())
             if (opt == mOptions.end())
-                OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find full screen options!", "Win32GLSupport::createWindow");
+                CM_EXCEPT(InvalidParametersException, "Can't find full screen options!");
             bool fullscreen = (opt->second.currentValue == "Yes");
             bool fullscreen = (opt->second.currentValue == "Yes");
 
 
             opt = mOptions.find("Video Mode");
             opt = mOptions.find("Video Mode");
             if (opt == mOptions.end())
             if (opt == mOptions.end())
-                OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find video mode options!", "Win32GLSupport::createWindow");
+                CM_EXCEPT(InvalidParametersException, "Can't find video mode options!");
             String val = opt->second.currentValue;
             String val = opt->second.currentValue;
             String::size_type pos = val.find('x');
             String::size_type pos = val.find('x');
             if (pos == String::npos)
             if (pos == String::npos)
-                OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid Video Mode provided", "Win32GLSupport::createWindow");
+                CM_EXCEPT(InvalidParametersException, "Invalid Video Mode provided");
 
 
 			unsigned int w = parseUnsignedInt(val.substr(0, pos));
 			unsigned int w = parseUnsignedInt(val.substr(0, pos));
             unsigned int h = parseUnsignedInt(val.substr(pos + 1));
             unsigned int h = parseUnsignedInt(val.substr(pos + 1));
@@ -243,21 +243,21 @@ namespace CamelotEngine {
 			NameValuePairList winOptions;
 			NameValuePairList winOptions;
 			opt = mOptions.find("Colour Depth");
 			opt = mOptions.find("Colour Depth");
 			if (opt == mOptions.end())
 			if (opt == mOptions.end())
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find Colour Depth options!", "Win32GLSupport::createWindow");
+				CM_EXCEPT(InvalidParametersException, "Can't find Colour Depth options!");
 			unsigned int colourDepth =
 			unsigned int colourDepth =
 				parseUnsignedInt(opt->second.currentValue);
 				parseUnsignedInt(opt->second.currentValue);
 			winOptions["colourDepth"] = toString(colourDepth);
 			winOptions["colourDepth"] = toString(colourDepth);
 
 
 			opt = mOptions.find("VSync");
 			opt = mOptions.find("VSync");
 			if (opt == mOptions.end())
 			if (opt == mOptions.end())
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find VSync options!", "Win32GLSupport::createWindow");
+				CM_EXCEPT(InvalidParametersException, "Can't find VSync options!");
 			bool vsync = (opt->second.currentValue == "Yes");
 			bool vsync = (opt->second.currentValue == "Yes");
 			winOptions["vsync"] = toString(vsync);
 			winOptions["vsync"] = toString(vsync);
 			renderSystem->setWaitForVerticalBlank(vsync);
 			renderSystem->setWaitForVerticalBlank(vsync);
 
 
 			opt = mOptions.find("VSync Interval");
 			opt = mOptions.find("VSync Interval");
 			if (opt == mOptions.end())
 			if (opt == mOptions.end())
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find VSync Interval options!", "Win32GLSupport::createWindow");
+				CM_EXCEPT(InvalidParametersException, "Can't find VSync Interval options!");
 			winOptions["vsyncInterval"] = opt->second.currentValue;
 			winOptions["vsyncInterval"] = opt->second.currentValue;
 
 
 
 
@@ -271,7 +271,7 @@ namespace CamelotEngine {
 
 
 			opt = mOptions.find("FSAA");
 			opt = mOptions.find("FSAA");
 			if (opt == mOptions.end())
 			if (opt == mOptions.end())
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find FSAA options!", "Win32GLSupport::createWindow");
+				CM_EXCEPT(InvalidParametersException, "Can't find FSAA options!");
 			std::vector<CamelotEngine::String> aavalues = StringUtil::split(opt->second.currentValue, " ", 1);
 			std::vector<CamelotEngine::String> aavalues = StringUtil::split(opt->second.currentValue, " ", 1);
 			unsigned int multisample = parseUnsignedInt(aavalues[0]);
 			unsigned int multisample = parseUnsignedInt(aavalues[0]);
 			String multisample_hint;
 			String multisample_hint;
@@ -283,7 +283,7 @@ namespace CamelotEngine {
 
 
 			opt = mOptions.find("sRGB Gamma Conversion");
 			opt = mOptions.find("sRGB Gamma Conversion");
 			if (opt == mOptions.end())
 			if (opt == mOptions.end())
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Can't find sRGB options!", "Win32GLSupport::createWindow");
+				CM_EXCEPT(InvalidParametersException, "Can't find sRGB options!");
 			bool hwGamma = (opt->second.currentValue == "Yes");
 			bool hwGamma = (opt->second.currentValue == "Yes");
 			winOptions["gamma"] = toString(hwGamma);
 			winOptions["gamma"] = toString(hwGamma);
 
 
@@ -461,7 +461,7 @@ namespace CamelotEngine {
 
 
 		// if a simple CreateWindow fails, then boy are we in trouble...
 		// if a simple CreateWindow fails, then boy are we in trouble...
 		if (hwnd == NULL)
 		if (hwnd == NULL)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "CreateWindow() failed", "Win32GLSupport::initializeWGL");
+			CM_EXCEPT(RenderingAPIException, "CreateWindow() failed");
 
 
 
 
 		// no chance of failure and no need to release thanks to CS_OWNDC
 		// no chance of failure and no need to release thanks to CS_OWNDC

+ 5 - 5
CamelotGLRenderer/Source/CmWin32RenderTexture.cpp

@@ -148,7 +148,7 @@ namespace CamelotEngine {
 		// Choose suitable pixel format
 		// Choose suitable pixel format
 		wglChoosePixelFormatARB(old_hdc,attrib,NULL,1,&format,&count);
 		wglChoosePixelFormatARB(old_hdc,attrib,NULL,1,&format,&count);
 		if(count == 0)
 		if(count == 0)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglChoosePixelFormatARB() failed", " Win32PBuffer::createPBuffer");
+			CM_EXCEPT(RenderingAPIException, "wglChoosePixelFormatARB() failed");
 
 
 		// Analyse pixel format
 		// Analyse pixel format
 		const int piAttributes[]={
 		const int piAttributes[]={
@@ -160,26 +160,26 @@ namespace CamelotEngine {
 
 
 		mPBuffer = wglCreatePbufferARB(old_hdc,format,mWidth,mHeight,pattrib_default);
 		mPBuffer = wglCreatePbufferARB(old_hdc,format,mWidth,mHeight,pattrib_default);
 		if(!mPBuffer)
 		if(!mPBuffer)
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglCreatePbufferARB() failed", " Win32PBuffer::createPBuffer");
+			CM_EXCEPT(RenderingAPIException, "wglCreatePbufferARB() failed");
 
 
 		mHDC = wglGetPbufferDCARB(mPBuffer);
 		mHDC = wglGetPbufferDCARB(mPBuffer);
 		if(!mHDC) {
 		if(!mHDC) {
 			wglDestroyPbufferARB(mPBuffer);
 			wglDestroyPbufferARB(mPBuffer);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglGetPbufferDCARB() failed", " Win32PBuffer::createPBuffer");
+			CM_EXCEPT(RenderingAPIException, "wglGetPbufferDCARB() failed");
 		}
 		}
 			
 			
 		mGlrc = wglCreateContext(mHDC);
 		mGlrc = wglCreateContext(mHDC);
 		if(!mGlrc) {
 		if(!mGlrc) {
 			wglReleasePbufferDCARB(mPBuffer,mHDC);
 			wglReleasePbufferDCARB(mPBuffer,mHDC);
 			wglDestroyPbufferARB(mPBuffer);
 			wglDestroyPbufferARB(mPBuffer);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglCreateContext() failed", " Win32PBuffer::createPBuffer");
+			CM_EXCEPT(RenderingAPIException, "wglCreateContext() failed");
 		}
 		}
 
 
 		if(!wglShareLists(old_context,mGlrc)) {
 		if(!wglShareLists(old_context,mGlrc)) {
 			wglDeleteContext(mGlrc);
 			wglDeleteContext(mGlrc);
 			wglReleasePbufferDCARB(mPBuffer,mHDC);
 			wglReleasePbufferDCARB(mPBuffer,mHDC);
 			wglDestroyPbufferARB(mPBuffer);
 			wglDestroyPbufferARB(mPBuffer);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglShareLists() failed", " Win32PBuffer::createPBuffer");
+			CM_EXCEPT(RenderingAPIException, "wglShareLists() failed");
 		}
 		}
 				
 				
 		// Query real width and height
 		// Query real width and height

+ 8 - 13
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -394,8 +394,7 @@ namespace CamelotEngine {
 				}
 				}
 
 
 				if (!formatOk)
 				if (!formatOk)
-					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-						"selectPixelFormat failed", "Win32Window::create");
+					CM_EXCEPT(RenderingAPIException, "selectPixelFormat failed");
 
 
 			}
 			}
 			// record what gamma option we used in the end
 			// record what gamma option we used in the end
@@ -407,11 +406,11 @@ namespace CamelotEngine {
 		{
 		{
 			mGlrc = wglCreateContext(mHDC);
 			mGlrc = wglCreateContext(mHDC);
 			if (!mGlrc)
 			if (!mGlrc)
-				OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
-				"wglCreateContext failed: " + translateWGLError(), "Win32Window::create");
+				CM_EXCEPT(RenderingAPIException, 
+				"wglCreateContext failed: " + translateWGLError());
 		}
 		}
 		if (!wglMakeCurrent(mHDC, mGlrc))
 		if (!wglMakeCurrent(mHDC, mGlrc))
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglMakeCurrent", "Win32Window::create");
+			CM_EXCEPT(RenderingAPIException, "wglMakeCurrent");
 
 
 		// Do not change vsync if the external window has the OpenGL control
 		// Do not change vsync if the external window has the OpenGL control
 		if (!mIsExternalGLControl) {
 		if (!mIsExternalGLControl) {
@@ -426,11 +425,11 @@ namespace CamelotEngine {
         {
         {
             // Restore old context
             // Restore old context
 		    if (!wglMakeCurrent(old_hdc, old_context))
 		    if (!wglMakeCurrent(old_hdc, old_context))
-			    OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglMakeCurrent() failed", "Win32Window::create");
+			    CM_EXCEPT(RenderingAPIException, "wglMakeCurrent() failed");
 
 
             // Share lists with old context
             // Share lists with old context
 		    if (!wglShareLists(old_context, mGlrc))
 		    if (!wglShareLists(old_context, mGlrc))
-			    OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglShareLists() failed", " Win32Window::create");
+			    CM_EXCEPT(RenderingAPIException, "wglShareLists() failed");
         }
         }
 
 
 		// Create RenderSystem context
 		// Create RenderSystem context
@@ -707,9 +706,7 @@ namespace CamelotEngine {
 			(dst.top < 0) || (dst.bottom > mHeight) ||
 			(dst.top < 0) || (dst.bottom > mHeight) ||
 			(dst.front != 0) || (dst.back != 1))
 			(dst.front != 0) || (dst.back != 1))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-						"Invalid box.",
-						"Win32Window::copyContentsToMemory" );
+			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 		}
 		}
 
 
 		if (buffer == FB_AUTO)
 		if (buffer == FB_AUTO)
@@ -722,9 +719,7 @@ namespace CamelotEngine {
 
 
 		if ((format == GL_NONE) || (type == 0))
 		if ((format == GL_NONE) || (type == 0))
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-						"Unsupported format.",
-						"Win32Window::copyContentsToMemory" );
+			CM_EXCEPT(InvalidParametersException, "Unsupported format.");
 		}
 		}
 
 
 
 

+ 1 - 1
CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp

@@ -61,7 +61,7 @@ namespace CamelotEngine
 
 
             if (forceException) 
             if (forceException) 
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, msg, ogreMethod);
+				CM_EXCEPT(InternalErrorException, msg);
 			}
 			}
 		}
 		}
     }
     }

+ 2 - 3
CamelotGLRenderer/Source/GLSL/src/CmGLSLLinkProgram.cpp

@@ -99,10 +99,9 @@ namespace CamelotEngine {
 		case RenderOperation::OT_TRIANGLE_STRIP:
 		case RenderOperation::OT_TRIANGLE_STRIP:
 			return GL_TRIANGLE_STRIP;
 			return GL_TRIANGLE_STRIP;
 		default:
 		default:
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
+			CM_EXCEPT(RenderingAPIException,
 				"Geometry shader output operation type can only be point list,"
 				"Geometry shader output operation type can only be point list,"
-				"line strip or triangle strip",
-				"GLSLLinkProgram::activate");
+				"line strip or triangle strip");
 		}
 		}
 	}
 	}
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------

+ 2 - 3
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp

@@ -130,9 +130,8 @@ namespace CamelotEngine {
 		char *out = cpp.Parse (src, src_len, out_size);
 		char *out = cpp.Parse (src, src_len, out_size);
 		if (!out || !out_size)
 		if (!out || !out_size)
 			// Failed to preprocess, break out
 			// Failed to preprocess, break out
-			OGRE_EXCEPT (Exception::ERR_RENDERINGAPI_ERROR,
-						 "Failed to preprocess shader ",
-						 __FUNCTION__);
+			CM_EXCEPT(RenderingAPIException,
+						 "Failed to preprocess shader ");
 
 
 		mSource = String (out, out_size);
 		mSource = String (out, out_size);
 		if (out < src || out > src + src_len)
 		if (out < src || out > src + src_len)

+ 4 - 4
CamelotGLRenderer/Source/atifs/src/ATI_FS_GLGpuProgram.cpp

@@ -125,8 +125,8 @@ void ATI_FS_GLGpuProgram::loadFromSource(void)
 		// check GL for GPU machine instruction bind erros
 		// check GL for GPU machine instruction bind erros
 		if (Error)
 		if (Error)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-				"Cannot Bind ATI fragment shader :", ""); 
+			CM_EXCEPT(InternalErrorException, 
+				"Cannot Bind ATI fragment shader :"); 
 		}
 		}
 
 
     }
     }
@@ -140,8 +140,8 @@ void ATI_FS_GLGpuProgram::loadFromSource(void)
 		//LogManager::getSingleton().logMessage("Warning: atifs compiler reported the following errors:");
 		//LogManager::getSingleton().logMessage("Warning: atifs compiler reported the following errors:");
 		//LogManager::getSingleton().logMessage(buff + mName);
 		//LogManager::getSingleton().logMessage(buff + mName);
 
 
-		//OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-		//	"Cannot Compile ATI fragment shader : \n\n" + buff , "");// + 
+		CM_EXCEPT(InternalErrorException, 
+			String("Cannot Compile ATI fragment shader : \n\n") + buff);// + 
     }
     }
 
 
 
 

+ 2 - 3
CamelotGLRenderer/Source/win32/CmWin32Context.cpp

@@ -67,8 +67,7 @@ namespace CamelotEngine {
 		
 		
 		if (!newCtx)
 		if (!newCtx)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-				"Error calling wglCreateContext", "Win32Context::clone");
+			CM_EXCEPT(InternalErrorException, "Error calling wglCreateContext");
 		}
 		}
 
 
 		HGLRC oldrc = wglGetCurrentContext();
 		HGLRC oldrc = wglGetCurrentContext();
@@ -79,7 +78,7 @@ namespace CamelotEngine {
 		{
 		{
 			String errorMsg = translateWGLError();
 			String errorMsg = translateWGLError();
 			wglDeleteContext(newCtx);
 			wglDeleteContext(newCtx);
-			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, String("wglShareLists() failed: ") + errorMsg, "Win32Context::clone");
+			CM_EXCEPT(RenderingAPIException, String("wglShareLists() failed: ") + errorMsg);
 		}
 		}
 		// restore old context
 		// restore old context
 		wglMakeCurrent(oldhdc, oldrc);
 		wglMakeCurrent(oldhdc, oldrc);

+ 1 - 2
CamelotRenderer/Source/CmApplication.cpp

@@ -23,8 +23,7 @@ namespace CamelotEngine
 		mGpuProgramManager = new HighLevelGpuProgramManager(); // TODO - Use Camelot::Module for instantiating this
 		mGpuProgramManager = new HighLevelGpuProgramManager(); // TODO - Use Camelot::Module for instantiating this
 		mDynLibManager = new DynLibManager(); // TODO - Same as above, use Module
 		mDynLibManager = new DynLibManager(); // TODO - Same as above, use Module
 
 
-		//RenderSystemManager::initialize("CamelotD3D9Renderer.dll");
-		RenderSystemManager::initialize("CamelotGLRenderer.dll");
+		RenderSystemManager::initialize(renderSystemDll);
 
 
 		RenderSystem* renderSystem = RenderSystemManager::getActive();
 		RenderSystem* renderSystem = RenderSystemManager::getActive();
 		renderSystem->_initialise(false, "Camelot Renderer");
 		renderSystem->_initialise(false, "Camelot Renderer");

+ 3 - 5
CamelotRenderer/Source/CmFrustum.cpp

@@ -102,8 +102,7 @@ namespace CamelotEngine {
     void Frustum::setNearClipDistance(float nearPlane)
     void Frustum::setNearClipDistance(float nearPlane)
     {
     {
         if (nearPlane <= 0)
         if (nearPlane <= 0)
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Near clip distance must be greater than zero.",
-                "Frustum::setNearClipDistance");
+            CM_EXCEPT(InvalidParametersException, "Near clip distance must be greater than zero.");
         mNearDist = nearPlane;
         mNearDist = nearPlane;
         invalidateFrustum();
         invalidateFrustum();
     }
     }
@@ -135,9 +134,8 @@ namespace CamelotEngine {
     {
     {
         if (focalLength <= 0)
         if (focalLength <= 0)
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-                "Focal length must be greater than zero.",
-                "Frustum::setFocalLength");
+            CM_EXCEPT(InvalidParametersException,
+                "Focal length must be greater than zero.");
         }
         }
 
 
         mFocalLength = focalLength;
         mFocalLength = focalLength;

+ 4 - 6
CamelotRenderer/Source/CmGpuProgramManager.cpp

@@ -104,9 +104,8 @@ namespace CamelotEngine {
 	{
 	{
 		if (mSharedParametersMap.find(name) != mSharedParametersMap.end())
 		if (mSharedParametersMap.find(name) != mSharedParametersMap.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"The shared parameter set '" + name + "' already exists!", 
-				"GpuProgramManager::createSharedParameters");
+			CM_EXCEPT(InvalidParametersException, 
+				"The shared parameter set '" + name + "' already exists!");
 		}
 		}
 		GpuSharedParametersPtr ret(new GpuSharedParameters(name));
 		GpuSharedParametersPtr ret(new GpuSharedParameters(name));
 		mSharedParametersMap[name] = ret;
 		mSharedParametersMap[name] = ret;
@@ -118,9 +117,8 @@ namespace CamelotEngine {
 		SharedParametersMap::const_iterator i = mSharedParametersMap.find(name);
 		SharedParametersMap::const_iterator i = mSharedParametersMap.find(name);
 		if (i == mSharedParametersMap.end())
 		if (i == mSharedParametersMap.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"No shared parameter set with name '" + name + "'!", 
-				"GpuProgramManager::createSharedParameters");
+			CM_EXCEPT(InvalidParametersException, 
+				"No shared parameter set with name '" + name + "'!");
 		}
 		}
 		return i->second;
 		return i->second;
 	}
 	}

+ 22 - 33
CamelotRenderer/Source/CmGpuProgramParams.cpp

@@ -246,9 +246,8 @@ namespace CamelotEngine
 	{
 	{
 		if (mNamedConstants.map.find(name) != mNamedConstants.map.end())
 		if (mNamedConstants.map.find(name) != mNamedConstants.map.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Constant entry with name '" + name + "' already exists. ", 
-				"GpuSharedParameters::addConstantDefinition");
+			CM_EXCEPT(InvalidParametersException, 
+				"Constant entry with name '" + name + "' already exists. ");
 		}
 		}
 		GpuConstantDefinition def;
 		GpuConstantDefinition def;
 		def.arraySize = arraySize;
 		def.arraySize = arraySize;
@@ -349,9 +348,8 @@ namespace CamelotEngine
 		GpuConstantDefinitionMap::const_iterator i = mNamedConstants.map.find(name);
 		GpuConstantDefinitionMap::const_iterator i = mNamedConstants.map.find(name);
 		if (i == mNamedConstants.map.end())
 		if (i == mNamedConstants.map.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Constant entry with name '" + name + "' does not exist. ", 
-				"GpuSharedParameters::getConstantDefinition");
+			CM_EXCEPT(InvalidParametersException, 
+				"Constant entry with name '" + name + "' does not exist. ");
 		}
 		}
 		return i->second;
 		return i->second;
 	}
 	}
@@ -1124,9 +1122,8 @@ namespace CamelotEngine
 	GpuLogicalIndexUse* GpuProgramParameters::_getIntConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, UINT16 variability)
 	GpuLogicalIndexUse* GpuProgramParameters::_getIntConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, UINT16 variability)
 	{
 	{
 		if (mIntLogicalToPhysical == nullptr)
 		if (mIntLogicalToPhysical == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This is not a low-level parameter parameter object",
-			"GpuProgramParameters::_getIntConstantPhysicalIndex");
+			CM_EXCEPT(InvalidParametersException, 
+			"This is not a low-level parameter parameter object");
 
 
 		GpuLogicalIndexUse* indexUse = 0;
 		GpuLogicalIndexUse* indexUse = 0;
 		CM_LOCK_MUTEX(mIntLogicalToPhysical->mutex)
 		CM_LOCK_MUTEX(mIntLogicalToPhysical->mutex)
@@ -1270,9 +1267,8 @@ namespace CamelotEngine
 	GpuConstantDefinitionIterator GpuProgramParameters::getConstantDefinitionIterator(void) const
 	GpuConstantDefinitionIterator GpuProgramParameters::getConstantDefinitionIterator(void) const
 	{
 	{
 		if (mNamedConstants == nullptr)
 		if (mNamedConstants == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This params object is not based on a program with named parameters.",
-			"GpuProgramParameters::getConstantDefinitionIterator");
+			CM_EXCEPT(InvalidParametersException, 
+			"This params object is not based on a program with named parameters.");
 
 
 		return mNamedConstants->map.begin();
 		return mNamedConstants->map.begin();
 
 
@@ -1281,9 +1277,8 @@ namespace CamelotEngine
 	const GpuNamedConstants& GpuProgramParameters::getConstantDefinitions() const
 	const GpuNamedConstants& GpuProgramParameters::getConstantDefinitions() const
 	{
 	{
 		if (mNamedConstants == nullptr)
 		if (mNamedConstants == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This params object is not based on a program with named parameters.",
-			"GpuProgramParameters::getConstantDefinitionIterator");
+			CM_EXCEPT(InvalidParametersException, 
+			"This params object is not based on a program with named parameters.");
 
 
 		return *mNamedConstants;
 		return *mNamedConstants;
 	}
 	}
@@ -1291,9 +1286,8 @@ namespace CamelotEngine
 	const GpuConstantDefinition& GpuProgramParameters::getConstantDefinition(const String& name) const
 	const GpuConstantDefinition& GpuProgramParameters::getConstantDefinition(const String& name) const
 	{
 	{
 		if (mNamedConstants == nullptr)
 		if (mNamedConstants == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This params object is not based on a program with named parameters.",
-			"GpuProgramParameters::getConstantDefinitionIterator");
+			CM_EXCEPT(InvalidParametersException, 
+			"This params object is not based on a program with named parameters.");
 
 
 
 
 		// locate, and throw exception if not found
 		// locate, and throw exception if not found
@@ -1310,9 +1304,8 @@ namespace CamelotEngine
 		if (mNamedConstants == nullptr)
 		if (mNamedConstants == nullptr)
 		{
 		{
 			if (throwExceptionIfNotFound)
 			if (throwExceptionIfNotFound)
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Named constants have not been initialised, perhaps a compile error.",
-				"GpuProgramParameters::_findNamedConstantDefinition");
+				CM_EXCEPT(InvalidParametersException, 
+				"Named constants have not been initialised, perhaps a compile error.");
 			return 0;
 			return 0;
 		}
 		}
 
 
@@ -1320,9 +1313,8 @@ namespace CamelotEngine
 		if (i == mNamedConstants->map.end())
 		if (i == mNamedConstants->map.end())
 		{
 		{
 			if (throwExceptionIfNotFound)
 			if (throwExceptionIfNotFound)
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-				"Parameter called " + name + " does not exist. ",
-				"GpuProgramParameters::_findNamedConstantDefinition");
+				CM_EXCEPT(InvalidParametersException, 
+				"Parameter called " + name + " does not exist. ");
 			return 0;
 			return 0;
 		}
 		}
 		else
 		else
@@ -1667,9 +1659,8 @@ namespace CamelotEngine
 		GpuProgramParameters::findFloatAutoConstantEntry(size_t logicalIndex)
 		GpuProgramParameters::findFloatAutoConstantEntry(size_t logicalIndex)
 	{
 	{
 		if (mFloatLogicalToPhysical == nullptr)
 		if (mFloatLogicalToPhysical == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This is not a low-level parameter parameter object",
-			"GpuProgramParameters::findFloatAutoConstantEntry");
+			CM_EXCEPT(InvalidParametersException, 
+			"This is not a low-level parameter parameter object");
 
 
 		return _findRawAutoConstantEntryFloat(
 		return _findRawAutoConstantEntryFloat(
 			_getFloatConstantPhysicalIndex(logicalIndex, 0, GPV_GLOBAL));
 			_getFloatConstantPhysicalIndex(logicalIndex, 0, GPV_GLOBAL));
@@ -1680,9 +1671,8 @@ namespace CamelotEngine
 		GpuProgramParameters::findIntAutoConstantEntry(size_t logicalIndex)
 		GpuProgramParameters::findIntAutoConstantEntry(size_t logicalIndex)
 	{
 	{
 		if (mIntLogicalToPhysical == nullptr)
 		if (mIntLogicalToPhysical == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This is not a low-level parameter parameter object",
-			"GpuProgramParameters::findIntAutoConstantEntry");
+			CM_EXCEPT(InvalidParametersException, 
+			"This is not a low-level parameter parameter object");
 
 
 		return _findRawAutoConstantEntryInt(
 		return _findRawAutoConstantEntryInt(
 			_getIntConstantPhysicalIndex(logicalIndex, 0, GPV_GLOBAL));
 			_getIntConstantPhysicalIndex(logicalIndex, 0, GPV_GLOBAL));
@@ -1694,9 +1684,8 @@ namespace CamelotEngine
 		GpuProgramParameters::findAutoConstantEntry(const String& paramName)
 		GpuProgramParameters::findAutoConstantEntry(const String& paramName)
 	{
 	{
 		if (mNamedConstants == nullptr)
 		if (mNamedConstants == nullptr)
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-			"This params object is not based on a program with named parameters.",
-			"GpuProgramParameters::findAutoConstantEntry");
+			CM_EXCEPT(InvalidParametersException, 
+			"This params object is not based on a program with named parameters.");
 
 
 		const GpuConstantDefinition& def = getConstantDefinition(paramName);
 		const GpuConstantDefinition& def = getConstantDefinition(paramName);
 		if (def.isFloat())
 		if (def.isFloat())

+ 11 - 17
CamelotRenderer/Source/CmHardwarePixelBuffer.cpp

@@ -97,8 +97,7 @@ namespace CamelotEngine
     /// Internal implementation of lock()
     /// Internal implementation of lock()
     void* HardwarePixelBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
     void* HardwarePixelBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
     {
     {
-        OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "lockImpl(offset,length) is not valid for PixelBuffers and should never be called",
-            "HardwarePixelBuffer::lockImpl");
+		CM_EXCEPT(InternalErrorException, "lockImpl(offset,length) is not valid for PixelBuffers and should never be called");
     }
     }
 
 
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
@@ -107,15 +106,13 @@ namespace CamelotEngine
 	{
 	{
 		if(isLocked() || src->isLocked())
 		if(isLocked() || src->isLocked())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
-				"Source and destination buffer may not be locked!",
-				"HardwarePixelBuffer::blit");
+			CM_EXCEPT(InternalErrorException,
+				"Source and destination buffer may not be locked!");
 		}
 		}
 		if(src.get() == this)
 		if(src.get() == this)
 		{
 		{
-			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
-                "Source must not be the same object",
-                "HardwarePixelBuffer::blit" ) ;
+			CM_EXCEPT(InternalErrorException,
+                "Source must not be the same object") ;
 		}
 		}
 		const PixelData &srclock = src->lock(srcBox, HBL_READ_ONLY);
 		const PixelData &srclock = src->lock(srcBox, HBL_READ_ONLY);
 
 
@@ -155,9 +152,8 @@ namespace CamelotEngine
 	void HardwarePixelBuffer::readData(size_t offset, size_t length, void* pDest)
 	void HardwarePixelBuffer::readData(size_t offset, size_t length, void* pDest)
 	{
 	{
 		// TODO
 		// TODO
-		OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-				"Reading a byte range is not implemented. Use blitToMemory.",
-				"HardwarePixelBuffer::readData");
+		CM_EXCEPT(NotImplementedException,
+				"Reading a byte range is not implemented. Use blitToMemory.");
 	}
 	}
 	//-----------------------------------------------------------------------------    
 	//-----------------------------------------------------------------------------    
 
 
@@ -165,17 +161,15 @@ namespace CamelotEngine
 			bool discardWholeBuffer)
 			bool discardWholeBuffer)
 	{
 	{
 		// TODO
 		// TODO
-		OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-				"Writing a byte range is not implemented. Use blitFromMemory.",
-				"HardwarePixelBuffer::writeData");
+		CM_EXCEPT(NotImplementedException,
+				"Writing a byte range is not implemented. Use blitFromMemory.");
 	}
 	}
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
     
     
     RenderTexture *HardwarePixelBuffer::getRenderTarget(size_t)
     RenderTexture *HardwarePixelBuffer::getRenderTarget(size_t)
     {
     {
-        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-				"Not yet implemented for this rendersystem.",
-				"HardwarePixelBuffer::getRenderTarget");
+        CM_EXCEPT(NotImplementedException,
+				"Not yet implemented for this rendersystem.");
     }
     }
 
 
 	//-----------------------------------------------------------------------------    
 	//-----------------------------------------------------------------------------    

+ 5 - 9
CamelotRenderer/Source/CmHardwareVertexBuffer.cpp

@@ -138,8 +138,7 @@ namespace CamelotEngine {
         case VET_UBYTE4:
         case VET_UBYTE4:
             return 4;
             return 4;
 		}
 		}
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid type", 
-			"VertexElement::getTypeCount");
+		CM_EXCEPT(InvalidParametersException, "Invalid type");
 	}
 	}
 	//-----------------------------------------------------------------------------
 	//-----------------------------------------------------------------------------
 	VertexElementType VertexElement::multiplyTypeCount(VertexElementType baseType, 
 	VertexElementType VertexElement::multiplyTypeCount(VertexElementType baseType, 
@@ -180,8 +179,7 @@ namespace CamelotEngine {
         default:
         default:
             break;
             break;
 		}
 		}
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid base type", 
-			"VertexElement::multiplyTypeCount");
+		CM_EXCEPT(InvalidParametersException, "Invalid base type");
 	}
 	}
 	//--------------------------------------------------------------------------
 	//--------------------------------------------------------------------------
 	VertexElementType VertexElement::getBestColourVertexElementType(void)
 	VertexElementType VertexElement::getBestColourVertexElementType(void)
@@ -525,9 +523,8 @@ namespace CamelotEngine {
 		VertexBufferBindingMap::iterator i = mBindingMap.find(index);
 		VertexBufferBindingMap::iterator i = mBindingMap.find(index);
 		if (i == mBindingMap.end())
 		if (i == mBindingMap.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
-				"Cannot find buffer binding for index " + toString(index),
-				"VertexBufferBinding::unsetBinding");
+			CM_EXCEPT(ItemIdentityException,
+				"Cannot find buffer binding for index " + toString(index));
 		}
 		}
 		mBindingMap.erase(i);
 		mBindingMap.erase(i);
 	}
 	}
@@ -549,8 +546,7 @@ namespace CamelotEngine {
 		VertexBufferBindingMap::const_iterator i = mBindingMap.find(index);
 		VertexBufferBindingMap::const_iterator i = mBindingMap.find(index);
 		if (i == mBindingMap.end())
 		if (i == mBindingMap.end())
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "No buffer is bound to that index.",
-				"VertexBufferBinding::getBuffer");
+			CM_EXCEPT(ItemIdentityException, "No buffer is bound to that index.");
 		}
 		}
 		return i->second;
 		return i->second;
 	}
 	}

+ 7 - 10
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -139,9 +139,8 @@ namespace CamelotEngine {
 	{
 	{
     if (mRealCapabilities != 0)
     if (mRealCapabilities != 0)
     {
     {
-      OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
-          "Custom render capabilities must be set before the RenderSystem is initialised.",
-          "RenderSystem::useCustomRenderSystemCapabilities");
+		CM_EXCEPT(InternalErrorException, 
+          "Custom render capabilities must be set before the RenderSystem is initialised.");
     }
     }
 
 
 		mCurrentCapabilities = capabilities;
 		mCurrentCapabilities = capabilities;
@@ -187,7 +186,7 @@ namespace CamelotEngine {
 
 
 				msg = "A render target of the same name '" + String(curDesc->name) + "' already "
 				msg = "A render target of the same name '" + String(curDesc->name) + "' already "
 					"exists.  You cannot create a new window with this name.";
 					"exists.  You cannot create a new window with this name.";
-				OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, msg, "RenderSystem::createRenderWindow" );
+				CM_EXCEPT(InternalErrorException, msg);
 			}
 			}
 		}
 		}
 		
 		
@@ -197,9 +196,8 @@ namespace CamelotEngine {
 			// Can not mix full screen and windowed rendering windows.
 			// Can not mix full screen and windowed rendering windows.
 			if (fullscreenWindowsCount != renderWindowDescriptions.size())
 			if (fullscreenWindowsCount != renderWindowDescriptions.size())
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-					"Can not create mix of full screen and windowed rendering windows",
-					"RenderSystem::createRenderWindows");
+				CM_EXCEPT(InvalidParametersException, 
+					"Can not create mix of full screen and windowed rendering windows");
 			}					
 			}					
 		}
 		}
 
 
@@ -331,11 +329,10 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	void RenderSystem::_setVertexTexture(size_t unit, const TexturePtr& tex)
 	void RenderSystem::_setVertexTexture(size_t unit, const TexturePtr& tex)
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, 
+		CM_EXCEPT(NotImplementedException, 
 			"This rendersystem does not support separate vertex texture samplers, "
 			"This rendersystem does not support separate vertex texture samplers, "
 			"you should use the regular texture samplers which are shared between "
 			"you should use the regular texture samplers which are shared between "
-			"the vertex and fragment units.", 
-			"RenderSystem::_setVertexTexture");
+			"the vertex and fragment units.");
 	}
 	}
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     void RenderSystem::_disableTextureUnit(size_t texUnit)
     void RenderSystem::_disableTextureUnit(size_t texUnit)

+ 2 - 3
CamelotRenderer/Source/CmRenderSystemManager.cpp

@@ -38,9 +38,8 @@ namespace CamelotEngine
 
 
 		if(mActiveRenderSystem == nullptr)
 		if(mActiveRenderSystem == nullptr)
 		{
 		{
-			OGRE_EXCEPT(CamelotEngine::Exception::ERR_INTERNAL_ERROR, 
-				"Cannot initialize render system. Renderer with the name '" + name + "' cannot be found.",
-				"RenderSystemManager::initialize")
+			CM_EXCEPT(InternalErrorException, 
+				"Cannot initialize render system. Renderer with the name '" + name + "' cannot be found.")
 		}
 		}
 	}
 	}
 
 

+ 4 - 4
CamelotRenderer/Source/CmRenderTarget.cpp

@@ -111,8 +111,8 @@ namespace CamelotEngine {
 		}
 		}
 		else
 		else
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,"No viewport with given zorder : "
-				+ toString(zorder), "RenderTarget::_updateViewport");
+			CM_EXCEPT(ItemIdentityException,"No viewport with given zorder : "
+				+ toString(zorder));
 		}
 		}
 	}
 	}
 
 
@@ -128,7 +128,7 @@ namespace CamelotEngine {
 			str << "Can't create another viewport for "
 			str << "Can't create another viewport for "
 				<< mName << " with Z-Order " << ZOrder
 				<< mName << " with Z-Order " << ZOrder
 				<< " because a viewport exists with this Z-Order already.";
 				<< " because a viewport exists with this Z-Order already.";
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, str.str(), "RenderTarget::addViewport");
+			CM_EXCEPT(InvalidParametersException, str.str());
         }
         }
         // Add viewport to list
         // Add viewport to list
         // Order based on Z-Order
         // Order based on Z-Order
@@ -163,7 +163,7 @@ namespace CamelotEngine {
 
 
     void RenderTarget::getCustomAttribute(const String& name, void* pData)
     void RenderTarget::getCustomAttribute(const String& name, void* pData)
     {
     {
-        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Attribute not found.", "RenderTarget::getCustomAttribute");
+        CM_EXCEPT(InvalidParametersException, "Attribute not found.");
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     unsigned short RenderTarget::getNumViewports(void) const
     unsigned short RenderTarget::getNumViewports(void) const

+ 4 - 6
CamelotRenderer/Source/CmRenderTexture.cpp

@@ -53,9 +53,8 @@ namespace CamelotEngine
 		if (buffer == FB_AUTO) buffer = FB_FRONT;
 		if (buffer == FB_AUTO) buffer = FB_FRONT;
 		if (buffer != FB_FRONT)
 		if (buffer != FB_FRONT)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-						"Invalid buffer.",
-						"RenderTexture::copyContentsToMemory" );
+			CM_EXCEPT(InvalidParametersException,
+						"Invalid buffer.");
 		}
 		}
 
 
 		mBuffer->blitToMemory(dst);
 		mBuffer->blitToMemory(dst);
@@ -76,8 +75,7 @@ namespace CamelotEngine
 	//-----------------------------------------------------------------------------
 	//-----------------------------------------------------------------------------
 	void MultiRenderTarget::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	void MultiRenderTarget::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	{
 	{
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-					"Cannot get MultiRenderTargets pixels",
-					"MultiRenderTarget::copyContentsToMemory");
+		CM_EXCEPT(InvalidParametersException, 
+					"Cannot get MultiRenderTargets pixels");
 	}
 	}
 }
 }

+ 2 - 3
CamelotRenderer/Source/CmTexture.cpp

@@ -132,9 +132,8 @@ namespace CamelotEngine {
     {
     {
         if(target->getNumFaces() != getNumFaces())
         if(target->getNumFaces() != getNumFaces())
         {
         {
-            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
-                "Texture types must match",
-                "Texture::copyToTexture");
+            CM_EXCEPT(InvalidParametersException, 
+                "Texture types must match");
         }
         }
         size_t numMips = std::min(getNumMipmaps(), target->getNumMipmaps());
         size_t numMips = std::min(getNumMipmaps(), target->getNumMipmaps());
         if((mUsage & TU_AUTOMIPMAP) || (target->getUsage()&TU_AUTOMIPMAP))
         if((mUsage & TU_AUTOMIPMAP) || (target->getUsage()&TU_AUTOMIPMAP))

+ 8 - 10
CamelotRenderer/Source/CmVertexIndexData.cpp

@@ -389,9 +389,8 @@ namespace CamelotEngine {
 			if (!oldElem)
 			if (!oldElem)
 			{
 			{
 				// Error, cannot create new elements with this method
 				// Error, cannot create new elements with this method
-				OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
-					"Element not found in old vertex declaration", 
-					"VertexData::reorganiseBuffers");
+				CM_EXCEPT(ItemIdentityException, 
+					"Element not found in old vertex declaration");
 			}
 			}
 			newToOldElementMap[&(*ei)] = oldElem;
 			newToOldElementMap[&(*ei)] = oldElem;
 		}
 		}
@@ -516,9 +515,8 @@ namespace CamelotEngine {
             const VertexElement& elem = *ai;
             const VertexElement& elem = *ai;
             if (!vertexBufferBinding->isBufferBound(elem.getSource()))
             if (!vertexBufferBinding->isBufferBound(elem.getSource()))
             {
             {
-                OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
-                    "No buffer is bound to that element source.",
-                    "VertexData::closeGapsInBindings");
+                CM_EXCEPT(ItemIdentityException,
+                    "No buffer is bound to that element source.");
             }
             }
         }
         }
 
 
@@ -578,13 +576,13 @@ namespace CamelotEngine {
 	{
 	{
 		if (destType != VET_COLOUR_ABGR && destType != VET_COLOUR_ARGB)
 		if (destType != VET_COLOUR_ABGR && destType != VET_COLOUR_ARGB)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-				"Invalid destType parameter", "VertexData::convertPackedColour");
+			CM_EXCEPT(InvalidParametersException,
+				"Invalid destType parameter");
 		}
 		}
 		if (srcType != VET_COLOUR_ABGR && srcType != VET_COLOUR_ARGB)
 		if (srcType != VET_COLOUR_ABGR && srcType != VET_COLOUR_ARGB)
 		{
 		{
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
-				"Invalid srcType parameter", "VertexData::convertPackedColour");
+			CM_EXCEPT(InvalidParametersException,
+				"Invalid srcType parameter");
 		}
 		}
 
 
 		const VertexBufferBinding::VertexBufferBindingMap& bindMap = 
 		const VertexBufferBinding::VertexBufferBindingMap& bindMap = 

+ 0 - 1
CamelotRenderer/TODO.txt

@@ -50,7 +50,6 @@ IMPORTANT: I think I should strive to make the renderer one unique CmRenderSyste
      - AND because I need to have it separated since I can't expect DirectX to compile on OSX or Linux
      - AND because I need to have it separated since I can't expect DirectX to compile on OSX or Linux
 
 
 TOMORROW:
 TOMORROW:
- - Add plugin loading for D3D9 and GL plugins and make sure everything works once more
  - Incorporate CamelotUtility library into CamelotRenderer
  - Incorporate CamelotUtility library into CamelotRenderer
    - Move remaining Utility files to CamelotUtility (files like StringUtil, PixelUtil and similar)
    - Move remaining Utility files to CamelotUtility (files like StringUtil, PixelUtil and similar)
      - Port exceptions
      - Port exceptions

+ 49 - 221
CamelotUtility/Include/CmException.h

@@ -1,93 +1,34 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
+#pragma once
 
 
-Copyright (c) 2000-2011 Torus Knot Software Ltd
+#include "CmPrerequisitesUtil.h"
 
 
-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:
+//#include <boost/static_assert.hpp>
+//#include <boost/type_traits.hpp>
 
 
-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 __Exception_H_
-#define __Exception_H_
-
-// Precompiler options
-#include "CmString.h"
-#include <exception>
+#if defined(_MSC_VER)
+#undef __PRETTY_FUNCTION__
+#define __PRETTY_FUNCTION__ __FUNCSIG__
+#endif
 
 
-namespace CamelotEngine {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup General
-	*  @{
-	*/
-	/** When thrown, provides information about an error that has occurred inside the engine.
-        @remarks
-            OGRE never uses return values to indicate errors. Instead, if an
-            error occurs, an exception is thrown, and this is the object that
-            encapsulates the detail of the problem. The application using
-            OGRE should always ensure that the exceptions are caught, so all
-            OGRE engine functions should occur within a
-            try{} catch(CamelotEngine::Exception& e) {} block.
-        @par
-            The user application should never create any instances of this
-            object unless it wishes to unify its error handling using the
-            same object.
-    */
+namespace CamelotEngine
+{
 	class CM_EXPORT Exception : public std::exception
 	class CM_EXPORT Exception : public std::exception
     {
     {
     protected:
     protected:
-        long line;
-        int number;
-		String typeName;
-        String description;
-        String source;
-        String file;
-		mutable String fullDesc;
+        long mLine;
+		String mTypeName;
+        String mDescription;
+        String mSource;
+        String mFile;
+		mutable String mFullDesc;
     public:
     public:
-        /** Static definitions of error codes.
-            @todo
-                Add many more exception codes, since we want the user to be able
-                to catch most of them.
-        */
-        enum ExceptionCodes {
-            ERR_CANNOT_WRITE_TO_FILE,
-            ERR_INVALID_STATE,
-            ERR_INVALIDPARAMS,
-            ERR_RENDERINGAPI_ERROR,
-            ERR_DUPLICATE_ITEM,
-            ERR_ITEM_NOT_FOUND,
-            ERR_FILE_NOT_FOUND,
-            ERR_INTERNAL_ERROR,
-            ERR_RT_ASSERTION_FAILED, 
-			ERR_NOT_IMPLEMENTED
-        };
-
         /** Default constructor.
         /** Default constructor.
         */
         */
-        Exception( int number, const String& description, const String& source );
+		Exception(const char* type, const String& description, const String& source);
 
 
         /** Advanced constructor.
         /** Advanced constructor.
         */
         */
-        Exception( int number, const String& description, const String& source, const char* type, const char* file, long line );
+		Exception(const char* type, const String& description, const String& source, const char* file, long line);
 
 
         /** Copy constructor.
         /** Copy constructor.
         */
         */
@@ -110,204 +51,91 @@ namespace CamelotEngine {
                 the place in which OGRE found the problem, and a text
                 the place in which OGRE found the problem, and a text
                 description from the 3D rendering library, if available.
                 description from the 3D rendering library, if available.
         */
         */
-        virtual const String& getFullDescription(void) const;
-
-        /** Gets the error code.
-        */
-        virtual int getNumber(void) const throw();
+		virtual const String& getFullDescription() const;
 
 
         /** Gets the source function.
         /** Gets the source function.
         */
         */
-        virtual const String &getSource() const { return source; }
+		virtual const String& getSource() const { return mSource; }
 
 
         /** Gets source file name.
         /** Gets source file name.
         */
         */
-        virtual const String &getFile() const { return file; }
+		virtual const String& getFile() const { return mFile; }
 
 
         /** Gets line number.
         /** Gets line number.
         */
         */
-        virtual long getLine() const { return line; }
+        virtual long getLine() const { return mLine; }
 
 
 		/** Returns a string with only the 'description' field of this exception. Use 
 		/** Returns a string with only the 'description' field of this exception. Use 
 			getFullDescriptionto get a full description of the error including line number,
 			getFullDescriptionto get a full description of the error including line number,
 			error number and what function threw the exception.
 			error number and what function threw the exception.
         */
         */
-		virtual const String &getDescription(void) const { return description; }
+		virtual const String& getDescription(void) const { return mDescription; }
 
 
 		/// Override std::exception::what
 		/// Override std::exception::what
 		const char* what() const throw() { return getFullDescription().c_str(); }
 		const char* what() const throw() { return getFullDescription().c_str(); }
-        
     };
     };
 
 
-
-	/** Template struct which creates a distinct type for each exception code.
-	@note
-	This is useful because it allows us to create an overloaded method
-	for returning different exception types by value without ambiguity. 
-	From 'Modern C++ Design' (Alexandrescu 2001).
-	*/
-	template <int num>
-	struct ExceptionCodeType
-	{
-		enum { number = num };
-	};
-
-	// Specialised exceptions allowing each to be caught specifically
-	// backwards-compatible since exception codes still used
-
-	class CM_EXPORT UnimplementedException : public Exception 
+	class CM_EXPORT NotImplementedException : public Exception 
 	{
 	{
 	public:
 	public:
-		UnimplementedException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "UnimplementedException", inFile, inLine) {}
+		NotImplementedException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("NotImplementedException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT FileNotFoundException : public Exception
 	class CM_EXPORT FileNotFoundException : public Exception
 	{
 	{
 	public:
 	public:
-		FileNotFoundException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "FileNotFoundException", inFile, inLine) {}
+		FileNotFoundException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("FileNotFoundException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT IOException : public Exception
 	class CM_EXPORT IOException : public Exception
 	{
 	{
 	public:
 	public:
-		IOException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "IOException", inFile, inLine) {}
+		IOException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("IOException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT InvalidStateException : public Exception
 	class CM_EXPORT InvalidStateException : public Exception
 	{
 	{
 	public:
 	public:
-		InvalidStateException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "InvalidStateException", inFile, inLine) {}
+		InvalidStateException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("InvalidStateException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT InvalidParametersException : public Exception
 	class CM_EXPORT InvalidParametersException : public Exception
 	{
 	{
 	public:
 	public:
-		InvalidParametersException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "InvalidParametersException", inFile, inLine) {}
+		InvalidParametersException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("InvalidParametersException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT ItemIdentityException : public Exception
 	class CM_EXPORT ItemIdentityException : public Exception
 	{
 	{
 	public:
 	public:
-		ItemIdentityException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "ItemIdentityException", inFile, inLine) {}
+		ItemIdentityException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("ItemIdentityException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT InternalErrorException : public Exception
 	class CM_EXPORT InternalErrorException : public Exception
 	{
 	{
 	public:
 	public:
-		InternalErrorException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "InternalErrorException", inFile, inLine) {}
+		InternalErrorException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("InternalErrorException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT RenderingAPIException : public Exception
 	class CM_EXPORT RenderingAPIException : public Exception
 	{
 	{
 	public:
 	public:
-		RenderingAPIException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "RenderingAPIException", inFile, inLine) {}
+		RenderingAPIException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("RenderingAPIException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
 	class CM_EXPORT RuntimeAssertionException : public Exception
 	class CM_EXPORT RuntimeAssertionException : public Exception
 	{
 	{
 	public:
 	public:
-		RuntimeAssertionException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
-			: Exception(inNumber, inDescription, inSource, "RuntimeAssertionException", inFile, inLine) {}
-	};
-
-
-	/** Class implementing dispatch methods in order to construct by-value
-		exceptions of a derived type based just on an exception code.
-	@remarks
-		This nicely handles construction of derived Exceptions by value (needed
-		for throwing) without suffering from ambiguity - each code is turned into
-		a distinct type so that methods can be overloaded. This allows OGRE_EXCEPT
-		to stay small in implementation (desirable since it is embedded) whilst
-		still performing rich code-to-type mapping. 
-	*/
-	class ExceptionFactory
-	{
-	private:
-		/// Private constructor, no construction
-		ExceptionFactory() {}
-	public:
-		static UnimplementedException create(
-			ExceptionCodeType<Exception::ERR_NOT_IMPLEMENTED> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return UnimplementedException(code.number, desc, src, file, line);
-		}
-		static FileNotFoundException create(
-			ExceptionCodeType<Exception::ERR_FILE_NOT_FOUND> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return FileNotFoundException(code.number, desc, src, file, line);
-		}
-		static IOException create(
-			ExceptionCodeType<Exception::ERR_CANNOT_WRITE_TO_FILE> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return IOException(code.number, desc, src, file, line);
-		}
-		static InvalidStateException create(
-			ExceptionCodeType<Exception::ERR_INVALID_STATE> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return InvalidStateException(code.number, desc, src, file, line);
-		}
-		static InvalidParametersException create(
-			ExceptionCodeType<Exception::ERR_INVALIDPARAMS> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return InvalidParametersException(code.number, desc, src, file, line);
-		}
-		static ItemIdentityException create(
-			ExceptionCodeType<Exception::ERR_ITEM_NOT_FOUND> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return ItemIdentityException(code.number, desc, src, file, line);
-		}
-		static ItemIdentityException create(
-			ExceptionCodeType<Exception::ERR_DUPLICATE_ITEM> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return ItemIdentityException(code.number, desc, src, file, line);
-		}
-		static InternalErrorException create(
-			ExceptionCodeType<Exception::ERR_INTERNAL_ERROR> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return InternalErrorException(code.number, desc, src, file, line);
-		}
-		static RenderingAPIException create(
-			ExceptionCodeType<Exception::ERR_RENDERINGAPI_ERROR> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return RenderingAPIException(code.number, desc, src, file, line);
-		}
-		static RuntimeAssertionException create(
-			ExceptionCodeType<Exception::ERR_RT_ASSERTION_FAILED> code, 
-			const String& desc, 
-			const String& src, const char* file, long line)
-		{
-			return RuntimeAssertionException(code.number, desc, src, file, line);
-		}
-
+		RuntimeAssertionException(const std::string& inDescription, const std::string& inSource, const char* inFile, long inLine)
+			: Exception("RuntimeAssertionException", inDescription, inSource, inFile, inLine) {}
 	};
 	};
-	
 
 
-	
-#ifndef OGRE_EXCEPT
-#define OGRE_EXCEPT(num, desc, src) throw CamelotEngine::ExceptionFactory::create( \
-	CamelotEngine::ExceptionCodeType<num>(), desc, src, __FILE__, __LINE__ );
+	// TODO - Temporarily disabled until I include boost
+#ifndef CM_EXCEPT
+#define CM_EXCEPT(type, desc)	\
+	throw type##(desc, __PRETTY_FUNCTION__, __FILE__, __LINE__);
+//	BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotEngine::Exception, type##>::value), "Invalid exception type (" #type ") for CM_EXCEPT macro. It needs to derive from CamelotEngine::Exception."); \
+//	throw type##(desc, __PRETTY_FUNCTION__, __FILE__, __LINE__);
 #endif
 #endif
-	/** @} */
-	/** @} */
+}
 
 
-} // namespace CamelotEngine
-
-#endif

+ 4 - 8
CamelotUtility/Source/CmDynLib.cpp

@@ -78,11 +78,9 @@ namespace CamelotEngine {
         m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
         m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
 
 
         if( !m_hInst )
         if( !m_hInst )
-            OGRE_EXCEPT(
-                Exception::ERR_INTERNAL_ERROR, 
+            CM_EXCEPT(InternalErrorException, 
                 "Could not load dynamic library " + mName + 
                 "Could not load dynamic library " + mName + 
-                ".  System Error: " + dynlibError(),
-                "DynLib::load" );
+                ".  System Error: " + dynlibError());
     }
     }
 
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
@@ -90,11 +88,9 @@ namespace CamelotEngine {
     {
     {
         if( DYNLIB_UNLOAD( m_hInst ) )
         if( DYNLIB_UNLOAD( m_hInst ) )
 		{
 		{
-            OGRE_EXCEPT(
-                Exception::ERR_INTERNAL_ERROR, 
+			CM_EXCEPT(InternalErrorException, 
                 "Could not unload dynamic library " + mName +
                 "Could not unload dynamic library " + mName +
-                ".  System Error: " + dynlibError(),
-                "DynLib::unload");
+                ".  System Error: " + dynlibError());
 		}
 		}
 
 
     }
     }

+ 27 - 94
CamelotUtility/Source/CmException.cpp

@@ -1,114 +1,47 @@
-/*
------------------------------------------------------------------------------
-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.
------------------------------------------------------------------------------
-*/
 #include "CmException.h"
 #include "CmException.h"
 
 
-#ifdef __BORLANDC__
-    #include <stdio.h>
-#endif
-
-namespace CamelotEngine {
+namespace CamelotEngine
+{
+	Exception::Exception(const char* type, const String& desc, const String& src) 
+		:mLine(0), mTypeName(type), mDescription(desc), mSource(src)
+    { }
 
 
-    Exception::Exception(int num, const String& desc, const String& src) :
-        line( 0 ),
-        number( num ),
-        description( desc ),
-        source( src )
-    {
-        // Log this error - not any more, allow catchers to do it
-        //LogManager::getSingleton().logMessage(this->getFullDescription());
-    }
-
-    Exception::Exception(int num, const String& desc, const String& src, 
-		const char* typ, const char* fil, long lin) :
-        line( lin ),
-        number( num ),
-		typeName(typ),
-        description( desc ),
-        source( src ),
-        file( fil )
-    {
-        // Log this error, mask it from debug though since it may be caught and ignored
-		// TODO - PORT - Log IGNORED
-  //      if(LogManager::getSingletonPtr())
-		//{
-  //          LogManager::getSingleton().logMessage(
-		//		this->getFullDescription(), 
-  //              LML_CRITICAL, true);
-		//}
-
-    }
+    Exception::Exception(const char* type, const String& desc, const String& src, const char* file, long line)
+		:mLine(line), mTypeName(type), mDescription(desc), mSource(src), mFile(file)
+    { }
 
 
     Exception::Exception(const Exception& rhs)
     Exception::Exception(const Exception& rhs)
-        : line( rhs.line ), 
-		number( rhs.number ), 
-		typeName( rhs.typeName ), 
-		description( rhs.description ), 
-		source( rhs.source ), 
-		file( rhs.file )
-    {
-    }
+        : mLine(rhs.mLine), mTypeName(rhs.mTypeName), mDescription(rhs.mDescription), 
+		mSource(rhs.mSource), mFile(rhs.mFile)
+    { }
 
 
-    void Exception::operator = ( const Exception& rhs )
+    void Exception::operator = (const Exception& rhs)
     {
     {
-        description = rhs.description;
-        number = rhs.number;
-        source = rhs.source;
-        file = rhs.file;
-        line = rhs.line;
-		typeName = rhs.typeName;
+        mDescription = rhs.mDescription;
+        mSource = rhs.mSource;
+        mFile = rhs.mFile;
+        mLine = rhs.mLine;
+		mTypeName = rhs.mTypeName;
     }
     }
 
 
     const String& Exception::getFullDescription(void) const
     const String& Exception::getFullDescription(void) const
     {
     {
-		if (fullDesc.empty())
+		if (mFullDesc.empty())
 		{
 		{
+			std::stringstream desc;
 
 
-			StringUtil::StrStreamType desc;
+			desc<< "CAMELOT EXCEPTION(" << mTypeName << "): "
+				<< mDescription 
+				<< " in " << mSource;
 
 
-			desc <<  "OGRE EXCEPTION(" << number << ":" << typeName << "): "
-				<< description 
-				<< " in " << source;
-
-			if( line > 0 )
+			if(mLine > 0)
 			{
 			{
-				desc << " at " << file << " (line " << line << ")";
+				desc << " at " << mFile << " (line " << mLine << ")";
 			}
 			}
 
 
-			fullDesc = desc.str();
+			mFullDesc = desc.str();
 		}
 		}
 
 
-		return fullDesc;
+		return mFullDesc;
     }
     }
-
-    int Exception::getNumber(void) const throw()
-    {
-        return number;
-    }
-
-}
-
+}

+ 8 - 14
CamelotUtility/Source/CmPixelUtil.cpp

@@ -950,10 +950,10 @@ namespace CamelotEngine {
 				// Entire buffer is being queried
 				// Entire buffer is being queried
 				return *this;
 				return *this;
 			}
 			}
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Cannot return subvolume of compressed PixelBuffer", "PixelBox::getSubVolume");
+			CM_EXCEPT(InvalidParametersException, "Cannot return subvolume of compressed PixelBuffer");
 		}
 		}
 		if(!contains(def))
 		if(!contains(def))
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Bounds out of range", "PixelBox::getSubVolume");
+			CM_EXCEPT(InvalidParametersException, "Bounds out of range");
 
 
 		const size_t elemSize = PixelUtil::getNumElemBytes(format);
 		const size_t elemSize = PixelUtil::getNumElemBytes(format);
 		// Calculate new data origin
 		// Calculate new data origin
@@ -1017,8 +1017,7 @@ namespace CamelotEngine {
 					assert(depth == 1);
 					assert(depth == 1);
                     return (std::max((int)width, 8) * std::max((int)height, 8) * 4 + 7) / 8;
                     return (std::max((int)width, 8) * std::max((int)height, 8) * 4 + 7) / 8;
 				default:
 				default:
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid compressed pixel format",
-					"PixelUtil::getMemorySize");
+				CM_EXCEPT(InvalidParametersException, "Invalid compressed pixel format");
 			}
 			}
 		}
 		}
 		else
 		else
@@ -1388,10 +1387,8 @@ namespace CamelotEngine {
 				break;
 				break;
             default:
             default:
                 // Not yet supported
                 // Not yet supported
-                OGRE_EXCEPT(
-                    Exception::ERR_NOT_IMPLEMENTED,
-                    "pack to "+getFormatName(pf)+" not implemented",
-                    "PixelUtil::packColour");
+                CM_EXCEPT(NotImplementedException,
+                    "pack to "+getFormatName(pf)+" not implemented");
                 break;
                 break;
             }
             }
         }
         }
@@ -1529,9 +1526,8 @@ namespace CamelotEngine {
 				break;
 				break;
             default:
             default:
                 // Not yet supported
                 // Not yet supported
-                OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-                    "unpack from "+getFormatName(pf)+" not implemented",
-                    "PixelUtil::unpackColour");
+                CM_EXCEPT(NotImplementedException,
+                    "unpack from "+getFormatName(pf)+" not implemented");
                 break;
                 break;
             }
             }
         }
         }
@@ -1563,9 +1559,7 @@ namespace CamelotEngine {
 			}
 			}
 			else
 			else
 			{
 			{
-				OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-					"This method can not be used to compress or decompress images",
-					"PixelUtil::bulkPixelConversion");
+				CM_EXCEPT(NotImplementedException, "This method can not be used to compress or decompress images");
 			}
 			}
 		}
 		}