Quellcode durchsuchen

Added DX9 and OpenGL video mode infos

Marko Pintera vor 11 Jahren
Ursprung
Commit
2c483382f8
32 geänderte Dateien mit 468 neuen und 637 gelöschten Zeilen
  1. 45 12
      CamelotCore/Include/CmFont.h
  2. 1 0
      CamelotCore/Include/CmTextureManager.h
  3. 1 1
      CamelotCore/Source/CmGameObjectHandle.cpp
  4. 7 6
      CamelotD3D11RenderSystem/Include/CmD3D11Driver.h
  5. 5 3
      CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp
  6. 14 3
      CamelotD3D11RenderSystem/Source/CmD3D11VideoModeInfo.cpp
  7. 2 4
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj
  8. 6 12
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters
  9. 10 20
      CamelotD3D9Renderer/Include/CmD3D9Driver.h
  10. 11 38
      CamelotD3D9Renderer/Include/CmD3D9DriverList.h
  11. 3 35
      CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h
  12. 0 27
      CamelotD3D9Renderer/Include/CmD3D9RenderWindow.h
  13. 0 63
      CamelotD3D9Renderer/Include/CmD3D9VideoMode.h
  14. 45 0
      CamelotD3D9Renderer/Include/CmD3D9VideoModeInfo.h
  15. 0 55
      CamelotD3D9Renderer/Include/CmD3D9VideoModeList.h
  16. 15 36
      CamelotD3D9Renderer/Source/CmD3D9Driver.cpp
  17. 20 53
      CamelotD3D9Renderer/Source/CmD3D9DriverList.cpp
  18. 3 3
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  19. 0 27
      CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp
  20. 0 55
      CamelotD3D9Renderer/Source/CmD3D9VideoMode.cpp
  21. 94 0
      CamelotD3D9Renderer/Source/CmD3D9VideoModeInfo.cpp
  22. 0 146
      CamelotD3D9Renderer/Source/CmD3D9VideoModeList.cpp
  23. 2 0
      CamelotGLRenderer/CamelotGLRenderer.vcxproj
  24. 6 0
      CamelotGLRenderer/CamelotGLRenderer.vcxproj.filters
  25. 5 0
      CamelotGLRenderer/Include/CmGLSupport.h
  26. 6 0
      CamelotGLRenderer/Include/CmWin32GLSupport.h
  27. 46 0
      CamelotGLRenderer/Include/CmWin32VideoModeInfo.h
  28. 2 0
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  29. 6 0
      CamelotGLRenderer/Source/CmWin32GLSupport.cpp
  30. 102 0
      CamelotGLRenderer/Source/CmWin32VideoModeInfo.cpp
  31. 7 38
      CamelotGLRenderer/Source/win32/CmGLUtil.h
  32. 4 0
      Polish.txt

+ 45 - 12
CamelotCore/Include/CmFont.h

@@ -6,14 +6,22 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains data about font characters of a specific size. Contains
+	 *			textures in which the characters are located and information
+	 *			about each individual character.
+	 */
 	struct CM_EXPORT FontData : public IReflectable
 	{
-		UINT32 size;
-		FONT_DESC fontDesc;
-		Vector<HTexture> texturePages;
-
+		/**
+		 * @brief	Returns a character description for the character with the specified ID.
+		 */
 		const CHAR_DESC& getCharDesc(UINT32 charId) const;
 
+		UINT32 size; /**< Font size for which the data is contained. */
+		FONT_DESC fontDesc; /**< Font description containing per-character and general font data. */
+		Vector<HTexture> texturePages; /**< Textures in which the characters are stored. */
+
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/************************************************************************/
@@ -28,16 +36,49 @@ namespace BansheeEngine
 	// but if you use a bitmap texture to initialize the font manually, then you will potentially have duplicate textures.
 	// Also, changing the source texture will not automatically update the font because there is no direct link between them.
 	// -- This is probably not a large problem, but it is something to keep an eye out.
+
+	/**
+	 * @brief	Font resource containing data about textual characters
+	 *			and how to render text.
+	 */
 	class CM_EXPORT Font : public Resource
 	{
 	public:
 		virtual ~Font();
 
+		/**
+		 * @brief	Initializes the font with specified per-size font data.
+		 *
+		 * @note	Internal method. Factory methods will call this automatically for you.
+		 */
 		void initialize(const Vector<FontData>& fontData);
 
+		/**
+		 * @brief	Returns font data for a specific size if it exists, null otherwise.
+		 */
 		const FontData* getFontDataForSize(UINT32 size) const;
+
+		/**
+		 * @brief	Attempts to find nearest available size next to the provided size.
+		 */
 		INT32 getClosestAvailableSize(UINT32 size) const;
 
+		/************************************************************************/
+		/* 								STATICS		                     		*/
+		/************************************************************************/
+
+		/**
+		 * @brief	Creates a new font from the provided per-size font data.
+		 */
+		static HFont create(const Vector<FontData>& fontInitData);
+
+		/**
+		 * @brief	Creates a new font pointer.
+		 *
+		 * @note	Internal method.
+		 */
+		static FontPtr _createPtr(const Vector<FontData>& fontInitData);
+
 	protected:
 		friend class FontManager;
 
@@ -53,13 +94,5 @@ namespace BansheeEngine
 		friend class FontRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		virtual RTTITypeBase* getRTTI() const;
-
-		/************************************************************************/
-		/* 								STATICS		                     		*/
-		/************************************************************************/
-		
-	public:
-		static HFont create(const Vector<FontData>& fontInitData);
-		static FontPtr _createPtr(const Vector<FontData>& fontInitData);
 	};
 }

+ 1 - 0
CamelotCore/Include/CmTextureManager.h

@@ -3,6 +3,7 @@
 #include "CmPrerequisites.h"
 
 #include "CmTexture.h"
+#include "CmMultiRenderTexture.h"
 #include "CmModule.h"
 
 namespace BansheeEngine 

+ 1 - 1
CamelotCore/Source/CmGameObjectHandle.cpp

@@ -25,7 +25,7 @@ namespace BansheeEngine
 		mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>(nullptr);
 	}
 
