src/video/windowsrt/SDL_winrtrenderer.cpp
changeset 8384 bc7a52629e1e
parent 8375 e33eb49b7f42
child 8399 1fa9dcfbeac5
     1.1 --- a/src/video/windowsrt/SDL_winrtrenderer.cpp	Tue Jan 08 22:50:29 2013 -0500
     1.2 +++ b/src/video/windowsrt/SDL_winrtrenderer.cpp	Tue Jan 08 23:11:22 2013 -0500
     1.3 @@ -11,7 +11,7 @@
     1.4  SDL_winrtrenderer::SDL_winrtrenderer() :
     1.5      m_mainTextureHelperSurface(NULL),
     1.6      m_loadingComplete(false),
     1.7 -	m_vertexCount(0)
     1.8 +    m_vertexCount(0)
     1.9  {
    1.10  }
    1.11  
    1.12 @@ -26,357 +26,357 @@
    1.13  // Initialize the Direct3D resources required to run.
    1.14  void SDL_winrtrenderer::Initialize(CoreWindow^ window)
    1.15  {
    1.16 -	m_window = window;
    1.17 -	
    1.18 -	CreateDeviceResources();
    1.19 -	CreateWindowSizeDependentResources();
    1.20 +    m_window = window;
    1.21 +    
    1.22 +    CreateDeviceResources();
    1.23 +    CreateWindowSizeDependentResources();
    1.24  }
    1.25  
    1.26  // Recreate all device resources and set them back to the current state.
    1.27  void SDL_winrtrenderer::HandleDeviceLost()
    1.28  {
    1.29 -	// Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
    1.30 -	m_windowBounds.Width = 0;
    1.31 -	m_windowBounds.Height = 0;
    1.32 -	m_swapChain = nullptr;
    1.33 +    // Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
    1.34 +    m_windowBounds.Width = 0;
    1.35 +    m_windowBounds.Height = 0;
    1.36 +    m_swapChain = nullptr;
    1.37  
    1.38 -	CreateDeviceResources();
    1.39 -	UpdateForWindowSizeChange();
    1.40 +    CreateDeviceResources();
    1.41 +    UpdateForWindowSizeChange();
    1.42  }
    1.43  
    1.44  // These are the resources that depend on the device.
    1.45  void SDL_winrtrenderer::CreateDeviceResources()
    1.46  {
    1.47 -	// This flag adds support for surfaces with a different color channel ordering
    1.48 -	// than the API default. It is required for compatibility with Direct2D.
    1.49 -	UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    1.50 +    // This flag adds support for surfaces with a different color channel ordering
    1.51 +    // than the API default. It is required for compatibility with Direct2D.
    1.52 +    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    1.53  
    1.54  #if defined(_DEBUG)
    1.55 -	// If the project is in a debug build, enable debugging via SDK Layers with this flag.
    1.56 -	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    1.57 +    // If the project is in a debug build, enable debugging via SDK Layers with this flag.
    1.58 +    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    1.59  #endif
    1.60  
    1.61 -	// This array defines the set of DirectX hardware feature levels this app will support.
    1.62 -	// Note the ordering should be preserved.
    1.63 -	// Don't forget to declare your application's minimum required feature level in its
    1.64 -	// description.  All applications are assumed to support 9.1 unless otherwise stated.
    1.65 -	D3D_FEATURE_LEVEL featureLevels[] = 
    1.66 -	{
    1.67 -		D3D_FEATURE_LEVEL_11_1,
    1.68 -		D3D_FEATURE_LEVEL_11_0,
    1.69 -		D3D_FEATURE_LEVEL_10_1,
    1.70 -		D3D_FEATURE_LEVEL_10_0,
    1.71 -		D3D_FEATURE_LEVEL_9_3,
    1.72 -		D3D_FEATURE_LEVEL_9_2,
    1.73 -		D3D_FEATURE_LEVEL_9_1
    1.74 -	};
    1.75 +    // This array defines the set of DirectX hardware feature levels this app will support.
    1.76 +    // Note the ordering should be preserved.
    1.77 +    // Don't forget to declare your application's minimum required feature level in its
    1.78 +    // description.  All applications are assumed to support 9.1 unless otherwise stated.
    1.79 +    D3D_FEATURE_LEVEL featureLevels[] = 
    1.80 +    {
    1.81 +        D3D_FEATURE_LEVEL_11_1,
    1.82 +        D3D_FEATURE_LEVEL_11_0,
    1.83 +        D3D_FEATURE_LEVEL_10_1,
    1.84 +        D3D_FEATURE_LEVEL_10_0,
    1.85 +        D3D_FEATURE_LEVEL_9_3,
    1.86 +        D3D_FEATURE_LEVEL_9_2,
    1.87 +        D3D_FEATURE_LEVEL_9_1
    1.88 +    };
    1.89  
    1.90 -	// Create the Direct3D 11 API device object and a corresponding context.
    1.91 -	ComPtr<ID3D11Device> device;
    1.92 -	ComPtr<ID3D11DeviceContext> context;
    1.93 -	DX::ThrowIfFailed(
    1.94 -		D3D11CreateDevice(
    1.95 -			nullptr, // Specify nullptr to use the default adapter.
    1.96 -			D3D_DRIVER_TYPE_HARDWARE,
    1.97 -			nullptr,
    1.98 -			creationFlags, // Set set debug and Direct2D compatibility flags.
    1.99 -			featureLevels, // List of feature levels this app can support.
   1.100 -			ARRAYSIZE(featureLevels),
   1.101 -			D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
   1.102 -			&device, // Returns the Direct3D device created.
   1.103 -			&m_featureLevel, // Returns feature level of device created.
   1.104 -			&context // Returns the device immediate context.
   1.105 -			)
   1.106 -		);
   1.107 +    // Create the Direct3D 11 API device object and a corresponding context.
   1.108 +    ComPtr<ID3D11Device> device;
   1.109 +    ComPtr<ID3D11DeviceContext> context;
   1.110 +    DX::ThrowIfFailed(
   1.111 +        D3D11CreateDevice(
   1.112 +            nullptr, // Specify nullptr to use the default adapter.
   1.113 +            D3D_DRIVER_TYPE_HARDWARE,
   1.114 +            nullptr,
   1.115 +            creationFlags, // Set set debug and Direct2D compatibility flags.
   1.116 +            featureLevels, // List of feature levels this app can support.
   1.117 +            ARRAYSIZE(featureLevels),
   1.118 +            D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
   1.119 +            &device, // Returns the Direct3D device created.
   1.120 +            &m_featureLevel, // Returns feature level of device created.
   1.121 +            &context // Returns the device immediate context.
   1.122 +            )
   1.123 +        );
   1.124  
   1.125 -	// Get the Direct3D 11.1 API device and context interfaces.
   1.126 -	DX::ThrowIfFailed(
   1.127 -		device.As(&m_d3dDevice)
   1.128 -		);
   1.129 +    // Get the Direct3D 11.1 API device and context interfaces.
   1.130 +    DX::ThrowIfFailed(
   1.131 +        device.As(&m_d3dDevice)
   1.132 +        );
   1.133  
   1.134 -	DX::ThrowIfFailed(
   1.135 -		context.As(&m_d3dContext)
   1.136 -		);
   1.137 +    DX::ThrowIfFailed(
   1.138 +        context.As(&m_d3dContext)
   1.139 +        );
   1.140  
   1.141      auto loadVSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimpleVertexShader.cso");
   1.142 -	auto loadPSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimplePixelShader.cso");
   1.143 +    auto loadPSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimplePixelShader.cso");
   1.144  
   1.145 -	auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
   1.146 -		DX::ThrowIfFailed(
   1.147 -			m_d3dDevice->CreateVertexShader(
   1.148 - 				fileData->Data,
   1.149 -				fileData->Length,
   1.150 -				nullptr,
   1.151 -				&m_vertexShader
   1.152 -				)
   1.153 -			);
   1.154 +    auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
   1.155 +        DX::ThrowIfFailed(
   1.156 +            m_d3dDevice->CreateVertexShader(
   1.157 +                fileData->Data,
   1.158 +                fileData->Length,
   1.159 +                nullptr,
   1.160 +                &m_vertexShader
   1.161 +                )
   1.162 +            );
   1.163  
   1.164 -		const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
   1.165 -		{
   1.166 -			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
   1.167 -			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   1.168 -		};
   1.169 +        const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
   1.170 +        {
   1.171 +            { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
   1.172 +            { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   1.173 +        };
   1.174  
   1.175 -		DX::ThrowIfFailed(
   1.176 -			m_d3dDevice->CreateInputLayout(
   1.177 -				vertexDesc,
   1.178 -				ARRAYSIZE(vertexDesc),
   1.179 -				fileData->Data,
   1.180 -				fileData->Length,
   1.181 -				&m_inputLayout
   1.182 -				)
   1.183 -			);
   1.184 -	});
   1.185 +        DX::ThrowIfFailed(
   1.186 +            m_d3dDevice->CreateInputLayout(
   1.187 +                vertexDesc,
   1.188 +                ARRAYSIZE(vertexDesc),
   1.189 +                fileData->Data,
   1.190 +                fileData->Length,
   1.191 +                &m_inputLayout
   1.192 +                )
   1.193 +            );
   1.194 +    });
   1.195  
   1.196 -	auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
   1.197 -		DX::ThrowIfFailed(
   1.198 -			m_d3dDevice->CreatePixelShader(
   1.199 -				fileData->Data,
   1.200 -				fileData->Length,
   1.201 -				nullptr,
   1.202 -				&m_pixelShader
   1.203 -				)
   1.204 -			);
   1.205 -	});
   1.206 +    auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
   1.207 +        DX::ThrowIfFailed(
   1.208 +            m_d3dDevice->CreatePixelShader(
   1.209 +                fileData->Data,
   1.210 +                fileData->Length,
   1.211 +                nullptr,
   1.212 +                &m_pixelShader
   1.213 +                )
   1.214 +            );
   1.215 +    });
   1.216  
   1.217 -	auto createVertexBuffer = (createPSTask && createVSTask).then([this] () {
   1.218 -		VertexPositionColor vertices[] = 
   1.219 -		{
   1.220 -			{XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 1.0f)},
   1.221 -			{XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 0.0f)},
   1.222 -			{XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
   1.223 -			{XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
   1.224 -		};
   1.225 +    auto createVertexBuffer = (createPSTask && createVSTask).then([this] () {
   1.226 +        VertexPositionColor vertices[] = 
   1.227 +        {
   1.228 +            {XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 1.0f)},
   1.229 +            {XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 0.0f)},
   1.230 +            {XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
   1.231 +            {XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
   1.232 +        };
   1.233  
   1.234 -		m_vertexCount = ARRAYSIZE(vertices);
   1.235 +        m_vertexCount = ARRAYSIZE(vertices);
   1.236  
   1.237 -		D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
   1.238 -		vertexBufferData.pSysMem = vertices;
   1.239 -		vertexBufferData.SysMemPitch = 0;
   1.240 -		vertexBufferData.SysMemSlicePitch = 0;
   1.241 -		CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
   1.242 -		DX::ThrowIfFailed(
   1.243 -			m_d3dDevice->CreateBuffer(
   1.244 -				&vertexBufferDesc,
   1.245 -				&vertexBufferData,
   1.246 -				&m_vertexBuffer
   1.247 -				)
   1.248 -			);
   1.249 -	});
   1.250 +        D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
   1.251 +        vertexBufferData.pSysMem = vertices;
   1.252 +        vertexBufferData.SysMemPitch = 0;
   1.253 +        vertexBufferData.SysMemSlicePitch = 0;
   1.254 +        CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
   1.255 +        DX::ThrowIfFailed(
   1.256 +            m_d3dDevice->CreateBuffer(
   1.257 +                &vertexBufferDesc,
   1.258 +                &vertexBufferData,
   1.259 +                &m_vertexBuffer
   1.260 +                )
   1.261 +            );
   1.262 +    });
   1.263  
   1.264      auto createMainSamplerTask = createVertexBuffer.then([this] () {
   1.265 -		D3D11_SAMPLER_DESC samplerDesc;
   1.266 -		samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
   1.267 -		samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.268 -		samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.269 -		samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.270 -		samplerDesc.MipLODBias = 0.0f;
   1.271 -		samplerDesc.MaxAnisotropy = 1;
   1.272 -		samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
   1.273 -		samplerDesc.BorderColor[0] = 0.0f;
   1.274 -		samplerDesc.BorderColor[1] = 0.0f;
   1.275 -		samplerDesc.BorderColor[2] = 0.0f;
   1.276 -		samplerDesc.BorderColor[3] = 0.0f;
   1.277 -		samplerDesc.MinLOD = 0.0f;
   1.278 -		samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
   1.279 -		DX::ThrowIfFailed(
   1.280 -			m_d3dDevice->CreateSamplerState(
   1.281 -				&samplerDesc,
   1.282 -				&m_mainSampler
   1.283 -				)
   1.284 -			);
   1.285 -	});
   1.286 +        D3D11_SAMPLER_DESC samplerDesc;
   1.287 +        samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
   1.288 +        samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.289 +        samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.290 +        samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
   1.291 +        samplerDesc.MipLODBias = 0.0f;
   1.292 +        samplerDesc.MaxAnisotropy = 1;
   1.293 +        samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
   1.294 +        samplerDesc.BorderColor[0] = 0.0f;
   1.295 +        samplerDesc.BorderColor[1] = 0.0f;
   1.296 +        samplerDesc.BorderColor[2] = 0.0f;
   1.297 +        samplerDesc.BorderColor[3] = 0.0f;
   1.298 +        samplerDesc.MinLOD = 0.0f;
   1.299 +        samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
   1.300 +        DX::ThrowIfFailed(
   1.301 +            m_d3dDevice->CreateSamplerState(
   1.302 +                &samplerDesc,
   1.303 +                &m_mainSampler
   1.304 +                )
   1.305 +            );
   1.306 +    });
   1.307  
   1.308 -	createMainSamplerTask.then([this] () {
   1.309 -		m_loadingComplete = true;
   1.310 -	});
   1.311 +    createMainSamplerTask.then([this] () {
   1.312 +        m_loadingComplete = true;
   1.313 +    });
   1.314  }
   1.315  
   1.316  // Allocate all memory resources that change on a window SizeChanged event.
   1.317  void SDL_winrtrenderer::CreateWindowSizeDependentResources()
   1.318  { 
   1.319 -	// Store the window bounds so the next time we get a SizeChanged event we can
   1.320 -	// avoid rebuilding everything if the size is identical.
   1.321 -	m_windowBounds = m_window->Bounds;
   1.322 +    // Store the window bounds so the next time we get a SizeChanged event we can
   1.323 +    // avoid rebuilding everything if the size is identical.
   1.324 +    m_windowBounds = m_window->Bounds;
   1.325  
   1.326 -	// Calculate the necessary swap chain and render target size in pixels.
   1.327 -	float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   1.328 -	float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
   1.329 +    // Calculate the necessary swap chain and render target size in pixels.
   1.330 +    float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   1.331 +    float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
   1.332  
   1.333 -	// The width and height of the swap chain must be based on the window's
   1.334 -	// landscape-oriented width and height. If the window is in a portrait
   1.335 -	// orientation, the dimensions must be reversed.
   1.336 -	m_orientation = DisplayProperties::CurrentOrientation;
   1.337 -	bool swapDimensions =
   1.338 -		m_orientation == DisplayOrientations::Portrait ||
   1.339 -		m_orientation == DisplayOrientations::PortraitFlipped;
   1.340 -	m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   1.341 -	m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
   1.342 +    // The width and height of the swap chain must be based on the window's
   1.343 +    // landscape-oriented width and height. If the window is in a portrait
   1.344 +    // orientation, the dimensions must be reversed.
   1.345 +    m_orientation = DisplayProperties::CurrentOrientation;
   1.346 +    bool swapDimensions =
   1.347 +        m_orientation == DisplayOrientations::Portrait ||
   1.348 +        m_orientation == DisplayOrientations::PortraitFlipped;
   1.349 +    m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   1.350 +    m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
   1.351  
   1.352 -	if(m_swapChain != nullptr)
   1.353 -	{
   1.354 -		// If the swap chain already exists, resize it.
   1.355 -		DX::ThrowIfFailed(
   1.356 -			m_swapChain->ResizeBuffers(
   1.357 -				2, // Double-buffered swap chain.
   1.358 -				static_cast<UINT>(m_renderTargetSize.Width),
   1.359 -				static_cast<UINT>(m_renderTargetSize.Height),
   1.360 -				DXGI_FORMAT_B8G8R8A8_UNORM,
   1.361 -				0
   1.362 -				)
   1.363 -			);
   1.364 -	}
   1.365 -	else
   1.366 -	{
   1.367 -		// Otherwise, create a new one using the same adapter as the existing Direct3D device.
   1.368 -		DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
   1.369 -		swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
   1.370 -		swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
   1.371 -		swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
   1.372 -		swapChainDesc.Stereo = false;
   1.373 -		swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
   1.374 -		swapChainDesc.SampleDesc.Quality = 0;
   1.375 -		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
   1.376 -		swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
   1.377 -		swapChainDesc.Scaling = DXGI_SCALING_NONE;
   1.378 -		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
   1.379 -		swapChainDesc.Flags = 0;
   1.380 +    if(m_swapChain != nullptr)
   1.381 +    {
   1.382 +        // If the swap chain already exists, resize it.
   1.383 +        DX::ThrowIfFailed(
   1.384 +            m_swapChain->ResizeBuffers(
   1.385 +                2, // Double-buffered swap chain.
   1.386 +                static_cast<UINT>(m_renderTargetSize.Width),
   1.387 +                static_cast<UINT>(m_renderTargetSize.Height),
   1.388 +                DXGI_FORMAT_B8G8R8A8_UNORM,
   1.389 +                0
   1.390 +                )
   1.391 +            );
   1.392 +    }
   1.393 +    else
   1.394 +    {
   1.395 +        // Otherwise, create a new one using the same adapter as the existing Direct3D device.
   1.396 +        DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
   1.397 +        swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
   1.398 +        swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
   1.399 +        swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
   1.400 +        swapChainDesc.Stereo = false;
   1.401 +        swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
   1.402 +        swapChainDesc.SampleDesc.Quality = 0;
   1.403 +        swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
   1.404 +        swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
   1.405 +        swapChainDesc.Scaling = DXGI_SCALING_NONE;
   1.406 +        swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
   1.407 +        swapChainDesc.Flags = 0;
   1.408  
   1.409 -		ComPtr<IDXGIDevice1>  dxgiDevice;
   1.410 -		DX::ThrowIfFailed(
   1.411 -			m_d3dDevice.As(&dxgiDevice)
   1.412 -			);
   1.413 +        ComPtr<IDXGIDevice1>  dxgiDevice;
   1.414 +        DX::ThrowIfFailed(
   1.415 +            m_d3dDevice.As(&dxgiDevice)
   1.416 +            );
   1.417  
   1.418 -		ComPtr<IDXGIAdapter> dxgiAdapter;
   1.419 -		DX::ThrowIfFailed(
   1.420 -			dxgiDevice->GetAdapter(&dxgiAdapter)
   1.421 -			);
   1.422 +        ComPtr<IDXGIAdapter> dxgiAdapter;
   1.423 +        DX::ThrowIfFailed(
   1.424 +            dxgiDevice->GetAdapter(&dxgiAdapter)
   1.425 +            );
   1.426  
   1.427 -		ComPtr<IDXGIFactory2> dxgiFactory;
   1.428 -		DX::ThrowIfFailed(
   1.429 -			dxgiAdapter->GetParent(
   1.430 -				__uuidof(IDXGIFactory2), 
   1.431 -				&dxgiFactory
   1.432 -				)
   1.433 -			);
   1.434 +        ComPtr<IDXGIFactory2> dxgiFactory;
   1.435 +        DX::ThrowIfFailed(
   1.436 +            dxgiAdapter->GetParent(
   1.437 +                __uuidof(IDXGIFactory2), 
   1.438 +                &dxgiFactory
   1.439 +                )
   1.440 +            );
   1.441  
   1.442 -		Windows::UI::Core::CoreWindow^ window = m_window.Get();
   1.443 -		DX::ThrowIfFailed(
   1.444 -			dxgiFactory->CreateSwapChainForCoreWindow(
   1.445 -				m_d3dDevice.Get(),
   1.446 -				reinterpret_cast<IUnknown*>(window),
   1.447 -				&swapChainDesc,
   1.448 -				nullptr, // Allow on all displays.
   1.449 -				&m_swapChain
   1.450 -				)
   1.451 -			);
   1.452 -			
   1.453 -		// Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
   1.454 -		// ensures that the application will only render after each VSync, minimizing power consumption.
   1.455 -		DX::ThrowIfFailed(
   1.456 -			dxgiDevice->SetMaximumFrameLatency(1)
   1.457 -			);
   1.458 -	}
   1.459 -	
   1.460 -	// Set the proper orientation for the swap chain, and generate the
   1.461 -	// 3D matrix transformation for rendering to the rotated swap chain.
   1.462 -	DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
   1.463 -	switch (m_orientation)
   1.464 -	{
   1.465 -		case DisplayOrientations::Landscape:
   1.466 -			rotation = DXGI_MODE_ROTATION_IDENTITY;
   1.467 -			m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
   1.468 -				1.0f, 0.0f, 0.0f, 0.0f,
   1.469 -				0.0f, 1.0f, 0.0f, 0.0f,
   1.470 -				0.0f, 0.0f, 1.0f, 0.0f,
   1.471 -				0.0f, 0.0f, 0.0f, 1.0f
   1.472 -				);
   1.473 -			break;
   1.474 +        Windows::UI::Core::CoreWindow^ window = m_window.Get();
   1.475 +        DX::ThrowIfFailed(
   1.476 +            dxgiFactory->CreateSwapChainForCoreWindow(
   1.477 +                m_d3dDevice.Get(),
   1.478 +                reinterpret_cast<IUnknown*>(window),
   1.479 +                &swapChainDesc,
   1.480 +                nullptr, // Allow on all displays.
   1.481 +                &m_swapChain
   1.482 +                )
   1.483 +            );
   1.484 +            
   1.485 +        // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
   1.486 +        // ensures that the application will only render after each VSync, minimizing power consumption.
   1.487 +        DX::ThrowIfFailed(
   1.488 +            dxgiDevice->SetMaximumFrameLatency(1)
   1.489 +            );
   1.490 +    }
   1.491 +    
   1.492 +    // Set the proper orientation for the swap chain, and generate the
   1.493 +    // 3D matrix transformation for rendering to the rotated swap chain.
   1.494 +    DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
   1.495 +    switch (m_orientation)
   1.496 +    {
   1.497 +        case DisplayOrientations::Landscape:
   1.498 +            rotation = DXGI_MODE_ROTATION_IDENTITY;
   1.499 +            m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
   1.500 +                1.0f, 0.0f, 0.0f, 0.0f,
   1.501 +                0.0f, 1.0f, 0.0f, 0.0f,
   1.502 +                0.0f, 0.0f, 1.0f, 0.0f,
   1.503 +                0.0f, 0.0f, 0.0f, 1.0f
   1.504 +                );
   1.505 +            break;
   1.506  
   1.507 -		case DisplayOrientations::Portrait:
   1.508 -			rotation = DXGI_MODE_ROTATION_ROTATE270;
   1.509 -			m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
   1.510 -				0.0f, 1.0f, 0.0f, 0.0f,
   1.511 -				-1.0f, 0.0f, 0.0f, 0.0f,
   1.512 -				0.0f, 0.0f, 1.0f, 0.0f,
   1.513 -				0.0f, 0.0f, 0.0f, 1.0f
   1.514 -				);
   1.515 -			break;
   1.516 +        case DisplayOrientations::Portrait:
   1.517 +            rotation = DXGI_MODE_ROTATION_ROTATE270;
   1.518 +            m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
   1.519 +                0.0f, 1.0f, 0.0f, 0.0f,
   1.520 +                -1.0f, 0.0f, 0.0f, 0.0f,
   1.521 +                0.0f, 0.0f, 1.0f, 0.0f,
   1.522 +                0.0f, 0.0f, 0.0f, 1.0f
   1.523 +                );
   1.524 +            break;
   1.525  
   1.526 -		case DisplayOrientations::LandscapeFlipped:
   1.527 -			rotation = DXGI_MODE_ROTATION_ROTATE180;
   1.528 -			m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
   1.529 -				-1.0f, 0.0f, 0.0f, 0.0f,
   1.530 -				0.0f, -1.0f, 0.0f, 0.0f,
   1.531 -				0.0f, 0.0f, 1.0f, 0.0f,
   1.532 -				0.0f, 0.0f, 0.0f, 1.0f
   1.533 -				);
   1.534 -			break;
   1.535 +        case DisplayOrientations::LandscapeFlipped:
   1.536 +            rotation = DXGI_MODE_ROTATION_ROTATE180;
   1.537 +            m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
   1.538 +                -1.0f, 0.0f, 0.0f, 0.0f,
   1.539 +                0.0f, -1.0f, 0.0f, 0.0f,
   1.540 +                0.0f, 0.0f, 1.0f, 0.0f,
   1.541 +                0.0f, 0.0f, 0.0f, 1.0f
   1.542 +                );
   1.543 +            break;
   1.544  
   1.545 -		case DisplayOrientations::PortraitFlipped:
   1.546 -			rotation = DXGI_MODE_ROTATION_ROTATE90;
   1.547 -			m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
   1.548 -				0.0f, -1.0f, 0.0f, 0.0f,
   1.549 -				1.0f, 0.0f, 0.0f, 0.0f,
   1.550 -				0.0f, 0.0f, 1.0f, 0.0f,
   1.551 -				0.0f, 0.0f, 0.0f, 1.0f
   1.552 -				);
   1.553 -			break;
   1.554 +        case DisplayOrientations::PortraitFlipped:
   1.555 +            rotation = DXGI_MODE_ROTATION_ROTATE90;
   1.556 +            m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
   1.557 +                0.0f, -1.0f, 0.0f, 0.0f,
   1.558 +                1.0f, 0.0f, 0.0f, 0.0f,
   1.559 +                0.0f, 0.0f, 1.0f, 0.0f,
   1.560 +                0.0f, 0.0f, 0.0f, 1.0f
   1.561 +                );
   1.562 +            break;
   1.563  
   1.564 -		default:
   1.565 -			throw ref new Platform::FailureException();
   1.566 -	}
   1.567 +        default:
   1.568 +            throw ref new Platform::FailureException();
   1.569 +    }
   1.570  
   1.571 -	DX::ThrowIfFailed(
   1.572 -		m_swapChain->SetRotation(rotation)
   1.573 -		);
   1.574 +    DX::ThrowIfFailed(
   1.575 +        m_swapChain->SetRotation(rotation)
   1.576 +        );
   1.577  
   1.578 -	// Create a render target view of the swap chain back buffer.
   1.579 -	ComPtr<ID3D11Texture2D> backBuffer;
   1.580 -	DX::ThrowIfFailed(
   1.581 -		m_swapChain->GetBuffer(
   1.582 -			0,
   1.583 -			__uuidof(ID3D11Texture2D),
   1.584 -			&backBuffer
   1.585 -			)
   1.586 -		);
   1.587 +    // Create a render target view of the swap chain back buffer.
   1.588 +    ComPtr<ID3D11Texture2D> backBuffer;
   1.589 +    DX::ThrowIfFailed(
   1.590 +        m_swapChain->GetBuffer(
   1.591 +            0,
   1.592 +            __uuidof(ID3D11Texture2D),
   1.593 +            &backBuffer
   1.594 +            )
   1.595 +        );
   1.596  
   1.597 -	DX::ThrowIfFailed(
   1.598 -		m_d3dDevice->CreateRenderTargetView(
   1.599 -			backBuffer.Get(),
   1.600 -			nullptr,
   1.601 -			&m_renderTargetView
   1.602 -			)
   1.603 -		);
   1.604 +    DX::ThrowIfFailed(
   1.605 +        m_d3dDevice->CreateRenderTargetView(
   1.606 +            backBuffer.Get(),
   1.607 +            nullptr,
   1.608 +            &m_renderTargetView
   1.609 +            )
   1.610 +        );
   1.611  
   1.612 -	// Create a depth stencil view.
   1.613 -	CD3D11_TEXTURE2D_DESC depthStencilDesc(
   1.614 -		DXGI_FORMAT_D24_UNORM_S8_UINT, 
   1.615 -		static_cast<UINT>(m_renderTargetSize.Width),
   1.616 -		static_cast<UINT>(m_renderTargetSize.Height),
   1.617 -		1,
   1.618 -		1,
   1.619 -		D3D11_BIND_DEPTH_STENCIL
   1.620 -		);
   1.621 +    // Create a depth stencil view.
   1.622 +    CD3D11_TEXTURE2D_DESC depthStencilDesc(
   1.623 +        DXGI_FORMAT_D24_UNORM_S8_UINT, 
   1.624 +        static_cast<UINT>(m_renderTargetSize.Width),
   1.625 +        static_cast<UINT>(m_renderTargetSize.Height),
   1.626 +        1,
   1.627 +        1,
   1.628 +        D3D11_BIND_DEPTH_STENCIL
   1.629 +        );
   1.630  
   1.631 -	ComPtr<ID3D11Texture2D> depthStencil;
   1.632 -	DX::ThrowIfFailed(
   1.633 -		m_d3dDevice->CreateTexture2D(
   1.634 -			&depthStencilDesc,
   1.635 -			nullptr,
   1.636 -			&depthStencil
   1.637 -			)
   1.638 -		);
   1.639 +    ComPtr<ID3D11Texture2D> depthStencil;
   1.640 +    DX::ThrowIfFailed(
   1.641 +        m_d3dDevice->CreateTexture2D(
   1.642 +            &depthStencilDesc,
   1.643 +            nullptr,
   1.644 +            &depthStencil
   1.645 +            )
   1.646 +        );
   1.647  
   1.648 -	// Set the rendering viewport to target the entire window.
   1.649 -	CD3D11_VIEWPORT viewport(
   1.650 -		0.0f,
   1.651 -		0.0f,
   1.652 -		m_renderTargetSize.Width,
   1.653 -		m_renderTargetSize.Height
   1.654 -		);
   1.655 +    // Set the rendering viewport to target the entire window.
   1.656 +    CD3D11_VIEWPORT viewport(
   1.657 +        0.0f,
   1.658 +        0.0f,
   1.659 +        m_renderTargetSize.Width,
   1.660 +        m_renderTargetSize.Height
   1.661 +        );
   1.662  
   1.663 -	m_d3dContext->RSSetViewports(1, &viewport);
   1.664 +    m_d3dContext->RSSetViewports(1, &viewport);
   1.665  }
   1.666  
   1.667  void SDL_winrtrenderer::ResizeMainTexture(int w, int h)
   1.668 @@ -384,17 +384,17 @@
   1.669      const int pixelSizeInBytes = 4;
   1.670  
   1.671      D3D11_TEXTURE2D_DESC textureDesc = {0};
   1.672 -	textureDesc.Width = w;
   1.673 -	textureDesc.Height = h;
   1.674 -	textureDesc.MipLevels = 1;
   1.675 -	textureDesc.ArraySize = 1;
   1.676 -	textureDesc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
   1.677 -	textureDesc.SampleDesc.Count = 1;
   1.678 -	textureDesc.SampleDesc.Quality = 0;
   1.679 -	textureDesc.Usage = D3D11_USAGE_DYNAMIC;
   1.680 -	textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
   1.681 -	textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   1.682 -	textureDesc.MiscFlags = 0;
   1.683 +    textureDesc.Width = w;
   1.684 +    textureDesc.Height = h;
   1.685 +    textureDesc.MipLevels = 1;
   1.686 +    textureDesc.ArraySize = 1;
   1.687 +    textureDesc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
   1.688 +    textureDesc.SampleDesc.Count = 1;
   1.689 +    textureDesc.SampleDesc.Quality = 0;
   1.690 +    textureDesc.Usage = D3D11_USAGE_DYNAMIC;
   1.691 +    textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
   1.692 +    textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   1.693 +    textureDesc.MiscFlags = 0;
   1.694  
   1.695      const int numPixels = textureDesc.Width * textureDesc.Height;
   1.696      std::vector<uint8> initialTexturePixels(numPixels * pixelSizeInBytes, 0x00);
   1.697 @@ -407,17 +407,17 @@
   1.698      //    initialTexturePixels[i+3] = 0xff;
   1.699      //}
   1.700  
   1.701 -	D3D11_SUBRESOURCE_DATA initialTextureData = {0};
   1.702 -	initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
   1.703 -	initialTextureData.SysMemPitch = textureDesc.Width * pixelSizeInBytes;
   1.704 -	initialTextureData.SysMemSlicePitch = numPixels * pixelSizeInBytes;
   1.705 -	DX::ThrowIfFailed(
   1.706 -		m_d3dDevice->CreateTexture2D(
   1.707 -			&textureDesc,
   1.708 -			&initialTextureData,
   1.709 -			&m_mainTexture
   1.710 -			)
   1.711 -		);
   1.712 +    D3D11_SUBRESOURCE_DATA initialTextureData = {0};
   1.713 +    initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
   1.714 +    initialTextureData.SysMemPitch = textureDesc.Width * pixelSizeInBytes;
   1.715 +    initialTextureData.SysMemSlicePitch = numPixels * pixelSizeInBytes;
   1.716 +    DX::ThrowIfFailed(
   1.717 +        m_d3dDevice->CreateTexture2D(
   1.718 +            &textureDesc,
   1.719 +            &initialTextureData,
   1.720 +            &m_mainTexture
   1.721 +            )
   1.722 +        );
   1.723  
   1.724      if (m_mainTextureHelperSurface) {
   1.725          SDL_FreeSurface(m_mainTextureHelperSurface);
   1.726 @@ -433,152 +433,152 @@
   1.727          DX::ThrowIfFailed(E_FAIL);  // TODO, WinRT: generate a better error here, taking into account who's calling this function.
   1.728      }
   1.729  
   1.730 -	D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
   1.731 -	resourceViewDesc.Format = textureDesc.Format;
   1.732 -	resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
   1.733 -	resourceViewDesc.Texture2D.MostDetailedMip = 0;
   1.734 -	resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
   1.735 -	DX::ThrowIfFailed(
   1.736 -		m_d3dDevice->CreateShaderResourceView(
   1.737 -			m_mainTexture.Get(),
   1.738 -			&resourceViewDesc,
   1.739 -			&m_mainTextureResourceView)
   1.740 -		);
   1.741 +    D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
   1.742 +    resourceViewDesc.Format = textureDesc.Format;
   1.743 +    resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
   1.744 +    resourceViewDesc.Texture2D.MostDetailedMip = 0;
   1.745 +    resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
   1.746 +    DX::ThrowIfFailed(
   1.747 +        m_d3dDevice->CreateShaderResourceView(
   1.748 +            m_mainTexture.Get(),
   1.749 +            &resourceViewDesc,
   1.750 +            &m_mainTextureResourceView)
   1.751 +        );
   1.752  }
   1.753  
   1.754  // This method is called in the event handler for the SizeChanged event.
   1.755  void SDL_winrtrenderer::UpdateForWindowSizeChange()
   1.756  {
   1.757 -	if (m_window->Bounds.Width  != m_windowBounds.Width ||
   1.758 -		m_window->Bounds.Height != m_windowBounds.Height ||
   1.759 -		m_orientation != DisplayProperties::CurrentOrientation)
   1.760 -	{
   1.761 -		ID3D11RenderTargetView* nullViews[] = {nullptr};
   1.762 -		m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
   1.763 -		m_renderTargetView = nullptr;
   1.764 -		m_d3dContext->Flush();
   1.765 -		CreateWindowSizeDependentResources();
   1.766 -	}
   1.767 +    if (m_window->Bounds.Width  != m_windowBounds.Width ||
   1.768 +        m_window->Bounds.Height != m_windowBounds.Height ||
   1.769 +        m_orientation != DisplayProperties::CurrentOrientation)
   1.770 +    {
   1.771 +        ID3D11RenderTargetView* nullViews[] = {nullptr};
   1.772 +        m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
   1.773 +        m_renderTargetView = nullptr;
   1.774 +        m_d3dContext->Flush();
   1.775 +        CreateWindowSizeDependentResources();
   1.776 +    }
   1.777  }
   1.778  
   1.779  void SDL_winrtrenderer::Render(SDL_Surface * surface, SDL_Rect * rects, int numrects)
   1.780  {
   1.781 -	const float blackColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
   1.782 -	m_d3dContext->ClearRenderTargetView(
   1.783 -		m_renderTargetView.Get(),
   1.784 -		blackColor
   1.785 -		);
   1.786 +    const float blackColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
   1.787 +    m_d3dContext->ClearRenderTargetView(
   1.788 +        m_renderTargetView.Get(),
   1.789 +        blackColor
   1.790 +        );
   1.791  
   1.792 -	// Only draw the screen once it is loaded (some loading is asynchronous).
   1.793 -	if (!m_loadingComplete)
   1.794 -	{
   1.795 -		return;
   1.796 -	}
   1.797 +    // Only draw the screen once it is loaded (some loading is asynchronous).
   1.798 +    if (!m_loadingComplete)
   1.799 +    {
   1.800 +        return;
   1.801 +    }
   1.802      if (!m_mainTextureResourceView)
   1.803      {
   1.804          return;
   1.805      }
   1.806  
   1.807 -	// Update the main texture (for SDL usage).  Start by mapping the SDL
   1.808 +    // Update the main texture (for SDL usage).  Start by mapping the SDL
   1.809      // window's main texture to CPU-accessible memory:
   1.810 -	D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
   1.811 -	DX::ThrowIfFailed(
   1.812 -		m_d3dContext->Map(
   1.813 -			m_mainTexture.Get(),
   1.814 -			0,
   1.815 -			D3D11_MAP_WRITE_DISCARD,
   1.816 -			0,
   1.817 -			&textureMemory)
   1.818 -		);
   1.819 +    D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
   1.820 +    DX::ThrowIfFailed(
   1.821 +        m_d3dContext->Map(
   1.822 +            m_mainTexture.Get(),
   1.823 +            0,
   1.824 +            D3D11_MAP_WRITE_DISCARD,
   1.825 +            0,
   1.826 +            &textureMemory)
   1.827 +        );
   1.828  
   1.829      // Copy pixel data to the locked texture's memory:
   1.830      m_mainTextureHelperSurface->pixels = textureMemory.pData;
   1.831      m_mainTextureHelperSurface->pitch = textureMemory.RowPitch;
   1.832      SDL_BlitSurface(surface, NULL, m_mainTextureHelperSurface, NULL);
   1.833 -	// TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
   1.834 +    // TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
   1.835  
   1.836      // Clean up a bit, then commit the texture's memory back to Direct3D:
   1.837      m_mainTextureHelperSurface->pixels = NULL;
   1.838      m_mainTextureHelperSurface->pitch = 0;
   1.839 -	m_d3dContext->Unmap(
   1.840 -		m_mainTexture.Get(),
   1.841 -		0);
   1.842 +    m_d3dContext->Unmap(
   1.843 +        m_mainTexture.Get(),
   1.844 +        0);
   1.845  
   1.846 -	m_d3dContext->OMSetRenderTargets(
   1.847 -		1,
   1.848 -		m_renderTargetView.GetAddressOf(),
   1.849 -		nullptr
   1.850 -		);
   1.851 +    m_d3dContext->OMSetRenderTargets(
   1.852 +        1,
   1.853 +        m_renderTargetView.GetAddressOf(),
   1.854 +        nullptr
   1.855 +        );
   1.856  
   1.857 -	UINT stride = sizeof(VertexPositionColor);
   1.858 -	UINT offset = 0;
   1.859 -	m_d3dContext->IASetVertexBuffers(
   1.860 -		0,
   1.861 -		1,
   1.862 -		m_vertexBuffer.GetAddressOf(),
   1.863 -		&stride,
   1.864 -		&offset
   1.865 -		);
   1.866 +    UINT stride = sizeof(VertexPositionColor);
   1.867 +    UINT offset = 0;
   1.868 +    m_d3dContext->IASetVertexBuffers(
   1.869 +        0,
   1.870 +        1,
   1.871 +        m_vertexBuffer.GetAddressOf(),
   1.872 +        &stride,
   1.873 +        &offset
   1.874 +        );
   1.875  
   1.876 -	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
   1.877 +    m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
   1.878  
   1.879 -	m_d3dContext->IASetInputLayout(m_inputLayout.Get());
   1.880 +    m_d3dContext->IASetInputLayout(m_inputLayout.Get());
   1.881  
   1.882 -	m_d3dContext->VSSetShader(
   1.883 -		m_vertexShader.Get(),
   1.884 -		nullptr,
   1.885 -		0
   1.886 -		);
   1.887 +    m_d3dContext->VSSetShader(
   1.888 +        m_vertexShader.Get(),
   1.889 +        nullptr,
   1.890 +        0
   1.891 +        );
   1.892  
   1.893 -	m_d3dContext->PSSetShader(
   1.894 -		m_pixelShader.Get(),
   1.895 -		nullptr,
   1.896 -		0
   1.897 -		);
   1.898 +    m_d3dContext->PSSetShader(
   1.899 +        m_pixelShader.Get(),
   1.900 +        nullptr,
   1.901 +        0
   1.902 +        );
   1.903  
   1.904 -	m_d3dContext->PSSetShaderResources(0, 1, m_mainTextureResourceView.GetAddressOf());
   1.905 +    m_d3dContext->PSSetShaderResources(0, 1, m_mainTextureResourceView.GetAddressOf());
   1.906  
   1.907 -	m_d3dContext->PSSetSamplers(0, 1, m_mainSampler.GetAddressOf());
   1.908 +    m_d3dContext->PSSetSamplers(0, 1, m_mainSampler.GetAddressOf());
   1.909  
   1.910 -	m_d3dContext->Draw(4, 0);
   1.911 +    m_d3dContext->Draw(4, 0);
   1.912  }
   1.913  
   1.914  // Method to deliver the final image to the display.
   1.915  void SDL_winrtrenderer::Present()
   1.916  {
   1.917 -	// The application may optionally specify "dirty" or "scroll"
   1.918 -	// rects to improve efficiency in certain scenarios.
   1.919 -	DXGI_PRESENT_PARAMETERS parameters = {0};
   1.920 -	parameters.DirtyRectsCount = 0;
   1.921 -	parameters.pDirtyRects = nullptr;
   1.922 -	parameters.pScrollRect = nullptr;
   1.923 -	parameters.pScrollOffset = nullptr;
   1.924 -	
   1.925 -	// The first argument instructs DXGI to block until VSync, putting the application
   1.926 -	// to sleep until the next VSync. This ensures we don't waste any cycles rendering
   1.927 -	// frames that will never be displayed to the screen.
   1.928 -	HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
   1.929 +    // The application may optionally specify "dirty" or "scroll"
   1.930 +    // rects to improve efficiency in certain scenarios.
   1.931 +    DXGI_PRESENT_PARAMETERS parameters = {0};
   1.932 +    parameters.DirtyRectsCount = 0;
   1.933 +    parameters.pDirtyRects = nullptr;
   1.934 +    parameters.pScrollRect = nullptr;
   1.935 +    parameters.pScrollOffset = nullptr;
   1.936 +    
   1.937 +    // The first argument instructs DXGI to block until VSync, putting the application
   1.938 +    // to sleep until the next VSync. This ensures we don't waste any cycles rendering
   1.939 +    // frames that will never be displayed to the screen.
   1.940 +    HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
   1.941  
   1.942 -	// Discard the contents of the render target.
   1.943 -	// This is a valid operation only when the existing contents will be entirely
   1.944 -	// overwritten. If dirty or scroll rects are used, this call should be removed.
   1.945 -	m_d3dContext->DiscardView(m_renderTargetView.Get());
   1.946 +    // Discard the contents of the render target.
   1.947 +    // This is a valid operation only when the existing contents will be entirely
   1.948 +    // overwritten. If dirty or scroll rects are used, this call should be removed.
   1.949 +    m_d3dContext->DiscardView(m_renderTargetView.Get());
   1.950  
   1.951 -	// If the device was removed either by a disconnect or a driver upgrade, we 
   1.952 -	// must recreate all device resources.
   1.953 -	if (hr == DXGI_ERROR_DEVICE_REMOVED)
   1.954 -	{
   1.955 -		HandleDeviceLost();
   1.956 -	}
   1.957 -	else
   1.958 -	{
   1.959 -		DX::ThrowIfFailed(hr);
   1.960 -	}
   1.961 +    // If the device was removed either by a disconnect or a driver upgrade, we 
   1.962 +    // must recreate all device resources.
   1.963 +    if (hr == DXGI_ERROR_DEVICE_REMOVED)
   1.964 +    {
   1.965 +        HandleDeviceLost();
   1.966 +    }
   1.967 +    else
   1.968 +    {
   1.969 +        DX::ThrowIfFailed(hr);
   1.970 +    }
   1.971  }
   1.972  
   1.973  // Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
   1.974  float SDL_winrtrenderer::ConvertDipsToPixels(float dips)
   1.975  {
   1.976 -	static const float dipsPerInch = 96.0f;
   1.977 -	return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
   1.978 +    static const float dipsPerInch = 96.0f;
   1.979 +    return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
   1.980  }