mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
WinRT: minor rotation/orientation code cleanup in the d3d11 renderer
This commit is contained in:
parent
b93ab1e6a3
commit
8b2694f986
@ -1062,6 +1062,18 @@ D3D11_GetRotationForOrientation(Windows::Graphics::Display::DisplayOrientations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
D3D11_IsDisplayRotated90Degrees(Windows::Graphics::Display::DisplayOrientations orientation)
|
||||||
|
{
|
||||||
|
switch (D3D11_GetRotationForOrientation(orientation)) {
|
||||||
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize all resources that change when the window's size changes.
|
// Initialize all resources that change when the window's size changes.
|
||||||
// TODO, WinRT: get D3D11_CreateWindowSizeDependentResources working on Win32
|
// TODO, WinRT: get D3D11_CreateWindowSizeDependentResources working on Win32
|
||||||
HRESULT
|
HRESULT
|
||||||
@ -1108,9 +1120,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||||
const bool swapDimensions = false;
|
const bool swapDimensions = false;
|
||||||
#else
|
#else
|
||||||
const bool swapDimensions =
|
const bool swapDimensions = D3D11_IsDisplayRotated90Degrees(data->orientation);
|
||||||
data->orientation == DisplayOrientations::Portrait ||
|
|
||||||
data->orientation == DisplayOrientations::PortraitFlipped;
|
|
||||||
#endif
|
#endif
|
||||||
data->renderTargetSize.x = swapDimensions ? windowHeight : windowWidth;
|
data->renderTargetSize.x = swapDimensions ? windowHeight : windowWidth;
|
||||||
data->renderTargetSize.y = swapDimensions ? windowWidth : windowHeight;
|
data->renderTargetSize.y = swapDimensions ? windowWidth : windowHeight;
|
||||||
@ -1687,16 +1697,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
|||||||
// for Windows Phone devices.
|
// for Windows Phone devices.
|
||||||
//
|
//
|
||||||
SDL_FRect orientationAlignedViewport;
|
SDL_FRect orientationAlignedViewport;
|
||||||
|
const bool swapDimensions = D3D11_IsDisplayRotated90Degrees(data->orientation);
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
|
||||||
const bool swapDimensions =
|
|
||||||
data->orientation == DisplayOrientations::Landscape ||
|
|
||||||
data->orientation == DisplayOrientations::LandscapeFlipped;
|
|
||||||
#else
|
|
||||||
const bool swapDimensions =
|
|
||||||
data->orientation == DisplayOrientations::Portrait ||
|
|
||||||
data->orientation == DisplayOrientations::PortraitFlipped;
|
|
||||||
#endif
|
|
||||||
if (swapDimensions) {
|
if (swapDimensions) {
|
||||||
orientationAlignedViewport.x = (float) renderer->viewport.y;
|
orientationAlignedViewport.x = (float) renderer->viewport.y;
|
||||||
orientationAlignedViewport.y = (float) renderer->viewport.x;
|
orientationAlignedViewport.y = (float) renderer->viewport.x;
|
||||||
|
Loading…
Reference in New Issue
Block a user