-	void GameObjectHandleBase::resolve(const GameObjectHandleBase& object) 
+	void GameObjectHandleBase::_resolve(const GameObjectHandleBase& object) 
 	{ 
 		mData->mPtr = object.mData->mPtr;
 		mData->mInstanceId = object.mData->mInstanceId;

+ 7 - 6
CamelotD3D11RenderSystem/Include/CmD3D11Driver.h

@@ -24,12 +24,13 @@ namespace BansheeEngine
 		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
 
 	private:
-		UINT32					mAdapterNumber;
-		UINT32					mNumOutputs;
-		DXGI_ADAPTER_DESC		mAdapterIdentifier;
-		IDXGIAdapter*			mDXGIAdapter;
-		VideoModeInfoPtr		mVideoModeInfo;
-
 		void init();
+
+	private:
+		UINT32 mAdapterNumber;
+		UINT32 mNumOutputs;
+		DXGI_ADAPTER_DESC mAdapterIdentifier;
+		IDXGIAdapter* mDXGIAdapter;
+		VideoModeInfoPtr mVideoModeInfo;
 	};
 }

+ 5 - 3
CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp

@@ -1,9 +1,10 @@
 #include "CmD3D11Driver.h"
+#include "CmD3D11VideoModeInfo.h"
 #include "CmException.h"
 
 namespace BansheeEngine
 {
-	D3D11Driver::D3D11Driver( const D3D11Driver &ob ) 
+	D3D11Driver::D3D11Driver(const D3D11Driver &ob) 
 	{
 		mAdapterNumber = ob.mAdapterNumber;
 		mAdapterIdentifier = ob.mAdapterIdentifier;
@@ -15,7 +16,7 @@ namespace BansheeEngine
 		init();
 	}
 
-	D3D11Driver::D3D11Driver(unsigned int adapterNumber, IDXGIAdapter* pDXGIAdapter)
+	D3D11Driver::D3D11Driver(UINT32 adapterNumber, IDXGIAdapter* pDXGIAdapter)
 	{
 		mAdapterNumber = adapterNumber;
 		mDXGIAdapter = pDXGIAdapter;
@@ -23,7 +24,6 @@ namespace BansheeEngine
 		if(mDXGIAdapter)
 			mDXGIAdapter->AddRef();
 
-		// get the description of the adapter
 		pDXGIAdapter->GetDesc(&mAdapterIdentifier);
 
 		init();
@@ -47,6 +47,8 @@ namespace BansheeEngine
 		}
 
 		mNumOutputs = outputIdx;
+
+		mVideoModeInfo = cm_shared_ptr<D3D11VideoModeInfo>(mDXGIAdapter);
 	}
 
 	D3D11Driver& D3D11Driver::operator=(const D3D11Driver& ob)

+ 14 - 3
CamelotD3D11RenderSystem/Source/CmD3D11VideoModeInfo.cpp

@@ -55,8 +55,8 @@ namespace BansheeEngine
 					bool foundRefreshRate = false;
 					for (auto refreshRate : d3d11videoMode->mD3D11RefreshRates)
 					{
-						if (refreshRate.numerator != displayMode.RefreshRate.Numerator ||
-							refreshRate.denominator != displayMode.RefreshRate.Denominator)
+						if (refreshRate.numerator == displayMode.RefreshRate.Numerator &&
+							refreshRate.denominator == displayMode.RefreshRate.Denominator)
 						{
 							foundRefreshRate = true;
 							break;
@@ -121,7 +121,18 @@ namespace BansheeEngine
 
 		output->FindClosestMatchingMode(&currentMode, &nearestMode, nullptr);
 
-		mDesktopVideoMode = cm_new<D3D11VideoMode>(nearestMode.Width, nearestMode.Height, this, nearestMode);
+		D3D11VideoMode* desktopVideoMode = cm_new<D3D11VideoMode>(nearestMode.Width, nearestMode.Height, this, nearestMode);;
+		
+		{
+			D3D11VideoMode::RefreshRate refreshRate;
+			refreshRate.numerator = nearestMode.RefreshRate.Numerator;
+			refreshRate.denominator = nearestMode.RefreshRate.Denominator;
+
+			desktopVideoMode->mD3D11RefreshRates.push_back(refreshRate);
+			desktopVideoMode->mRefreshRates.push_back(refreshRate.numerator / (float)refreshRate.denominator);
+		}
+
+		mDesktopVideoMode = desktopVideoMode;
 	}
 
 	D3D11VideoOutputInfo::~D3D11VideoOutputInfo()

+ 2 - 4
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj

@@ -263,8 +263,7 @@
     <ClInclude Include="Include\CmD3D9Texture.h" />
     <ClInclude Include="Include\CmD3D9TextureManager.h" />
     <ClInclude Include="Include\CmD3D9VertexDeclaration.h" />
-    <ClInclude Include="Include\CmD3D9VideoMode.h" />
-    <ClInclude Include="Include\CmD3D9VideoModeList.h" />
+    <ClInclude Include="Include\CmD3D9VideoModeInfo.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="CmD3D9Plugin.cpp" />
@@ -295,8 +294,7 @@
     <ClCompile Include="Source\CmD3D9Texture.cpp" />
     <ClCompile Include="Source\CmD3D9TextureManager.cpp" />
     <ClCompile Include="Source\CmD3D9VertexDeclaration.cpp" />
-    <ClCompile Include="Source\CmD3D9VideoMode.cpp" />
-    <ClCompile Include="Source\CmD3D9VideoModeList.cpp" />
+    <ClCompile Include="Source\CmD3D9VideoModeInfo.cpp" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 6 - 12
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters

@@ -69,12 +69,6 @@
     <ClInclude Include="Include\CmD3D9VertexDeclaration.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D9VideoMode.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmD3D9VideoModeList.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D9RenderWindowManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -114,6 +108,9 @@
     <ClInclude Include="Include\CmD3D9GpuProgramRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmD3D9VideoModeInfo.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D9Device.cpp">
@@ -164,12 +161,6 @@
     <ClCompile Include="Source\CmD3D9VertexDeclaration.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D9VideoMode.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmD3D9VideoModeList.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="CmD3D9Plugin.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -206,5 +197,8 @@
     <ClCompile Include="Source\CmD3D9TimerQuery.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmD3D9VideoModeInfo.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 10 - 20
CamelotD3D9Renderer/Include/CmD3D9Driver.h

@@ -10,32 +10,22 @@ namespace BansheeEngine
 
 	class CM_D3D9_EXPORT D3D9Driver
 	{
-	
 	public:
-		// Constructors
-		D3D9Driver();						// Default
-		D3D9Driver( const D3D9Driver &ob );	// Copy
-		D3D9Driver( unsigned int adapterNumber, 
-			const D3DCAPS9& deviceCaps,
-			const D3DADAPTER_IDENTIFIER9& adapterIdentifer, 
-			const D3DDISPLAYMODE& desktopDisplayMode);
+		D3D9Driver();
+		D3D9Driver(const D3D9Driver &ob);
+		D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps, const D3DADAPTER_IDENTIFIER9& adapterIdentifer);
 		~D3D9Driver();
 
+		const D3DCAPS9&	getD3D9DeviceCaps() const { return mD3D9DeviceCaps; }
+		String getDriverName() const;
+		String getDriverDescription() const;
 				
-		const D3DCAPS9&		getD3D9DeviceCaps	() const { return mD3D9DeviceCaps; }
-		String				DriverName			() const;
-		String				DriverDescription	() const;
-				
-		unsigned int					getAdapterNumber	() const { return mAdapterNumber; }
-		const D3DADAPTER_IDENTIFIER9&	getAdapterIdentifier() const { return mAdapterIdentifier; }
-		const D3DDISPLAYMODE&			getDesktopMode		() const { return mDesktopDisplayMode; }
-		D3D9VideoModeList*				getVideoModeList	();
-			
+		UINT32 getAdapterNumber() const { return mAdapterNumber; }
+		const D3DADAPTER_IDENTIFIER9& getAdapterIdentifier() const { return mAdapterIdentifier; }
+
 	private:				
-		unsigned int mAdapterNumber;
+		UINT32 mAdapterNumber;
 		D3DCAPS9 mD3D9DeviceCaps;		
 		D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
-		D3DDISPLAYMODE mDesktopDisplayMode;
-		D3D9VideoModeList* mpVideoModeList;	
 	};
 }

