Browse Source

Ability to specify size when changing window to windowed

Marko Pintera 11 years ago
parent
commit
ff73fc789d

+ 1 - 1
BansheeCore/Include/CmCoreThreadAccessor.h

@@ -154,7 +154,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc RenderWindow::setWindowed
 		 * @copydoc RenderWindow::setWindowed
 		 */
 		 */
-		void setWindowed(RenderWindowPtr& renderWindow);
+		void setWindowed(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height);
 
 
 		/**
 		/**
 		* @brief	Queues a new generic command that will be added to the command queue.
 		* @brief	Queues a new generic command that will be added to the command queue.

+ 10 - 5
BansheeCore/Include/CmRenderWindow.h

@@ -65,10 +65,10 @@ namespace BansheeEngine
 		/** 
 		/** 
 		 * @brief	Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
 		 * @brief	Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
 		 *
 		 *
-		 * @param	width		Width of the window back buffer in pixels.
-		 * @param	height		Height of the window back buffer in pixels.
-		 * @param	refreshRate	Refresh rate of the window in Hertz. This is ignored in windowed mode.
-		 * @param	monitorIdx	Index of the monitor to go fullscreen on. This is ignored in windowed mode.
+		 * @param	width		Width of the window frame buffer in pixels.
+		 * @param	height		Height of the window frame buffer in pixels.
+		 * @param	refreshRate	Refresh rate of the window in Hertz.
+		 * @param	monitorIdx	Index of the monitor to go fullscreen on.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 *			If the exact provided mode isn't available, closest one is used instead.
 		 *			If the exact provided mode isn't available, closest one is used instead.
@@ -86,8 +86,13 @@ namespace BansheeEngine
 
 
 		/**
 		/**
 		 * @brief	Switches the window to windowed mode.
 		 * @brief	Switches the window to windowed mode.
+		 *
+		 * @param	Window width in pixels.
+		 * @param	Window height in pixels.
+		 *
+		 * @note	Core thread.
 		 */
 		 */
-		virtual void setWindowed() { }
+		virtual void setWindowed(UINT32 width, UINT32 height) { }
 
 
         /**
         /**
          * @brief	Hide or show the window.
          * @brief	Hide or show the window.

+ 2 - 2
BansheeCore/Source/CmCoreThreadAccessor.cpp

@@ -271,9 +271,9 @@ namespace BansheeEngine
 		mCommandQueue->queue(std::bind(funcPtr, renderWindow.get(), std::cref(mode)));
 		mCommandQueue->queue(std::bind(funcPtr, renderWindow.get(), std::cref(mode)));
 	}
 	}
 
 
-	void CoreThreadAccessorBase::setWindowed(RenderWindowPtr& renderWindow)
+	void CoreThreadAccessorBase::setWindowed(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height)
 	{
 	{
-		mCommandQueue->queue(std::bind(&RenderWindow::setWindowed, renderWindow.get()));
+		mCommandQueue->queue(std::bind(&RenderWindow::setWindowed, renderWindow.get(), width, height));
 	}
 	}
 
 
 	AsyncOp CoreThreadAccessorBase::queueReturnCommand(std::function<void(AsyncOp&)> commandCallback)
 	AsyncOp CoreThreadAccessorBase::queueReturnCommand(std::function<void(AsyncOp&)> commandCallback)

+ 1 - 1
BansheeD3D11RenderSystem/Include/CmD3D11RenderWindow.h

@@ -43,7 +43,7 @@ namespace BansheeEngine
 		/**
 		/**
 		* @copydoc RenderWindow::setWindowed
 		* @copydoc RenderWindow::setWindowed
 		*/
 		*/
-		void setWindowed();
+		void setWindowed(UINT32 width, UINT32 height);
 
 
 		/**
 		/**
 		 * @copydoc RenderWindow::copyContentsToMemory
 		 * @copydoc RenderWindow::copyContentsToMemory

+ 4 - 1
BansheeD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -424,11 +424,14 @@ namespace BansheeEngine
 		mSwapChain->SetFullscreenState(true, outputInfo.getDXGIOutput());
 		mSwapChain->SetFullscreenState(true, outputInfo.getDXGIOutput());
 	}
 	}
 
 
-	void D3D11RenderWindow::setWindowed()
+	void D3D11RenderWindow::setWindowed(UINT32 width, UINT32 height)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
+		mWidth = width;
+		mHeight = height;
 		mIsFullScreen = false;
 		mIsFullScreen = false;
+
 		mSwapChainDesc.Windowed = false;
 		mSwapChainDesc.Windowed = false;
 		mSwapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
 		mSwapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
 		mSwapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
 		mSwapChainDesc.BufferDesc.RefreshRate.Denominator = 0;

+ 1 - 1
BansheeD3D9RenderSystem/Include/CmD3D9RenderWindow.h

@@ -24,7 +24,7 @@ namespace BansheeEngine
 		/**
 		/**
 		* @copydoc RenderWindow::setWindowed
 		* @copydoc RenderWindow::setWindowed
 		*/
 		*/
