From d16357cd5ce810c74fcee602ed13028d397c6254 Mon Sep 17 00:00:00 2001 From: donkopunchstania Date: Fri, 7 Jan 2011 04:57:59 +0000 Subject: [PATCH] Add anvideo config option to automatically resize the render window to the size of the game's output resolution. This avoids artifacts that appear when the render target is scaled to fit a window of a different size. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6764 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 18 +++++-- Source/Core/Core/Src/Host.h | 3 +- Source/Core/DolphinWX/Src/Frame.cpp | 22 +++++++- Source/Core/DolphinWX/Src/Frame.h | 3 +- Source/Core/DolphinWX/Src/Main.cpp | 9 +++- Source/Core/DolphinWX/Src/MainNoGUI.cpp | 2 +- Source/Core/VideoCommon/Src/EmuWindow.cpp | 2 +- Source/Core/VideoCommon/Src/RenderBase.cpp | 53 ++++++++++++------- Source/Core/VideoCommon/Src/RenderBase.h | 1 + Source/Core/VideoCommon/Src/VideoConfig.cpp | 2 + Source/Core/VideoCommon/Src/VideoConfig.h | 1 + .../VideoUICommon/Src/VideoConfigDiag.cpp | 2 + Source/PluginSpecs/pluginspecs_video.h | 4 +- .../Plugins/Plugin_VideoDX11/Src/Render.cpp | 24 +++++++-- Source/Plugins/Plugin_VideoDX11/Src/Render.h | 1 + Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 25 +++++++-- Source/Plugins/Plugin_VideoDX9/Src/Render.h | 1 + Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 4 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 18 +++++++ Source/Plugins/Plugin_VideoOGL/Src/Render.h | 2 + .../Plugin_VideoSoftware/Src/GLUtil.cpp | 4 +- 21 files changed, 158 insertions(+), 43 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 0b0c8af66a..97d5b2fe8f 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -80,7 +80,8 @@ volatile u32 DrawnFrame = 0; u32 DrawnVideo = 0; // Function forwarding -void Callback_VideoRequestWindowSize(int& x, int& y, int& width, int& height); +void Callback_VideoGetWindowSize(int& x, int& y, int& width, int& height); +void Callback_VideoRequestWindowSize(int& width, int& height); void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak); void Callback_VideoCopiedToXFB(bool video_update); void Callback_DSPLog(const TCHAR* _szMessage, int _v); @@ -342,6 +343,7 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow; VideoInitialize.pLog = Callback_VideoLog; VideoInitialize.pSysMessage = Host_SysMessage; + VideoInitialize.pGetWindowSize = Callback_VideoGetWindowSize; VideoInitialize.pRequestWindowSize = Callback_VideoRequestWindowSize; VideoInitialize.pCopiedToXFB = Callback_VideoCopiedToXFB; VideoInitialize.pPeekMessages = NULL; @@ -717,10 +719,18 @@ void Callback_VideoCopiedToXFB(bool video_update) Frame::FrameUpdate(); } -// Ask the host for the desired window size -void Callback_VideoRequestWindowSize(int& x, int& y, int& width, int& height) +// Ask the host for the window size +void Callback_VideoGetWindowSize(int& x, int& y, int& width, int& height) { - Host_RequestWindowSize(x, y, width, height); + Host_GetRenderWindowSize(x, y, width, height); +} + +// Suggest to the host that it sets the window to the given size. +// The host may or may not decide to do this depending on fullscreen or not. +// Sets width and height to the actual size of the window. +void Callback_VideoRequestWindowSize(int& width, int& height) +{ + Host_RequestRenderWindowSize(width, height); } // Callback_DSPLog diff --git a/Source/Core/Core/Src/Host.h b/Source/Core/Core/Src/Host.h index e91c2138cd..310cb6f462 100644 --- a/Source/Core/Core/Src/Host.h +++ b/Source/Core/Core/Src/Host.h @@ -46,7 +46,8 @@ void Host_NotifyMapLoaded(); void Host_UpdateBreakPointView(); void Host_ShowJitResults(unsigned int address); void Host_SetDebugMode(bool enable); -void Host_RequestWindowSize(int& x, int& y, int& width, int& height); +void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height); +void Host_RequestRenderWindowSize(int& width, int& height); bool Host_RendererHasFocus(); void Host_SetWaitCursor(bool enable); diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index fcf183e291..c280b200da 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -669,7 +669,7 @@ void CFrame::OnHostMessage(wxCommandEvent& event) } } -void CFrame::OnSizeRequest(int& x, int& y, int& width, int& height) +void CFrame::GetRenderWindowSize(int& x, int& y, int& width, int& height) { wxMutexGuiEnter(); m_RenderParent->GetSize(&width, &height); @@ -677,6 +677,26 @@ void CFrame::OnSizeRequest(int& x, int& y, int& width, int& height) wxMutexGuiLeave(); } +void CFrame::OnRenderWindowSizeRequest(int& width, int& height) +{ + wxMutexGuiEnter(); + + if (IsFullScreen()) + { + m_RenderParent->GetSize(&width, &height); + } + else if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) + { + m_RenderParent->SetClientSize(width, height); + } + else + { + m_RenderParent->GetParent()->SetClientSize(width, height); + } + + wxMutexGuiLeave(); +} + bool CFrame::RendererHasFocus() { if (m_RenderParent == NULL) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 04068bf30c..b948d38a09 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -123,7 +123,8 @@ class CFrame : public CRenderFrame void PostEvent(wxCommandEvent& event); void StatusBarMessage(const char * Text, ...); void ClearStatusBar(); - void OnSizeRequest(int& x, int& y, int& width, int& height); + void GetRenderWindowSize(int& x, int& y, int& width, int& height); + void OnRenderWindowSizeRequest(int& width, int& height); void BootGame(const std::string& filename); void OnRenderParentClose(wxCloseEvent& event); void OnRenderParentMove(wxMoveEvent& event); diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index f49b14b9d8..ec6d1fb2e5 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -602,9 +602,14 @@ void Host_UpdateMemoryView() void Host_SetDebugMode(bool) {} -void Host_RequestWindowSize(int& x, int& y, int& width, int& height) +void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { - main_frame->OnSizeRequest(x, y, width, height); + main_frame->GetRenderWindowSize(x, y, width, height); +} + +void Host_RequestRenderWindowSize(int& width, int& height) +{ + main_frame->OnRenderWindowSizeRequest(width, height); } void Host_SetWaitCursor(bool enable) diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 0abb2c1b6c..a0dc1fa08f 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -93,7 +93,7 @@ void Host_UpdateMemoryView(){} void Host_SetDebugMode(bool){} -void Host_RequestWindowSize(int& x, int& y, int& width, int& height) +void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos; y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos; diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp index 62882c48e6..3f37687f26 100644 --- a/Source/Core/VideoCommon/Src/EmuWindow.cpp +++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp @@ -323,7 +323,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title) // 3. Request window sizes which actually make the client area map to a common resolution HWND Ret; int x=0, y=0, width=640, height=480; - g_VideoInitialize.pRequestWindowSize(x, y, width, height); + g_VideoInitialize.pGetWindowSize(x, y, width, height); // TODO: Don't show if fullscreen Ret = OpenWindow(hParent, hInstance, width, height, title); diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp index 4e67c5c72f..4d584f2711 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.cpp +++ b/Source/Core/VideoCommon/Src/RenderBase.cpp @@ -114,13 +114,42 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect } } +void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY) +{ + switch (g_ActiveConfig.iEFBScale) + { + case 3: // 2x + scaledX = x * 2; + scaledY = y * 2; + break; + case 4: // 3x + scaledX = x * 3; + scaledY = y * 3; + break; + case 5: // 0.75x + scaledX = (x * 3) / 4; + scaledY = (y * 3) / 4; + break; + case 6: // 0.5x + scaledX = x / 2; + scaledY = y / 2; + break; + case 7: // 0.375x + scaledX = (x * 3) / 8; + scaledY = (y * 3) / 8; + break; + default: + scaledX = x; + scaledY = y; + }; +} + // return true if target size changed bool Renderer::CalculateTargetSize(int multiplier) { int newEFBWidth, newEFBHeight; switch (s_LastEFBScale) { - default: case 0: // fractional newEFBWidth = (int)(EFB_WIDTH * xScale); newEFBHeight = (int)(EFB_HEIGHT * yScale); @@ -129,25 +158,9 @@ bool Renderer::CalculateTargetSize(int multiplier) newEFBWidth = EFB_WIDTH * (int)ceilf(xScale); newEFBHeight = EFB_HEIGHT * (int)ceilf(yScale); break; - case 2: // 1x - case 3: // 2x - case 4: // 3x - newEFBWidth = EFB_WIDTH * (g_ActiveConfig.iEFBScale - 1); - newEFBHeight = EFB_HEIGHT * (g_ActiveConfig.iEFBScale - 1); - break; - case 5: // 0.75x - newEFBWidth = (EFB_WIDTH * 3) / 4; - newEFBHeight = (EFB_HEIGHT * 3) / 4; - break; - case 6: // 0.5x - newEFBWidth = EFB_WIDTH / 2; - newEFBHeight = EFB_HEIGHT / 2; - break; - case 7: // 0.375x - newEFBWidth = (EFB_WIDTH * 3) / 8; - newEFBHeight = (EFB_HEIGHT * 3) / 8; - break; - }; + default: + CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight); + } newEFBWidth *= multiplier; newEFBHeight *= multiplier; diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h index 58e4699d5d..1d265083d9 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.h +++ b/Source/Core/VideoCommon/Src/RenderBase.h @@ -134,6 +134,7 @@ protected: static Common::CriticalSection s_criticalScreenshot; static std::string s_sScreenshotName; + static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY); static bool CalculateTargetSize(int multiplier = 1); static void CalculateXYScale(const TargetRectangle& dst_rect); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index ddca461be9..f08cbe8a7f 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -61,6 +61,7 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Settings", "UseXFB", &bUseXFB, 0); iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0); iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, true); + iniFile.Get("Settings", "AdjustWindowSize", &bAdjustWindowSize, false); iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings //Safe texture cache params @@ -179,6 +180,7 @@ void VideoConfig::Save(const char *ini_file) iniFile.Set("Settings", "UseXFB", bUseXFB); iniFile.Set("Settings", "UseRealXFB", bUseRealXFB); iniFile.Set("Settings", "UseNativeMips", bUseNativeMips); + iniFile.Set("Settings", "AdjustWindowSize", bAdjustWindowSize); iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache); //safe texture cache params diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 9ffffe2f0c..276ef6f903 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -77,6 +77,7 @@ struct VideoConfig bool bUseXFB; bool bUseRealXFB; bool bUseNativeMips; + bool bAdjustWindowSize; // OpenCL bool bEnableOpenCL; diff --git a/Source/Core/VideoUICommon/Src/VideoConfigDiag.cpp b/Source/Core/VideoUICommon/Src/VideoConfigDiag.cpp index c438cf5e1e..b81c18b024 100644 --- a/Source/Core/VideoUICommon/Src/VideoConfigDiag.cpp +++ b/Source/Core/VideoUICommon/Src/VideoConfigDiag.cpp @@ -101,6 +101,7 @@ wxString crop_tooltip = wxT(""); wxString opencl_tooltip = wxT(""); wxString dlc_tooltip = wxT(""); wxString hotkeys_tooltip = wxT(""); +wxString adjust_window_size_tooltip = wxT("Adjusts the window to match the game's output resolution scaled by the EFB scale.\nIt is best to set the aspect ratio to stretch when using this."); wxString ppshader_tooltip = wxT(""); wxString cache_efb_copies_tooltip = _("When using EFB to RAM we very often need to decode RAM data to a VRAM texture, which is a very time-consuming task.\nWith this option enabled, we'll skip decoding a texture if it didn't change.\nThis results in a nice speedup, but possibly causes glitches.\nIf you have any problems with this option enabled you should either try increasing the safety of the texture cache or disable this option.\n(NOTE: The safier the texture cache is adjusted the lower the speedup will be; accurate texture cache set to \"safe\" might actually be slower!)"); @@ -425,6 +426,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable OpenCL"), opencl_tooltip, vconfig.bEnableOpenCL)); szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable Display List Caching"), dlc_tooltip, vconfig.bDlistCachingEnable)); szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable Hotkeys"), hotkeys_tooltip, vconfig.bOSDHotKey)); + szr_misc->Add(new SettingCheckBox(page_advanced, wxT("Adjust window size"), adjust_window_size_tooltip, vconfig.bAdjustWindowSize)); // postproc shader if (vconfig.backend_info.PPShaders.size()) diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index 835a6e9381..32b0954048 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -19,7 +19,8 @@ typedef void (*TProcessFifoEvents)(void); typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress); typedef void (*TVideoLog)(const char* _pMessage, int _bBreak); typedef void (*TSysMessage)(const char *fmt, ...); -typedef void (*TRequestWindowSize)(int& x, int& y, int& width, int& height); +typedef void (*TGetWindowSize)(int& x, int& y, int& width, int& height); +typedef void (*TRequestWindowSize)(int& width, int& height); typedef void (*TCopiedToXFB)(bool video_update); typedef unsigned int (*TPeekMessages)(void); typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title @@ -87,6 +88,7 @@ typedef struct TGetMemoryPointer pGetMemoryPointer; TVideoLog pLog; TSysMessage pSysMessage; + TGetWindowSize pGetWindowSize; TRequestWindowSize pRequestWindowSize; TCopiedToXFB pCopiedToXFB; TPeekMessages pPeekMessages; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 1fd7f095ed..af368790c8 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -317,7 +317,7 @@ Renderer::Renderer() int x, y, w_temp, h_temp; s_blendMode = 0; - g_VideoInitialize.pRequestWindowSize(x, y, w_temp, h_temp); + g_VideoInitialize.pGetWindowSize(x, y, w_temp, h_temp); D3D::Create(EmuWindow::GetWnd()); @@ -412,6 +412,19 @@ bool Renderer::CheckForResize() return false; } +void Renderer::SetWindowSize(int width, int height) +{ + if (width < 1) + width = 1; + if (height < 1) + height = 1; + + // Scale the window size by the EFB scale. + CalculateTargetScale(width, height, width, height); + + g_VideoInitialize.pRequestWindowSize(width, height); +} + bool Renderer::SetScissorRect() { TargetRectangle rc; @@ -957,7 +970,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons // Enable any configuration changes UpdateActiveConfig(); - const bool WindowResized = CheckForResize(); + + if (g_ActiveConfig.bAdjustWindowSize) + SetWindowSize(fbWidth, fbHeight); + + const bool windowResized = CheckForResize(); bool xfbchanged = false; @@ -993,7 +1010,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons D3D::Present(); // resize the back buffers NOW to avoid flickering - if (xfbchanged || WindowResized || + if (xfbchanged || + windowResized || s_LastEFBScale != g_ActiveConfig.iEFBScale || s_LastAA != g_ActiveConfig.iMultisampleMode) { diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.h b/Source/Plugins/Plugin_VideoDX11/Src/Render.h index ee6e27c43a..db052b7e59 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.h @@ -44,6 +44,7 @@ public: bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc); static bool CheckForResize(); + static void SetWindowSize(int width, int height); }; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 9a751837ba..40bd58d816 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -256,7 +256,7 @@ Renderer::Renderer() // Multisample Anti-aliasing hasn't been implemented yet use supersamling instead int backbuffer_ms_mode = 0; - g_VideoInitialize.pRequestWindowSize(x, y, w_temp, h_temp); + g_VideoInitialize.pGetWindowSize(x, y, w_temp, h_temp); for (fullScreenRes = 0; fullScreenRes < (int)D3D::GetAdapter(g_ActiveConfig.iAdapter).resolutions.size(); fullScreenRes++) { @@ -423,6 +423,19 @@ bool Renderer::CheckForResize() return false; } +void Renderer::SetWindowSize(int width, int height) +{ + if (width < 1) + width = 1; + if (height < 1) + height = 1; + + // Scale the window size by the EFB scale. + CalculateTargetScale(width, height, width, height); + + g_VideoInitialize.pRequestWindowSize(width, height); +} + bool Renderer::SetScissorRect() { TargetRectangle rc; @@ -1174,7 +1187,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons // Enable any configuration changes UpdateActiveConfig(); - const bool WindowResized = CheckForResize(); + + if (g_ActiveConfig.bAdjustWindowSize) + SetWindowSize(fbWidth, fbHeight); + + const bool windowResized = CheckForResize(); bool xfbchanged = false; @@ -1191,7 +1208,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons u32 newAA = g_ActiveConfig.iMultisampleMode; - if (xfbchanged || WindowResized || s_LastEFBScale != g_ActiveConfig.iEFBScale || s_LastAA != newAA) + if (xfbchanged || windowResized || s_LastEFBScale != g_ActiveConfig.iEFBScale || s_LastAA != newAA) { s_LastAA = newAA; @@ -1206,7 +1223,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface()); - if (WindowResized) + if (windowResized) { SetupDeviceObjects(); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index 02123ed44a..967e996634 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -44,6 +44,7 @@ public: bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc); static bool CheckForResize(); + static void SetWindowSize(int width, int height); }; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 5c77a7581f..62a5acbaa4 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -313,7 +313,7 @@ THREAD_RETURN XEventThread(void *pArg) bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) { int _tx, _ty, _twidth, _theight; - g_VideoInitialize.pRequestWindowSize(_tx, _ty, _twidth, _theight); + g_VideoInitialize.pGetWindowSize(_tx, _ty, _twidth, _theight); // Control window size and picture scaling s_backbuffer_width = _twidth; @@ -488,7 +488,7 @@ bool OpenGL_MakeCurrent() return wglMakeCurrent(hDC,hRC) ? true : false; #elif defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_WX) && (HAVE_WX) - g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); + g_VideoInitialize.pGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); #endif return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 5448edd378..8df0f91692 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1235,7 +1235,12 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons #endif // Finish up the current frame, print some stats + + if (g_ActiveConfig.bAdjustWindowSize) + SetWindowSize(fbWidth, fbHeight); + OpenGL_Update(); // just updates the render window position and the backbuffer size + bool xfbchanged = false; if (s_XFB_width != fbWidth || s_XFB_height != fbHeight) @@ -1592,4 +1597,17 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle return result; } +void Renderer::SetWindowSize(int width, int height) +{ + if (width < 1) + width = 1; + if (height < 1) + height = 1; + + // Scale the window size by the EFB scale. + CalculateTargetScale(width, height, width, height); + + g_VideoInitialize.pRequestWindowSize(width, height); +} + } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h index 80d8b9e83d..37bfd28d2e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h @@ -44,6 +44,8 @@ public: void UpdateViewport(); bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc); + + void SetWindowSize(int width, int height); }; } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index 5630cd6892..77f72ff792 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -104,7 +104,7 @@ void UpdateFPSDisplay(const char *text) bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight) { int xPos, yPos; - g_VideoInitialize.pRequestWindowSize(xPos, yPos, _twidth, _theight); + g_VideoInitialize.pGetWindowSize(xPos, yPos, _twidth, _theight); #if defined(_WIN32) EmuWindow::SetSize(_twidth, _theight); @@ -308,7 +308,7 @@ bool OpenGL_MakeCurrent() #elif defined(_WIN32) return wglMakeCurrent(hDC,hRC) ? true : false; #elif defined(HAVE_X11) && HAVE_X11 - g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); + g_VideoInitialize.pGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); #endif