+ 11 - 38
CamelotD3D9Renderer/Include/CmD3D9DriverList.h

@@ -1,32 +1,4 @@
-/*
------------------------------------------------------------------------------
-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 __D3D9DRIVERLIST_H__
-#define __D3D9DRIVERLIST_H__
+#pragma once
 
 #include "CmD3D9Prerequisites.h"
 #include "CmD3D9Driver.h"
@@ -35,18 +7,19 @@ namespace BansheeEngine
 {
 	class CM_D3D9_EXPORT D3D9DriverList
 	{
-	private:
-		Vector<D3D9Driver> mDriverList;
-		
 	public:
 		D3D9DriverList();
 		~D3D9DriverList();
 
-		BOOL enumerate();
-		size_t count() const;
-		D3D9Driver* item( size_t index );
+		UINT32 count() const;
+
+		D3D9Driver* item(UINT32 index);
+		D3D9Driver* item(const String &name);
+
+		VideoModeInfoPtr getVideoModeInfo() const { return mVideoModeInfo; }
 
-		D3D9Driver* item( const String &name );
+	private:
+		Vector<D3D9Driver> mDriverList;
+		VideoModeInfoPtr mVideoModeInfo;
 	};
-}
-#endif
+}

+ 3 - 35
CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h

@@ -1,32 +1,4 @@
-/*
------------------------------------------------------------------------------
-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 __D3D9PREREQUISITES_H__
-#define __D3D9PREREQUISITES_H__
+#pragma once
 
 #include "CmPrerequisites.h"
 
@@ -34,7 +6,6 @@ THE SOFTWARE.
 #define D3D9_DEVICE_ACCESS_UNLOCK
 #define D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-// Define versions for if DirectX is in use (Win32 only)
 #define DIRECT3D_VERSION 0x0900
 
 // some D3D commonly used macros
@@ -87,9 +58,7 @@ namespace BansheeEngine
 		TID_D3D9_GpuFragmentProgram = 10002
 	};
 
-    //-------------------------------------------
-	// Windows setttings
-	//-------------------------------------------
+
 #if (CM_PLATFORM == CM_PLATFORM_WIN32) && !defined(CM_STATIC_LIB)
 #	ifdef CM_RSD3D9_EXPORTS
 #		define CM_D3D9_EXPORT __declspec(dllexport)
@@ -102,6 +71,5 @@ namespace BansheeEngine
 #	endif
 #else
 #	define CM_D3D9_EXPORT
-#endif	// CM_PLATFORM_WIN32
-}
 #endif
+}

+ 0 - 27
CamelotD3D9Renderer/Include/CmD3D9RenderWindow.h

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-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 "CmD3D9Prerequisites.h"

+ 0 - 63
CamelotD3D9Renderer/Include/CmD3D9VideoMode.h

@@ -1,63 +0,0 @@
-/*
------------------------------------------------------------------------------
-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 __D3D9VIDEOMODE_H__
-#define __D3D9VIDEOMODE_H__
-
-#include "CmD3D9Prerequisites.h"
-#include "CmString.h"
-
-namespace BansheeEngine 
-{
-	static unsigned int modeCount = 0;
-
-	class CM_D3D9_EXPORT D3D9VideoMode
-	{
-	private:
-		D3DDISPLAYMODE mDisplayMode;
-		unsigned int modeNumber;
-
-	public:
-		D3D9VideoMode() { modeNumber = ++modeCount; ZeroMemory( &mDisplayMode, sizeof(D3DDISPLAYMODE) ); }
-		D3D9VideoMode( const D3D9VideoMode &ob ) { modeNumber = ++modeCount; mDisplayMode = ob.mDisplayMode; }
-		D3D9VideoMode( D3DDISPLAYMODE d3ddm ) { modeNumber = ++modeCount; mDisplayMode = d3ddm; }
-		~D3D9VideoMode()
-		{
-			modeCount--;
-		}
-
-		unsigned int getWidth() const { return mDisplayMode.Width; }
-		unsigned int getHeight() const { return mDisplayMode.Height; }
-		D3DFORMAT getFormat() const { return mDisplayMode.Format; }
-		unsigned int getRefreshRate() const { return mDisplayMode.RefreshRate; }
-		unsigned int getColourDepth() const;
-		D3DDISPLAYMODE getDisplayMode() const { return mDisplayMode; }
-		void increaseRefreshRate(unsigned int rr) { mDisplayMode.RefreshRate = rr; } 
-		String getDescription() const;
-	};
-}
-#endif

+ 45 - 0
CamelotD3D9Renderer/Include/CmD3D9VideoModeInfo.h

@@ -0,0 +1,45 @@
+#pragma once
+
+#include "CmD3D9Prerequisites.h"
+#include "CmVideoModeInfo.h"
+
+namespace BansheeEngine
+{
+	/**
+	* @copydoc	VideoMode
+	*/
+	class CM_D3D9_EXPORT D3D9VideoMode : public VideoMode
+	{
+	public:
+		D3D9VideoMode(UINT32 width, UINT32 height, VideoOutputInfo* outputInfo);
+
+	private:
+		friend class D3D9VideoOutputInfo;
+	};
+
+	/**
+	* @copydoc	VideoOutputInfo
+	*/
+	class CM_D3D9_EXPORT D3D9VideoOutputInfo : public VideoOutputInfo
+	{
+	public:
+		D3D9VideoOutputInfo(IDirect3D9* d3d9device, UINT32 adapterIdx);
+
+		/**
+		 * @brief	Gets a Win32 handle to the monitor referenced by this object.
+		 */
+		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
+
+	private:
+		HMONITOR mMonitorHandle;
+	};
+
+	/**
+	* @copydoc	VideoModeInfo
+	*/
+	class CM_D3D9_EXPORT D3D9VideoModeInfo : public VideoModeInfo
+	{
+	public:
+		D3D9VideoModeInfo(IDirect3D9* d3d9device);
+	};
+}

