WinRT: converted tabs to spaces in src/video/windowsrt/*
authorDavid Ludwig <dludwig@pobox.com>
Tue, 08 Jan 2013 23:11:22 -0500
changeset 8384bc7a52629e1e
parent 8383 1f415392ccf0
child 8385 e954dfbf2ecc
WinRT: converted tabs to spaces in src/video/windowsrt/*
src/video/windowsrt/DirectXHelper.h
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtrenderer.cpp
src/video/windowsrt/SDL_winrtrenderer.h
src/video/windowsrt/SimplePixelShader.hlsl
src/video/windowsrt/SimpleVertexShader.hlsl
     1.1 --- a/src/video/windowsrt/DirectXHelper.h	Tue Jan 08 22:50:29 2013 -0500
     1.2 +++ b/src/video/windowsrt/DirectXHelper.h	Tue Jan 08 23:11:22 2013 -0500
     1.3 @@ -6,31 +6,31 @@
     1.4  
     1.5  namespace DX
     1.6  {
     1.7 -	inline void ThrowIfFailed(HRESULT hr)
     1.8 -	{
     1.9 -		if (FAILED(hr))
    1.10 -		{
    1.11 -			// Set a breakpoint on this line to catch Win32 API errors.
    1.12 -			throw Platform::Exception::CreateException(hr);
    1.13 -		}
    1.14 -	}
    1.15 +    inline void ThrowIfFailed(HRESULT hr)
    1.16 +    {
    1.17 +        if (FAILED(hr))
    1.18 +        {
    1.19 +            // Set a breakpoint on this line to catch Win32 API errors.
    1.20 +            throw Platform::Exception::CreateException(hr);
    1.21 +        }
    1.22 +    }
    1.23  
    1.24 -	// Function that reads from a binary file asynchronously.
    1.25 -	inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
    1.26 -	{
    1.27 -		using namespace Windows::Storage;
    1.28 -		using namespace Concurrency;
    1.29 -		
    1.30 -		auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
    1.31 -		
    1.32 -		return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file) 
    1.33 -		{
    1.34 -			return FileIO::ReadBufferAsync(file);
    1.35 -		}).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^ 
    1.36 -		{
    1.37 -			auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
    1.38 -			Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
    1.39 -			return fileData;
    1.40 -		});
    1.41 -	}
    1.42 +    // Function that reads from a binary file asynchronously.
    1.43 +    inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
    1.44 +    {
    1.45 +        using namespace Windows::Storage;
    1.46 +        using namespace Concurrency;
    1.47 +        
    1.48 +        auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
    1.49 +        
    1.50 +        return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file) 
    1.51 +        {
    1.52 +            return FileIO::ReadBufferAsync(file);
    1.53 +        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^ 
    1.54 +        {
    1.55 +            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
    1.56 +            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
    1.57 +            return fileData;
    1.58 +        });
    1.59 +    }
    1.60  }
     2.1 --- a/src/video/windowsrt/SDL_WinRTApp.cpp	Tue Jan 08 22:50:29 2013 -0500
     2.2 +++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Tue Jan 08 23:11:22 2013 -0500
     2.3 @@ -42,8 +42,8 @@
     2.4  using namespace concurrency;
     2.5  
     2.6  SDL_WinRTApp::SDL_WinRTApp() :
     2.7 -	m_windowClosed(false),
     2.8 -	m_windowVisible(true),
     2.9 +    m_windowClosed(false),
    2.10 +    m_windowVisible(true),
    2.11      m_sdlWindowData(NULL),
    2.12      m_useRelativeMouseMode(false)
    2.13  {
    2.14 @@ -51,52 +51,52 @@
    2.15  
    2.16  void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
    2.17  {
    2.18 -	applicationView->Activated +=
    2.19 +    applicationView->Activated +=
    2.20          ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
    2.21  
    2.22 -	CoreApplication::Suspending +=
    2.23 +    CoreApplication::Suspending +=
    2.24          ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
    2.25  
    2.26 -	CoreApplication::Resuming +=
    2.27 +    CoreApplication::Resuming +=
    2.28          ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
    2.29  
    2.30 -	m_renderer = ref new SDL_winrtrenderer();
    2.31 +    m_renderer = ref new SDL_winrtrenderer();
    2.32  }
    2.33  
    2.34  void SDL_WinRTApp::SetWindow(CoreWindow^ window)
    2.35  {
    2.36 -	window->SizeChanged += 
    2.37 +    window->SizeChanged += 
    2.38          ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
    2.39  
    2.40 -	window->VisibilityChanged +=
    2.41 -		ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
    2.42 +    window->VisibilityChanged +=
    2.43 +        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
    2.44  
    2.45 -	window->Closed += 
    2.46 +    window->Closed += 
    2.47          ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
    2.48  
    2.49 -	window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
    2.50 +    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
    2.51  
    2.52 -	window->PointerPressed +=
    2.53 -		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
    2.54 +    window->PointerPressed +=
    2.55 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
    2.56  
    2.57      window->PointerReleased +=
    2.58 -		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
    2.59 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
    2.60  
    2.61 -	window->PointerMoved +=
    2.62 -		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
    2.63 +    window->PointerMoved +=
    2.64 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
    2.65  
    2.66      // Retrieves relative-only mouse movements:
    2.67      Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
    2.68          ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
    2.69  
    2.70      window->KeyDown +=
    2.71 -		ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
    2.72 +        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
    2.73  
    2.74 -	window->KeyUp +=
    2.75 -		ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
    2.76 +    window->KeyUp +=
    2.77 +        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
    2.78  
    2.79  
    2.80 -	m_renderer->Initialize(CoreWindow::GetForCurrentThread());
    2.81 +    m_renderer->Initialize(CoreWindow::GetForCurrentThread());
    2.82  }
    2.83  
    2.84  void SDL_WinRTApp::Load(Platform::String^ entryPoint)
    2.85 @@ -117,26 +117,26 @@
    2.86  
    2.87  void SDL_WinRTApp::PumpEvents()
    2.88  {
    2.89 -	if (!m_windowClosed)
    2.90 -	{
    2.91 -		if (m_windowVisible)
    2.92 -		{
    2.93 -			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
    2.94 -		}
    2.95 -		else
    2.96 -		{
    2.97 -			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
    2.98 -		}
    2.99 -	}
   2.100 +    if (!m_windowClosed)
   2.101 +    {
   2.102 +        if (m_windowVisible)
   2.103 +        {
   2.104 +            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
   2.105 +        }
   2.106 +        else
   2.107 +        {
   2.108 +            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
   2.109 +        }
   2.110 +    }
   2.111  }
   2.112  
   2.113  void SDL_WinRTApp::UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects)
   2.114  {
   2.115      if (!m_windowClosed && m_windowVisible)
   2.116 -	{
   2.117 -		m_renderer->Render(surface, rects, numrects);
   2.118 -		m_renderer->Present(); // This call is synchronized to the display frame rate.
   2.119 -	}
   2.120 +    {
   2.121 +        m_renderer->Render(surface, rects, numrects);
   2.122 +        m_renderer->Present(); // This call is synchronized to the display frame rate.
   2.123 +    }
   2.124  }
   2.125  
   2.126  void SDL_WinRTApp::Uninitialize()
   2.127 @@ -145,24 +145,24 @@
   2.128  
   2.129  void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
   2.130  {
   2.131 -	m_renderer->UpdateForWindowSizeChange();
   2.132 +    m_renderer->UpdateForWindowSizeChange();
   2.133  }
   2.134  
   2.135  void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   2.136  {
   2.137 -	m_windowVisible = args->Visible;
   2.138 +    m_windowVisible = args->Visible;
   2.139  }
   2.140  
   2.141  void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
   2.142  {
   2.143 -	m_windowClosed = true;
   2.144 +    m_windowClosed = true;
   2.145  }
   2.146  
   2.147  void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
   2.148  {
   2.149      if (m_sdlWindowData)
   2.150      {
   2.151 -    	SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_PRESSED, SDL_BUTTON_LEFT);
   2.152 +        SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_PRESSED, SDL_BUTTON_LEFT);
   2.153      }
   2.154  }
   2.155  
   2.156 @@ -170,7 +170,7 @@
   2.157  {
   2.158      if (m_sdlWindowData)
   2.159      {
   2.160 -    	SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_RELEASED, SDL_BUTTON_LEFT);
   2.161 +        SDL_SendMouseButton(m_sdlWindowData->sdlWindow, SDL_RELEASED, SDL_BUTTON_LEFT);
   2.162      }
   2.163  }
   2.164  
   2.165 @@ -492,7 +492,7 @@
   2.166  
   2.167  void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
   2.168  {
   2.169 -	CoreWindow::GetForCurrentThread()->Activate();
   2.170 +    CoreWindow::GetForCurrentThread()->Activate();
   2.171  }
   2.172  
   2.173  static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
   2.174 @@ -517,13 +517,13 @@
   2.175  
   2.176  void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
   2.177  {
   2.178 -	// Save app state asynchronously after requesting a deferral. Holding a deferral
   2.179 -	// indicates that the application is busy performing suspending operations. Be
   2.180 -	// aware that a deferral may not be held indefinitely. After about five seconds,
   2.181 -	// the app will be forced to exit.
   2.182 -	SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
   2.183 -	create_task([this, deferral]()
   2.184 -	{
   2.185 +    // Save app state asynchronously after requesting a deferral. Holding a deferral
   2.186 +    // indicates that the application is busy performing suspending operations. Be
   2.187 +    // aware that a deferral may not be held indefinitely. After about five seconds,
   2.188 +    // the app will be forced to exit.
   2.189 +    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
   2.190 +    create_task([this, deferral]()
   2.191 +    {
   2.192          // Send a window-minimized event immediately to observers.
   2.193          // CoreDispatcher::ProcessEvents, which is the backbone on which
   2.194          // SDL_WinRTApp::PumpEvents is built, will not return to its caller
   2.195 @@ -541,15 +541,15 @@
   2.196              SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);   // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   2.197              SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
   2.198          }
   2.199 -		deferral->Complete();
   2.200 -	});
   2.201 +        deferral->Complete();
   2.202 +    });
   2.203  }
   2.204  
   2.205  void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
   2.206  {
   2.207 -	// Restore any data or state that was unloaded on suspend. By default, data
   2.208 -	// and state are persisted when resuming from suspend. Note that this event
   2.209 -	// does not occur if the app was previously terminated.
   2.210 +    // Restore any data or state that was unloaded on suspend. By default, data
   2.211 +    // and state are persisted when resuming from suspend. Note that this event
   2.212 +    // does not occur if the app was previously terminated.
   2.213      if (m_sdlWindowData)
   2.214      {
   2.215          SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);    // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   2.216 @@ -619,6 +619,6 @@
   2.217  {
   2.218      SDL_WinRT_main = mainFunction;
   2.219      auto direct3DApplicationSource = ref new Direct3DApplicationSource();
   2.220 -	CoreApplication::Run(direct3DApplicationSource);
   2.221 -	return 0;
   2.222 +    CoreApplication::Run(direct3DApplicationSource);
   2.223 +    return 0;
   2.224  }
     3.1 --- a/src/video/windowsrt/SDL_WinRTApp.h	Tue Jan 08 22:50:29 2013 -0500
     3.2 +++ b/src/video/windowsrt/SDL_WinRTApp.h	Tue Jan 08 23:11:22 2013 -0500
     3.3 @@ -10,14 +10,14 @@
     3.4  ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
     3.5  {
     3.6  public:
     3.7 -	SDL_WinRTApp();
     3.8 -	
     3.9 -	// IFrameworkView Methods.
    3.10 -	virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
    3.11 -	virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
    3.12 -	virtual void Load(Platform::String^ entryPoint);
    3.13 -	virtual void Run();
    3.14 -	virtual void Uninitialize();
    3.15 +    SDL_WinRTApp();
    3.16 +    
    3.17 +    // IFrameworkView Methods.
    3.18 +    virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
    3.19 +    virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
    3.20 +    virtual void Load(Platform::String^ entryPoint);
    3.21 +    virtual void Run();
    3.22 +    virtual void Uninitialize();
    3.23  
    3.24  internal:
    3.25      // SDL-specific methods
    3.26 @@ -32,25 +32,25 @@
    3.27      Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
    3.28  
    3.29  protected:
    3.30 -	// Event Handlers.
    3.31 -	void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
    3.32 -	void OnLogicalDpiChanged(Platform::Object^ sender);
    3.33 -	void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
    3.34 -	void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
    3.35 -	void OnResuming(Platform::Object^ sender, Platform::Object^ args);
    3.36 -	void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
    3.37 -	void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
    3.38 -	void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.39 -	void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.40 -	void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.41 +    // Event Handlers.
    3.42 +    void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
    3.43 +    void OnLogicalDpiChanged(Platform::Object^ sender);
    3.44 +    void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
    3.45 +    void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
    3.46 +    void OnResuming(Platform::Object^ sender, Platform::Object^ args);
    3.47 +    void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
    3.48 +    void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
    3.49 +    void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.50 +    void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.51 +    void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    3.52      void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
    3.53      void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    3.54      void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    3.55  
    3.56  private:
    3.57 -	SDL_winrtrenderer^ m_renderer;
    3.58 -	bool m_windowClosed;
    3.59 -	bool m_windowVisible;
    3.60 +    SDL_winrtrenderer^ m_renderer;
    3.61 +    bool m_windowClosed;
    3.62 +    bool m_windowVisible;
    3.63      const SDL_WindowData* m_sdlWindowData;
    3.64      bool m_useRelativeMouseMode;
    3.65  };
    3.66 @@ -58,5 +58,5 @@
    3.67  ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
    3.68  {
    3.69  public:
    3.70 -	virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
    3.71 +    virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
    3.72  };
     4.1 --- a/src/video/windowsrt/SDL_winrtrenderer.cpp	Tue Jan 08 22:50:29 2013 -0500
     4.2 +++ b/src/video/windowsrt/SDL_winrtrenderer.cpp	Tue Jan 08 23:11:22 2013 -0500
     4.3 @@ -11,7 +11,7 @@
     4.4  SDL_winrtrenderer::SDL_winrtrenderer() :
     4.5      m_mainTextureHelperSurface(NULL),
     4.6      m_loadingComplete(false),
     4.7 -	m_vertexCount(0)
     4.8 +    m_vertexCount(0)
     4.9  {
    4.10  }
    4.11  
    4.12 @@ -26,357 +26,357 @@
    4.13  // Initialize the Direct3D resources required to run.
    4.14  void SDL_winrtrenderer::Initialize(CoreWindow^ window)
    4.15  {
    4.16 -	m_window = window;
    4.17 -	
    4.18 -	CreateDeviceResources();
    4.19 -	CreateWindowSizeDependentResources();
    4.20 +    m_window = window;
    4.21 +    
    4.22 +    CreateDeviceResources();
    4.23 +    CreateWindowSizeDependentResources();
    4.24  }
    4.25  
    4.26  // Recreate all device resources and set them back to the current state.
    4.27  void SDL_winrtrenderer::HandleDeviceLost()
    4.28  {
    4.29 -	// Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
    4.30 -	m_windowBounds.Width = 0;
    4.31 -	m_windowBounds.Height = 0;
    4.32 -	m_swapChain = nullptr;
    4.33 +    // Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
    4.34 +    m_windowBounds.Width = 0;
    4.35 +    m_windowBounds.Height = 0;
    4.36 +    m_swapChain = nullptr;
    4.37  
    4.38 -	CreateDeviceResources();
    4.39 -	UpdateForWindowSizeChange();
    4.40 +    CreateDeviceResources();
    4.41 +    UpdateForWindowSizeChange();
    4.42  }
    4.43  
    4.44  // These are the resources that depend on the device.
    4.45  void SDL_winrtrenderer::CreateDeviceResources()
    4.46  {
    4.47 -	// This flag adds support for surfaces with a different color channel ordering
    4.48 -	// than the API default. It is required for compatibility with Direct2D.
    4.49 -	UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    4.50 +    // This flag adds support for surfaces with a different color channel ordering
    4.51 +    // than the API default. It is required for compatibility with Direct2D.
    4.52 +    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    4.53  
    4.54  #if defined(_DEBUG)
    4.55 -	// If the project is in a debug build, enable debugging via SDK Layers with this flag.
    4.56 -	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    4.57 +    // If the project is in a debug build, enable debugging via SDK Layers with this flag.
    4.58 +    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    4.59  #endif
    4.60  
    4.61 -	// This array defines the set of DirectX hardware feature levels this app will support.
    4.62 -	// Note the ordering should be preserved.
    4.63 -	// Don't forget to declare your application's minimum required feature level in its
    4.64 -	// description.  All applications are assumed to support 9.1 unless otherwise stated.
    4.65 -	D3D_FEATURE_LEVEL featureLevels[] = 
    4.66 -	{
    4.67 -		D3D_FEATURE_LEVEL_11_1,
    4.68 -		D3D_FEATURE_LEVEL_11_0,
    4.69 -		D3D_FEATURE_LEVEL_10_1,
    4.70 -		D3D_FEATURE_LEVEL_10_0,
    4.71 -		D3D_FEATURE_LEVEL_9_3,
    4.72 -		D3D_FEATURE_LEVEL_9_2,
    4.73 -		D3D_FEATURE_LEVEL_9_1
    4.74 -	};
    4.75 +    // This array defines the set of DirectX hardware feature levels this app will support.
    4.76 +    // Note the ordering should be preserved.
    4.77 +    // Don't forget to declare your application's minimum required feature level in its
    4.78 +    // description.  All applications are assumed to support 9.1 unless otherwise stated.
    4.79 +    D3D_FEATURE_LEVEL featureLevels[] = 
    4.80 +    {
    4.81 +        D3D_FEATURE_LEVEL_11_1,
    4.82 +        D3D_FEATURE_LEVEL_11_0,
    4.83 +        D3D_FEATURE_LEVEL_10_1,
    4.84 +        D3D_FEATURE_LEVEL_10_0,
    4.85 +        D3D_FEATURE_LEVEL_9_3,
    4.86 +        D3D_FEATURE_LEVEL_9_2,
    4.87 +        D3D_FEATURE_LEVEL_9_1
    4.88 +    };
    4.89  
    4.90 -	// Create the Direct3D 11 API device object and a corresponding context.
    4.91 -	ComPtr<ID3D11Device> device;
    4.92 -	ComPtr<ID3D11DeviceContext> context;
    4.93 -	DX::ThrowIfFailed(
    4.94 -		D3D11CreateDevice(
    4.95 -			nullptr, // Specify nullptr to use the default adapter.
    4.96 -			D3D_DRIVER_TYPE_HARDWARE,
    4.97 -			nullptr,
    4.98 -			creationFlags, // Set set debug and Direct2D compatibility flags.
    4.99 -			featureLevels, // List of feature levels this app can support.
   4.100 -			ARRAYSIZE(featureLevels),
   4.101 -			D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
   4.102 -			&device, // Returns the Direct3D device created.
   4.103 -			&m_featureLevel, // Returns feature level of device created.
   4.104 -			&context // Returns the device immediate context.
   4.105 -			)
   4.106 -		);
   4.107 +    // Create the Direct3D 11 API device object and a corresponding context.
   4.108 +    ComPtr<ID3D11Device> device;
   4.109 +    ComPtr<ID3D11DeviceContext> context;
   4.110 +    DX::ThrowIfFailed(
   4.111 +        D3D11CreateDevice(
   4.112 +            nullptr, // Specify nullptr to use the default adapter.
   4.113 +            D3D_DRIVER_TYPE_HARDWARE,
   4.114 +            nullptr,
   4.115 +            creationFlags, // Set set debug and Direct2D compatibility flags.
   4.116 +            featureLevels, // List of feature levels this app can support.
   4.117 +            ARRAYSIZE(featureLevels),
   4.118 +            D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
   4.119 +            &device, // Returns the Direct3D device created.
   4.120 +            &m_featureLevel, // Returns feature level of device created.
   4.121 +            &context // Returns the device immediate context.
   4.122 +            )
   4.123 +        );
   4.124  
   4.125 -	// Get the Direct3D 11.1 API device and context interfaces.
   4.126 -	DX::ThrowIfFailed(
   4.127 -		device.As(&m_d3dDevice)
   4.128 -		);
   4.129 +    // Get the Direct3D 11.1 API device and context interfaces.
   4.130 +    DX::ThrowIfFailed(
   4.131 +        device.As(&m_d3dDevice)
   4.132 +        );
   4.133  
   4.134 -	DX::ThrowIfFailed(
   4.135 -		context.As(&m_d3dContext)
   4.136 -		);
   4.137 +    DX::ThrowIfFailed(
   4.138 +        context.As(&m_d3dContext)
   4.139 +        );
   4.140  
   4.141      auto loadVSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimpleVertexShader.cso");
   4.142 -	auto loadPSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimplePixelShader.cso");
   4.143 +    auto loadPSTask = DX::ReadDataAsync("SDL_VS2012_WinRT\\SimplePixelShader.cso");
   4.144  
   4.145 -	auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
   4.146 -		DX::ThrowIfFailed(
   4.147 -			m_d3dDevice->CreateVertexShader(
   4.148 - 				fileData->Data,
   4.149 -				fileData->Length,
   4.150 -				nullptr,
   4.151 -				&m_vertexShader
   4.152 -				)
   4.153 -			);
   4.154 +    auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
   4.155 +        DX::ThrowIfFailed(
   4.156 +            m_d3dDevice->CreateVertexShader(
   4.157 +                fileData->Data,
   4.158 +                fileData->Length,
   4.159 +                nullptr,
   4.160 +                &m_vertexShader
   4.161 +                )
   4.162 +            );
   4.163  
   4.164 -		const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
   4.165 -		{
   4.166 -			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
   4.167 -			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   4.168 -		};
   4.169 +        const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
   4.170 +        {
   4.171 +            { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
   4.172 +            { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   4.173 +        };
   4.174  
   4.175 -		DX::ThrowIfFailed(
   4.176 -			m_d3dDevice->CreateInputLayout(
   4.177 -				vertexDesc,
   4.178 -				ARRAYSIZE(vertexDesc),
   4.179 -				fileData->Data,
   4.180 -				fileData->Length,
   4.181 -				&m_inputLayout
   4.182 -				)
   4.183 -			);
   4.184 -	});
   4.185 +        DX::ThrowIfFailed(
   4.186 +            m_d3dDevice->CreateInputLayout(
   4.187 +                vertexDesc,
   4.188 +                ARRAYSIZE(vertexDesc),
   4.189 +                fileData->Data,
   4.190 +                fileData->Length,
   4.191 +                &m_inputLayout
   4.192 +                )
   4.193 +            );
   4.194 +    });
   4.195  
   4.196 -	auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
   4.197 -		DX::ThrowIfFailed(
   4.198 -			m_d3dDevice->CreatePixelShader(
   4.199 -				fileData->Data,
   4.200 -				fileData->Length,
   4.201 -				nullptr,
   4.202 -				&m_pixelShader
   4.203 -				)
   4.204 -			);
   4.205 -	});
   4.206 +    auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
   4.207 +        DX::ThrowIfFailed(
   4.208 +            m_d3dDevice->CreatePixelShader(
   4.209 +                fileData->Data,
   4.210 +                fileData->Length,
   4.211 +                nullptr,
   4.212 +                &m_pixelShader
   4.213 +                )
   4.214 +            );
   4.215 +    });
   4.216  
   4.217 -	auto createVertexBuffer = (createPSTask && createVSTask).then([this] () {
   4.218 -		VertexPositionColor vertices[] = 
   4.219 -		{
   4.220 -			{XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 1.0f)},
   4.221 -			{XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 0.0f)},
   4.222 -			{XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
   4.223 -			{XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
   4.224 -		};
   4.225 +    auto createVertexBuffer = (createPSTask && createVSTask).then([this] () {
   4.226 +        VertexPositionColor vertices[] = 
   4.227 +        {
   4.228 +            {XMFLOAT3(-1.0f, -1.0f, 0.0f),  XMFLOAT2(0.0f, 1.0f)},
   4.229 +            {XMFLOAT3(-1.0f, 1.0f, 0.0f), XMFLOAT2(0.0f, 0.0f)},
   4.230 +            {XMFLOAT3(1.0f, -1.0f, 0.0f), XMFLOAT2(1.0f, 1.0f)},
   4.231 +            {XMFLOAT3(1.0f, 1.0f, 0.0f), XMFLOAT2(1.0f, 0.0f)},
   4.232 +        };
   4.233  
   4.234 -		m_vertexCount = ARRAYSIZE(vertices);
   4.235 +        m_vertexCount = ARRAYSIZE(vertices);
   4.236  
   4.237 -		D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
   4.238 -		vertexBufferData.pSysMem = vertices;
   4.239 -		vertexBufferData.SysMemPitch = 0;
   4.240 -		vertexBufferData.SysMemSlicePitch = 0;
   4.241 -		CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
   4.242 -		DX::ThrowIfFailed(
   4.243 -			m_d3dDevice->CreateBuffer(
   4.244 -				&vertexBufferDesc,
   4.245 -				&vertexBufferData,
   4.246 -				&m_vertexBuffer
   4.247 -				)
   4.248 -			);
   4.249 -	});
   4.250 +        D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
   4.251 +        vertexBufferData.pSysMem = vertices;
   4.252 +        vertexBufferData.SysMemPitch = 0;
   4.253 +        vertexBufferData.SysMemSlicePitch = 0;
   4.254 +        CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
   4.255 +        DX::ThrowIfFailed(
   4.256 +            m_d3dDevice->CreateBuffer(
   4.257 +                &vertexBufferDesc,
   4.258 +                &vertexBufferData,
   4.259 +                &m_vertexBuffer
   4.260 +                )
   4.261 +            );
   4.262 +    });
   4.263  
   4.264      auto createMainSamplerTask = createVertexBuffer.then([this] () {
   4.265 -		D3D11_SAMPLER_DESC samplerDesc;
   4.266 -		samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
   4.267 -		samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.268 -		samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.269 -		samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.270 -		samplerDesc.MipLODBias = 0.0f;
   4.271 -		samplerDesc.MaxAnisotropy = 1;
   4.272 -		samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
   4.273 -		samplerDesc.BorderColor[0] = 0.0f;
   4.274 -		samplerDesc.BorderColor[1] = 0.0f;
   4.275 -		samplerDesc.BorderColor[2] = 0.0f;
   4.276 -		samplerDesc.BorderColor[3] = 0.0f;
   4.277 -		samplerDesc.MinLOD = 0.0f;
   4.278 -		samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
   4.279 -		DX::ThrowIfFailed(
   4.280 -			m_d3dDevice->CreateSamplerState(
   4.281 -				&samplerDesc,
   4.282 -				&m_mainSampler
   4.283 -				)
   4.284 -			);
   4.285 -	});
   4.286 +        D3D11_SAMPLER_DESC samplerDesc;
   4.287 +        samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
   4.288 +        samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.289 +        samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.290 +        samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
   4.291 +        samplerDesc.MipLODBias = 0.0f;
   4.292 +        samplerDesc.MaxAnisotropy = 1;
   4.293 +        samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
   4.294 +        samplerDesc.BorderColor[0] = 0.0f;
   4.295 +        samplerDesc.BorderColor[1] = 0.0f;
   4.296 +        samplerDesc.BorderColor[2] = 0.0f;
   4.297 +        samplerDesc.BorderColor[3] = 0.0f;
   4.298 +        samplerDesc.MinLOD = 0.0f;
   4.299 +        samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
   4.300 +        DX::ThrowIfFailed(
   4.301 +            m_d3dDevice->CreateSamplerState(
   4.302 +                &samplerDesc,
   4.303 +                &m_mainSampler
   4.304 +                )
   4.305 +            );
   4.306 +    });
   4.307  
   4.308 -	createMainSamplerTask.then([this] () {
   4.309 -		m_loadingComplete = true;
   4.310 -	});
   4.311 +    createMainSamplerTask.then([this] () {
   4.312 +        m_loadingComplete = true;
   4.313 +    });
   4.314  }
   4.315  
   4.316  // Allocate all memory resources that change on a window SizeChanged event.
   4.317  void SDL_winrtrenderer::CreateWindowSizeDependentResources()
   4.318  { 
   4.319 -	// Store the window bounds so the next time we get a SizeChanged event we can
   4.320 -	// avoid rebuilding everything if the size is identical.
   4.321 -	m_windowBounds = m_window->Bounds;
   4.322 +    // Store the window bounds so the next time we get a SizeChanged event we can
   4.323 +    // avoid rebuilding everything if the size is identical.
   4.324 +    m_windowBounds = m_window->Bounds;
   4.325  
   4.326 -	// Calculate the necessary swap chain and render target size in pixels.
   4.327 -	float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   4.328 -	float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
   4.329 +    // Calculate the necessary swap chain and render target size in pixels.
   4.330 +    float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   4.331 +    float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
   4.332  
   4.333 -	// The width and height of the swap chain must be based on the window's
   4.334 -	// landscape-oriented width and height. If the window is in a portrait
   4.335 -	// orientation, the dimensions must be reversed.
   4.336 -	m_orientation = DisplayProperties::CurrentOrientation;
   4.337 -	bool swapDimensions =
   4.338 -		m_orientation == DisplayOrientations::Portrait ||
   4.339 -		m_orientation == DisplayOrientations::PortraitFlipped;
   4.340 -	m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   4.341 -	m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
   4.342 +    // The width and height of the swap chain must be based on the window's
   4.343 +    // landscape-oriented width and height. If the window is in a portrait
   4.344 +    // orientation, the dimensions must be reversed.
   4.345 +    m_orientation = DisplayProperties::CurrentOrientation;
   4.346 +    bool swapDimensions =
   4.347 +        m_orientation == DisplayOrientations::Portrait ||
   4.348 +        m_orientation == DisplayOrientations::PortraitFlipped;
   4.349 +    m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   4.350 +    m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
   4.351  
   4.352 -	if(m_swapChain != nullptr)
   4.353 -	{
   4.354 -		// If the swap chain already exists, resize it.
   4.355 -		DX::ThrowIfFailed(
   4.356 -			m_swapChain->ResizeBuffers(
   4.357 -				2, // Double-buffered swap chain.
   4.358 -				static_cast<UINT>(m_renderTargetSize.Width),
   4.359 -				static_cast<UINT>(m_renderTargetSize.Height),
   4.360 -				DXGI_FORMAT_B8G8R8A8_UNORM,
   4.361 -				0
   4.362 -				)
   4.363 -			);
   4.364 -	}
   4.365 -	else
   4.366 -	{
   4.367 -		// Otherwise, create a new one using the same adapter as the existing Direct3D device.
   4.368 -		DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
   4.369 -		swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
   4.370 -		swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
   4.371 -		swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
   4.372 -		swapChainDesc.Stereo = false;
   4.373 -		swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
   4.374 -		swapChainDesc.SampleDesc.Quality = 0;
   4.375 -		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
   4.376 -		swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
   4.377 -		swapChainDesc.Scaling = DXGI_SCALING_NONE;
   4.378 -		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
   4.379 -		swapChainDesc.Flags = 0;
   4.380 +    if(m_swapChain != nullptr)
   4.381 +    {
   4.382 +        // If the swap chain already exists, resize it.
   4.383 +        DX::ThrowIfFailed(
   4.384 +            m_swapChain->ResizeBuffers(
   4.385 +                2, // Double-buffered swap chain.
   4.386 +                static_cast<UINT>(m_renderTargetSize.Width),
   4.387 +                static_cast<UINT>(m_renderTargetSize.Height),
   4.388 +                DXGI_FORMAT_B8G8R8A8_UNORM,
   4.389 +                0
   4.390 +                )
   4.391 +            );
   4.392 +    }
   4.393 +    else
   4.394 +    {
   4.395 +        // Otherwise, create a new one using the same adapter as the existing Direct3D device.
   4.396 +        DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
   4.397 +        swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
   4.398 +        swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
   4.399 +        swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
   4.400 +        swapChainDesc.Stereo = false;
   4.401 +        swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
   4.402 +        swapChainDesc.SampleDesc.Quality = 0;
   4.403 +        swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
   4.404 +        swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
   4.405 +        swapChainDesc.Scaling = DXGI_SCALING_NONE;
   4.406 +        swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
   4.407 +        swapChainDesc.Flags = 0;
   4.408  
   4.409 -		ComPtr<IDXGIDevice1>  dxgiDevice;
   4.410 -		DX::ThrowIfFailed(
   4.411 -			m_d3dDevice.As(&dxgiDevice)
   4.412 -			);
   4.413 +        ComPtr<IDXGIDevice1>  dxgiDevice;
   4.414 +        DX::ThrowIfFailed(
   4.415 +            m_d3dDevice.As(&dxgiDevice)
   4.416 +            );
   4.417  
   4.418 -		ComPtr<IDXGIAdapter> dxgiAdapter;
   4.419 -		DX::ThrowIfFailed(
   4.420 -			dxgiDevice->GetAdapter(&dxgiAdapter)
   4.421 -			);
   4.422 +        ComPtr<IDXGIAdapter> dxgiAdapter;
   4.423 +        DX::ThrowIfFailed(
   4.424 +            dxgiDevice->GetAdapter(&dxgiAdapter)
   4.425 +            );
   4.426  
   4.427 -		ComPtr<IDXGIFactory2> dxgiFactory;
   4.428 -		DX::ThrowIfFailed(
   4.429 -			dxgiAdapter->GetParent(
   4.430 -				__uuidof(IDXGIFactory2), 
   4.431 -				&dxgiFactory
   4.432 -				)
   4.433 -			);
   4.434 +        ComPtr<IDXGIFactory2> dxgiFactory;
   4.435 +        DX::ThrowIfFailed(
   4.436 +            dxgiAdapter->GetParent(
   4.437 +                __uuidof(IDXGIFactory2), 
   4.438 +                &dxgiFactory
   4.439 +                )
   4.440 +            );
   4.441  
   4.442 -		Windows::UI::Core::CoreWindow^ window = m_window.Get();
   4.443 -		DX::ThrowIfFailed(
   4.444 -			dxgiFactory->CreateSwapChainForCoreWindow(
   4.445 -				m_d3dDevice.Get(),
   4.446 -				reinterpret_cast<IUnknown*>(window),
   4.447 -				&swapChainDesc,
   4.448 -				nullptr, // Allow on all displays.
   4.449 -				&m_swapChain
   4.450 -				)
   4.451 -			);
   4.452 -			
   4.453 -		// Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
   4.454 -		// ensures that the application will only render after each VSync, minimizing power consumption.
   4.455 -		DX::ThrowIfFailed(
   4.456 -			dxgiDevice->SetMaximumFrameLatency(1)
   4.457 -			);
   4.458 -	}
   4.459 -	
   4.460 -	// Set the proper orientation for the swap chain, and generate the
   4.461 -	// 3D matrix transformation for rendering to the rotated swap chain.
   4.462 -	DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
   4.463 -	switch (m_orientation)
   4.464 -	{
   4.465 -		case DisplayOrientations::Landscape:
   4.466 -			rotation = DXGI_MODE_ROTATION_IDENTITY;
   4.467 -			m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
   4.468 -				1.0f, 0.0f, 0.0f, 0.0f,
   4.469 -				0.0f, 1.0f, 0.0f, 0.0f,
   4.470 -				0.0f, 0.0f, 1.0f, 0.0f,
   4.471 -				0.0f, 0.0f, 0.0f, 1.0f
   4.472 -				);
   4.473 -			break;
   4.474 +        Windows::UI::Core::CoreWindow^ window = m_window.Get();
   4.475 +        DX::ThrowIfFailed(
   4.476 +            dxgiFactory->CreateSwapChainForCoreWindow(
   4.477 +                m_d3dDevice.Get(),
   4.478 +                reinterpret_cast<IUnknown*>(window),
   4.479 +                &swapChainDesc,
   4.480 +                nullptr, // Allow on all displays.
   4.481 +                &m_swapChain
   4.482 +                )
   4.483 +            );
   4.484 +            
   4.485 +        // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
   4.486 +        // ensures that the application will only render after each VSync, minimizing power consumption.
   4.487 +        DX::ThrowIfFailed(
   4.488 +            dxgiDevice->SetMaximumFrameLatency(1)
   4.489 +            );
   4.490 +    }
   4.491 +    
   4.492 +    // Set the proper orientation for the swap chain, and generate the
   4.493 +    // 3D matrix transformation for rendering to the rotated swap chain.
   4.494 +    DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
   4.495 +    switch (m_orientation)
   4.496 +    {
   4.497 +        case DisplayOrientations::Landscape:
   4.498 +            rotation = DXGI_MODE_ROTATION_IDENTITY;
   4.499 +            m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
   4.500 +                1.0f, 0.0f, 0.0f, 0.0f,
   4.501 +                0.0f, 1.0f, 0.0f, 0.0f,
   4.502 +                0.0f, 0.0f, 1.0f, 0.0f,
   4.503 +                0.0f, 0.0f, 0.0f, 1.0f
   4.504 +                );
   4.505 +            break;
   4.506  
   4.507 -		case DisplayOrientations::Portrait:
   4.508 -			rotation = DXGI_MODE_ROTATION_ROTATE270;
   4.509 -			m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
   4.510 -				0.0f, 1.0f, 0.0f, 0.0f,
   4.511 -				-1.0f, 0.0f, 0.0f, 0.0f,
   4.512 -				0.0f, 0.0f, 1.0f, 0.0f,
   4.513 -				0.0f, 0.0f, 0.0f, 1.0f
   4.514 -				);
   4.515 -			break;
   4.516 +        case DisplayOrientations::Portrait:
   4.517 +            rotation = DXGI_MODE_ROTATION_ROTATE270;
   4.518 +            m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
   4.519 +                0.0f, 1.0f, 0.0f, 0.0f,
   4.520 +                -1.0f, 0.0f, 0.0f, 0.0f,
   4.521 +                0.0f, 0.0f, 1.0f, 0.0f,
   4.522 +                0.0f, 0.0f, 0.0f, 1.0f
   4.523 +                );
   4.524 +            break;
   4.525  
   4.526 -		case DisplayOrientations::LandscapeFlipped:
   4.527 -			rotation = DXGI_MODE_ROTATION_ROTATE180;
   4.528 -			m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
   4.529 -				-1.0f, 0.0f, 0.0f, 0.0f,
   4.530 -				0.0f, -1.0f, 0.0f, 0.0f,
   4.531 -				0.0f, 0.0f, 1.0f, 0.0f,
   4.532 -				0.0f, 0.0f, 0.0f, 1.0f
   4.533 -				);
   4.534 -			break;
   4.535 +        case DisplayOrientations::LandscapeFlipped:
   4.536 +            rotation = DXGI_MODE_ROTATION_ROTATE180;
   4.537 +            m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
   4.538 +                -1.0f, 0.0f, 0.0f, 0.0f,
   4.539 +                0.0f, -1.0f, 0.0f, 0.0f,
   4.540 +                0.0f, 0.0f, 1.0f, 0.0f,
   4.541 +                0.0f, 0.0f, 0.0f, 1.0f
   4.542 +                );
   4.543 +            break;
   4.544  
   4.545 -		case DisplayOrientations::PortraitFlipped:
   4.546 -			rotation = DXGI_MODE_ROTATION_ROTATE90;
   4.547 -			m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
   4.548 -				0.0f, -1.0f, 0.0f, 0.0f,
   4.549 -				1.0f, 0.0f, 0.0f, 0.0f,
   4.550 -				0.0f, 0.0f, 1.0f, 0.0f,
   4.551 -				0.0f, 0.0f, 0.0f, 1.0f
   4.552 -				);
   4.553 -			break;
   4.554 +        case DisplayOrientations::PortraitFlipped:
   4.555 +            rotation = DXGI_MODE_ROTATION_ROTATE90;
   4.556 +            m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
   4.557 +                0.0f, -1.0f, 0.0f, 0.0f,
   4.558 +                1.0f, 0.0f, 0.0f, 0.0f,
   4.559 +                0.0f, 0.0f, 1.0f, 0.0f,
   4.560 +                0.0f, 0.0f, 0.0f, 1.0f
   4.561 +                );
   4.562 +            break;
   4.563  
   4.564 -		default:
   4.565 -			throw ref new Platform::FailureException();
   4.566 -	}
   4.567 +        default:
   4.568 +            throw ref new Platform::FailureException();
   4.569 +    }
   4.570  
   4.571 -	DX::ThrowIfFailed(
   4.572 -		m_swapChain->SetRotation(rotation)
   4.573 -		);
   4.574 +    DX::ThrowIfFailed(
   4.575 +        m_swapChain->SetRotation(rotation)
   4.576 +        );
   4.577  
   4.578 -	// Create a render target view of the swap chain back buffer.
   4.579 -	ComPtr<ID3D11Texture2D> backBuffer;
   4.580 -	DX::ThrowIfFailed(
   4.581 -		m_swapChain->GetBuffer(
   4.582 -			0,
   4.583 -			__uuidof(ID3D11Texture2D),
   4.584 -			&backBuffer
   4.585 -			)
   4.586 -		);
   4.587 +    // Create a render target view of the swap chain back buffer.
   4.588 +    ComPtr<ID3D11Texture2D> backBuffer;
   4.589 +    DX::ThrowIfFailed(
   4.590 +        m_swapChain->GetBuffer(
   4.591 +            0,
   4.592 +            __uuidof(ID3D11Texture2D),
   4.593 +            &backBuffer
   4.594 +            )
   4.595 +        );
   4.596  
   4.597 -	DX::ThrowIfFailed(
   4.598 -		m_d3dDevice->CreateRenderTargetView(
   4.599 -			backBuffer.Get(),
   4.600 -			nullptr,
   4.601 -			&m_renderTargetView
   4.602 -			)
   4.603 -		);
   4.604 +    DX::ThrowIfFailed(
   4.605 +        m_d3dDevice->CreateRenderTargetView(
   4.606 +            backBuffer.Get(),
   4.607 +            nullptr,
   4.608 +            &m_renderTargetView
   4.609 +            )
   4.610 +        );
   4.611  
   4.612 -	// Create a depth stencil view.
   4.613 -	CD3D11_TEXTURE2D_DESC depthStencilDesc(
   4.614 -		DXGI_FORMAT_D24_UNORM_S8_UINT, 
   4.615 -		static_cast<UINT>(m_renderTargetSize.Width),
   4.616 -		static_cast<UINT>(m_renderTargetSize.Height),
   4.617 -		1,
   4.618 -		1,
   4.619 -		D3D11_BIND_DEPTH_STENCIL
   4.620 -		);
   4.621 +    // Create a depth stencil view.
   4.622 +    CD3D11_TEXTURE2D_DESC depthStencilDesc(
   4.623 +        DXGI_FORMAT_D24_UNORM_S8_UINT, 
   4.624 +        static_cast<UINT>(m_renderTargetSize.Width),
   4.625 +        static_cast<UINT>(m_renderTargetSize.Height),
   4.626 +        1,
   4.627 +        1,
   4.628 +        D3D11_BIND_DEPTH_STENCIL
   4.629 +        );
   4.630  
   4.631 -	ComPtr<ID3D11Texture2D> depthStencil;
   4.632 -	DX::ThrowIfFailed(
   4.633 -		m_d3dDevice->CreateTexture2D(
   4.634 -			&depthStencilDesc,
   4.635 -			nullptr,
   4.636 -			&depthStencil
   4.637 -			)
   4.638 -		);
   4.639 +    ComPtr<ID3D11Texture2D> depthStencil;
   4.640 +    DX::ThrowIfFailed(
   4.641 +        m_d3dDevice->CreateTexture2D(
   4.642 +            &depthStencilDesc,
   4.643 +            nullptr,
   4.644 +            &depthStencil
   4.645 +            )
   4.646 +        );
   4.647  
   4.648 -	// Set the rendering viewport to target the entire window.
   4.649 -	CD3D11_VIEWPORT viewport(
   4.650 -		0.0f,
   4.651 -		0.0f,
   4.652 -		m_renderTargetSize.Width,
   4.653 -		m_renderTargetSize.Height
   4.654 -		);
   4.655 +    // Set the rendering viewport to target the entire window.
   4.656 +    CD3D11_VIEWPORT viewport(
   4.657 +        0.0f,
   4.658 +        0.0f,
   4.659 +        m_renderTargetSize.Width,
   4.660 +        m_renderTargetSize.Height
   4.661 +        );
   4.662  
   4.663 -	m_d3dContext->RSSetViewports(1, &viewport);
   4.664 +    m_d3dContext->RSSetViewports(1, &viewport);
   4.665  }
   4.666  
   4.667  void SDL_winrtrenderer::ResizeMainTexture(int w, int h)
   4.668 @@ -384,17 +384,17 @@
   4.669      const int pixelSizeInBytes = 4;
   4.670  
   4.671      D3D11_TEXTURE2D_DESC textureDesc = {0};
   4.672 -	textureDesc.Width = w;
   4.673 -	textureDesc.Height = h;
   4.674 -	textureDesc.MipLevels = 1;
   4.675 -	textureDesc.ArraySize = 1;
   4.676 -	textureDesc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
   4.677 -	textureDesc.SampleDesc.Count = 1;
   4.678 -	textureDesc.SampleDesc.Quality = 0;
   4.679 -	textureDesc.Usage = D3D11_USAGE_DYNAMIC;
   4.680 -	textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
   4.681 -	textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   4.682 -	textureDesc.MiscFlags = 0;
   4.683 +    textureDesc.Width = w;
   4.684 +    textureDesc.Height = h;
   4.685 +    textureDesc.MipLevels = 1;
   4.686 +    textureDesc.ArraySize = 1;
   4.687 +    textureDesc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
   4.688 +    textureDesc.SampleDesc.Count = 1;
   4.689 +    textureDesc.SampleDesc.Quality = 0;
   4.690 +    textureDesc.Usage = D3D11_USAGE_DYNAMIC;
   4.691 +    textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
   4.692 +    textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   4.693 +    textureDesc.MiscFlags = 0;
   4.694  
   4.695      const int numPixels = textureDesc.Width * textureDesc.Height;
   4.696      std::vector<uint8> initialTexturePixels(numPixels * pixelSizeInBytes, 0x00);
   4.697 @@ -407,17 +407,17 @@
   4.698      //    initialTexturePixels[i+3] = 0xff;
   4.699      //}
   4.700  
   4.701 -	D3D11_SUBRESOURCE_DATA initialTextureData = {0};
   4.702 -	initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
   4.703 -	initialTextureData.SysMemPitch = textureDesc.Width * pixelSizeInBytes;
   4.704 -	initialTextureData.SysMemSlicePitch = numPixels * pixelSizeInBytes;
   4.705 -	DX::ThrowIfFailed(
   4.706 -		m_d3dDevice->CreateTexture2D(
   4.707 -			&textureDesc,
   4.708 -			&initialTextureData,
   4.709 -			&m_mainTexture
   4.710 -			)
   4.711 -		);
   4.712 +    D3D11_SUBRESOURCE_DATA initialTextureData = {0};
   4.713 +    initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
   4.714 +    initialTextureData.SysMemPitch = textureDesc.Width * pixelSizeInBytes;
   4.715 +    initialTextureData.SysMemSlicePitch = numPixels * pixelSizeInBytes;
   4.716 +    DX::ThrowIfFailed(
   4.717 +        m_d3dDevice->CreateTexture2D(
   4.718 +            &textureDesc,
   4.719 +            &initialTextureData,
   4.720 +            &m_mainTexture
   4.721 +            )
   4.722 +        );
   4.723  
   4.724      if (m_mainTextureHelperSurface) {
   4.725          SDL_FreeSurface(m_mainTextureHelperSurface);
   4.726 @@ -433,152 +433,152 @@
   4.727          DX::ThrowIfFailed(E_FAIL);  // TODO, WinRT: generate a better error here, taking into account who's calling this function.
   4.728      }
   4.729  
   4.730 -	D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
   4.731 -	resourceViewDesc.Format = textureDesc.Format;
   4.732 -	resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
   4.733 -	resourceViewDesc.Texture2D.MostDetailedMip = 0;
   4.734 -	resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
   4.735 -	DX::ThrowIfFailed(
   4.736 -		m_d3dDevice->CreateShaderResourceView(
   4.737 -			m_mainTexture.Get(),
   4.738 -			&resourceViewDesc,
   4.739 -			&m_mainTextureResourceView)
   4.740 -		);
   4.741 +    D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
   4.742 +    resourceViewDesc.Format = textureDesc.Format;
   4.743 +    resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
   4.744 +    resourceViewDesc.Texture2D.MostDetailedMip = 0;
   4.745 +    resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
   4.746 +    DX::ThrowIfFailed(
   4.747 +        m_d3dDevice->CreateShaderResourceView(
   4.748 +            m_mainTexture.Get(),
   4.749 +            &resourceViewDesc,
   4.750 +            &m_mainTextureResourceView)
   4.751 +        );
   4.752  }
   4.753  
   4.754  // This method is called in the event handler for the SizeChanged event.
   4.755  void SDL_winrtrenderer::UpdateForWindowSizeChange()
   4.756  {
   4.757 -	if (m_window->Bounds.Width  != m_windowBounds.Width ||
   4.758 -		m_window->Bounds.Height != m_windowBounds.Height ||
   4.759 -		m_orientation != DisplayProperties::CurrentOrientation)
   4.760 -	{
   4.761 -		ID3D11RenderTargetView* nullViews[] = {nullptr};
   4.762 -		m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
   4.763 -		m_renderTargetView = nullptr;
   4.764 -		m_d3dContext->Flush();
   4.765 -		CreateWindowSizeDependentResources();
   4.766 -	}
   4.767 +    if (m_window->Bounds.Width  != m_windowBounds.Width ||
   4.768 +        m_window->Bounds.Height != m_windowBounds.Height ||
   4.769 +        m_orientation != DisplayProperties::CurrentOrientation)
   4.770 +    {
   4.771 +        ID3D11RenderTargetView* nullViews[] = {nullptr};
   4.772 +        m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
   4.773 +        m_renderTargetView = nullptr;
   4.774 +        m_d3dContext->Flush();
   4.775 +        CreateWindowSizeDependentResources();
   4.776 +    }
   4.777  }
   4.778  
   4.779  void SDL_winrtrenderer::Render(SDL_Surface * surface, SDL_Rect * rects, int numrects)
   4.780  {
   4.781 -	const float blackColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
   4.782 -	m_d3dContext->ClearRenderTargetView(
   4.783 -		m_renderTargetView.Get(),
   4.784 -		blackColor
   4.785 -		);
   4.786 +    const float blackColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
   4.787 +    m_d3dContext->ClearRenderTargetView(
   4.788 +        m_renderTargetView.Get(),
   4.789 +        blackColor
   4.790 +        );
   4.791  
   4.792 -	// Only draw the screen once it is loaded (some loading is asynchronous).
   4.793 -	if (!m_loadingComplete)
   4.794 -	{
   4.795 -		return;
   4.796 -	}
   4.797 +    // Only draw the screen once it is loaded (some loading is asynchronous).
   4.798 +    if (!m_loadingComplete)
   4.799 +    {
   4.800 +        return;
   4.801 +    }
   4.802      if (!m_mainTextureResourceView)
   4.803      {
   4.804          return;
   4.805      }
   4.806  
   4.807 -	// Update the main texture (for SDL usage).  Start by mapping the SDL
   4.808 +    // Update the main texture (for SDL usage).  Start by mapping the SDL
   4.809      // window's main texture to CPU-accessible memory:
   4.810 -	D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
   4.811 -	DX::ThrowIfFailed(
   4.812 -		m_d3dContext->Map(
   4.813 -			m_mainTexture.Get(),
   4.814 -			0,
   4.815 -			D3D11_MAP_WRITE_DISCARD,
   4.816 -			0,
   4.817 -			&textureMemory)
   4.818 -		);
   4.819 +    D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
   4.820 +    DX::ThrowIfFailed(
   4.821 +        m_d3dContext->Map(
   4.822 +            m_mainTexture.Get(),
   4.823 +            0,
   4.824 +            D3D11_MAP_WRITE_DISCARD,
   4.825 +            0,
   4.826 +            &textureMemory)
   4.827 +        );
   4.828  
   4.829      // Copy pixel data to the locked texture's memory:
   4.830      m_mainTextureHelperSurface->pixels = textureMemory.pData;
   4.831      m_mainTextureHelperSurface->pitch = textureMemory.RowPitch;
   4.832      SDL_BlitSurface(surface, NULL, m_mainTextureHelperSurface, NULL);
   4.833 -	// TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
   4.834 +    // TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
   4.835  
   4.836      // Clean up a bit, then commit the texture's memory back to Direct3D:
   4.837      m_mainTextureHelperSurface->pixels = NULL;
   4.838      m_mainTextureHelperSurface->pitch = 0;
   4.839 -	m_d3dContext->Unmap(
   4.840 -		m_mainTexture.Get(),
   4.841 -		0);
   4.842 +    m_d3dContext->Unmap(
   4.843 +        m_mainTexture.Get(),
   4.844 +        0);
   4.845  
   4.846 -	m_d3dContext->OMSetRenderTargets(
   4.847 -		1,
   4.848 -		m_renderTargetView.GetAddressOf(),
   4.849 -		nullptr
   4.850 -		);
   4.851 +    m_d3dContext->OMSetRenderTargets(
   4.852 +        1,
   4.853 +        m_renderTargetView.GetAddressOf(),
   4.854 +        nullptr
   4.855 +        );
   4.856  
   4.857 -	UINT stride = sizeof(VertexPositionColor);
   4.858 -	UINT offset = 0;
   4.859 -	m_d3dContext->IASetVertexBuffers(
   4.860 -		0,
   4.861 -		1,
   4.862 -		m_vertexBuffer.GetAddressOf(),
   4.863 -		&stride,
   4.864 -		&offset
   4.865 -		);
   4.866 +    UINT stride = sizeof(VertexPositionColor);
   4.867 +    UINT offset = 0;
   4.868 +    m_d3dContext->IASetVertexBuffers(
   4.869 +        0,
   4.870 +        1,
   4.871 +        m_vertexBuffer.GetAddressOf(),
   4.872 +        &stride,
   4.873 +        &offset
   4.874 +        );
   4.875  
   4.876 -	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
   4.877 +    m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
   4.878  
   4.879 -	m_d3dContext->IASetInputLayout(m_inputLayout.Get());
   4.880 +    m_d3dContext->IASetInputLayout(m_inputLayout.Get());
   4.881  
   4.882 -	m_d3dContext->VSSetShader(
   4.883 -		m_vertexShader.Get(),
   4.884 -		nullptr,
   4.885 -		0
   4.886 -		);
   4.887 +    m_d3dContext->VSSetShader(
   4.888 +        m_vertexShader.Get(),
   4.889 +        nullptr,
   4.890 +        0
   4.891 +        );
   4.892  
   4.893 -	m_d3dContext->PSSetShader(
   4.894 -		m_pixelShader.Get(),
   4.895 -		nullptr,
   4.896 -		0
   4.897 -		);
   4.898 +    m_d3dContext->PSSetShader(
   4.899 +        m_pixelShader.Get(),
   4.900 +        nullptr,
   4.901 +        0
   4.902 +        );
   4.903  
   4.904 -	m_d3dContext->PSSetShaderResources(0, 1, m_mainTextureResourceView.GetAddressOf());
   4.905 +    m_d3dContext->PSSetShaderResources(0, 1, m_mainTextureResourceView.GetAddressOf());
   4.906  
   4.907 -	m_d3dContext->PSSetSamplers(0, 1, m_mainSampler.GetAddressOf());
   4.908 +    m_d3dContext->PSSetSamplers(0, 1, m_mainSampler.GetAddressOf());
   4.909  
   4.910 -	m_d3dContext->Draw(4, 0);
   4.911 +    m_d3dContext->Draw(4, 0);
   4.912  }
   4.913  
   4.914  // Method to deliver the final image to the display.
   4.915  void SDL_winrtrenderer::Present()
   4.916  {
   4.917 -	// The application may optionally specify "dirty" or "scroll"
   4.918 -	// rects to improve efficiency in certain scenarios.
   4.919 -	DXGI_PRESENT_PARAMETERS parameters = {0};
   4.920 -	parameters.DirtyRectsCount = 0;
   4.921 -	parameters.pDirtyRects = nullptr;
   4.922 -	parameters.pScrollRect = nullptr;
   4.923 -	parameters.pScrollOffset = nullptr;
   4.924 -	
   4.925 -	// The first argument instructs DXGI to block until VSync, putting the application
   4.926 -	// to sleep until the next VSync. This ensures we don't waste any cycles rendering
   4.927 -	// frames that will never be displayed to the screen.
   4.928 -	HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
   4.929 +    // The application may optionally specify "dirty" or "scroll"
   4.930 +    // rects to improve efficiency in certain scenarios.
   4.931 +    DXGI_PRESENT_PARAMETERS parameters = {0};
   4.932 +    parameters.DirtyRectsCount = 0;
   4.933 +    parameters.pDirtyRects = nullptr;
   4.934 +    parameters.pScrollRect = nullptr;
   4.935 +    parameters.pScrollOffset = nullptr;
   4.936 +    
   4.937 +    // The first argument instructs DXGI to block until VSync, putting the application
   4.938 +    // to sleep until the next VSync. This ensures we don't waste any cycles rendering
   4.939 +    // frames that will never be displayed to the screen.
   4.940 +    HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
   4.941  
   4.942 -	// Discard the contents of the render target.
   4.943 -	// This is a valid operation only when the existing contents will be entirely
   4.944 -	// overwritten. If dirty or scroll rects are used, this call should be removed.
   4.945 -	m_d3dContext->DiscardView(m_renderTargetView.Get());
   4.946 +    // Discard the contents of the render target.
   4.947 +    // This is a valid operation only when the existing contents will be entirely
   4.948 +    // overwritten. If dirty or scroll rects are used, this call should be removed.
   4.949 +    m_d3dContext->DiscardView(m_renderTargetView.Get());
   4.950  
   4.951 -	// If the device was removed either by a disconnect or a driver upgrade, we 
   4.952 -	// must recreate all device resources.
   4.953 -	if (hr == DXGI_ERROR_DEVICE_REMOVED)
   4.954 -	{
   4.955 -		HandleDeviceLost();
   4.956 -	}
   4.957 -	else
   4.958 -	{
   4.959 -		DX::ThrowIfFailed(hr);
   4.960 -	}
   4.961 +    // If the device was removed either by a disconnect or a driver upgrade, we 
   4.962 +    // must recreate all device resources.
   4.963 +    if (hr == DXGI_ERROR_DEVICE_REMOVED)
   4.964 +    {
   4.965 +        HandleDeviceLost();
   4.966 +    }
   4.967 +    else
   4.968 +    {
   4.969 +        DX::ThrowIfFailed(hr);
   4.970 +    }
   4.971  }
   4.972  
   4.973  // Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
   4.974  float SDL_winrtrenderer::ConvertDipsToPixels(float dips)
   4.975  {
   4.976 -	static const float dipsPerInch = 96.0f;
   4.977 -	return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
   4.978 +    static const float dipsPerInch = 96.0f;
   4.979 +    return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
   4.980  }
     5.1 --- a/src/video/windowsrt/SDL_winrtrenderer.h	Tue Jan 08 22:50:29 2013 -0500
     5.2 +++ b/src/video/windowsrt/SDL_winrtrenderer.h	Tue Jan 08 23:11:22 2013 -0500
     5.3 @@ -5,57 +5,57 @@
     5.4  
     5.5  struct VertexPositionColor
     5.6  {
     5.7 -	DirectX::XMFLOAT3 pos;
     5.8 -	DirectX::XMFLOAT2 tex;
     5.9 +    DirectX::XMFLOAT3 pos;
    5.10 +    DirectX::XMFLOAT2 tex;
    5.11  };
    5.12  
    5.13  // Helper class that initializes DirectX APIs for 3D rendering.
    5.14  ref class SDL_winrtrenderer
    5.15  {
    5.16  internal:
    5.17 -	SDL_winrtrenderer();
    5.18 +    SDL_winrtrenderer();
    5.19  
    5.20  public:
    5.21      virtual ~SDL_winrtrenderer();
    5.22 -	virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
    5.23 -	virtual void HandleDeviceLost();
    5.24 -	virtual void CreateDeviceResources();
    5.25 -	virtual void CreateWindowSizeDependentResources();
    5.26 -	virtual void UpdateForWindowSizeChange();
    5.27 -	virtual void Present();
    5.28 -	virtual float ConvertDipsToPixels(float dips);
    5.29 +    virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
    5.30 +    virtual void HandleDeviceLost();
    5.31 +    virtual void CreateDeviceResources();
    5.32 +    virtual void CreateWindowSizeDependentResources();
    5.33 +    virtual void UpdateForWindowSizeChange();
    5.34 +    virtual void Present();
    5.35 +    virtual float ConvertDipsToPixels(float dips);
    5.36  
    5.37  internal:
    5.38 -	virtual void Render(SDL_Surface * surface, SDL_Rect * rects, int numrects);
    5.39 +    virtual void Render(SDL_Surface * surface, SDL_Rect * rects, int numrects);
    5.40      void ResizeMainTexture(int w, int h);
    5.41  
    5.42  protected private:
    5.43 -	// Direct3D Objects.
    5.44 -	Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
    5.45 -	Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
    5.46 -	Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
    5.47 -	Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
    5.48 -	Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
    5.49 -	Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
    5.50 -	Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
    5.51 -	Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
    5.52 -	Microsoft::WRL::ComPtr<ID3D11Texture2D> m_mainTexture;
    5.53 -	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_mainTextureResourceView;
    5.54 -	Microsoft::WRL::ComPtr<ID3D11SamplerState> m_mainSampler;
    5.55 +    // Direct3D Objects.
    5.56 +    Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
    5.57 +    Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
    5.58 +    Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
    5.59 +    Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
    5.60 +    Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
    5.61 +    Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
    5.62 +    Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
    5.63 +    Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
    5.64 +    Microsoft::WRL::ComPtr<ID3D11Texture2D> m_mainTexture;
    5.65 +    Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_mainTextureResourceView;
    5.66 +    Microsoft::WRL::ComPtr<ID3D11SamplerState> m_mainSampler;
    5.67  
    5.68      // UpdateWindowSurface helper objects
    5.69      SDL_Surface * m_mainTextureHelperSurface;
    5.70  
    5.71 -	// Cached renderer properties.
    5.72 -	D3D_FEATURE_LEVEL m_featureLevel;
    5.73 -	Windows::Foundation::Size m_renderTargetSize;
    5.74 -	Windows::Foundation::Rect m_windowBounds;
    5.75 -	Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
    5.76 -	Windows::Graphics::Display::DisplayOrientations m_orientation;
    5.77 -	uint32 m_vertexCount;
    5.78 +    // Cached renderer properties.
    5.79 +    D3D_FEATURE_LEVEL m_featureLevel;
    5.80 +    Windows::Foundation::Size m_renderTargetSize;
    5.81 +    Windows::Foundation::Rect m_windowBounds;
    5.82 +    Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
    5.83 +    Windows::Graphics::Display::DisplayOrientations m_orientation;
    5.84 +    uint32 m_vertexCount;
    5.85  
    5.86 -	// Transform used for display orientation.
    5.87 -	DirectX::XMFLOAT4X4 m_orientationTransform3D;
    5.88 +    // Transform used for display orientation.
    5.89 +    DirectX::XMFLOAT4X4 m_orientationTransform3D;
    5.90  
    5.91      // Has the renderer finished loading?
    5.92      bool m_loadingComplete;
     6.1 --- a/src/video/windowsrt/SimplePixelShader.hlsl	Tue Jan 08 22:50:29 2013 -0500
     6.2 +++ b/src/video/windowsrt/SimplePixelShader.hlsl	Tue Jan 08 23:11:22 2013 -0500
     6.3 @@ -3,13 +3,13 @@
     6.4  
     6.5  struct PixelShaderInput
     6.6  {
     6.7 -	float4 pos : SV_POSITION;
     6.8 +    float4 pos : SV_POSITION;
     6.9  
    6.10 -	float2 tex : TEXCOORD0;
    6.11 +    float2 tex : TEXCOORD0;
    6.12  };
    6.13  
    6.14  float4 main(PixelShaderInput input) : SV_TARGET
    6.15  {
    6.16 -	//return float4(input.color,1.0f);
    6.17 -	return theTexture.Sample(theSampler, input.tex);
    6.18 +    //return float4(input.color,1.0f);
    6.19 +    return theTexture.Sample(theSampler, input.tex);
    6.20  }
     7.1 --- a/src/video/windowsrt/SimpleVertexShader.hlsl	Tue Jan 08 22:50:29 2013 -0500
     7.2 +++ b/src/video/windowsrt/SimpleVertexShader.hlsl	Tue Jan 08 23:11:22 2013 -0500
     7.3 @@ -3,20 +3,20 @@
     7.4  
     7.5  struct VertexShaderInput
     7.6  {
     7.7 -	float3 pos : POSITION;
     7.8 -	float2 tex : TEXCOORD0;
     7.9 +    float3 pos : POSITION;
    7.10 +    float2 tex : TEXCOORD0;
    7.11  };
    7.12  
    7.13  struct VertexShaderOutput
    7.14  {
    7.15 -	float4 pos : SV_POSITION;
    7.16 -	float2 tex : TEXCOORD0;
    7.17 +    float4 pos : SV_POSITION;
    7.18 +    float2 tex : TEXCOORD0;
    7.19  };
    7.20  
    7.21  VertexShaderOutput main(VertexShaderInput input)
    7.22  {
    7.23 -	VertexShaderOutput output;
    7.24 -	output.pos = float4(input.pos, 1.0f);
    7.25 -	output.tex = input.tex;
    7.26 -	return output;
    7.27 +    VertexShaderOutput output;
    7.28 +    output.pos = float4(input.pos, 1.0f);
    7.29 +    output.tex = input.tex;
    7.30 +    return output;
    7.31  }