WinRT: another device-rotation and rendering fix

This commit is contained in:
David Ludwig 2013-02-19 22:07:07 -05:00
parent 4a906d9edf
commit 0cc80148f4
2 changed files with 37 additions and 2 deletions

View file

@ -975,6 +975,9 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
XMMatrixTranslation(-1, -1, 0),
XMMatrixRotationX(XM_PI)
)));
#if 0
data->vertexShaderConstantsData.view = XMMatrixIdentity();
#endif
//
// Update the Direct3D viewport, which seems to be aligned to the
@ -1152,14 +1155,15 @@ D3D11_RenderFillRects(SDL_Renderer * renderer,
#if 0
// Set up a test pattern:
SDL_FRect rects[] = {
SDL_FRect _rects[] = {
{-1.1f, 1.1f, 1.1f, -1.1f},
{-1.0f, 1.0f, 1.0f, -1.0f}, // red
{0.0f, 1.0f, 1.0f, -1.0f}, // green
{-1.0f, 0.0f, 1.0f, -1.0f}, // blue
{0.0f, 0.0f, 1.0f, -1.0f} // white
};
count = sizeof(rects) / sizeof(SDL_FRect);
count = sizeof(_rects) / sizeof(SDL_FRect);
#define rects _rects
#endif
for (int i = 0; i < count; ++i) {

View file

@ -12,6 +12,8 @@ extern "C" {
#include "../../events/scancodes_windows.h"
#include "SDL_events.h"
#include "SDL_log.h"
#include "SDL_render.h"
#include "../../render/SDL_sysrender.h"
}
#include <string>
@ -168,6 +170,30 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
m_sdlWindowData->sdlWindow->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
// HACK, Feb 19, 2013: SDL_WINDOWEVENT_RESIZED events, when sent,
// will attempt to fix the values of the main window's renderer's
// viewport. While this can be good, it does appear to be buggy,
// and can cause a fullscreen viewport to become corrupted. This
// behavior was noticed on a Surface RT while rotating the device
// from landscape to portrait. Oddly enough, this did not occur
// in the Windows Simulator.
//
// Backing up, then restoring, the main renderer's 'resized' flag
// seems to fix fullscreen viewport problems when rotating a
// Windows device.
//
// Commencing hack in 3... 2... 1...
SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
// For now, limit the hack to when the Direct3D 11.1 is getting used:
const bool usingD3D11Renderer = \
(rendererForMainWindow != NULL) &&
(SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
SDL_bool wasD3D11RendererResized = SDL_FALSE;
if (usingD3D11Renderer) {
wasD3D11RendererResized = rendererForMainWindow->resized;
}
// Send the window-resize event to the rest of SDL, and to apps:
const int windowWidth = (int) ceil(args->Size.Width);
const int windowHeight = (int) ceil(args->Size.Height);
SDL_SendWindowEvent(
@ -175,6 +201,11 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
SDL_WINDOWEVENT_RESIZED,
windowWidth,
windowHeight);
// Viewport hack, part two:
if (usingD3D11Renderer) {
rendererForMainWindow->resized = wasD3D11RendererResized;
}
}
}