+ 0 - 55
CamelotD3D9Renderer/Include/CmD3D9VideoModeList.h

@@ -1,55 +0,0 @@
-/*
------------------------------------------------------------------------------
-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 __D3D9VIDEOMODELIST_H__
-#define __D3D9VIDEOMODELIST_H__
-
-#include "CmD3D9Prerequisites.h"
-#include "CmD3D9Driver.h"
-#include "CmD3D9VideoMode.h"
-
-namespace BansheeEngine 
-{
-	class CM_D3D9_EXPORT D3D9VideoModeList
-	{
-	private:
-		D3D9Driver* mpDriver;
-		Vector<D3D9VideoMode> mModeList;
-
-	public:
-		D3D9VideoModeList( D3D9Driver* pDriver );
-		~D3D9VideoModeList();
-
-		BOOL enumerate();
-
-		D3D9VideoMode* item( size_t index );
-		size_t count();
-
-		D3D9VideoMode* item( const String &name );
-	};
-}
-#endif

+ 15 - 36
CamelotD3D9Renderer/Source/CmD3D9Driver.cpp

@@ -1,65 +1,44 @@
 #include "CmD3D9Driver.h"
-#include "CmD3D9VideoModeList.h"
-#include "CmD3D9VideoMode.h"
 
 namespace BansheeEngine
 {   
 	D3D9Driver::D3D9Driver()
 	{						
-		mAdapterNumber	= 0;
+		mAdapterNumber = 0;
 		ZeroMemory(&mD3D9DeviceCaps, sizeof(mD3D9DeviceCaps));
-		ZeroMemory(&mAdapterIdentifier, sizeof(mAdapterIdentifier));
-		ZeroMemory(&mDesktopDisplayMode, sizeof(mDesktopDisplayMode));		
-		mpVideoModeList = NULL;				
+		ZeroMemory(&mAdapterIdentifier, sizeof(mAdapterIdentifier));			
 	}
 
-	D3D9Driver::D3D9Driver( const D3D9Driver &ob )
+	D3D9Driver::D3D9Driver(const D3D9Driver &ob)
 	{			
-		mAdapterNumber		= ob.mAdapterNumber;
-		mD3D9DeviceCaps		= ob.mD3D9DeviceCaps;
-		mAdapterIdentifier	= ob.mAdapterIdentifier;
-		mDesktopDisplayMode = ob.mDesktopDisplayMode;
-		mpVideoModeList		= NULL;				
+		mAdapterNumber = ob.mAdapterNumber;
+		mD3D9DeviceCaps	= ob.mD3D9DeviceCaps;
+		mAdapterIdentifier = ob.mAdapterIdentifier;		
 	}
 
-	D3D9Driver::D3D9Driver( unsigned int adapterNumber,
-		const D3DCAPS9& deviceCaps,
-		const D3DADAPTER_IDENTIFIER9& adapterIdentifier, 
-		const D3DDISPLAYMODE& desktopDisplayMode )
+	D3D9Driver::D3D9Driver(UINT32 adapterNumber, const D3DCAPS9& deviceCaps,
+		const D3DADAPTER_IDENTIFIER9& adapterIdentifier)
 	{				
-		mAdapterNumber		= adapterNumber;
-		mD3D9DeviceCaps		= deviceCaps;
-		mAdapterIdentifier	= adapterIdentifier;
-		mDesktopDisplayMode = desktopDisplayMode;
-		mpVideoModeList		= NULL;			
+		mAdapterNumber = adapterNumber;
+		mD3D9DeviceCaps	= deviceCaps;
+		mAdapterIdentifier = adapterIdentifier;		
 	}
 
 	D3D9Driver::~D3D9Driver()
-	{
-		if(mpVideoModeList != nullptr)
-			cm_delete(mpVideoModeList);
-	}
+	{ }
 
-	String D3D9Driver::DriverName() const
+	String D3D9Driver::getDriverName() const
 	{
 		return String(mAdapterIdentifier.Driver);
 	}
 
-	String D3D9Driver::DriverDescription() const
+	String D3D9Driver::getDriverDescription() const
 	{       
 		StringStream str;
 		str << "Monitor-" << (mAdapterNumber+1) << "-" << mAdapterIdentifier.Description;
 		String driverDescription(str.str());
 		StringUtil::trim(driverDescription);
 
-        return  driverDescription;
+        return driverDescription;
 	}
-
-	D3D9VideoModeList* D3D9Driver::getVideoModeList()
-	{
-		if( !mpVideoModeList )
-			mpVideoModeList = cm_new<D3D9VideoModeList>(this);
-
-		return mpVideoModeList;
-	}	
 }

+ 20 - 53
CamelotD3D9Renderer/Source/CmD3D9DriverList.cpp

@@ -1,88 +1,55 @@
-/*
------------------------------------------------------------------------------
-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 "CmD3D9DriverList.h"
+#include "CmD3D9VideoModeInfo.h"
 #include "CmException.h"
 #include "CmD3D9RenderSystem.h"
 
 namespace BansheeEngine 
 {
 	D3D9DriverList::D3D9DriverList()
-	{
-		enumerate();
-	}
-
-	D3D9DriverList::~D3D9DriverList(void)
-	{
-		mDriverList.clear();
-	}
-
-	BOOL D3D9DriverList::enumerate()
 	{
 		IDirect3D9* lpD3D9 = D3D9RenderSystem::getDirect3D9();
 
-		for( UINT iAdapter=0; iAdapter < lpD3D9->GetAdapterCount(); ++iAdapter )
+		for (UINT32 i = 0; i < lpD3D9->GetAdapterCount(); i++)
 		{
 			D3DADAPTER_IDENTIFIER9 adapterIdentifier;
-			D3DDISPLAYMODE d3ddm;
 			D3DCAPS9 d3dcaps9;
-			
-			lpD3D9->GetAdapterIdentifier( iAdapter, 0, &adapterIdentifier );
-			lpD3D9->GetAdapterDisplayMode( iAdapter, &d3ddm );
-			lpD3D9->GetDeviceCaps( iAdapter, D3DDEVTYPE_HAL, &d3dcaps9 );
 
-			mDriverList.push_back( D3D9Driver( iAdapter, d3dcaps9, adapterIdentifier, d3ddm ) );
+			lpD3D9->GetAdapterIdentifier(i, 0, &adapterIdentifier);
+			lpD3D9->GetDeviceCaps(i, D3DDEVTYPE_HAL, &d3dcaps9);
+
+			mDriverList.push_back(D3D9Driver(i, d3dcaps9, adapterIdentifier));
 		}
 
-		return TRUE;
+		mVideoModeInfo = cm_shared_ptr<D3D9VideoModeInfo>(lpD3D9);
+	}
+
+	D3D9DriverList::~D3D9DriverList()
+	{
+		mDriverList.clear();
 	}
 
-	size_t D3D9DriverList::count() const 
+	UINT32 D3D9DriverList::count() const
 	{
-		return mDriverList.size();
+		return (UINT32)mDriverList.size();
 	}
 
-	D3D9Driver* D3D9DriverList::item( size_t index )
+	D3D9Driver* D3D9DriverList::item(UINT32 index)
 	{
-		return &mDriverList.at( index );
+		return &mDriverList.at(index);
 	}
 
-	D3D9Driver* D3D9DriverList::item( const String &name )
+	D3D9Driver* D3D9DriverList::item(const String &name)
 	{
 		Vector<D3D9Driver>::iterator it = mDriverList.begin();
 		if (it == mDriverList.end())
-			return NULL;
+			return nullptr;
 
 		for (;it != mDriverList.end(); ++it)
 		{
-			if (it->DriverDescription() == name)
+			if (it->getDriverDescription() == name)
 				return &(*it);
 		}
 
-		return NULL;
+		return nullptr;
 	}
 }

+ 3 - 3
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -2,8 +2,6 @@
 #include "CmD3D9Prerequisites.h"
 #include "CmD3D9DriverList.h"
 #include "CmD3D9Driver.h"
-#include "CmD3D9VideoModeList.h"
-#include "CmD3D9VideoMode.h"
 #include "CmD3D9RenderWindow.h"
 #include "CmD3D9TextureManager.h"
 #include "CmD3D9Texture.h"
@@ -118,6 +116,8 @@ namespace BansheeEngine
 		mDriverVersion.release = HIWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.LowPart);
 		mDriverVersion.build = LOWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.LowPart);
 
+		mVideoModeInfo = getDirect3DDrivers()->getVideoModeInfo();
+
 		// Create the device manager.
 		mDeviceManager = cm_new<D3D9DeviceManager>();
 
@@ -1632,7 +1632,7 @@ namespace BansheeEngine
 			rsc = cm_new<RenderSystemCapabilities>();
 
 		rsc->setDriverVersion(mDriverVersion);
-		rsc->setDeviceName(mActiveD3DDriver->DriverDescription());
+		rsc->setDeviceName(mActiveD3DDriver->getDriverDescription());
 		rsc->setRenderSystemName(getName());
 
 		// Init caps to maximum.		

+ 0 - 27
CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-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 "CmD3D9RenderWindow.h"
 #include "CmInput.h"
 #include "CmCoreThread.h"

+ 0 - 55
CamelotD3D9Renderer/Source/CmD3D9VideoMode.cpp

@@ -1,55 +0,0 @@
-/*
------------------------------------------------------------------------------
-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 "CmD3D9VideoMode.h"
-
-namespace BansheeEngine 
-{
-	String D3D9VideoMode::getDescription() const
-	{
-		char tmp[128];
-		unsigned int colourDepth = 16;
-		if( mDisplayMode.Format == D3DFMT_X8R8G8B8 ||
-			mDisplayMode.Format == D3DFMT_A8R8G8B8 ||
-			mDisplayMode.Format == D3DFMT_R8G8B8 )
-			colourDepth = 32;
-
-		sprintf( tmp, "%d x %d @ %d-bit colour", mDisplayMode.Width, mDisplayMode.Height, colourDepth );
-		return String(tmp);
-	}
-
-	unsigned int D3D9VideoMode::getColourDepth() const
-	{
-		unsigned int colourDepth = 16;
-		if( mDisplayMode.Format == D3DFMT_X8R8G8B8 ||
-			mDisplayMode.Format == D3DFMT_A8R8G8B8 ||
-			mDisplayMode.Format == D3DFMT_R8G8B8 )
-			colourDepth = 32;
-
-		return colourDepth;
-	}
-}

+ 94 - 0
CamelotD3D9Renderer/Source/CmD3D9VideoModeInfo.cpp

@@ -0,0 +1,94 @@
+#include "CmD3D9VideoModeInfo.h"
+#include "CmD3D9RenderSystem.h"
+#include "CmException.h"
+
+namespace BansheeEngine
+{
+	D3D9VideoModeInfo::D3D9VideoModeInfo(IDirect3D9* d3d9device)
+	{
+		for (UINT32 i = 0; i < d3d9device->GetAdapterCount(); i++)
+		{
+			D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+			D3DCAPS9 d3dcaps9;
+
+			d3d9device->GetAdapterIdentifier(i, 0, &adapterIdentifier);
+			d3d9device->GetDeviceCaps(i, D3DDEVTYPE_HAL, &d3dcaps9);
+
+			mOutputs.push_back(cm_new<D3D9VideoOutputInfo>(d3d9device, i));
+		}
+	}
+
+	D3D9VideoOutputInfo::D3D9VideoOutputInfo(IDirect3D9* d3d9device, UINT32 adapterIdx)
+		:mMonitorHandle(0)
+	{
+		IDirect3D9* pD3D = D3D9RenderSystem::getDirect3D9();
+
+		D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+		pD3D->GetAdapterIdentifier(adapterIdx, 0, &adapterIdentifier);
+
+		mName = adapterIdentifier.DeviceName;
+
+		for (UINT32 i = 0; i < pD3D->GetAdapterModeCount(adapterIdx, D3DFMT_X8R8G8B8); i++)
+		{
+			D3DDISPLAYMODE displayMode;
+			pD3D->EnumAdapterModes(adapterIdx, D3DFMT_X8R8G8B8, i, &displayMode);
+
+			bool foundVideoMode = false;
+			for (auto videoMode : mVideoModes)
+			{
+				D3D9VideoMode* d3d9videoMode = static_cast<D3D9VideoMode*>(videoMode);
+
+				if (d3d9videoMode->mWidth == displayMode.Width && d3d9videoMode->mHeight == displayMode.Height)
+				{
+					bool foundRefreshRate = false;
+					for (auto refreshRate : d3d9videoMode->mRefreshRates)
+					{
+						UINT32 intRefresh = Math::roundToInt(refreshRate);
+
+						if (refreshRate == displayMode.RefreshRate)
+						{
+							foundRefreshRate = true;
+							break;
+						}
+					}
+
+					if (!foundRefreshRate)
+					{
+						d3d9videoMode->mRefreshRates.push_back((float)displayMode.RefreshRate);
+					}
+
+					foundVideoMode = true;
+					break;
+				}
+			}
+
+			if (!foundVideoMode)
+			{
+				D3D9VideoMode* videoMode = cm_new<D3D9VideoMode>(displayMode.Width, displayMode.Height, this);
+				videoMode->mRefreshRates.push_back((float)displayMode.RefreshRate);
+
+				mVideoModes.push_back(videoMode);
+			}
+		}
+
+		// Get desktop display mode
+		HMONITOR hMonitor = pD3D->GetAdapterMonitor(adapterIdx);
+		MONITORINFOEX monitorInfo;
+		monitorInfo.cbSize = sizeof(MONITORINFOEX);
+		GetMonitorInfo(hMonitor, &monitorInfo);
+
+		DEVMODE devMode;
+		devMode.dmSize = sizeof(DEVMODE);
+		devMode.dmDriverExtra = 0;
+		EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
+
+		D3D9VideoMode* desktopVideoMode = cm_new<D3D9VideoMode>(devMode.dmPelsWidth, devMode.dmPelsHeight, this);
+		desktopVideoMode->mRefreshRates.push_back((float)devMode.dmDisplayFrequency);
+
+		mDesktopVideoMode = desktopVideoMode;
+	}
+
+	D3D9VideoMode::D3D9VideoMode(UINT32 width, UINT32 height, VideoOutputInfo* outputInfo)
+		:VideoMode(width, height, outputInfo)
+	{ }
+}

+ 0 - 146
CamelotD3D9Renderer/Source/CmD3D9VideoModeList.cpp

@@ -1,146 +0,0 @@
-/*
------------------------------------------------------------------------------
-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 "CmD3D9VideoModeList.h"
-#include "CmException.h"
-#include "CmD3D9RenderSystem.h"
-
-namespace BansheeEngine 
-{
-	D3D9VideoModeList::D3D9VideoModeList( D3D9Driver* pDriver )
-	{
-		if( NULL == pDriver )
-			CM_EXCEPT(InvalidParametersException, "pDriver parameter is NULL");
-
-		mpDriver = pDriver;
-		enumerate();
-	}
-
-	D3D9VideoModeList::~D3D9VideoModeList()
-	{
-		mpDriver = NULL;
-		mModeList.clear();
-	}
-
-	BOOL D3D9VideoModeList::enumerate()
-	{
-		UINT iMode;
-		IDirect3D9* pD3D = D3D9RenderSystem::getDirect3D9();
-		UINT adapter = mpDriver->getAdapterNumber();
-
-		for( iMode=0; iMode < pD3D->GetAdapterModeCount( adapter, D3DFMT_R5G6B5 ); iMode++ )
-		{
-			D3DDISPLAYMODE displayMode;
-			pD3D->EnumAdapterModes( adapter, D3DFMT_R5G6B5, iMode, &displayMode );
-
-			// Filter out low-resolutions
-			if( displayMode.Width < 640 || displayMode.Height < 400 )
-				continue;
-
-			// Check to see if it is already in the list (to filter out refresh rates)
-			BOOL found = FALSE;
-			Vector<D3D9VideoMode>::iterator it;
-			for( it = mModeList.begin(); it != mModeList.end(); it++ )
-			{
-				D3DDISPLAYMODE oldDisp = it->getDisplayMode();
-				if( oldDisp.Width == displayMode.Width &&
-					oldDisp.Height == displayMode.Height &&
-					oldDisp.Format == displayMode.Format )
-				{
-					// Check refresh rate and favour higher if poss
-					if (oldDisp.RefreshRate < displayMode.RefreshRate)
-						it->increaseRefreshRate(displayMode.RefreshRate);
-					found = TRUE;
-					break;
-				}
-			}
-
-			if( !found )
-				mModeList.push_back( D3D9VideoMode( displayMode ) );
-		}
-
-		for( iMode=0; iMode < pD3D->GetAdapterModeCount( adapter, D3DFMT_X8R8G8B8 ); iMode++ )
-		{
-			D3DDISPLAYMODE displayMode;
-			pD3D->EnumAdapterModes( adapter, D3DFMT_X8R8G8B8, iMode, &displayMode );
-
-			// Filter out low-resolutions
-			if( displayMode.Width < 640 || displayMode.Height < 400 )
-				continue;
-
-			// Check to see if it is already in the list (to filter out refresh rates)
-			BOOL found = FALSE;
-			Vector<D3D9VideoMode>::iterator it;
-			for( it = mModeList.begin(); it != mModeList.end(); it++ )
-			{
-				D3DDISPLAYMODE oldDisp = it->getDisplayMode();
-				if( oldDisp.Width == displayMode.Width &&
-					oldDisp.Height == displayMode.Height &&
-					oldDisp.Format == displayMode.Format )
-				{
-					// Check refresh rate and favour higher if poss
-					if (oldDisp.RefreshRate < displayMode.RefreshRate)
-						it->increaseRefreshRate(displayMode.RefreshRate);
-					found = TRUE;
-					break;
-				}
-			}
-
-			if( !found )
-				mModeList.push_back( D3D9VideoMode( displayMode ) );
-		}
-
-		return TRUE;
-	}
-
-	size_t D3D9VideoModeList::count()
-	{
-		return mModeList.size();
-	}
-
-	D3D9VideoMode* D3D9VideoModeList::item( size_t index )
-	{
-		Vector<D3D9VideoMode>::iterator p = mModeList.begin();
-
-		return &p[index];
-	}
-
-	D3D9VideoMode* D3D9VideoModeList::item( const String &name )
-	{
-		Vector<D3D9VideoMode>::iterator it = mModeList.begin();
-		if (it == mModeList.end())
-			return NULL;
-
-		for (;it != mModeList.end(); ++it)
-		{
-			if (it->getDescription() == name)
-				return &(*it);
-		}
-
-		return NULL;
-	}
-}

+ 2 - 0
CamelotGLRenderer/CamelotGLRenderer.vcxproj

@@ -261,6 +261,7 @@
     <ClInclude Include="Include\CmWin32Context.h" />
     <ClInclude Include="Include\CmWin32GLSupport.h" />
     <ClInclude Include="Include\CmWin32Prerequisites.h" />
+    <ClInclude Include="Include\CmWin32VideoModeInfo.h" />
     <ClInclude Include="Include\CmWin32Window.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLGpuProgram.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLParamParser.h" />
@@ -294,6 +295,7 @@
     <ClCompile Include="Source\CmGLTexture.cpp" />
     <ClCompile Include="Source\CmGLTextureManager.cpp" />
     <ClCompile Include="Source\CmWin32GLSupport.cpp" />
+    <ClCompile Include="Source\CmWin32VideoModeInfo.cpp" />
     <ClCompile Include="Source\CmWin32Window.cpp" />
     <ClCompile Include="Source\glew.cpp" />
     <ClCompile Include="Source\GLSL\src\CmGLSLGpuProgram.cpp" />

+ 6 - 0
CamelotGLRenderer/CamelotGLRenderer.vcxproj.filters

@@ -132,6 +132,9 @@
     <ClInclude Include="Include\BsGLVertexArrayObjectManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmWin32VideoModeInfo.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmGLContext.cpp">
@@ -227,5 +230,8 @@
     <ClCompile Include="Source\BsGLVertexArrayObjectManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmWin32VideoModeInfo.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 5 - 0
CamelotGLRenderer/Include/CmGLSupport.h

@@ -60,6 +60,11 @@ namespace BansheeEngine
 		*/
 		virtual void initializeExtensions();
 
