Просмотр исходного кода

Moved string/exception to utility
Added DynLib to Utility

Marko Pintera 13 лет назад
Родитель
Сommit
c54c3f6ed7

+ 69 - 0
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{796B6DFF-BA04-42B7-A43A-2B14D707A33A}</ProjectGuid>
+    <RootNamespace>CamelotD3D9Renderer</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 17 - 0
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+</Project>

+ 15 - 12
CamelotRenderer.sln

@@ -2,11 +2,14 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 2012
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotRenderer", "CamelotRenderer\CamelotRenderer.vcxproj", "{9B21D41C-516B-43BF-9B10-E99B599C7589}"
-EndProject
-Project("{F088123C-0E9E-452A-89E6-6BA2F21D5CAC}") = "CamelotModel", "CamelotModel\CamelotModel.modelproj", "{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}"
+	ProjectSection(ProjectDependencies) = postProject
+		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
+	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotUtility", "CamelotUtility\CamelotUtility.vcxproj", "{CC7F9445-71C9-4559-9976-FF0A64DCB582}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotD3D9Renderer", "CamelotD3D9Renderer\CamelotD3D9Renderer.vcxproj", "{796B6DFF-BA04-42B7-A43A-2B14D707A33A}"
+EndProject
 Global
 	GlobalSection(SubversionScc) = preSolution
 		Svn-Managed = True
@@ -31,16 +34,6 @@ Global
 		{9B21D41C-516B-43BF-9B10-E99B599C7589}.Release|Mixed Platforms.Build.0 = Release|Win32
 		{9B21D41C-516B-43BF-9B10-E99B599C7589}.Release|Win32.ActiveCfg = Release|Win32
 		{9B21D41C-516B-43BF-9B10-E99B599C7589}.Release|Win32.Build.0 = Release|Win32
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Debug|Win32.ActiveCfg = Debug|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Release|Any CPU.Build.0 = Release|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{CF27AA3E-CBE5-48FA-9562-12B4BF474ACD}.Release|Win32.ActiveCfg = Release|Any CPU
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Debug|Any CPU.ActiveCfg = Debug|Win32
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Debug|Mixed Platforms.Build.0 = Debug|Win32
@@ -51,6 +44,16 @@ Global
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Release|Mixed Platforms.Build.0 = Release|Win32
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Release|Win32.ActiveCfg = Release|Win32
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582}.Release|Win32.Build.0 = Release|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Debug|Win32.Build.0 = Debug|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Release|Any CPU.ActiveCfg = Release|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Release|Win32.ActiveCfg = Release|Win32
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 1 - 1
CamelotRenderer/CamelotRenderer.cpp