-		void setWindowed();
+		void setWindowed(UINT32 width, UINT32 height);
 
 
 		/**
 		/**
 		 * @copydoc RenderWindow::setHidden
 		 * @copydoc RenderWindow::setHidden

+ 3 - 2
BansheeD3D9RenderSystem/Source/CmD3D9RenderWindow.cpp

@@ -298,7 +298,7 @@ namespace BansheeEngine
 		setFullscreen(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getOutputIdx());
 		setFullscreen(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getOutputIdx());
 	}
 	}
 
 
-	void D3D9RenderWindow::setWindowed()
+	void D3D9RenderWindow::setWindowed(UINT32 width, UINT32 height)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
@@ -306,8 +306,9 @@ namespace BansheeEngine
 			return;
 			return;
 
 
 		mIsFullScreen = false;
 		mIsFullScreen = false;
-
 		mStyle = mWindowedStyle;
 		mStyle = mWindowedStyle;
+		mWidth = width;
+		mHeight = height;
 
 
 		unsigned int winWidth, winHeight;
 		unsigned int winWidth, winHeight;
 		_adjustWindow(mWidth, mHeight, mStyle, &winWidth, &winHeight);
 		_adjustWindow(mWidth, mHeight, mStyle, &winWidth, &winHeight);

+ 1 - 1
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -31,7 +31,7 @@ namespace BansheeEngine
 	{
 	{
 		if (cm_dbg_fullscreen)
 		if (cm_dbg_fullscreen)
 		{
 		{
-			gCoreAccessor().setWindowed(gCoreApplication().getPrimaryWindow());
+			gCoreAccessor().setWindowed(gCoreApplication().getPrimaryWindow(), 1280, 720);
 		}
 		}
 		else
 		else
 		{
 		{

+ 1 - 1
BansheeGLRenderSystem/Include/CmWin32Window.h

@@ -23,7 +23,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc RenderWindow::setWindowed
 		 * @copydoc RenderWindow::setWindowed
 		 */
 		 */
-		void setWindowed();
+		void setWindowed(UINT32 width, UINT32 height);
 
 
 		/**
 		/**
 		 * @copydoc RenderWindow::setHidden
 		 * @copydoc RenderWindow::setHidden

+ 3 - 1
BansheeGLRenderSystem/Source/CmWin32Window.cpp

@@ -421,7 +421,7 @@ namespace BansheeEngine
 		setFullscreen(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getOutputIdx());
 		setFullscreen(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getOutputIdx());
 	}
 	}
 
 
-	void Win32Window::setWindowed()
+	void Win32Window::setWindowed(UINT32 width, UINT32 height)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
@@ -429,6 +429,8 @@ namespace BansheeEngine
 			return;
 			return;
 
 
 		mIsFullScreen = false;
 		mIsFullScreen = false;
+		mWidth = width;
+		mHeight = height;
 
 
 		// Drop out of fullscreen
 		// Drop out of fullscreen
 		ChangeDisplaySettingsEx(mDeviceName, NULL, NULL, 0, NULL);
 		ChangeDisplaySettingsEx(mDeviceName, NULL, NULL, 0, NULL);

+ 0 - 4
Polish.txt

@@ -28,10 +28,6 @@ DISREGARD MONITOR INDEX ON DX9
 
 
  -----------------------------
  -----------------------------
 
 
- Refactor:
- - Make CmApplication a base of BsApplication
- - If I merge CmApp and BsApp consider refactoring CmApplication::mainLoopCallback
-
 Consider renaming Profiler to CPUProfiler and CPUProfiler to something else. Since now I have GPUProfiler it's confusing to have one named just Profiler.
 Consider renaming Profiler to CPUProfiler and CPUProfiler to something else. Since now I have GPUProfiler it's confusing to have one named just Profiler.
 Profiler can only be called from sim/core thread which is also a bit weird.
 Profiler can only be called from sim/core thread which is also a bit weird.