+		/**
+		 * @brief	Gets a structure describing all available video modes.
+		 */
+		virtual VideoModeInfoPtr getVideoModeInfo() const = 0;
+
 	protected:
 		Set<String> extensionList;
 

+ 6 - 0
CamelotGLRenderer/Include/CmWin32GLSupport.h

@@ -37,6 +37,12 @@ namespace BansheeEngine
 		Win32Context* createContext(HDC hdc, HGLRC externalGlrc = 0);
 
 		bool selectPixelFormat(HDC hdc, int colourDepth, int multisample, bool hwGamma);
+
+		/**
+		 * @copydoc	GLSupport::getVideoModeInfo
+		 */
+		VideoModeInfoPtr getVideoModeInfo() const;
+
 	private:
 		// Allowed video modes
 		Vector<DEVMODE> mDevModes;

+ 46 - 0
CamelotGLRenderer/Include/CmWin32VideoModeInfo.h

@@ -0,0 +1,46 @@
+#pragma once
+
+#include "CmGLPrerequisites.h"
+#include "CmVideoModeInfo.h"
+
+namespace BansheeEngine
+{
+	/**
+	* @copydoc	VideoMode
+	*/
+	class CM_RSGL_EXPORT Win32VideoMode : public VideoMode
+	{
+	public:
+		Win32VideoMode(UINT32 width, UINT32 height, VideoOutputInfo* outputInfo);
+
+	private:
+		friend class Win32VideoOutputInfo;
+	};
+
+	/**
+	* @copydoc	VideoOutputInfo
+	*/
+	class CM_RSGL_EXPORT Win32VideoOutputInfo : public VideoOutputInfo
+	{
+	public:
+		Win32VideoOutputInfo(char* deviceName);
+		~Win32VideoOutputInfo();
+
+		/**
+		* @brief	Gets a Win32 handle to the monitor referenced by this object.
+		*/
+		HMONITOR getMonitorHandle() const { return mMonitorHandle; }
+
+	private:
+		HMONITOR mMonitorHandle;
+	};
+
+	/**
+	* @copydoc	VideoModeInfo
+	*/
+	class CM_RSGL_EXPORT Win32VideoModeInfo : public VideoModeInfo
+	{
+	public:
+		Win32VideoModeInfo();
+	};
+}