@@ -31,7 +31,7 @@ int _tmain(int argc, _TCHAR* argv[])
 {
 	//const String& name = CamelotEngine::gApplication().getRenderSystem()->getName();
 
-	gApplication().startUp();
+	gApplication().startUp("RenderSystemD3D9.dll");
 
 	int a = 5;
 

+ 0 - 6
CamelotRenderer/CamelotRenderer.vcxproj

@@ -127,7 +127,6 @@
     <ClInclude Include="CmD3D9VideoMode.h" />
     <ClInclude Include="CmD3D9VideoModeList.h" />
     <ClInclude Include="CmDefaultHardwareBufferManager.h" />
-    <ClInclude Include="CmException.h" />
     <ClInclude Include="CmFrustum.h" />
     <ClInclude Include="CmGpuProgram.h" />
     <ClInclude Include="CmGpuProgramManager.h" />
@@ -152,8 +151,6 @@
     <ClInclude Include="CmRenderTexture.h" />
     <ClInclude Include="CmRenderWindow.h" />
     <ClInclude Include="CmSingleton.h" />
-    <ClInclude Include="CmString.h" />
-    <ClInclude Include="CmStringConverter.h" />
     <ClInclude Include="CmTexture.h" />
     <ClInclude Include="CmTextureManager.h" />
     <ClInclude Include="CmTextureState.h" />
@@ -252,7 +249,6 @@
     <ClCompile Include="CmD3D9VideoMode.cpp" />
     <ClCompile Include="CmD3D9VideoModeList.cpp" />
     <ClCompile Include="CmDefaultHardwareBufferManager.cpp" />
-    <ClCompile Include="CmException.cpp" />
     <ClCompile Include="CmFrustum.cpp" />
     <ClCompile Include="CmGpuProgram.cpp" />
     <ClCompile Include="CmGpuProgramManager.cpp" />
@@ -270,8 +266,6 @@
     <ClCompile Include="CmRenderTarget.cpp" />
     <ClCompile Include="CmRenderTexture.cpp" />
     <ClCompile Include="CmRenderWindow.cpp" />
-    <ClCompile Include="CmString.cpp" />
-    <ClCompile Include="CmStringConverter.cpp" />
     <ClCompile Include="CmTexture.cpp" />
     <ClCompile Include="CmTextureManager.cpp" />
     <ClCompile Include="CmTextureState.cpp" />

+ 0 - 18
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -401,9 +401,6 @@
     <ClInclude Include="CmConfigOptionMap.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
-    <ClInclude Include="CmException.h">
-      <Filter>Header Files\ForRemoval</Filter>
-    </ClInclude>
     <ClInclude Include="CmHeaderPrefix.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
@@ -419,12 +416,6 @@
     <ClInclude Include="CmSingleton.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
-    <ClInclude Include="CmString.h">
-      <Filter>Header Files\ForRemoval</Filter>
-    </ClInclude>
-    <ClInclude Include="CmStringConverter.h">
-      <Filter>Header Files\ForRemoval</Filter>
-    </ClInclude>
     <ClInclude Include="CmBlendMode.h">
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
@@ -778,15 +769,6 @@
     <ClCompile Include="RenderSystemGL\Source\CmWin32Window.cpp">
       <Filter>RenderSystemGL\Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="CmException.cpp">
-      <Filter>Source Files\ForRemoval</Filter>
-    </ClCompile>
-    <ClCompile Include="CmString.cpp">
-      <Filter>Source Files\ForRemoval</Filter>
-    </ClCompile>
-    <ClCompile Include="CmStringConverter.cpp">
-      <Filter>Source Files\ForRemoval</Filter>
-    </ClCompile>
     <ClCompile Include="CmColourValue.cpp">
       <Filter>Source Files\Utility</Filter>
     </ClCompile>

+ 1 - 1
CamelotRenderer/CmApplication.cpp

@@ -17,7 +17,7 @@ namespace CamelotEngine
 		:mRenderWindow(nullptr), mViewport(nullptr), mCamera(nullptr), mGpuProgramManager(nullptr)
 	{ }
 
-	void Application::startUp()
+	void Application::startUp(String renderSystemDll)
 	{
 		mGpuProgramManager = new HighLevelGpuProgramManager(); // TODO - Use Camelot::Module for instantiating this
 

+ 1 - 1
CamelotRenderer/CmApplication.h

@@ -18,7 +18,7 @@ namespace CamelotEngine
 		public:
 			Application();
 
-			void startUp();
+			void startUp(String renderSystemDll);
 			void shutDown();
 
 			void DBG_renderSimpleFrame();

+ 0 - 22
CamelotRenderer/CmPrerequisites.h

@@ -58,7 +58,6 @@ namespace CamelotEngine {
 	class MultiRenderTarget;
     class RenderWindow;
     class RenderOperation;
-    class StringConverter;
     class StringInterface;
     class TextureState;
     class Texture;
@@ -78,27 +77,6 @@ namespace CamelotEngine
 	typedef std::shared_ptr<Texture> TexturePtr;
 }
 
-namespace CamelotEngine
-{
-	#if OGRE_WCHAR_T_STRINGS
-		typedef std::wstring _StringBase;
-	#else
-		typedef std::string _StringBase;
-	#endif
-
-	#if OGRE_WCHAR_T_STRINGS
-		typedef std::basic_stringstream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > _StringStreamBase;
-	#else
-		typedef std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> > _StringStreamBase;
-	#endif
-
-	typedef _StringBase String;
-	typedef _StringStreamBase StringStream;
-	typedef StringStream stringstream;
-
-}
-
-
 #endif // __OgrePrerequisites_H__
 
 

+ 2 - 0
CamelotRenderer/CmRenderSystemManager.cpp

@@ -8,6 +8,8 @@ namespace CamelotEngine
 
 	void RenderSystemManager::initialize(const std::string& name)
 	{
+		assert(mActiveRenderSystem == nullptr); // Once loaded the render system is set for life
+
 		for(auto iter = getAvailableFactories().begin(); iter != getAvailableFactories().end(); ++iter)
 		{
 			if((*iter)->name() == name)

+ 4 - 3
CamelotRenderer/TODO.txt

@@ -60,10 +60,8 @@ TOMORROW:
 
 Other notes:
  - Search for all remaining "TODO PORT" comments and fix them
- - Make sure to remove all ogre memory allocators and memory category bullshit (Possibly replace with Camelot versions?)
  - Remove Ogre::String and Ogre::float (Possibly replace with Camelot versions?)
  - Ogre::ColourValue -> CamelotEngine::Color (Other struct names are okay for the most part)
- - Port all math methods to Camelot
  - Rename all macros and other OGRE references to CM
  - How am I notified on device reset? (When I need to reload my resources)
  - If possible, make sure GLSL uses EntryPoint and Profile fields I have added to GpuProgram
@@ -85,4 +83,7 @@ After everything is polished:
 
  - Go to Game Engine Architecture book and make a list of Utility systems we will need (Config files, Parsers, File I/O etc)
  - Go to GEA book and read about resource managers before implementing them
-   - Actually I should re-read most of the chapers in the book, or all of it
+   - Actually I should re-read most of the chapers in the book, or all of it
+
+ - OpenGL non-Win32 window files haven't been properly parsed or tested
+   - Since I probably can't compile them, try adding them to VS and see what intellisense says?

+ 10 - 0
CamelotUtility/CamelotUtility.vcxproj

@@ -71,7 +71,11 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="Include\CmColourValue.h" />
+    <ClInclude Include="Include\CmException.h" />
     <ClInclude Include="Include\CmMathAsm.h" />
+    <ClInclude Include="Include\CmString.h" />
+    <ClInclude Include="Include\CmStringConverter.h" />
     <ClInclude Include="Include\CmThreadDefines.h" />
     <ClInclude Include="Include\CmTypes.h" />
     <ClInclude Include="Include\CmFwdDeclUtil.h" />
@@ -89,17 +93,23 @@
     <ClInclude Include="Include\CmVector2.h" />
     <ClInclude Include="Include\CmVector3.h" />
     <ClInclude Include="Include\CmVector4.h" />
+    <ClInclude Include="Include\CmDynLib.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Include\CmAxisAlignedBox.cpp" />
+    <ClCompile Include="Source\CmColourValue.cpp" />
+    <ClCompile Include="Source\CmException.cpp" />
     <ClCompile Include="Source\CmMath.cpp" />
     <ClCompile Include="Source\CmMatrix3.cpp" />
     <ClCompile Include="Source\CmMatrix4.cpp" />
     <ClCompile Include="Source\CmPlane.cpp" />
     <ClCompile Include="Source\CmQuaternion.cpp" />
+    <ClCompile Include="Source\CmString.cpp" />
+    <ClCompile Include="Source\CmStringConverter.cpp" />
     <ClCompile Include="Source\CmVector2.cpp" />
     <ClCompile Include="Source\CmVector3.cpp" />
     <ClCompile Include="Source\CmVector4.cpp" />
+    <ClCompile Include="Source\CmDynLib.cpp" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 30 - 0
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -81,6 +81,21 @@
     <ClInclude Include="Include\CmThreadDefines.h">
       <Filter>Header Files\Threading</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmDynLib.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmException.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmString.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmStringConverter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmColourValue.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Include\CmAxisAlignedBox.cpp">
@@ -110,5 +125,20 @@
     <ClCompile Include="Source\CmVector4.cpp">
       <Filter>Source Files\Math</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmDynLib.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmException.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmString.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmStringConverter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmColourValue.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 334 - 0
CamelotUtility/Include/CmColourValue.h

@@ -0,0 +1,334 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2011 Torus Knot Software Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef _COLOURVALUE_H__
+#define _COLOURVALUE_H__
+
+#include "CmPrerequisitesUtil.h"
+
+namespace CamelotEngine {
+	/** \addtogroup Core
+	*  @{
+	*/
+	/** \addtogroup General
+	*  @{
+	*/
+
+    typedef UINT32 RGBA;
+    typedef UINT32 ARGB;
+    typedef UINT32 ABGR;
+	typedef UINT32 BGRA;
+
+    /** Class representing colour.
+	    @remarks
+		    Colour is represented as 4 components, each of which is a
+		    floating-point value from 0.0 to 1.0.
+	    @par
+		    The 3 'normal' colour components are red, green and blue, a higher
+		    number indicating greater amounts of that component in the colour.
+		    The forth component is the 'alpha' value, which represents
+		    transparency. In this case, 0.0 is completely transparent and 1.0 is
+		    fully opaque.
+    */
+    class CM_EXPORT ColourValue
+    {
+    public:
+        static const ColourValue ZERO;
+        static const ColourValue Black;
+        static const ColourValue White;
+        static const ColourValue Red;
+        static const ColourValue Green;
+        static const ColourValue Blue;
+
+	    explicit ColourValue( float red = 1.0f,
+				    float green = 1.0f,
+				    float blue = 1.0f,
+				    float alpha = 1.0f ) : r(red), g(green), b(blue), a(alpha)
+        { }
+
+	    bool operator==(const ColourValue& rhs) const;
+	    bool operator!=(const ColourValue& rhs) const;
+
+        float r,g,b,a;
+
+	    /** Retrieves colour as RGBA.
+	    */
+	    RGBA getAsRGBA(void) const;
+
+	    /** Retrieves colour as ARGB.
+	    */
+	    ARGB getAsARGB(void) const;
+
+		/** Retrieves colour as BGRA.
+		*/
+		BGRA getAsBGRA(void) const;
+
+		/** Retrieves colours as ABGR */
+	    ABGR getAsABGR(void) const;
+
+	    /** Sets colour as RGBA.
+	    */
+        void setAsRGBA(const RGBA val);
+
+	    /** Sets colour as ARGB.
+	    */
+        void setAsARGB(const ARGB val);
+
+		/** Sets colour as BGRA.
+		*/
+		void setAsBGRA(const BGRA val);
+
+	    /** Sets colour as ABGR.
+	    */
+        void setAsABGR(const ABGR val);
+
+        /** Clamps colour value to the range [0, 1].
+        */
+        void saturate(void)
+        {
+            if (r < 0)
+                r = 0;
+            else if (r > 1)
+                r = 1;
+
+            if (g < 0)
+                g = 0;
+            else if (g > 1)
+                g = 1;
+
+            if (b < 0)
+                b = 0;
+            else if (b > 1)
+                b = 1;
+
+            if (a < 0)
+                a = 0;
+            else if (a > 1)
+                a = 1;
+        }
+
+        /** As saturate, except that this colour value is unaffected and
+            the saturated colour value is returned as a copy. */
+        ColourValue saturateCopy(void) const
+        {
+            ColourValue ret = *this;
+            ret.saturate();
+            return ret;
+        }
+
+		/// Array accessor operator
+		inline float operator [] ( const size_t i ) const
+		{
+			assert( i < 4 );
+
+			return *(&r+i);
+		}
+
+		/// Array accessor operator
+		inline float& operator [] ( const size_t i )
+		{
+			assert( i < 4 );
+
+			return *(&r+i);
+		}
+
+		/// Pointer accessor for direct copying
+		inline float* ptr()
+		{
+			return &r;
+		}
+		/// Pointer accessor for direct copying
+		inline const float* ptr() const
+		{
+			return &r;
+		}
+
+		
+		// arithmetic operations
+        inline ColourValue operator + ( const ColourValue& rkVector ) const
+        {
+            ColourValue kSum;
+
+            kSum.r = r + rkVector.r;
+            kSum.g = g + rkVector.g;
+            kSum.b = b + rkVector.b;
+            kSum.a = a + rkVector.a;
+
+            return kSum;
+        }
+
+        inline ColourValue operator - ( const ColourValue& rkVector ) const
+        {
+            ColourValue kDiff;
+
+            kDiff.r = r - rkVector.r;
+            kDiff.g = g - rkVector.g;
+            kDiff.b = b - rkVector.b;
+            kDiff.a = a - rkVector.a;
+
+            return kDiff;
+        }
+
+        inline ColourValue operator * (const float fScalar ) const
+        {
+            ColourValue kProd;
+
+            kProd.r = fScalar*r;
+            kProd.g = fScalar*g;
+            kProd.b = fScalar*b;
+            kProd.a = fScalar*a;
+
+            return kProd;
+        }
+
+        inline ColourValue operator * ( const ColourValue& rhs) const
+        {
+            ColourValue kProd;
+
+            kProd.r = rhs.r * r;
+            kProd.g = rhs.g * g;
+            kProd.b = rhs.b * b;
+            kProd.a = rhs.a * a;
+
+            return kProd;
+        }
+
+        inline ColourValue operator / ( const ColourValue& rhs) const
+        {
+            ColourValue kProd;
+
+            kProd.r = rhs.r / r;
+            kProd.g = rhs.g / g;
+            kProd.b = rhs.b / b;
+            kProd.a = rhs.a / a;
+
+            return kProd;
+        }
+
+        inline ColourValue operator / (const float fScalar ) const
+        {
+            assert( fScalar != 0.0 );
+
+            ColourValue kDiv;
+
+            float fInv = 1.0f / fScalar;
+            kDiv.r = r * fInv;
+            kDiv.g = g * fInv;
+            kDiv.b = b * fInv;
+            kDiv.a = a * fInv;
+
+            return kDiv;
+        }
+
+        inline friend ColourValue operator * (const float fScalar, const ColourValue& rkVector )
+        {
+            ColourValue kProd;
+
+            kProd.r = fScalar * rkVector.r;
+            kProd.g = fScalar * rkVector.g;
+            kProd.b = fScalar * rkVector.b;
+            kProd.a = fScalar * rkVector.a;
+
+            return kProd;
+        }
+
+        // arithmetic updates
+        inline ColourValue& operator += ( const ColourValue& rkVector )
+        {
+            r += rkVector.r;
+            g += rkVector.g;
+            b += rkVector.b;
+            a += rkVector.a;
+
+            return *this;
+        }
+
+        inline ColourValue& operator -= ( const ColourValue& rkVector )
+        {
+            r -= rkVector.r;
+            g -= rkVector.g;
+            b -= rkVector.b;
+            a -= rkVector.a;
+
+            return *this;
+        }
+
+        inline ColourValue& operator *= (const float fScalar )
+        {
+            r *= fScalar;
+            g *= fScalar;
+            b *= fScalar;
+            a *= fScalar;
+            return *this;
+        }
+
+        inline ColourValue& operator /= (const float fScalar )
+        {
+            assert( fScalar != 0.0 );
+
+            float fInv = 1.0f / fScalar;
+
+            r *= fInv;
+            g *= fInv;
+            b *= fInv;
+            a *= fInv;
+
+            return *this;
+        }
+
+		/** Set a colour value from Hue, Saturation and Brightness.
+		@param hue Hue value, scaled to the [0,1] range as opposed to the 0-360
+		@param saturation Saturation level, [0,1]
+		@param brightness Brightness level, [0,1]
+		*/
+		void setHSB(float hue, float saturation, float brightness);
+
+		/** Convert the current colour to Hue, Saturation and Brightness values. 
+		@param hue Output hue value, scaled to the [0,1] range as opposed to the 0-360
+		@param saturation Output saturation level, [0,1]
+		@param brightness Output brightness level, [0,1]
+		*/
+		void getHSB(float* hue, float* saturation, float* brightness) const;
+
+
+
+		/** Function for writing to a stream.
+		*/
+		inline CM_EXPORT friend std::ostream& operator <<
+			( std::ostream& o, const ColourValue& c )
+		{
+			o << "ColourValue(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
+			return o;
+		}
+
+    };
+	/** @} */
+	/** @} */
+
+} // namespace
+
+#endif

+ 122 - 0
CamelotUtility/Include/CmDynLib.h

@@ -0,0 +1,122 @@
+/*
+-----------------------------------------------------------------------------
+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.
+-----------------------------------------------------------------------------
+*/
+#pragma once
+
+#include "CmPrerequisitesUtil.h"
+#include "CmString.h"
+
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+#    define DYNLIB_HANDLE hInstance
+#    define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
+#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
+#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
+
+struct HINSTANCE__;
+typedef struct HINSTANCE__* hInstance;
+
+#elif CM_PLATFORM == CM_PLATFORM_LINUX
+#    define DYNLIB_HANDLE void*
+#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
+#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
+#    define DYNLIB_UNLOAD( a ) dlclose( a )
+
+#elif CM_PLATFORM == CM_PLATFORM_APPLE
+#    define DYNLIB_HANDLE void*
+#    define DYNLIB_LOAD( a ) mac_loadDylib( a )
+#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
+#    define DYNLIB_UNLOAD( a ) dlclose( a )
+
+#endif
+
+namespace CamelotEngine {
+	/** \addtogroup Core
+	*  @{
+	*/
+	/** \addtogroup General
+	*  @{
+	*/
+
+    /** Resource holding data about a dynamic library.
+        @remarks
+            This class holds the data required to get symbols from
+            libraries loaded at run-time (i.e. from DLL's for so's)
+        @author
+            Adrian Cearn„u ([email protected])
+        @since
+            27 January 2002
+        @see
+            Resource
+    */
+	class CM_EXPORT DynLib
+    {
+	protected:
+		String mName;
+        /// Gets the last loading error
+        String dynlibError(void);
+    public:
+        /** Default constructor - used by DynLibManager.
+            @warning
+                Do not call directly
+        */
+        DynLib( const String& name );
+
+        /** Default destructor.
+        */
+        ~DynLib();
+
+        /** Load the library
+        */
+        void load();
+        /** Unload the library
+        */
+        void unload();
+		/// Get the name of the library
+		const String& getName(void) const { return mName; }
+
+        /**
+            Returns the address of the given symbol from the loaded library.
+            @param
+                strName The name of the symbol to search for
+            @returns
+                If the function succeeds, the returned value is a handle to
+                the symbol.
+            @par
+                If the function fails, the returned value is <b>NULL</b>.
+
+        */
+        void* getSymbol( const String& strName ) const throw();
+
+    protected:
+
+        /// Handle to the loaded library.
+        DYNLIB_HANDLE m_hInst;
+    };
+	/** @} */
+	/** @} */
+
+}

+ 0 - 38
CamelotRenderer/CmException.h → CamelotUtility/Include/CmException.h

@@ -29,46 +29,9 @@ THE SOFTWARE.
 #define __Exception_H_
 
 // Precompiler options
-#include "CmPrerequisites.h"
-#include "CmHeaderPrefix.h"
 #include "CmString.h"
 #include <exception>
 
-// Backwards compatibility with old assert mode definitions
-#if OGRE_RELEASE_ASSERT == 1
-#   define OGRE_ASSERT_MODE 1
-#endif
-
-// Check for OGRE assert mode
-
-// RELEASE_EXCEPTIONS mode
-#if OGRE_ASSERT_MODE == 1
-#   ifdef _DEBUG
-#       define OgreAssert( a, b ) assert( (a) && (b) )
-
-#   else
-#       if OGRE_COMP != CM_COMPILER_BORL
-#           define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( CamelotEngine::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
-#       else
-#           define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( CamelotEngine::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
-#       endif
-
-#   endif
-
-// EXCEPTIONS mode
-#elif OGRE_ASSERT_MODE == 2
-#   if OGRE_COMP != CM_COMPILER_BORL
-#       define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( CamelotEngine::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
-#   else
-#       define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( CamelotEngine::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
-#   endif
-
-// STANDARD mode
-#else
-#   define OgreAssert( a, b ) assert( (a) && (b) )
-
-#endif
-
 namespace CamelotEngine {
 	/** \addtogroup Core
 	*  @{
@@ -347,5 +310,4 @@ namespace CamelotEngine {
 
 } // namespace CamelotEngine
 
-#include "CmHeaderSuffix.h"
 #endif

+ 1 - 40
CamelotUtility/Include/CmPrerequisitesUtil.h

@@ -42,43 +42,4 @@ THE SOFTWARE
 // Commonly used standard headers
 #include "CmStdHeaders.h"
 
-// Standard containers, for easier access in my own namespace
-namespace CamelotEngine
-{ 
-	template <typename T, typename A = char > 
-	struct deque 
-	{ 
-		typedef typename std::deque<T> type;    
-	}; 
-
-	template <typename T, typename A = char > 
-	struct vector 
-	{ 
-		typedef typename std::vector<T> type;    
-	}; 
-
-	template <typename T, typename A = char > 
-	struct list 
-	{ 
-		typedef typename std::list<T> type;    
-	}; 
-
-	template <typename T, typename P = std::less<T>, typename A = char > 
-	struct set 
-	{ 
-		typedef typename std::set<T, P> type;    
-	}; 
-
-	template <typename K, typename V, typename P = std::less<K>, typename A = char > 
-	struct map 
-	{ 
-		typedef typename std::map<K, V, P> type; 
-	}; 
-
-	template <typename K, typename V, typename P = std::less<K>, typename A = char > 
-	struct multimap 
-	{ 
-		typedef typename std::multimap<K, V, P> type; 
-	}; 
-
-}
+#include "CmString.h"

+ 37 - 0
CamelotUtility/Include/CmStdHeaders.h

@@ -149,4 +149,41 @@ namespace CamelotEngine
 #       define HashSet ::std::hash_set
 #   endif
 #endif
+
+	// Standard containers, for easier access in my own namespace
+	template <typename T, typename A = char > 
+	struct deque 
+	{ 
+		typedef typename std::deque<T> type;    
+	}; 
+
+	template <typename T, typename A = char > 
+	struct vector 
+	{ 
+		typedef typename std::vector<T> type;    
+	}; 
+
+	template <typename T, typename A = char > 
+	struct list 
+	{ 
+		typedef typename std::list<T> type;    
+	}; 
+
+	template <typename T, typename P = std::less<T>, typename A = char > 
+	struct set 
+	{ 
+		typedef typename std::set<T, P> type;    
+	}; 
+
+	template <typename K, typename V, typename P = std::less<K>, typename A = char > 
+	struct map 
+	{ 
+		typedef typename std::map<K, V, P> type; 
+	}; 
+
+	template <typename K, typename V, typename P = std::less<K>, typename A = char > 
+	struct multimap 
+	{ 
+		typedef typename std::multimap<K, V, P> type; 
+	}; 
 }

+ 18 - 1
CamelotRenderer/CmString.h → CamelotUtility/Include/CmString.h

@@ -28,7 +28,7 @@ THE SOFTWARE.
 #ifndef _String_H__
 #define _String_H__
 
-#include "CmPrerequisites.h"
+#include "CmPrerequisitesUtil.h"
 
 // If we're using the GCC 3.1 C++ Std lib
 #if CM_COMPILER == CM_COMPILER_GNUC && CM_COMP_VER >= 310 && !defined(STLPORT)
@@ -63,6 +63,23 @@ namespace __gnu_cxx
 #endif
 
 namespace CamelotEngine {
+
+#if CM_WCHAR_T_STRINGS
+		typedef std::wstring _StringBase;
+#else
+		typedef std::string _StringBase;
+#endif
+
+#if CM_WCHAR_T_STRINGS
+		typedef std::basic_stringstream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > _StringStreamBase;
+#else
+		typedef std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> > _StringStreamBase;
+#endif
+
+		typedef _StringBase String;
+		typedef _StringStreamBase StringStream;
+		typedef StringStream stringstream;
+
 	/** \addtogroup Core
 	*  @{
 	*/

+ 2 - 2
CamelotRenderer/CmStringConverter.h → CamelotUtility/Include/CmStringConverter.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #ifndef __StringConverter_H__
 #define __StringConverter_H__
 
-#include "CmPrerequisites.h"
+#include "CmPrerequisitesUtil.h"
 #include "CmString.h"
 #include "CmColourValue.h"
 #include "CmMath.h"
@@ -91,7 +91,7 @@ namespace CamelotEngine {
         static String toString(int val, unsigned short width = 0, 
             char fill = ' ', 
             std::ios::fmtflags flags = std::ios::fmtflags(0) );
-#if CM_ARCH_TYPE == CM_ARCHITECTURE_64 || CM_PLATFORM == CM_PLATFORM_APPLE || CM_PLATFORM == OGRE_PLATFORM_IPHONE
+#if CM_ARCH_TYPE == CM_ARCHITECTURE_64 || CM_PLATFORM == CM_PLATFORM_APPLE
         /** Converts an unsigned int to a String. */
         static String toString(unsigned int val, 
             unsigned short width = 0, char fill = ' ', 

+ 406 - 0
CamelotUtility/Source/CmColourValue.cpp

@@ -0,0 +1,406 @@
+/*
+-----------------------------------------------------------------------------
+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 "CmColourValue.h"
+#include "CmMath.h"
+
+namespace CamelotEngine {
+
+    const ColourValue ColourValue::ZERO = ColourValue(0.0,0.0,0.0,0.0);
+    const ColourValue ColourValue::Black = ColourValue(0.0,0.0,0.0);
+    const ColourValue ColourValue::White = ColourValue(1.0,1.0,1.0);
+    const ColourValue ColourValue::Red = ColourValue(1.0,0.0,0.0);
+    const ColourValue ColourValue::Green = ColourValue(0.0,1.0,0.0);
+    const ColourValue ColourValue::Blue = ColourValue(0.0,0.0,1.0);
+
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    ABGR ColourValue::getAsABGR(void) const
+#else
+    RGBA ColourValue::getAsRGBA(void) const
+#endif
+    {
+        UINT8 val8;
+        UINT32 val32 = 0;
+
+        // Convert to 32bit pattern
+        // (RGBA = 8888)
+
+        // Red
+        val8 = static_cast<UINT8>(r * 255);
+        val32 = val8 << 24;
+
+        // Green
+        val8 = static_cast<UINT8>(g * 255);
+        val32 += val8 << 16;
+
+        // Blue
+        val8 = static_cast<UINT8>(b * 255);
+        val32 += val8 << 8;
+
+        // Alpha
+        val8 = static_cast<UINT8>(a * 255);
+        val32 += val8;
+
+        return val32;
+    }
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    BGRA ColourValue::getAsBGRA(void) const
+#else
+    ARGB ColourValue::getAsARGB(void) const
+#endif
+    {
+        UINT8 val8;
+        UINT32 val32 = 0;
+
+        // Convert to 32bit pattern
+        // (ARGB = 8888)
+
+        // Alpha
+        val8 = static_cast<UINT8>(a * 255);
+        val32 = val8 << 24;
+
+        // Red
+        val8 = static_cast<UINT8>(r * 255);
+        val32 += val8 << 16;
+
+        // Green
+        val8 = static_cast<UINT8>(g * 255);
+        val32 += val8 << 8;
+
+        // Blue
+        val8 = static_cast<UINT8>(b * 255);
+        val32 += val8;
+
+
+        return val32;
+    }
+	//---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+	ARGB ColourValue::getAsARGB(void) const
+#else
+	BGRA ColourValue::getAsBGRA(void) const
+#endif
+	{
+		UINT8 val8;
+		UINT32 val32 = 0;
+
+		// Convert to 32bit pattern
+		// (ARGB = 8888)
+
+		// Blue
+		val8 = static_cast<UINT8>(b * 255);
+		val32 = val8 << 24;
+
+		// Green
+		val8 = static_cast<UINT8>(g * 255);
+		val32 += val8 << 16;
+
+		// Red
+		val8 = static_cast<UINT8>(r * 255);
+		val32 += val8 << 8;
+
+		// Alpha
+		val8 = static_cast<UINT8>(a * 255);
+		val32 += val8;
+
+
+		return val32;
+	}
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    RGBA ColourValue::getAsRGBA(void) const
+#else
+    ABGR ColourValue::getAsABGR(void) const
+#endif
+    {
+        UINT8 val8;
+        UINT32 val32 = 0;
+
+        // Convert to 32bit pattern
+        // (ABRG = 8888)
+
+        // Alpha
+        val8 = static_cast<UINT8>(a * 255);
+        val32 = val8 << 24;
+
+        // Blue
+        val8 = static_cast<UINT8>(b * 255);
+        val32 += val8 << 16;
+
+        // Green
+        val8 = static_cast<UINT8>(g * 255);
+        val32 += val8 << 8;
+
+        // Red
+        val8 = static_cast<UINT8>(r * 255);
+        val32 += val8;
+
+
+        return val32;
+    }
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    void ColourValue::setAsABGR(const ABGR val)
+#else
+    void ColourValue::setAsRGBA(const RGBA val)
+#endif
+    {
+        UINT32 val32 = val;
+
+        // Convert from 32bit pattern
+        // (RGBA = 8888)
+
+        // Red
+        r = ((val32 >> 24) & 0xFF) / 255.0f;
+
+        // Green
+        g = ((val32 >> 16) & 0xFF) / 255.0f;
+
+        // Blue
+        b = ((val32 >> 8) & 0xFF) / 255.0f;
+
+        // Alpha
+        a = (val32 & 0xFF) / 255.0f;
+    }
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    void ColourValue::setAsBGRA(const BGRA val)
+#else
+    void ColourValue::setAsARGB(const ARGB val)
+#endif
+    {
+        UINT32 val32 = val;
+
+        // Convert from 32bit pattern
+        // (ARGB = 8888)
+
+        // Alpha
+        a = ((val32 >> 24) & 0xFF) / 255.0f;
+
+        // Red
+        r = ((val32 >> 16) & 0xFF) / 255.0f;
+
+        // Green
+        g = ((val32 >> 8) & 0xFF) / 255.0f;
+
+        // Blue
+        b = (val32 & 0xFF) / 255.0f;
+    }
+	//---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+	void ColourValue::setAsARGB(const ARGB val)
+#else
+	void ColourValue::setAsBGRA(const BGRA val)
+#endif
+	{
+		UINT32 val32 = val;
+
+		// Convert from 32bit pattern
+		// (ARGB = 8888)
+
+		// Blue
+		b = ((val32 >> 24) & 0xFF) / 255.0f;
+
+		// Green
+		g = ((val32 >> 16) & 0xFF) / 255.0f;
+
+		// Red
+		r = ((val32 >> 8) & 0xFF) / 255.0f;
+
+		// Alpha
+		a = (val32 & 0xFF) / 255.0f;
+	}
+    //---------------------------------------------------------------------
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    void ColourValue::setAsRGBA(const RGBA val)
+#else
+    void ColourValue::setAsABGR(const ABGR val)
+#endif
+    {
+        UINT32 val32 = val;
+
+        // Convert from 32bit pattern
+        // (ABGR = 8888)
+
+        // Alpha
+        a = ((val32 >> 24) & 0xFF) / 255.0f;
+
+        // Blue
+        b = ((val32 >> 16) & 0xFF) / 255.0f;
+
+        // Green
+        g = ((val32 >> 8) & 0xFF) / 255.0f;
+
+        // Red
+        r = (val32 & 0xFF) / 255.0f;
+    }
+    //---------------------------------------------------------------------
+    bool ColourValue::operator==(const ColourValue& rhs) const
+    {
+        return (r == rhs.r &&
+            g == rhs.g &&
+            b == rhs.b &&
+            a == rhs.a);
+    }
+    //---------------------------------------------------------------------
+    bool ColourValue::operator!=(const ColourValue& rhs) const
+    {
+        return !(*this == rhs);
+    }
+	//---------------------------------------------------------------------
+	void ColourValue::setHSB(float hue, float saturation, float brightness)
+	{
+		// wrap hue
+		if (hue > 1.0f)
+		{
+			hue -= (int)hue;
+		}
+		else if (hue < 0.0f)
+		{
+			hue += (int)hue + 1;
+		}
+		// clamp saturation / brightness
+		saturation = std::min(saturation, (float)1.0);
+		saturation = std::max(saturation, (float)0.0);
+		brightness = std::min(brightness, (float)1.0);
+		brightness = std::max(brightness, (float)0.0);
+
+		if (brightness == 0.0f)
+		{   
+			// early exit, this has to be black
+			r = g = b = 0.0f;
+			return;
+		}
+
+		if (saturation == 0.0f)
+		{   
+			// early exit, this has to be grey
+
+			r = g = b = brightness;
+			return;
+		}
+
+
+		float hueDomain  = hue * 6.0f;
+		if (hueDomain >= 6.0f)
+		{
+			// wrap around, and allow mathematical errors
+			hueDomain = 0.0f;
+		}
+		unsigned short domain = (unsigned short)hueDomain;
+		float f1 = brightness * (1 - saturation);
+		float f2 = brightness * (1 - saturation * (hueDomain - domain));
+		float f3 = brightness * (1 - saturation * (1 - (hueDomain - domain)));
+
+		switch (domain)
+		{
+		case 0:
+			// red domain; green ascends
+			r = brightness;
+			g = f3;
+			b = f1;
+			break;
+		case 1:
+			// yellow domain; red descends
+			r = f2;
+			g = brightness;
+			b = f1;
+			break;
+		case 2:
+			// green domain; blue ascends
+			r = f1;
+			g = brightness;
+			b = f3;
+			break;
+		case 3:
+			// cyan domain; green descends
+			r = f1;
+			g = f2;
+			b = brightness;
+			break;
+		case 4:
+			// blue domain; red ascends
+			r = f3;
+			g = f1;
+			b = brightness;
+			break;
+		case 5:
+			// magenta domain; blue descends
+			r = brightness;
+			g = f1;
+			b = f2;
+			break;
+		}
+
+
+	}
+	//---------------------------------------------------------------------
+	void ColourValue::getHSB(float* hue, float* saturation, float* brightness) const
+	{
+
+		float vMin = std::min(r, std::min(g, b));
+		float vMax = std::max(r, std::max(g, b));
+		float delta = vMax - vMin;
+
+		*brightness = vMax;
+
+		if (Math::RealEqual(delta, 0.0f, 1e-6f))
+		{
+			// grey
+			*hue = 0;
+			*saturation = 0;
+		}
+		else                                    
+		{
+			// a colour
+			*saturation = delta / vMax;
+
+			float deltaR = (((vMax - r) / 6.0f) + (delta / 2.0f)) / delta;
+			float deltaG = (((vMax - g) / 6.0f) + (delta / 2.0f)) / delta;
+			float deltaB = (((vMax - b) / 6.0f) + (delta / 2.0f)) / delta;
+
+			if (Math::RealEqual(r, vMax))
+				*hue = deltaB - deltaG;
+			else if (Math::RealEqual(g, vMax))
+				*hue = 0.3333333f + deltaR - deltaB;
+			else if (Math::RealEqual(b, vMax)) 
+				*hue = 0.6666667f + deltaG - deltaR;
+
+			if (*hue < 0.0f) 
+				*hue += 1.0f;
+			if (*hue > 1.0f)
+				*hue -= 1.0f;
+		}
+
+		
+	}
+
+}
+

+ 134 - 0
CamelotUtility/Source/CmDynLib.cpp

@@ -0,0 +1,134 @@
+/*
+-----------------------------------------------------------------------------
+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 "CmDynLib.h"
+
+#include "CmException.h"
+
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+#  define WIN32_LEAN_AND_MEAN
+#  if !defined(NOMINMAX) && defined(_MSC_VER)
+#	define NOMINMAX // required to stop windows.h messing up std::min
+#  endif
+#  include <windows.h>
+#endif
+
+#if CM_PLATFORM == CM_PLATFORM_APPLE || CM_PLATFORM == CM_PLATFORM_IPHONE
+#   include "macUtils.h"
+#   include <dlfcn.h>
+#endif
+
+
+namespace CamelotEngine {
+
+    //-----------------------------------------------------------------------
+    DynLib::DynLib( const String& name )
+    {
+        mName = name;
+        m_hInst = NULL;
+    }
+
+    //-----------------------------------------------------------------------
+    DynLib::~DynLib()
+    {
+    }
+
+    //-----------------------------------------------------------------------
+    void DynLib::load()
+    {
+		String name = mName;
+#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
+        // dlopen() does not add .so to the filename, like windows does for .dll
+        if (name.substr(name.length() - 3, 3) != ".so")
+           name += ".so";
+#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+        // dlopen() does not add .dylib to the filename, like windows does for .dll
+        if (name.substr(name.length() - 6, 6) != ".dylib")
+			name += ".dylib";
+#elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+		// Although LoadLibraryEx will add .dll itself when you only specify the library name,
+		// if you include a relative path then it does not. So, add it to be sure.
+		if (name.substr(name.length() - 4, 4) != ".dll")
+			name += ".dll";
+#endif
+        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
+
+        if( !m_hInst )
+            OGRE_EXCEPT(
+                Exception::ERR_INTERNAL_ERROR, 
+                "Could not load dynamic library " + mName + 
+                ".  System Error: " + dynlibError(),
+                "DynLib::load" );
+    }
+
+    //-----------------------------------------------------------------------
+    void DynLib::unload()
+    {
+        if( DYNLIB_UNLOAD( m_hInst ) )
+		{
+            OGRE_EXCEPT(
+                Exception::ERR_INTERNAL_ERROR, 
+                "Could not unload dynamic library " + mName +
+                ".  System Error: " + dynlibError(),
+                "DynLib::unload");
+		}
+
+    }
+
+    //-----------------------------------------------------------------------
+    void* DynLib::getSymbol( const String& strName ) const throw()
+    {
+        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
+    }
+    //-----------------------------------------------------------------------
+    String DynLib::dynlibError( void ) 
+    {
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+        LPVOID lpMsgBuf; 
+        FormatMessage( 
+            FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+            FORMAT_MESSAGE_FROM_SYSTEM | 
+            FORMAT_MESSAGE_IGNORE_INSERTS, 
+            NULL, 
+            GetLastError(), 
+            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
+            (LPTSTR) &lpMsgBuf, 
+            0, 
+            NULL 
+            ); 
+        String ret = (char*)lpMsgBuf;
+        // Free the buffer.
+        LocalFree( lpMsgBuf );
+        return ret;
+#elif CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
+        return String(dlerror());
+#else
+        return String("");
+#endif
+    }
+
+}

+ 0 - 0
CamelotRenderer/CmException.cpp → CamelotUtility/Source/CmException.cpp


+ 0 - 0
CamelotRenderer/CmString.cpp → CamelotUtility/Source/CmString.cpp


+ 0 - 0
CamelotRenderer/CmStringConverter.cpp → CamelotUtility/Source/CmStringConverter.cpp