diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 9fd1854318..e232757344 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1028,28 +1028,6 @@ bool D3DFB::IsFullscreen () return !Windowed; } -//========================================================================== -// -// D3DFB :: ScaleCoordsFromWindow -// -// Given coordinates in window space, return coordinates in what the game -// thinks screen space is. -// -//========================================================================== - -void D3DFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) -{ - RECT rect; - - if (GetClientRect(Window, &rect)) - { - x = SWORD(x * Width / (rect.right - rect.left)); - y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); - } - // Subtract letterboxing borders - y -= (TrueHeight - Height) / 2; -} - //========================================================================== // // D3DFB :: Lock diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index ecf570ff88..2aa694f3b4 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -806,19 +806,6 @@ bool DDrawFB::Is8BitMode() return vid_displaybits == 8; } -void DDrawFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) -{ - RECT rect; - - if (GetClientRect(Window, &rect)) - { - x = SWORD(x * Width / (rect.right - rect.left)); - y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); - } - // Subtract letterboxing borders - y -= (TrueHeight - Height) / 2; -} - bool DDrawFB::IsValid () { return PrimarySurf != NULL; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 9699157cd9..934931ea01 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -127,10 +127,12 @@ public: virtual void Blank () = 0; virtual bool PaintToWindow () = 0; virtual HRESULT GetHR () = 0; + virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y); protected: virtual bool CreateResources () = 0; virtual void ReleaseResources () = 0; + virtual int GetTrueHeight() { return GetHeight(); } bool Windowed; @@ -165,7 +167,7 @@ public: void NewRefreshRate(); HRESULT GetHR (); bool Is8BitMode(); - void ScaleCoordsFromWindow(SWORD &x, SWORD &y); + virtual int GetTrueHeight() { return TrueHeight; } void Blank (); bool PaintToWindow (); @@ -270,7 +272,7 @@ public: void WipeCleanup(); HRESULT GetHR (); bool Is8BitMode() { return false; } - void ScaleCoordsFromWindow(SWORD &x, SWORD &y); + virtual int GetTrueHeight() { return TrueHeight; } private: friend class D3DTex; diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 3071ae8e72..8aa74bfb58 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -736,6 +736,29 @@ void Win32Video::SetWindowedScale (float scale) // FIXME } +//========================================================================== +// +// BaseWinFB :: ScaleCoordsFromWindow +// +// Given coordinates in window space, return coordinates in what the game +// thinks screen space is. +// +//========================================================================== + +void BaseWinFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) +{ + RECT rect; + + int TrueHeight = GetTrueHeight(); + if (GetClientRect(Window, &rect)) + { + x = SWORD(x * Width / (rect.right - rect.left)); + y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); + } + // Subtract letterboxing borders + y -= (TrueHeight - Height) / 2; +} + //========================================================================== // // SetFPSLimit