+ 2 - 0
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -102,6 +102,8 @@ namespace BansheeEngine
 		THROW_IF_NOT_CORE_THREAD;
 
 		mGLSupport->start();
+		mVideoModeInfo = mGLSupport->getVideoModeInfo();
+
 		RenderWindowManager::startUp<GLRenderWindowManager>(this);
 
 		RenderStateManager::startUp();

+ 6 - 0
CamelotGLRenderer/Source/CmWin32GLSupport.cpp

@@ -3,6 +3,7 @@
 #include "CmWin32Window.h"
 #include "CmGLRenderSystem.h"
 #include "CmWin32Context.h"
+#include "CmWin32VideoModeInfo.h"
 #include "CmException.h"
 #include "GL/wglew.h"
 #include <algorithm>
@@ -313,6 +314,11 @@ namespace BansheeEngine
 		return (format && SetPixelFormat(hdc, format, &pfd));
 	}
 
+	VideoModeInfoPtr Win32GLSupport::getVideoModeInfo() const
+	{
+		return cm_shared_ptr<Win32VideoModeInfo>();
+	}
+
 	String translateWGLError()
 	{
 		int winError = GetLastError();

+ 102 - 0
CamelotGLRenderer/Source/CmWin32VideoModeInfo.cpp

@@ -0,0 +1,102 @@
+#include "CmWin32VideoModeInfo.h"
+#include "CmMath.h"
+#include "CmException.h"
+
+namespace BansheeEngine
+{
+	Win32VideoModeInfo::Win32VideoModeInfo()
+	{
+		DISPLAY_DEVICE displayDevice;
+		memset(&displayDevice, 0, sizeof(DISPLAY_DEVICE));
+		displayDevice.cb = sizeof(DISPLAY_DEVICE);
+
+		UINT32 i = 0;
+		while (EnumDisplayDevices(nullptr, i++, &displayDevice, 0))
+		{
+			if ((displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) == 0)
+				continue;
+
+			mOutputs.push_back(cm_new<Win32VideoOutputInfo>(displayDevice.DeviceName));
+		}
+	}
+
+	Win32VideoOutputInfo::Win32VideoOutputInfo(char* deviceName)
+		:mMonitorHandle(0)
+	{
+		mName = deviceName;
+
+		DISPLAY_DEVICE displayDevice;
+		displayDevice.cb = sizeof(DISPLAY_DEVICE);
+
+		UINT32 i = 0;
+		while (EnumDisplayDevices(deviceName, i++, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
+		{
+			if (displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE)
+			{
+				mMonitorHandle = (HMONITOR)CreateFile(displayDevice.DeviceID, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+			}
+		}
+
+		DEVMODE devMode;
+		devMode.dmSize = sizeof(DEVMODE);
+		devMode.dmDriverExtra = 0;
+
+		i = 0;
+		while (EnumDisplaySettings(deviceName, i++, &devMode))
+		{
+			bool foundVideoMode = false;
+			for (auto videoMode : mVideoModes)
+			{
+				Win32VideoMode* win32VideoMode = static_cast<Win32VideoMode*>(videoMode);
+
+				if (win32VideoMode->mWidth == devMode.dmPelsWidth && win32VideoMode->mHeight == devMode.dmPelsHeight)
+				{
+					bool foundRefreshRate = false;
+					for (auto refreshRate : win32VideoMode->mRefreshRates)
+					{
+						UINT32 intRefresh = Math::roundToInt(refreshRate);
+
+						if (refreshRate == devMode.dmDisplayFrequency)
+						{
+							foundRefreshRate = true;
+							break;
+						}
+					}
+
+					if (!foundRefreshRate)
+					{
+						win32VideoMode->mRefreshRates.push_back((float)devMode.dmDisplayFrequency);
+					}
+
+					foundVideoMode = true;
+					break;
+				}
+			}
+
+			if (!foundVideoMode)
+			{
+				Win32VideoMode* videoMode = cm_new<Win32VideoMode>(devMode.dmPelsWidth, devMode.dmPelsHeight, this);
+				videoMode->mRefreshRates.push_back((float)devMode.dmDisplayFrequency);
+
+				mVideoModes.push_back(videoMode);
+			}
+		}
+
+		// Get desktop display mode
+		EnumDisplaySettings(deviceName, ENUM_CURRENT_SETTINGS, &devMode);
+
+		Win32VideoMode* desktopVideoMode = cm_new<Win32VideoMode>(devMode.dmPelsWidth, devMode.dmPelsHeight, this);
+		desktopVideoMode->mRefreshRates.push_back((float)devMode.dmDisplayFrequency);
+
+		mDesktopVideoMode = desktopVideoMode;
+	}
+
+	Win32VideoOutputInfo::~Win32VideoOutputInfo()
+	{
+		CloseHandle(mMonitorHandle);
+	}
+
+	Win32VideoMode::Win32VideoMode(UINT32 width, UINT32 height, VideoOutputInfo* outputInfo)
+		:VideoMode(width, height, outputInfo)
+	{ }
+}

+ 7 - 38
CamelotGLRenderer/Source/win32/CmGLUtil.h

@@ -1,43 +1,12 @@
-/*
------------------------------------------------------------------------------
-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 INCL_OGRE_GLUTIL_H
-#define INCL_OGRE_GLUTIL_H
+#pragma once
 
 #include "CmWin32GLSupport.h"
+#include "CmWin32VideoModeInfo.h"
 
-namespace BansheeEngine {
-    
-inline GLSupport* getGLSupport()
+namespace BansheeEngine 
 {
-    return cm_new<Win32GLSupport>();
-}
-
+	GLSupport* getGLSupport()
+	{
+		return cm_new<Win32GLSupport>();
+	}
 };
-
-#endif // INCL_OGRE_GLUTIL_H

+ 4 - 0
Polish.txt

@@ -9,6 +9,10 @@ Finish GPUProfiler:
 
  ---------------------------
 
+ Make hierarchical documentation. Organize stuff based on type. Once I actually generate the documentation add Doxygen grouping tags (or whatever they're called)
+
+ ---------------------------
+
  Fullscreen stuff:
 
 Add VideoModeInfo to OpenGL and DX9. Remove any existing functionality.