WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
authorDavid Ludwig <dludwig@pobox.com>
Sat, 27 Oct 2012 21:20:00 -0400
changeset 8322839cd578a474
parent 8321 d95a438e6c84
child 8323 5f90284114fa
WinRT: moved contents of platform-specific SDLmain into SDL.dll, where it should probably have been in the first place
VisualC/SDL/SDL_VS2012_WinRT.vcxproj
VisualC/SDLmain/SDLmain_VS2012_WinRT.vcxproj
src/main/windowsrt/BasicTimer.h
src/main/windowsrt/CubeRenderer.cpp
src/main/windowsrt/CubeRenderer.h
src/main/windowsrt/Direct3DBase.cpp
src/main/windowsrt/Direct3DBase.h
src/main/windowsrt/DirectXHelper.h
src/main/windowsrt/SDL_WinRTApp.cpp
src/main/windowsrt/SDL_WinRTApp.h
src/main/windowsrt/SDLmain_WinRT_common.h
src/main/windowsrt/SimplePixelShader.hlsl
src/main/windowsrt/SimpleVertexShader.hlsl
src/video/windowsrt/BasicTimer.h
src/video/windowsrt/CubeRenderer.cpp
src/video/windowsrt/CubeRenderer.h
src/video/windowsrt/Direct3DBase.cpp
src/video/windowsrt/Direct3DBase.h
src/video/windowsrt/DirectXHelper.h
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDLmain_WinRT_common.h
src/video/windowsrt/SimplePixelShader.hlsl
src/video/windowsrt/SimpleVertexShader.hlsl
     1.1 --- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj	Sat Oct 27 20:12:31 2012 -0400
     1.2 +++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj	Sat Oct 27 21:20:00 2012 -0400
     1.3 @@ -101,6 +101,30 @@
     1.4      <ClCompile Include="..\..\src\video\SDL_stretch.c" />
     1.5      <ClCompile Include="..\..\src\video\SDL_surface.c" />
     1.6      <ClCompile Include="..\..\src\video\SDL_video.c" />
     1.7 +    <ClCompile Include="..\..\src\video\windowsrt\CubeRenderer.cpp">
     1.8 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
     1.9 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.10 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.11 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.12 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    1.13 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    1.14 +    </ClCompile>
    1.15 +    <ClCompile Include="..\..\src\video\windowsrt\Direct3DBase.cpp">
    1.16 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.17 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.18 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.19 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.20 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    1.21 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    1.22 +    </ClCompile>
    1.23 +    <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
    1.24 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.25 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.26 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.27 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.28 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    1.29 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    1.30 +    </ClCompile>
    1.31    </ItemGroup>
    1.32    <ItemGroup>
    1.33      <ClInclude Include="..\..\include\begin_code.h" />
    1.34 @@ -204,6 +228,12 @@
    1.35      <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
    1.36      <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    1.37      <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    1.38 +    <ClInclude Include="..\..\src\video\windowsrt\BasicTimer.h" />
    1.39 +    <ClInclude Include="..\..\src\video\windowsrt\CubeRenderer.h" />
    1.40 +    <ClInclude Include="..\..\src\video\windowsrt\Direct3DBase.h" />
    1.41 +    <ClInclude Include="..\..\src\video\windowsrt\DirectXHelper.h" />
    1.42 +    <ClInclude Include="..\..\src\video\windowsrt\SDLmain_WinRT_common.h" />
    1.43 +    <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
    1.44    </ItemGroup>
    1.45    <PropertyGroup Label="Globals">
    1.46      <ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid>
    1.47 @@ -310,6 +340,7 @@
    1.48        <SubSystem>Console</SubSystem>
    1.49        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.50        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.51 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.52      </Link>
    1.53    </ItemDefinitionGroup>
    1.54    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    1.55 @@ -323,6 +354,7 @@
    1.56        <SubSystem>Console</SubSystem>
    1.57        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.58        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.59 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.60      </Link>
    1.61    </ItemDefinitionGroup>
    1.62    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
    1.63 @@ -336,6 +368,7 @@
    1.64        <SubSystem>Console</SubSystem>
    1.65        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.66        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.67 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.68      </Link>
    1.69    </ItemDefinitionGroup>
    1.70    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
    1.71 @@ -349,6 +382,7 @@
    1.72        <SubSystem>Console</SubSystem>
    1.73        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.74        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.75 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.76      </Link>
    1.77    </ItemDefinitionGroup>
    1.78    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    1.79 @@ -362,6 +396,7 @@
    1.80        <SubSystem>Console</SubSystem>
    1.81        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.82        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.83 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.84      </Link>
    1.85    </ItemDefinitionGroup>
    1.86    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    1.87 @@ -375,6 +410,7 @@
    1.88        <SubSystem>Console</SubSystem>
    1.89        <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
    1.90        <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    1.91 +      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    1.92      </Link>
    1.93    </ItemDefinitionGroup>
    1.94    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
     2.1 --- a/VisualC/SDLmain/SDLmain_VS2012_WinRT.vcxproj	Sat Oct 27 20:12:31 2012 -0400
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,199 +0,0 @@
     2.4 -<?xml version="1.0" encoding="utf-8"?>
     2.5 -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2.6 -  <ItemGroup Label="ProjectConfigurations">
     2.7 -    <ProjectConfiguration Include="Debug|ARM">
     2.8 -      <Configuration>Debug</Configuration>
     2.9 -      <Platform>ARM</Platform>
    2.10 -    </ProjectConfiguration>
    2.11 -    <ProjectConfiguration Include="Debug|Win32">
    2.12 -      <Configuration>Debug</Configuration>
    2.13 -      <Platform>Win32</Platform>
    2.14 -    </ProjectConfiguration>
    2.15 -    <ProjectConfiguration Include="Debug|x64">
    2.16 -      <Configuration>Debug</Configuration>
    2.17 -      <Platform>x64</Platform>
    2.18 -    </ProjectConfiguration>
    2.19 -    <ProjectConfiguration Include="Release|ARM">
    2.20 -      <Configuration>Release</Configuration>
    2.21 -      <Platform>ARM</Platform>
    2.22 -    </ProjectConfiguration>
    2.23 -    <ProjectConfiguration Include="Release|Win32">
    2.24 -      <Configuration>Release</Configuration>
    2.25 -      <Platform>Win32</Platform>
    2.26 -    </ProjectConfiguration>
    2.27 -    <ProjectConfiguration Include="Release|x64">
    2.28 -      <Configuration>Release</Configuration>
    2.29 -      <Platform>x64</Platform>
    2.30 -    </ProjectConfiguration>
    2.31 -  </ItemGroup>
    2.32 -  <ItemGroup>
    2.33 -    <ClInclude Include="..\..\src\main\windowsrt\BasicTimer.h" />
    2.34 -    <ClInclude Include="..\..\src\main\windowsrt\CubeRenderer.h" />
    2.35 -    <ClInclude Include="..\..\src\main\windowsrt\Direct3DBase.h" />
    2.36 -    <ClInclude Include="..\..\src\main\windowsrt\DirectXHelper.h" />
    2.37 -    <ClInclude Include="..\..\src\main\windowsrt\SDLmain_WinRT_common.h" />
    2.38 -    <ClInclude Include="..\..\src\main\windowsrt\SDL_WinRTApp.h" />
    2.39 -  </ItemGroup>
    2.40 -  <ItemGroup>
    2.41 -    <ClCompile Include="..\..\src\main\windowsrt\CubeRenderer.cpp" />
    2.42 -    <ClCompile Include="..\..\src\main\windowsrt\Direct3DBase.cpp" />
    2.43 -    <ClCompile Include="..\..\src\main\windowsrt\SDL_WinRTApp.cpp" />
    2.44 -  </ItemGroup>
    2.45 -  <PropertyGroup Label="Globals">
    2.46 -    <ProjectGuid>{48666378-b527-43f5-8968-f867a6f8d2a3}</ProjectGuid>
    2.47 -    <Keyword>Win32Proj</Keyword>
    2.48 -    <ProjectName>SDLmain_VS2012_WinRT</ProjectName>
    2.49 -    <RootNamespace>SDLmain_VS2012_WinRT</RootNamespace>
    2.50 -    <DefaultLanguage>en-US</DefaultLanguage>
    2.51 -    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
    2.52 -    <AppContainerApplication>true</AppContainerApplication>
    2.53 -  </PropertyGroup>
    2.54 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    2.55 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    2.56 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.57 -    <UseDebugLibraries>true</UseDebugLibraries>
    2.58 -    <PlatformToolset>v110</PlatformToolset>
    2.59 -  </PropertyGroup>
    2.60 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    2.61 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.62 -    <UseDebugLibraries>true</UseDebugLibraries>
    2.63 -    <PlatformToolset>v110</PlatformToolset>
    2.64 -  </PropertyGroup>
    2.65 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    2.66 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.67 -    <UseDebugLibraries>true</UseDebugLibraries>
    2.68 -    <PlatformToolset>v110</PlatformToolset>
    2.69 -  </PropertyGroup>
    2.70 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    2.71 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.72 -    <UseDebugLibraries>false</UseDebugLibraries>
    2.73 -    <WholeProgramOptimization>true</WholeProgramOptimization>
    2.74 -    <PlatformToolset>v110</PlatformToolset>
    2.75 -  </PropertyGroup>
    2.76 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    2.77 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.78 -    <UseDebugLibraries>false</UseDebugLibraries>
    2.79 -    <WholeProgramOptimization>true</WholeProgramOptimization>
    2.80 -    <PlatformToolset>v110</PlatformToolset>
    2.81 -  </PropertyGroup>
    2.82 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    2.83 -    <ConfigurationType>StaticLibrary</ConfigurationType>
    2.84 -    <UseDebugLibraries>false</UseDebugLibraries>
    2.85 -    <WholeProgramOptimization>true</WholeProgramOptimization>
    2.86 -    <PlatformToolset>v110</PlatformToolset>
    2.87 -  </PropertyGroup>
    2.88 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
    2.89 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    2.90 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    2.91 -  </ImportGroup>
    2.92 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    2.93 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    2.94 -  </ImportGroup>
    2.95 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    2.96 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    2.97 -  </ImportGroup>
    2.98 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    2.99 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   2.100 -  </ImportGroup>
   2.101 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   2.102 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   2.103 -  </ImportGroup>
   2.104 -  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
   2.105 -    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   2.106 -  </ImportGroup>
   2.107 -  <PropertyGroup Label="UserMacros" />
   2.108 -  <PropertyGroup />
   2.109 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
   2.110 -    <GenerateManifest>false</GenerateManifest>
   2.111 -  </PropertyGroup>
   2.112 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   2.113 -    <GenerateManifest>false</GenerateManifest>
   2.114 -  </PropertyGroup>
   2.115 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
   2.116 -    <GenerateManifest>false</GenerateManifest>
   2.117 -  </PropertyGroup>
   2.118 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
   2.119 -    <GenerateManifest>false</GenerateManifest>
   2.120 -  </PropertyGroup>
   2.121 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   2.122 -    <GenerateManifest>false</GenerateManifest>
   2.123 -  </PropertyGroup>
   2.124 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
   2.125 -    <GenerateManifest>false</GenerateManifest>
   2.126 -  </PropertyGroup>
   2.127 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
   2.128 -    <ClCompile>
   2.129 -      <PrecompiledHeader>NotUsing</PrecompiledHeader>
   2.130 -      <CompileAsWinRT>true</CompileAsWinRT>
   2.131 -      <SDLCheck>true</SDLCheck>
   2.132 -    </ClCompile>
   2.133 -    <Link>
   2.134 -      <SubSystem>Console</SubSystem>
   2.135 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.136 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.137 -    </Link>
   2.138 -  </ItemDefinitionGroup>
   2.139 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   2.140 -    <ClCompile>
   2.141 -      <PrecompiledHeader>NotUsing</PrecompiledHeader>
   2.142 -      <CompileAsWinRT>true</CompileAsWinRT>
   2.143 -      <SDLCheck>true</SDLCheck>
   2.144 -    </ClCompile>
   2.145 -    <Link>
   2.146 -      <SubSystem>Console</SubSystem>
   2.147 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.148 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.149 -    </Link>
   2.150 -  </ItemDefinitionGroup>
   2.151 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
   2.152 -    <ClCompile>
   2.153 -      <PrecompiledHeader>Use</PrecompiledHeader>
   2.154 -      <CompileAsWinRT>false</CompileAsWinRT>
   2.155 -      <SDLCheck>true</SDLCheck>
   2.156 -    </ClCompile>
   2.157 -    <Link>
   2.158 -      <SubSystem>Console</SubSystem>
   2.159 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.160 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.161 -    </Link>
   2.162 -  </ItemDefinitionGroup>
   2.163 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
   2.164 -    <ClCompile>
   2.165 -      <PrecompiledHeader>Use</PrecompiledHeader>
   2.166 -      <CompileAsWinRT>false</CompileAsWinRT>
   2.167 -      <SDLCheck>true</SDLCheck>
   2.168 -    </ClCompile>
   2.169 -    <Link>
   2.170 -      <SubSystem>Console</SubSystem>
   2.171 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.172 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.173 -    </Link>
   2.174 -  </ItemDefinitionGroup>
   2.175 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   2.176 -    <ClCompile>
   2.177 -      <PrecompiledHeader>Use</PrecompiledHeader>
   2.178 -      <CompileAsWinRT>false</CompileAsWinRT>
   2.179 -      <SDLCheck>true</SDLCheck>
   2.180 -    </ClCompile>
   2.181 -    <Link>
   2.182 -      <SubSystem>Console</SubSystem>
   2.183 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.184 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.185 -    </Link>
   2.186 -  </ItemDefinitionGroup>
   2.187 -  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
   2.188 -    <ClCompile>
   2.189 -      <PrecompiledHeader>Use</PrecompiledHeader>
   2.190 -      <CompileAsWinRT>false</CompileAsWinRT>
   2.191 -      <SDLCheck>true</SDLCheck>
   2.192 -    </ClCompile>
   2.193 -    <Link>
   2.194 -      <SubSystem>Console</SubSystem>
   2.195 -      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
   2.196 -      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
   2.197 -    </Link>
   2.198 -  </ItemDefinitionGroup>
   2.199 -  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   2.200 -  <ImportGroup Label="ExtensionTargets">
   2.201 -  </ImportGroup>
   2.202 -</Project>
   2.203 \ No newline at end of file
     3.1 --- a/src/main/windowsrt/BasicTimer.h	Sat Oct 27 20:12:31 2012 -0400
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,76 +0,0 @@
     3.4 -#pragma once
     3.5 -
     3.6 -#include <wrl.h>
     3.7 -
     3.8 -// Helper class for basic timing.
     3.9 -ref class BasicTimer sealed
    3.10 -{
    3.11 -public:
    3.12 -	// Initializes internal timer values.
    3.13 -	BasicTimer()
    3.14 -	{
    3.15 -		if (!QueryPerformanceFrequency(&m_frequency))
    3.16 -		{
    3.17 -			throw ref new Platform::FailureException();
    3.18 -		}
    3.19 -		Reset();
    3.20 -	}
    3.21 -	
    3.22 -	// Reset the timer to initial values.
    3.23 -	void Reset()
    3.24 -	{
    3.25 -		Update();
    3.26 -		m_startTime = m_currentTime;
    3.27 -		m_total = 0.0f;
    3.28 -		m_delta = 1.0f / 60.0f;
    3.29 -	}
    3.30 -	
    3.31 -	// Update the timer's internal values.
    3.32 -	void Update()
    3.33 -	{
    3.34 -		if (!QueryPerformanceCounter(&m_currentTime))
    3.35 -		{
    3.36 -			throw ref new Platform::FailureException();
    3.37 -		}
    3.38 -		
    3.39 -		m_total = static_cast<float>(
    3.40 -			static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) /
    3.41 -			static_cast<double>(m_frequency.QuadPart)
    3.42 -			);
    3.43 -		
    3.44 -		if (m_lastTime.QuadPart == m_startTime.QuadPart)
    3.45 -		{
    3.46 -			// If the timer was just reset, report a time delta equivalent to 60Hz frame time.
    3.47 -			m_delta = 1.0f / 60.0f;
    3.48 -		}
    3.49 -		else
    3.50 -		{
    3.51 -			m_delta = static_cast<float>(
    3.52 -				static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) /
    3.53 -				static_cast<double>(m_frequency.QuadPart)
    3.54 -				);
    3.55 -		}
    3.56 -		
    3.57 -		m_lastTime = m_currentTime;
    3.58 -	}
    3.59 -	
    3.60 -	// Duration in seconds between the last call to Reset() and the last call to Update().
    3.61 -	property float Total
    3.62 -	{
    3.63 -		float get() { return m_total; }
    3.64 -	}
    3.65 -	
    3.66 -	// Duration in seconds between the previous two calls to Update().
    3.67 -	property float Delta
    3.68 -	{
    3.69 -		float get() { return m_delta; }
    3.70 -	}
    3.71 -
    3.72 -private:
    3.73 -	LARGE_INTEGER m_frequency;
    3.74 -	LARGE_INTEGER m_currentTime;
    3.75 -	LARGE_INTEGER m_startTime;
    3.76 -	LARGE_INTEGER m_lastTime;
    3.77 -	float m_total;
    3.78 -	float m_delta;
    3.79 -};
     4.1 --- a/src/main/windowsrt/CubeRenderer.cpp	Sat Oct 27 20:12:31 2012 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,256 +0,0 @@
     4.4 -#include "SDLmain_WinRT_common.h"
     4.5 -#include "CubeRenderer.h"
     4.6 -
     4.7 -using namespace DirectX;
     4.8 -using namespace Microsoft::WRL;
     4.9 -using namespace Windows::Foundation;
    4.10 -using namespace Windows::UI::Core;
    4.11 -
    4.12 -CubeRenderer::CubeRenderer() :
    4.13 -	m_loadingComplete(false),
    4.14 -	m_indexCount(0)
    4.15 -{
    4.16 -}
    4.17 -
    4.18 -void CubeRenderer::CreateDeviceResources()
    4.19 -{
    4.20 -	Direct3DBase::CreateDeviceResources();
    4.21 -
    4.22 -	auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
    4.23 -	auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
    4.24 -
    4.25 -	auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
    4.26 -		DX::ThrowIfFailed(
    4.27 -			m_d3dDevice->CreateVertexShader(
    4.28 - 				fileData->Data,
    4.29 -				fileData->Length,
    4.30 -				nullptr,
    4.31 -				&m_vertexShader
    4.32 -				)
    4.33 -			);
    4.34 -
    4.35 -		const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
    4.36 -		{
    4.37 -			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
    4.38 -			{ "COLOR",    0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    4.39 -		};
    4.40 -
    4.41 -		DX::ThrowIfFailed(
    4.42 -			m_d3dDevice->CreateInputLayout(
    4.43 -				vertexDesc,
    4.44 -				ARRAYSIZE(vertexDesc),
    4.45 -				fileData->Data,
    4.46 -				fileData->Length,
    4.47 -				&m_inputLayout
    4.48 -				)
    4.49 -			);
    4.50 -	});
    4.51 -
    4.52 -	auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
    4.53 -		DX::ThrowIfFailed(
    4.54 -			m_d3dDevice->CreatePixelShader(
    4.55 -				fileData->Data,
    4.56 -				fileData->Length,
    4.57 -				nullptr,
    4.58 -				&m_pixelShader
    4.59 -				)
    4.60 -			);
    4.61 -
    4.62 -		CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
    4.63 -		DX::ThrowIfFailed(
    4.64 -			m_d3dDevice->CreateBuffer(
    4.65 -				&constantBufferDesc,
    4.66 -				nullptr,
    4.67 -				&m_constantBuffer
    4.68 -				)
    4.69 -			);
    4.70 -	});
    4.71 -
    4.72 -	auto createCubeTask = (createPSTask && createVSTask).then([this] () {
    4.73 -		VertexPositionColor cubeVertices[] = 
    4.74 -		{
    4.75 -			{XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f)},
    4.76 -			{XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f)},
    4.77 -			{XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f)},
    4.78 -			{XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f)},
    4.79 -			{XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f)},
    4.80 -			{XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f)},
    4.81 -			{XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f)},
    4.82 -			{XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f)},
    4.83 -		};
    4.84 -
    4.85 -		D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
    4.86 -		vertexBufferData.pSysMem = cubeVertices;
    4.87 -		vertexBufferData.SysMemPitch = 0;
    4.88 -		vertexBufferData.SysMemSlicePitch = 0;
    4.89 -		CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices), D3D11_BIND_VERTEX_BUFFER);
    4.90 -		DX::ThrowIfFailed(
    4.91 -			m_d3dDevice->CreateBuffer(
    4.92 -				&vertexBufferDesc,
    4.93 -				&vertexBufferData,
    4.94 -				&m_vertexBuffer
    4.95 -				)
    4.96 -			);
    4.97 -
    4.98 -		unsigned short cubeIndices[] = 
    4.99 -		{
   4.100 -			0,2,1, // -x
   4.101 -			1,2,3,
   4.102 -
   4.103 -			4,5,6, // +x
   4.104 -			5,7,6,
   4.105 -
   4.106 -			0,1,5, // -y
   4.107 -			0,5,4,
   4.108 -
   4.109 -			2,6,7, // +y
   4.110 -			2,7,3,
   4.111 -
   4.112 -			0,4,6, // -z
   4.113 -			0,6,2,
   4.114 -
   4.115 -			1,3,7, // +z
   4.116 -			1,7,5,
   4.117 -		};
   4.118 -
   4.119 -		m_indexCount = ARRAYSIZE(cubeIndices);
   4.120 -
   4.121 -		D3D11_SUBRESOURCE_DATA indexBufferData = {0};
   4.122 -		indexBufferData.pSysMem = cubeIndices;
   4.123 -		indexBufferData.SysMemPitch = 0;
   4.124 -		indexBufferData.SysMemSlicePitch = 0;
   4.125 -		CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER);
   4.126 -		DX::ThrowIfFailed(
   4.127 -			m_d3dDevice->CreateBuffer(
   4.128 -				&indexBufferDesc,
   4.129 -				&indexBufferData,
   4.130 -				&m_indexBuffer
   4.131 -				)
   4.132 -			);
   4.133 -	});
   4.134 -
   4.135 -	createCubeTask.then([this] () {
   4.136 -		m_loadingComplete = true;
   4.137 -	});
   4.138 -}
   4.139 -
   4.140 -void CubeRenderer::CreateWindowSizeDependentResources()
   4.141 -{
   4.142 -	Direct3DBase::CreateWindowSizeDependentResources();
   4.143 -
   4.144 -	float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
   4.145 -	float fovAngleY = 70.0f * XM_PI / 180.0f;
   4.146 -
   4.147 -	// Note that the m_orientationTransform3D matrix is post-multiplied here
   4.148 -	// in order to correctly orient the scene to match the display orientation.
   4.149 -	// This post-multiplication step is required for any draw calls that are
   4.150 -	// made to the swap chain render target. For draw calls to other targets,
   4.151 -	// this transform should not be applied.
   4.152 -	XMStoreFloat4x4(
   4.153 -		&m_constantBufferData.projection,
   4.154 -		XMMatrixTranspose(
   4.155 -			XMMatrixMultiply(
   4.156 -				XMMatrixPerspectiveFovRH(
   4.157 -					fovAngleY,
   4.158 -					aspectRatio,
   4.159 -					0.01f,
   4.160 -					100.0f
   4.161 -					),
   4.162 -				XMLoadFloat4x4(&m_orientationTransform3D)
   4.163 -				)
   4.164 -			)
   4.165 -		);
   4.166 -}
   4.167 -
   4.168 -void CubeRenderer::Update(float timeTotal, float timeDelta)
   4.169 -{
   4.170 -	(void) timeDelta; // Unused parameter.
   4.171 -
   4.172 -	XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);
   4.173 -	XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);
   4.174 -	XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
   4.175 -
   4.176 -	XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
   4.177 -	XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
   4.178 -}
   4.179 -
   4.180 -void CubeRenderer::Render()
   4.181 -{
   4.182 -	const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f };
   4.183 -	m_d3dContext->ClearRenderTargetView(
   4.184 -		m_renderTargetView.Get(),
   4.185 -		midnightBlue
   4.186 -		);
   4.187 -
   4.188 -	m_d3dContext->ClearDepthStencilView(
   4.189 -		m_depthStencilView.Get(),
   4.190 -		D3D11_CLEAR_DEPTH,
   4.191 -		1.0f,
   4.192 -		0
   4.193 -		);
   4.194 -
   4.195 -	// Only draw the cube once it is loaded (loading is asynchronous).
   4.196 -	if (!m_loadingComplete)
   4.197 -	{
   4.198 -		return;
   4.199 -	}
   4.200 -
   4.201 -	m_d3dContext->OMSetRenderTargets(
   4.202 -		1,
   4.203 -		m_renderTargetView.GetAddressOf(),
   4.204 -		m_depthStencilView.Get()
   4.205 -		);
   4.206 -
   4.207 -	m_d3dContext->UpdateSubresource(
   4.208 -		m_constantBuffer.Get(),
   4.209 -		0,
   4.210 -		NULL,
   4.211 -		&m_constantBufferData,
   4.212 -		0,
   4.213 -		0
   4.214 -		);
   4.215 -
   4.216 -	UINT stride = sizeof(VertexPositionColor);
   4.217 -	UINT offset = 0;
   4.218 -	m_d3dContext->IASetVertexBuffers(
   4.219 -		0,
   4.220 -		1,
   4.221 -		m_vertexBuffer.GetAddressOf(),
   4.222 -		&stride,
   4.223 -		&offset
   4.224 -		);
   4.225 -
   4.226 -	m_d3dContext->IASetIndexBuffer(
   4.227 -		m_indexBuffer.Get(),
   4.228 -		DXGI_FORMAT_R16_UINT,
   4.229 -		0
   4.230 -		);
   4.231 -
   4.232 -	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
   4.233 -
   4.234 -	m_d3dContext->IASetInputLayout(m_inputLayout.Get());
   4.235 -
   4.236 -	m_d3dContext->VSSetShader(
   4.237 -		m_vertexShader.Get(),
   4.238 -		nullptr,
   4.239 -		0
   4.240 -		);
   4.241 -
   4.242 -	m_d3dContext->VSSetConstantBuffers(
   4.243 -		0,
   4.244 -		1,
   4.245 -		m_constantBuffer.GetAddressOf()
   4.246 -		);
   4.247 -
   4.248 -	m_d3dContext->PSSetShader(
   4.249 -		m_pixelShader.Get(),
   4.250 -		nullptr,
   4.251 -		0
   4.252 -		);
   4.253 -
   4.254 -	m_d3dContext->DrawIndexed(
   4.255 -		m_indexCount,
   4.256 -		0,
   4.257 -		0
   4.258 -		);
   4.259 -}
     5.1 --- a/src/main/windowsrt/CubeRenderer.h	Sat Oct 27 20:12:31 2012 -0400
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,44 +0,0 @@
     5.4 -#pragma once
     5.5 -
     5.6 -#include "Direct3DBase.h"
     5.7 -
     5.8 -struct ModelViewProjectionConstantBuffer
     5.9 -{
    5.10 -	DirectX::XMFLOAT4X4 model;
    5.11 -	DirectX::XMFLOAT4X4 view;
    5.12 -	DirectX::XMFLOAT4X4 projection;
    5.13 -};
    5.14 -
    5.15 -struct VertexPositionColor
    5.16 -{
    5.17 -	DirectX::XMFLOAT3 pos;
    5.18 -	DirectX::XMFLOAT3 color;
    5.19 -};
    5.20 -
    5.21 -// This class renders a simple spinning cube.
    5.22 -ref class CubeRenderer sealed : public Direct3DBase
    5.23 -{
    5.24 -public:
    5.25 -	CubeRenderer();
    5.26 -
    5.27 -	// Direct3DBase methods.
    5.28 -	virtual void CreateDeviceResources() override;
    5.29 -	virtual void CreateWindowSizeDependentResources() override;
    5.30 -	virtual void Render() override;
    5.31 -	
    5.32 -	// Method for updating time-dependent objects.
    5.33 -	void Update(float timeTotal, float timeDelta);
    5.34 -
    5.35 -private:
    5.36 -	bool m_loadingComplete;
    5.37 -
    5.38 -	Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
    5.39 -	Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
    5.40 -	Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
    5.41 -	Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
    5.42 -	Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
    5.43 -	Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
    5.44 -
    5.45 -	uint32 m_indexCount;
    5.46 -	ModelViewProjectionConstantBuffer m_constantBufferData;
    5.47 -};
     6.1 --- a/src/main/windowsrt/Direct3DBase.cpp	Sat Oct 27 20:12:31 2012 -0400
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,344 +0,0 @@
     6.4 -#include "SDLmain_WinRT_common.h"
     6.5 -#include "Direct3DBase.h"
     6.6 -
     6.7 -using namespace DirectX;
     6.8 -using namespace Microsoft::WRL;
     6.9 -using namespace Windows::UI::Core;
    6.10 -using namespace Windows::Foundation;
    6.11 -using namespace Windows::Graphics::Display;
    6.12 -
    6.13 -// Constructor.
    6.14 -Direct3DBase::Direct3DBase()
    6.15 -{
    6.16 -}
    6.17 -
    6.18 -// Initialize the Direct3D resources required to run.
    6.19 -void Direct3DBase::Initialize(CoreWindow^ window)
    6.20 -{
    6.21 -	m_window = window;
    6.22 -	
    6.23 -	CreateDeviceResources();
    6.24 -	CreateWindowSizeDependentResources();
    6.25 -}
    6.26 -
    6.27 -// Recreate all device resources and set them back to the current state.
    6.28 -void Direct3DBase::HandleDeviceLost()
    6.29 -{
    6.30 -	// Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
    6.31 -	m_windowBounds.Width = 0;
    6.32 -	m_windowBounds.Height = 0;
    6.33 -	m_swapChain = nullptr;
    6.34 -
    6.35 -	CreateDeviceResources();
    6.36 -	UpdateForWindowSizeChange();
    6.37 -}
    6.38 -
    6.39 -// These are the resources that depend on the device.
    6.40 -void Direct3DBase::CreateDeviceResources()
    6.41 -{
    6.42 -	// This flag adds support for surfaces with a different color channel ordering
    6.43 -	// than the API default. It is required for compatibility with Direct2D.
    6.44 -	UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    6.45 -
    6.46 -#if defined(_DEBUG)
    6.47 -	// If the project is in a debug build, enable debugging via SDK Layers with this flag.
    6.48 -	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    6.49 -#endif
    6.50 -
    6.51 -	// This array defines the set of DirectX hardware feature levels this app will support.
    6.52 -	// Note the ordering should be preserved.
    6.53 -	// Don't forget to declare your application's minimum required feature level in its
    6.54 -	// description.  All applications are assumed to support 9.1 unless otherwise stated.
    6.55 -	D3D_FEATURE_LEVEL featureLevels[] = 
    6.56 -	{
    6.57 -		D3D_FEATURE_LEVEL_11_1,
    6.58 -		D3D_FEATURE_LEVEL_11_0,
    6.59 -		D3D_FEATURE_LEVEL_10_1,
    6.60 -		D3D_FEATURE_LEVEL_10_0,
    6.61 -		D3D_FEATURE_LEVEL_9_3,
    6.62 -		D3D_FEATURE_LEVEL_9_2,
    6.63 -		D3D_FEATURE_LEVEL_9_1
    6.64 -	};
    6.65 -
    6.66 -	// Create the Direct3D 11 API device object and a corresponding context.
    6.67 -	ComPtr<ID3D11Device> device;
    6.68 -	ComPtr<ID3D11DeviceContext> context;
    6.69 -	DX::ThrowIfFailed(
    6.70 -		D3D11CreateDevice(
    6.71 -			nullptr, // Specify nullptr to use the default adapter.
    6.72 -			D3D_DRIVER_TYPE_HARDWARE,
    6.73 -			nullptr,
    6.74 -			creationFlags, // Set set debug and Direct2D compatibility flags.
    6.75 -			featureLevels, // List of feature levels this app can support.
    6.76 -			ARRAYSIZE(featureLevels),
    6.77 -			D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
    6.78 -			&device, // Returns the Direct3D device created.
    6.79 -			&m_featureLevel, // Returns feature level of device created.
    6.80 -			&context // Returns the device immediate context.
    6.81 -			)
    6.82 -		);
    6.83 -
    6.84 -	// Get the Direct3D 11.1 API device and context interfaces.
    6.85 -	DX::ThrowIfFailed(
    6.86 -		device.As(&m_d3dDevice)
    6.87 -		);
    6.88 -
    6.89 -	DX::ThrowIfFailed(
    6.90 -		context.As(&m_d3dContext)
    6.91 -		);
    6.92 -}
    6.93 -
    6.94 -// Allocate all memory resources that change on a window SizeChanged event.
    6.95 -void Direct3DBase::CreateWindowSizeDependentResources()
    6.96 -{ 
    6.97 -	// Store the window bounds so the next time we get a SizeChanged event we can
    6.98 -	// avoid rebuilding everything if the size is identical.
    6.99 -	m_windowBounds = m_window->Bounds;
   6.100 -
   6.101 -	// Calculate the necessary swap chain and render target size in pixels.
   6.102 -	float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   6.103 -	float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
   6.104 -
   6.105 -	// The width and height of the swap chain must be based on the window's
   6.106 -	// landscape-oriented width and height. If the window is in a portrait
   6.107 -	// orientation, the dimensions must be reversed.
   6.108 -	m_orientation = DisplayProperties::CurrentOrientation;
   6.109 -	bool swapDimensions =
   6.110 -		m_orientation == DisplayOrientations::Portrait ||
   6.111 -		m_orientation == DisplayOrientations::PortraitFlipped;
   6.112 -	m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   6.113 -	m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
   6.114 -
   6.115 -	if(m_swapChain != nullptr)
   6.116 -	{
   6.117 -		// If the swap chain already exists, resize it.
   6.118 -		DX::ThrowIfFailed(
   6.119 -			m_swapChain->ResizeBuffers(
   6.120 -				2, // Double-buffered swap chain.
   6.121 -				static_cast<UINT>(m_renderTargetSize.Width),
   6.122 -				static_cast<UINT>(m_renderTargetSize.Height),
   6.123 -				DXGI_FORMAT_B8G8R8A8_UNORM,
   6.124 -				0
   6.125 -				)
   6.126 -			);
   6.127 -	}
   6.128 -	else
   6.129 -	{
   6.130 -		// Otherwise, create a new one using the same adapter as the existing Direct3D device.
   6.131 -		DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
   6.132 -		swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
   6.133 -		swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
   6.134 -		swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
   6.135 -		swapChainDesc.Stereo = false;
   6.136 -		swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
   6.137 -		swapChainDesc.SampleDesc.Quality = 0;
   6.138 -		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
   6.139 -		swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
   6.140 -		swapChainDesc.Scaling = DXGI_SCALING_NONE;
   6.141 -		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
   6.142 -		swapChainDesc.Flags = 0;
   6.143 -
   6.144 -		ComPtr<IDXGIDevice1>  dxgiDevice;
   6.145 -		DX::ThrowIfFailed(
   6.146 -			m_d3dDevice.As(&dxgiDevice)
   6.147 -			);
   6.148 -
   6.149 -		ComPtr<IDXGIAdapter> dxgiAdapter;
   6.150 -		DX::ThrowIfFailed(
   6.151 -			dxgiDevice->GetAdapter(&dxgiAdapter)
   6.152 -			);
   6.153 -
   6.154 -		ComPtr<IDXGIFactory2> dxgiFactory;
   6.155 -		DX::ThrowIfFailed(
   6.156 -			dxgiAdapter->GetParent(
   6.157 -				__uuidof(IDXGIFactory2), 
   6.158 -				&dxgiFactory
   6.159 -				)
   6.160 -			);
   6.161 -
   6.162 -		Windows::UI::Core::CoreWindow^ window = m_window.Get();
   6.163 -		DX::ThrowIfFailed(
   6.164 -			dxgiFactory->CreateSwapChainForCoreWindow(
   6.165 -				m_d3dDevice.Get(),
   6.166 -				reinterpret_cast<IUnknown*>(window),
   6.167 -				&swapChainDesc,
   6.168 -				nullptr, // Allow on all displays.
   6.169 -				&m_swapChain
   6.170 -				)
   6.171 -			);
   6.172 -			
   6.173 -		// Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
   6.174 -		// ensures that the application will only render after each VSync, minimizing power consumption.
   6.175 -		DX::ThrowIfFailed(
   6.176 -			dxgiDevice->SetMaximumFrameLatency(1)
   6.177 -			);
   6.178 -	}
   6.179 -	
   6.180 -	// Set the proper orientation for the swap chain, and generate the
   6.181 -	// 3D matrix transformation for rendering to the rotated swap chain.
   6.182 -	DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
   6.183 -	switch (m_orientation)
   6.184 -	{
   6.185 -		case DisplayOrientations::Landscape:
   6.186 -			rotation = DXGI_MODE_ROTATION_IDENTITY;
   6.187 -			m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
   6.188 -				1.0f, 0.0f, 0.0f, 0.0f,
   6.189 -				0.0f, 1.0f, 0.0f, 0.0f,
   6.190 -				0.0f, 0.0f, 1.0f, 0.0f,
   6.191 -				0.0f, 0.0f, 0.0f, 1.0f
   6.192 -				);
   6.193 -			break;
   6.194 -
   6.195 -		case DisplayOrientations::Portrait:
   6.196 -			rotation = DXGI_MODE_ROTATION_ROTATE270;
   6.197 -			m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
   6.198 -				0.0f, 1.0f, 0.0f, 0.0f,
   6.199 -				-1.0f, 0.0f, 0.0f, 0.0f,
   6.200 -				0.0f, 0.0f, 1.0f, 0.0f,
   6.201 -				0.0f, 0.0f, 0.0f, 1.0f
   6.202 -				);
   6.203 -			break;
   6.204 -
   6.205 -		case DisplayOrientations::LandscapeFlipped:
   6.206 -			rotation = DXGI_MODE_ROTATION_ROTATE180;
   6.207 -			m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
   6.208 -				-1.0f, 0.0f, 0.0f, 0.0f,
   6.209 -				0.0f, -1.0f, 0.0f, 0.0f,
   6.210 -				0.0f, 0.0f, 1.0f, 0.0f,
   6.211 -				0.0f, 0.0f, 0.0f, 1.0f
   6.212 -				);
   6.213 -			break;
   6.214 -
   6.215 -		case DisplayOrientations::PortraitFlipped:
   6.216 -			rotation = DXGI_MODE_ROTATION_ROTATE90;
   6.217 -			m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
   6.218 -				0.0f, -1.0f, 0.0f, 0.0f,
   6.219 -				1.0f, 0.0f, 0.0f, 0.0f,
   6.220 -				0.0f, 0.0f, 1.0f, 0.0f,
   6.221 -				0.0f, 0.0f, 0.0f, 1.0f
   6.222 -				);
   6.223 -			break;
   6.224 -
   6.225 -		default:
   6.226 -			throw ref new Platform::FailureException();
   6.227 -	}
   6.228 -
   6.229 -	DX::ThrowIfFailed(
   6.230 -		m_swapChain->SetRotation(rotation)
   6.231 -		);
   6.232 -
   6.233 -	// Create a render target view of the swap chain back buffer.
   6.234 -	ComPtr<ID3D11Texture2D> backBuffer;
   6.235 -	DX::ThrowIfFailed(
   6.236 -		m_swapChain->GetBuffer(
   6.237 -			0,
   6.238 -			__uuidof(ID3D11Texture2D),
   6.239 -			&backBuffer
   6.240 -			)
   6.241 -		);
   6.242 -
   6.243 -	DX::ThrowIfFailed(
   6.244 -		m_d3dDevice->CreateRenderTargetView(
   6.245 -			backBuffer.Get(),
   6.246 -			nullptr,
   6.247 -			&m_renderTargetView
   6.248 -			)
   6.249 -		);
   6.250 -
   6.251 -	// Create a depth stencil view.
   6.252 -	CD3D11_TEXTURE2D_DESC depthStencilDesc(
   6.253 -		DXGI_FORMAT_D24_UNORM_S8_UINT, 
   6.254 -		static_cast<UINT>(m_renderTargetSize.Width),
   6.255 -		static_cast<UINT>(m_renderTargetSize.Height),
   6.256 -		1,
   6.257 -		1,
   6.258 -		D3D11_BIND_DEPTH_STENCIL
   6.259 -		);
   6.260 -
   6.261 -	ComPtr<ID3D11Texture2D> depthStencil;
   6.262 -	DX::ThrowIfFailed(
   6.263 -		m_d3dDevice->CreateTexture2D(
   6.264 -			&depthStencilDesc,
   6.265 -			nullptr,
   6.266 -			&depthStencil
   6.267 -			)
   6.268 -		);
   6.269 -
   6.270 -	CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
   6.271 -	DX::ThrowIfFailed(
   6.272 -		m_d3dDevice->CreateDepthStencilView(
   6.273 -			depthStencil.Get(),
   6.274 -			&depthStencilViewDesc,
   6.275 -			&m_depthStencilView
   6.276 -			)
   6.277 -		);
   6.278 -
   6.279 -	// Set the rendering viewport to target the entire window.
   6.280 -	CD3D11_VIEWPORT viewport(
   6.281 -		0.0f,
   6.282 -		0.0f,
   6.283 -		m_renderTargetSize.Width,
   6.284 -		m_renderTargetSize.Height
   6.285 -		);
   6.286 -
   6.287 -	m_d3dContext->RSSetViewports(1, &viewport);
   6.288 -}
   6.289 -
   6.290 -// This method is called in the event handler for the SizeChanged event.
   6.291 -void Direct3DBase::UpdateForWindowSizeChange()
   6.292 -{
   6.293 -	if (m_window->Bounds.Width  != m_windowBounds.Width ||
   6.294 -		m_window->Bounds.Height != m_windowBounds.Height ||
   6.295 -		m_orientation != DisplayProperties::CurrentOrientation)
   6.296 -	{
   6.297 -		ID3D11RenderTargetView* nullViews[] = {nullptr};
   6.298 -		m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
   6.299 -		m_renderTargetView = nullptr;
   6.300 -		m_depthStencilView = nullptr;
   6.301 -		m_d3dContext->Flush();
   6.302 -		CreateWindowSizeDependentResources();
   6.303 -	}
   6.304 -}
   6.305 -
   6.306 -// Method to deliver the final image to the display.
   6.307 -void Direct3DBase::Present()
   6.308 -{
   6.309 -	// The application may optionally specify "dirty" or "scroll"
   6.310 -	// rects to improve efficiency in certain scenarios.
   6.311 -	DXGI_PRESENT_PARAMETERS parameters = {0};
   6.312 -	parameters.DirtyRectsCount = 0;
   6.313 -	parameters.pDirtyRects = nullptr;
   6.314 -	parameters.pScrollRect = nullptr;
   6.315 -	parameters.pScrollOffset = nullptr;
   6.316 -	
   6.317 -	// The first argument instructs DXGI to block until VSync, putting the application
   6.318 -	// to sleep until the next VSync. This ensures we don't waste any cycles rendering
   6.319 -	// frames that will never be displayed to the screen.
   6.320 -	HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
   6.321 -
   6.322 -	// Discard the contents of the render target.
   6.323 -	// This is a valid operation only when the existing contents will be entirely
   6.324 -	// overwritten. If dirty or scroll rects are used, this call should be removed.
   6.325 -	m_d3dContext->DiscardView(m_renderTargetView.Get());
   6.326 -
   6.327 -	// Discard the contents of the depth stencil.
   6.328 -	m_d3dContext->DiscardView(m_depthStencilView.Get());
   6.329 -
   6.330 -	// If the device was removed either by a disconnect or a driver upgrade, we 
   6.331 -	// must recreate all device resources.
   6.332 -	if (hr == DXGI_ERROR_DEVICE_REMOVED)
   6.333 -	{
   6.334 -		HandleDeviceLost();
   6.335 -	}
   6.336 -	else
   6.337 -	{
   6.338 -		DX::ThrowIfFailed(hr);
   6.339 -	}
   6.340 -}
   6.341 -
   6.342 -// Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
   6.343 -float Direct3DBase::ConvertDipsToPixels(float dips)
   6.344 -{
   6.345 -	static const float dipsPerInch = 96.0f;
   6.346 -	return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
   6.347 -}
     7.1 --- a/src/main/windowsrt/Direct3DBase.h	Sat Oct 27 20:12:31 2012 -0400
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,38 +0,0 @@
     7.4 -#pragma once
     7.5 -
     7.6 -#include "DirectXHelper.h"
     7.7 -
     7.8 -// Helper class that initializes DirectX APIs for 3D rendering.
     7.9 -ref class Direct3DBase abstract
    7.10 -{
    7.11 -internal:
    7.12 -	Direct3DBase();
    7.13 -
    7.14 -public:
    7.15 -	virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
    7.16 -	virtual void HandleDeviceLost();
    7.17 -	virtual void CreateDeviceResources();
    7.18 -	virtual void CreateWindowSizeDependentResources();
    7.19 -	virtual void UpdateForWindowSizeChange();
    7.20 -	virtual void Render() = 0;
    7.21 -	virtual void Present();
    7.22 -	virtual float ConvertDipsToPixels(float dips);
    7.23 -
    7.24 -protected private:
    7.25 -	// Direct3D Objects.
    7.26 -	Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
    7.27 -	Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
    7.28 -	Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
    7.29 -	Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
    7.30 -	Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
    7.31 -
    7.32 -	// Cached renderer properties.
    7.33 -	D3D_FEATURE_LEVEL m_featureLevel;
    7.34 -	Windows::Foundation::Size m_renderTargetSize;
    7.35 -	Windows::Foundation::Rect m_windowBounds;
    7.36 -	Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
    7.37 -	Windows::Graphics::Display::DisplayOrientations m_orientation;
    7.38 -
    7.39 -	// Transform used for display orientation.
    7.40 -	DirectX::XMFLOAT4X4 m_orientationTransform3D;
    7.41 -};
     8.1 --- a/src/main/windowsrt/DirectXHelper.h	Sat Oct 27 20:12:31 2012 -0400
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,36 +0,0 @@
     8.4 -#pragma once
     8.5 -
     8.6 -#include <wrl/client.h>
     8.7 -#include <ppl.h>
     8.8 -#include <ppltasks.h>
     8.9 -
    8.10 -namespace DX
    8.11 -{
    8.12 -	inline void ThrowIfFailed(HRESULT hr)
    8.13 -	{
    8.14 -		if (FAILED(hr))
    8.15 -		{
    8.16 -			// Set a breakpoint on this line to catch Win32 API errors.
    8.17 -			throw Platform::Exception::CreateException(hr);
    8.18 -		}
    8.19 -	}
    8.20 -
    8.21 -	// Function that reads from a binary file asynchronously.
    8.22 -	inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
    8.23 -	{
    8.24 -		using namespace Windows::Storage;
    8.25 -		using namespace Concurrency;
    8.26 -		
    8.27 -		auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
    8.28 -		
    8.29 -		return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file) 
    8.30 -		{
    8.31 -			return FileIO::ReadBufferAsync(file);
    8.32 -		}).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^ 
    8.33 -		{
    8.34 -			auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
    8.35 -			Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
    8.36 -			return fileData;
    8.37 -		});
    8.38 -	}
    8.39 -}
     9.1 --- a/src/main/windowsrt/SDL_WinRTApp.cpp	Sat Oct 27 20:12:31 2012 -0400
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,148 +0,0 @@
     9.4 -#include "SDLmain_WinRT_common.h"
     9.5 -#include "SDL_WinRTApp.h"
     9.6 -#include "BasicTimer.h"
     9.7 -
     9.8 -using namespace Windows::ApplicationModel;
     9.9 -using namespace Windows::ApplicationModel::Core;
    9.10 -using namespace Windows::ApplicationModel::Activation;
    9.11 -using namespace Windows::UI::Core;
    9.12 -using namespace Windows::System;
    9.13 -using namespace Windows::Foundation;
    9.14 -using namespace Windows::Graphics::Display;
    9.15 -using namespace concurrency;
    9.16 -
    9.17 -SDL_WinRTApp::SDL_WinRTApp() :
    9.18 -	m_windowClosed(false),
    9.19 -	m_windowVisible(true)
    9.20 -{
    9.21 -}
    9.22 -
    9.23 -void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
    9.24 -{
    9.25 -	applicationView->Activated +=
    9.26 -        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
    9.27 -
    9.28 -	CoreApplication::Suspending +=
    9.29 -        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
    9.30 -
    9.31 -	CoreApplication::Resuming +=
    9.32 -        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
    9.33 -
    9.34 -	m_renderer = ref new CubeRenderer();
    9.35 -}
    9.36 -
    9.37 -void SDL_WinRTApp::SetWindow(CoreWindow^ window)
    9.38 -{
    9.39 -	window->SizeChanged += 
    9.40 -        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
    9.41 -
    9.42 -	window->VisibilityChanged +=
    9.43 -		ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
    9.44 -
    9.45 -	window->Closed += 
    9.46 -        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
    9.47 -
    9.48 -	window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
    9.49 -
    9.50 -	window->PointerPressed +=
    9.51 -		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
    9.52 -
    9.53 -	window->PointerMoved +=
    9.54 -		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
    9.55 -
    9.56 -	m_renderer->Initialize(CoreWindow::GetForCurrentThread());
    9.57 -}
    9.58 -
    9.59 -void SDL_WinRTApp::Load(Platform::String^ entryPoint)
    9.60 -{
    9.61 -}
    9.62 -
    9.63 -void SDL_WinRTApp::Run()
    9.64 -{
    9.65 -	BasicTimer^ timer = ref new BasicTimer();
    9.66 -
    9.67 -	while (!m_windowClosed)
    9.68 -	{
    9.69 -		if (m_windowVisible)
    9.70 -		{
    9.71 -			timer->Update();
    9.72 -			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
    9.73 -			m_renderer->Update(timer->Total, timer->Delta);
    9.74 -			m_renderer->Render();
    9.75 -			m_renderer->Present(); // This call is synchronized to the display frame rate.
    9.76 -		}
    9.77 -		else
    9.78 -		{
    9.79 -			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
    9.80 -		}
    9.81 -	}
    9.82 -}
    9.83 -
    9.84 -void SDL_WinRTApp::Uninitialize()
    9.85 -{
    9.86 -}
    9.87 -
    9.88 -void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
    9.89 -{
    9.90 -	m_renderer->UpdateForWindowSizeChange();
    9.91 -}
    9.92 -
    9.93 -void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
    9.94 -{
    9.95 -	m_windowVisible = args->Visible;
    9.96 -}
    9.97 -
    9.98 -void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
    9.99 -{
   9.100 -	m_windowClosed = true;
   9.101 -}
   9.102 -
   9.103 -void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
   9.104 -{
   9.105 -	// Insert your code here.
   9.106 -}
   9.107 -
   9.108 -void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
   9.109 -{
   9.110 -	// Insert your code here.
   9.111 -}
   9.112 -
   9.113 -void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
   9.114 -{
   9.115 -	CoreWindow::GetForCurrentThread()->Activate();
   9.116 -}
   9.117 -
   9.118 -void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
   9.119 -{
   9.120 -	// Save app state asynchronously after requesting a deferral. Holding a deferral
   9.121 -	// indicates that the application is busy performing suspending operations. Be
   9.122 -	// aware that a deferral may not be held indefinitely. After about five seconds,
   9.123 -	// the app will be forced to exit.
   9.124 -	SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
   9.125 -
   9.126 -	create_task([this, deferral]()
   9.127 -	{
   9.128 -		// Insert your code here.
   9.129 -
   9.130 -		deferral->Complete();
   9.131 -	});
   9.132 -}
   9.133 - 
   9.134 -void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
   9.135 -{
   9.136 -	// Restore any data or state that was unloaded on suspend. By default, data
   9.137 -	// and state are persisted when resuming from suspend. Note that this event
   9.138 -	// does not occur if the app was previously terminated.
   9.139 -}
   9.140 -
   9.141 -IFrameworkView^ Direct3DApplicationSource::CreateView()
   9.142 -{
   9.143 -    return ref new SDL_WinRTApp();
   9.144 -}
   9.145 -
   9.146 -int SDL_WinRT_RunApplication(/*Platform::Array<Platform::String^>^*/)
   9.147 -{
   9.148 -	auto direct3DApplicationSource = ref new Direct3DApplicationSource();
   9.149 -	CoreApplication::Run(direct3DApplicationSource);
   9.150 -	return 0;
   9.151 -}
    10.1 --- a/src/main/windowsrt/SDL_WinRTApp.h	Sat Oct 27 20:12:31 2012 -0400
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,40 +0,0 @@
    10.4 -#pragma once
    10.5 -
    10.6 -#include "SDLmain_WinRT_common.h"
    10.7 -#include "CubeRenderer.h"
    10.8 -
    10.9 -ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
   10.10 -{
   10.11 -public:
   10.12 -	SDL_WinRTApp();
   10.13 -	
   10.14 -	// IFrameworkView Methods.
   10.15 -	virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
   10.16 -	virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
   10.17 -	virtual void Load(Platform::String^ entryPoint);
   10.18 -	virtual void Run();
   10.19 -	virtual void Uninitialize();
   10.20 -
   10.21 -protected:
   10.22 -	// Event Handlers.
   10.23 -	void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
   10.24 -	void OnLogicalDpiChanged(Platform::Object^ sender);
   10.25 -	void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
   10.26 -	void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
   10.27 -	void OnResuming(Platform::Object^ sender, Platform::Object^ args);
   10.28 -	void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
   10.29 -	void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
   10.30 -	void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.31 -	void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.32 -
   10.33 -private:
   10.34 -	CubeRenderer^ m_renderer;
   10.35 -	bool m_windowClosed;
   10.36 -	bool m_windowVisible;
   10.37 -};
   10.38 -
   10.39 -ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
   10.40 -{
   10.41 -public:
   10.42 -	virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
   10.43 -};
    11.1 --- a/src/main/windowsrt/SDLmain_WinRT_common.h	Sat Oct 27 20:12:31 2012 -0400
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,7 +0,0 @@
    11.4 -#pragma once
    11.5 -
    11.6 -#include <wrl/client.h>
    11.7 -#include <d3d11_1.h>
    11.8 -#include <DirectXMath.h>
    11.9 -#include <memory>
   11.10 -#include <agile.h>
   11.11 \ No newline at end of file
    12.1 --- a/src/main/windowsrt/SimplePixelShader.hlsl	Sat Oct 27 20:12:31 2012 -0400
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,10 +0,0 @@
    12.4 -struct PixelShaderInput
    12.5 -{
    12.6 -	float4 pos : SV_POSITION;
    12.7 -	float3 color : COLOR0;
    12.8 -};
    12.9 -
   12.10 -float4 main(PixelShaderInput input) : SV_TARGET
   12.11 -{
   12.12 -	return float4(input.color,1.0f);
   12.13 -}
    13.1 --- a/src/main/windowsrt/SimpleVertexShader.hlsl	Sat Oct 27 20:12:31 2012 -0400
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,35 +0,0 @@
    13.4 -cbuffer ModelViewProjectionConstantBuffer : register(b0)
    13.5 -{
    13.6 -	matrix model;
    13.7 -	matrix view;
    13.8 -	matrix projection;
    13.9 -};
   13.10 -
   13.11 -struct VertexShaderInput
   13.12 -{
   13.13 -	float3 pos : POSITION;
   13.14 -	float3 color : COLOR0;
   13.15 -};
   13.16 -
   13.17 -struct VertexShaderOutput
   13.18 -{
   13.19 -	float4 pos : SV_POSITION;
   13.20 -	float3 color : COLOR0;
   13.21 -};
   13.22 -
   13.23 -VertexShaderOutput main(VertexShaderInput input)
   13.24 -{
   13.25 -	VertexShaderOutput output;
   13.26 -	float4 pos = float4(input.pos, 1.0f);
   13.27 -
   13.28 -	// Transform the vertex position into projected space.
   13.29 -	pos = mul(pos, model);
   13.30 -	pos = mul(pos, view);
   13.31 -	pos = mul(pos, projection);
   13.32 -	output.pos = pos;
   13.33 -
   13.34 -	// Pass through the color without modification.
   13.35 -	output.color = input.color;
   13.36 -
   13.37 -	return output;
   13.38 -}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/video/windowsrt/BasicTimer.h	Sat Oct 27 21:20:00 2012 -0400
    14.3 @@ -0,0 +1,76 @@
    14.4 +#pragma once
    14.5 +
    14.6 +#include <wrl.h>
    14.7 +
    14.8 +// Helper class for basic timing.
    14.9 +ref class BasicTimer sealed
   14.10 +{
   14.11 +public:
   14.12 +	// Initializes internal timer values.
   14.13 +	BasicTimer()
   14.14 +	{
   14.15 +		if (!QueryPerformanceFrequency(&m_frequency))
   14.16 +		{
   14.17 +			throw ref new Platform::FailureException();
   14.18 +		}
   14.19 +		Reset();
   14.20 +	}
   14.21 +	
   14.22 +	// Reset the timer to initial values.
   14.23 +	void Reset()
   14.24 +	{
   14.25 +		Update();
   14.26 +		m_startTime = m_currentTime;
   14.27 +		m_total = 0.0f;
   14.28 +		m_delta = 1.0f / 60.0f;
   14.29 +	}
   14.30 +	
   14.31 +	// Update the timer's internal values.
   14.32 +	void Update()
   14.33 +	{
   14.34 +		if (!QueryPerformanceCounter(&m_currentTime))
   14.35 +		{
   14.36 +			throw ref new Platform::FailureException();
   14.37 +		}
   14.38 +		
   14.39 +		m_total = static_cast<float>(
   14.40 +			static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) /
   14.41 +			static_cast<double>(m_frequency.QuadPart)
   14.42 +			);
   14.43 +		
   14.44 +		if (m_lastTime.QuadPart == m_startTime.QuadPart)
   14.45 +		{
   14.46 +			// If the timer was just reset, report a time delta equivalent to 60Hz frame time.
   14.47 +			m_delta = 1.0f / 60.0f;
   14.48 +		}
   14.49 +		else
   14.50 +		{
   14.51 +			m_delta = static_cast<float>(
   14.52 +				static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) /
   14.53 +				static_cast<double>(m_frequency.QuadPart)
   14.54 +				);
   14.55 +		}
   14.56 +		
   14.57 +		m_lastTime = m_currentTime;
   14.58 +	}
   14.59 +	
   14.60 +	// Duration in seconds between the last call to Reset() and the last call to Update().
   14.61 +	property float Total
   14.62 +	{
   14.63 +		float get() { return m_total; }
   14.64 +	}
   14.65 +	
   14.66 +	// Duration in seconds between the previous two calls to Update().
   14.67 +	property float Delta
   14.68 +	{
   14.69 +		float get() { return m_delta; }
   14.70 +	}
   14.71 +
   14.72 +private:
   14.73 +	LARGE_INTEGER m_frequency;
   14.74 +	LARGE_INTEGER m_currentTime;
   14.75 +	LARGE_INTEGER m_startTime;
   14.76 +	LARGE_INTEGER m_lastTime;
   14.77 +	float m_total;
   14.78 +	float m_delta;
   14.79 +};
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/video/windowsrt/CubeRenderer.cpp	Sat Oct 27 21:20:00 2012 -0400
    15.3 @@ -0,0 +1,256 @@
    15.4 +#include "SDLmain_WinRT_common.h"
    15.5 +#include "CubeRenderer.h"
    15.6 +
    15.7 +using namespace DirectX;
    15.8 +using namespace Microsoft::WRL;
    15.9 +using namespace Windows::Foundation;
   15.10 +using namespace Windows::UI::Core;
   15.11 +
   15.12 +CubeRenderer::CubeRenderer() :
   15.13 +	m_loadingComplete(false),
   15.14 +	m_indexCount(0)
   15.15 +{
   15.16 +}
   15.17 +
   15.18 +void CubeRenderer::CreateDeviceResources()
   15.19 +{
   15.20 +	Direct3DBase::CreateDeviceResources();
   15.21 +
   15.22 +	auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
   15.23 +	auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
   15.24 +
   15.25 +	auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
   15.26 +		DX::ThrowIfFailed(
   15.27 +			m_d3dDevice->CreateVertexShader(
   15.28 + 				fileData->Data,
   15.29 +				fileData->Length,
   15.30 +				nullptr,
   15.31 +				&m_vertexShader
   15.32 +				)
   15.33 +			);
   15.34 +
   15.35 +		const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = 
   15.36 +		{
   15.37 +			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
   15.38 +			{ "COLOR",    0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   15.39 +		};
   15.40 +
   15.41 +		DX::ThrowIfFailed(
   15.42 +			m_d3dDevice->CreateInputLayout(
   15.43 +				vertexDesc,
   15.44 +				ARRAYSIZE(vertexDesc),
   15.45 +				fileData->Data,
   15.46 +				fileData->Length,
   15.47 +				&m_inputLayout
   15.48 +				)
   15.49 +			);
   15.50 +	});
   15.51 +
   15.52 +	auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
   15.53 +		DX::ThrowIfFailed(
   15.54 +			m_d3dDevice->CreatePixelShader(
   15.55 +				fileData->Data,
   15.56 +				fileData->Length,
   15.57 +				nullptr,
   15.58 +				&m_pixelShader
   15.59 +				)
   15.60 +			);
   15.61 +
   15.62 +		CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
   15.63 +		DX::ThrowIfFailed(
   15.64 +			m_d3dDevice->CreateBuffer(
   15.65 +				&constantBufferDesc,
   15.66 +				nullptr,
   15.67 +				&m_constantBuffer
   15.68 +				)
   15.69 +			);
   15.70 +	});
   15.71 +
   15.72 +	auto createCubeTask = (createPSTask && createVSTask).then([this] () {
   15.73 +		VertexPositionColor cubeVertices[] = 
   15.74 +		{
   15.75 +			{XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f)},
   15.76 +			{XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f)},
   15.77 +			{XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f)},
   15.78 +			{XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f)},
   15.79 +			{XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f)},
   15.80 +			{XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f)},
   15.81 +			{XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f)},
   15.82 +			{XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f)},
   15.83 +		};
   15.84 +
   15.85 +		D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
   15.86 +		vertexBufferData.pSysMem = cubeVertices;
   15.87 +		vertexBufferData.SysMemPitch = 0;
   15.88 +		vertexBufferData.SysMemSlicePitch = 0;
   15.89 +		CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices), D3D11_BIND_VERTEX_BUFFER);
   15.90 +		DX::ThrowIfFailed(
   15.91 +			m_d3dDevice->CreateBuffer(
   15.92 +				&vertexBufferDesc,
   15.93 +				&vertexBufferData,
   15.94 +				&m_vertexBuffer
   15.95 +				)
   15.96 +			);
   15.97 +
   15.98 +		unsigned short cubeIndices[] = 
   15.99 +		{
  15.100 +			0,2,1, // -x
  15.101 +			1,2,3,
  15.102 +
  15.103 +			4,5,6, // +x
  15.104 +			5,7,6,
  15.105 +
  15.106 +			0,1,5, // -y
  15.107 +			0,5,4,
  15.108 +
  15.109 +			2,6,7, // +y
  15.110 +			2,7,3,
  15.111 +
  15.112 +			0,4,6, // -z
  15.113 +			0,6,2,
  15.114 +
  15.115 +			1,3,7, // +z
  15.116 +			1,7,5,
  15.117 +		};
  15.118 +
  15.119 +		m_indexCount = ARRAYSIZE(cubeIndices);
  15.120 +
  15.121 +		D3D11_SUBRESOURCE_DATA indexBufferData = {0};
  15.122 +		indexBufferData.pSysMem = cubeIndices;
  15.123 +		indexBufferData.SysMemPitch = 0;
  15.124 +		indexBufferData.SysMemSlicePitch = 0;
  15.125 +		CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER);
  15.126 +		DX::ThrowIfFailed(
  15.127 +			m_d3dDevice->CreateBuffer(
  15.128 +				&indexBufferDesc,
  15.129 +				&indexBufferData,
  15.130 +				&m_indexBuffer
  15.131 +				)
  15.132 +			);
  15.133 +	});
  15.134 +
  15.135 +	createCubeTask.then([this] () {
  15.136 +		m_loadingComplete = true;
  15.137 +	});
  15.138 +}
  15.139 +
  15.140 +void CubeRenderer::CreateWindowSizeDependentResources()
  15.141 +{
  15.142 +	Direct3DBase::CreateWindowSizeDependentResources();
  15.143 +
  15.144 +	float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
  15.145 +	float fovAngleY = 70.0f * XM_PI / 180.0f;
  15.146 +
  15.147 +	// Note that the m_orientationTransform3D matrix is post-multiplied here
  15.148 +	// in order to correctly orient the scene to match the display orientation.
  15.149 +	// This post-multiplication step is required for any draw calls that are
  15.150 +	// made to the swap chain render target. For draw calls to other targets,
  15.151 +	// this transform should not be applied.
  15.152 +	XMStoreFloat4x4(
  15.153 +		&m_constantBufferData.projection,
  15.154 +		XMMatrixTranspose(
  15.155 +			XMMatrixMultiply(
  15.156 +				XMMatrixPerspectiveFovRH(
  15.157 +					fovAngleY,
  15.158 +					aspectRatio,
  15.159 +					0.01f,
  15.160 +					100.0f
  15.161 +					),
  15.162 +				XMLoadFloat4x4(&m_orientationTransform3D)
  15.163 +				)
  15.164 +			)
  15.165 +		);
  15.166 +}
  15.167 +
  15.168 +void CubeRenderer::Update(float timeTotal, float timeDelta)
  15.169 +{
  15.170 +	(void) timeDelta; // Unused parameter.
  15.171 +
  15.172 +	XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);
  15.173 +	XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);
  15.174 +	XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
  15.175 +
  15.176 +	XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
  15.177 +	XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
  15.178 +}
  15.179 +
  15.180 +void CubeRenderer::Render()
  15.181 +{
  15.182 +	const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f };
  15.183 +	m_d3dContext->ClearRenderTargetView(
  15.184 +		m_renderTargetView.Get(),
  15.185 +		midnightBlue
  15.186 +		);
  15.187 +
  15.188 +	m_d3dContext->ClearDepthStencilView(
  15.189 +		m_depthStencilView.Get(),
  15.190 +		D3D11_CLEAR_DEPTH,
  15.191 +		1.0f,
  15.192 +		0
  15.193 +		);
  15.194 +
  15.195 +	// Only draw the cube once it is loaded (loading is asynchronous).
  15.196 +	if (!m_loadingComplete)
  15.197 +	{
  15.198 +		return;
  15.199 +	}
  15.200 +
  15.201 +	m_d3dContext->OMSetRenderTargets(
  15.202 +		1,
  15.203 +		m_renderTargetView.GetAddressOf(),
  15.204 +		m_depthStencilView.Get()
  15.205 +		);
  15.206 +
  15.207 +	m_d3dContext->UpdateSubresource(
  15.208 +		m_constantBuffer.Get(),
  15.209 +		0,
  15.210 +		NULL,
  15.211 +		&m_constantBufferData,
  15.212 +		0,
  15.213 +		0
  15.214 +		);
  15.215 +
  15.216 +	UINT stride = sizeof(VertexPositionColor);
  15.217 +	UINT offset = 0;
  15.218 +	m_d3dContext->IASetVertexBuffers(
  15.219 +		0,
  15.220 +		1,
  15.221 +		m_vertexBuffer.GetAddressOf(),
  15.222 +		&stride,
  15.223 +		&offset
  15.224 +		);
  15.225 +
  15.226 +	m_d3dContext->IASetIndexBuffer(
  15.227 +		m_indexBuffer.Get(),
  15.228 +		DXGI_FORMAT_R16_UINT,
  15.229 +		0
  15.230 +		);
  15.231 +
  15.232 +	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
  15.233 +
  15.234 +	m_d3dContext->IASetInputLayout(m_inputLayout.Get());
  15.235 +
  15.236 +	m_d3dContext->VSSetShader(
  15.237 +		m_vertexShader.Get(),
  15.238 +		nullptr,
  15.239 +		0
  15.240 +		);
  15.241 +
  15.242 +	m_d3dContext->VSSetConstantBuffers(
  15.243 +		0,
  15.244 +		1,
  15.245 +		m_constantBuffer.GetAddressOf()
  15.246 +		);
  15.247 +
  15.248 +	m_d3dContext->PSSetShader(
  15.249 +		m_pixelShader.Get(),
  15.250 +		nullptr,
  15.251 +		0
  15.252 +		);
  15.253 +
  15.254 +	m_d3dContext->DrawIndexed(
  15.255 +		m_indexCount,
  15.256 +		0,
  15.257 +		0
  15.258 +		);
  15.259 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/video/windowsrt/CubeRenderer.h	Sat Oct 27 21:20:00 2012 -0400
    16.3 @@ -0,0 +1,44 @@
    16.4 +#pragma once
    16.5 +
    16.6 +#include "Direct3DBase.h"
    16.7 +
    16.8 +struct ModelViewProjectionConstantBuffer
    16.9 +{
   16.10 +	DirectX::XMFLOAT4X4 model;
   16.11 +	DirectX::XMFLOAT4X4 view;
   16.12 +	DirectX::XMFLOAT4X4 projection;
   16.13 +};
   16.14 +
   16.15 +struct VertexPositionColor
   16.16 +{
   16.17 +	DirectX::XMFLOAT3 pos;
   16.18 +	DirectX::XMFLOAT3 color;
   16.19 +};
   16.20 +
   16.21 +// This class renders a simple spinning cube.
   16.22 +ref class CubeRenderer sealed : public Direct3DBase
   16.23 +{
   16.24 +public:
   16.25 +	CubeRenderer();
   16.26 +
   16.27 +	// Direct3DBase methods.
   16.28 +	virtual void CreateDeviceResources() override;
   16.29 +	virtual void CreateWindowSizeDependentResources() override;
   16.30 +	virtual void Render() override;
   16.31 +	
   16.32 +	// Method for updating time-dependent objects.
   16.33 +	void Update(float timeTotal, float timeDelta);
   16.34 +
   16.35 +private:
   16.36 +	bool m_loadingComplete;
   16.37 +
   16.38 +	Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
   16.39 +	Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
   16.40 +	Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
   16.41 +	Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
   16.42 +	Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
   16.43 +	Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
   16.44 +
   16.45 +	uint32 m_indexCount;
   16.46 +	ModelViewProjectionConstantBuffer m_constantBufferData;
   16.47 +};
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/video/windowsrt/Direct3DBase.cpp	Sat Oct 27 21:20:00 2012 -0400
    17.3 @@ -0,0 +1,344 @@
    17.4 +#include "SDLmain_WinRT_common.h"
    17.5 +#include "Direct3DBase.h"
    17.6 +
    17.7 +using namespace DirectX;
    17.8 +using namespace Microsoft::WRL;
    17.9 +using namespace Windows::UI::Core;
   17.10 +using namespace Windows::Foundation;
   17.11 +using namespace Windows::Graphics::Display;
   17.12 +
   17.13 +// Constructor.
   17.14 +Direct3DBase::Direct3DBase()
   17.15 +{
   17.16 +}
   17.17 +
   17.18 +// Initialize the Direct3D resources required to run.
   17.19 +void Direct3DBase::Initialize(CoreWindow^ window)
   17.20 +{
   17.21 +	m_window = window;
   17.22 +	
   17.23 +	CreateDeviceResources();
   17.24 +	CreateWindowSizeDependentResources();
   17.25 +}
   17.26 +
   17.27 +// Recreate all device resources and set them back to the current state.
   17.28 +void Direct3DBase::HandleDeviceLost()
   17.29 +{
   17.30 +	// Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
   17.31 +	m_windowBounds.Width = 0;
   17.32 +	m_windowBounds.Height = 0;
   17.33 +	m_swapChain = nullptr;
   17.34 +
   17.35 +	CreateDeviceResources();
   17.36 +	UpdateForWindowSizeChange();
   17.37 +}
   17.38 +
   17.39 +// These are the resources that depend on the device.
   17.40 +void Direct3DBase::CreateDeviceResources()
   17.41 +{
   17.42 +	// This flag adds support for surfaces with a different color channel ordering
   17.43 +	// than the API default. It is required for compatibility with Direct2D.
   17.44 +	UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
   17.45 +
   17.46 +#if defined(_DEBUG)
   17.47 +	// If the project is in a debug build, enable debugging via SDK Layers with this flag.
   17.48 +	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
   17.49 +#endif
   17.50 +
   17.51 +	// This array defines the set of DirectX hardware feature levels this app will support.
   17.52 +	// Note the ordering should be preserved.
   17.53 +	// Don't forget to declare your application's minimum required feature level in its
   17.54 +	// description.  All applications are assumed to support 9.1 unless otherwise stated.
   17.55 +	D3D_FEATURE_LEVEL featureLevels[] = 
   17.56 +	{
   17.57 +		D3D_FEATURE_LEVEL_11_1,
   17.58 +		D3D_FEATURE_LEVEL_11_0,
   17.59 +		D3D_FEATURE_LEVEL_10_1,
   17.60 +		D3D_FEATURE_LEVEL_10_0,
   17.61 +		D3D_FEATURE_LEVEL_9_3,
   17.62 +		D3D_FEATURE_LEVEL_9_2,
   17.63 +		D3D_FEATURE_LEVEL_9_1
   17.64 +	};
   17.65 +
   17.66 +	// Create the Direct3D 11 API device object and a corresponding context.
   17.67 +	ComPtr<ID3D11Device> device;
   17.68 +	ComPtr<ID3D11DeviceContext> context;
   17.69 +	DX::ThrowIfFailed(
   17.70 +		D3D11CreateDevice(
   17.71 +			nullptr, // Specify nullptr to use the default adapter.
   17.72 +			D3D_DRIVER_TYPE_HARDWARE,
   17.73 +			nullptr,
   17.74 +			creationFlags, // Set set debug and Direct2D compatibility flags.
   17.75 +			featureLevels, // List of feature levels this app can support.
   17.76 +			ARRAYSIZE(featureLevels),
   17.77 +			D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
   17.78 +			&device, // Returns the Direct3D device created.
   17.79 +			&m_featureLevel, // Returns feature level of device created.
   17.80 +			&context // Returns the device immediate context.
   17.81 +			)
   17.82 +		);
   17.83 +
   17.84 +	// Get the Direct3D 11.1 API device and context interfaces.
   17.85 +	DX::ThrowIfFailed(
   17.86 +		device.As(&m_d3dDevice)
   17.87 +		);
   17.88 +
   17.89 +	DX::ThrowIfFailed(
   17.90 +		context.As(&m_d3dContext)
   17.91 +		);
   17.92 +}
   17.93 +
   17.94 +// Allocate all memory resources that change on a window SizeChanged event.
   17.95 +void Direct3DBase::CreateWindowSizeDependentResources()
   17.96 +{ 
   17.97 +	// Store the window bounds so the next time we get a SizeChanged event we can
   17.98 +	// avoid rebuilding everything if the size is identical.
   17.99 +	m_windowBounds = m_window->Bounds;
  17.100 +
  17.101 +	// Calculate the necessary swap chain and render target size in pixels.
  17.102 +	float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
  17.103 +	float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
  17.104 +
  17.105 +	// The width and height of the swap chain must be based on the window's
  17.106 +	// landscape-oriented width and height. If the window is in a portrait
  17.107 +	// orientation, the dimensions must be reversed.
  17.108 +	m_orientation = DisplayProperties::CurrentOrientation;
  17.109 +	bool swapDimensions =
  17.110 +		m_orientation == DisplayOrientations::Portrait ||
  17.111 +		m_orientation == DisplayOrientations::PortraitFlipped;
  17.112 +	m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
  17.113 +	m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
  17.114 +
  17.115 +	if(m_swapChain != nullptr)
  17.116 +	{
  17.117 +		// If the swap chain already exists, resize it.
  17.118 +		DX::ThrowIfFailed(
  17.119 +			m_swapChain->ResizeBuffers(
  17.120 +				2, // Double-buffered swap chain.
  17.121 +				static_cast<UINT>(m_renderTargetSize.Width),
  17.122 +				static_cast<UINT>(m_renderTargetSize.Height),
  17.123 +				DXGI_FORMAT_B8G8R8A8_UNORM,
  17.124 +				0
  17.125 +				)
  17.126 +			);
  17.127 +	}
  17.128 +	else
  17.129 +	{
  17.130 +		// Otherwise, create a new one using the same adapter as the existing Direct3D device.
  17.131 +		DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
  17.132 +		swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
  17.133 +		swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
  17.134 +		swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
  17.135 +		swapChainDesc.Stereo = false;
  17.136 +		swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
  17.137 +		swapChainDesc.SampleDesc.Quality = 0;
  17.138 +		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
  17.139 +		swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
  17.140 +		swapChainDesc.Scaling = DXGI_SCALING_NONE;
  17.141 +		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
  17.142 +		swapChainDesc.Flags = 0;
  17.143 +
  17.144 +		ComPtr<IDXGIDevice1>  dxgiDevice;
  17.145 +		DX::ThrowIfFailed(
  17.146 +			m_d3dDevice.As(&dxgiDevice)
  17.147 +			);
  17.148 +
  17.149 +		ComPtr<IDXGIAdapter> dxgiAdapter;
  17.150 +		DX::ThrowIfFailed(
  17.151 +			dxgiDevice->GetAdapter(&dxgiAdapter)
  17.152 +			);
  17.153 +
  17.154 +		ComPtr<IDXGIFactory2> dxgiFactory;
  17.155 +		DX::ThrowIfFailed(
  17.156 +			dxgiAdapter->GetParent(
  17.157 +				__uuidof(IDXGIFactory2), 
  17.158 +				&dxgiFactory
  17.159 +				)
  17.160 +			);
  17.161 +
  17.162 +		Windows::UI::Core::CoreWindow^ window = m_window.Get();
  17.163 +		DX::ThrowIfFailed(
  17.164 +			dxgiFactory->CreateSwapChainForCoreWindow(
  17.165 +				m_d3dDevice.Get(),
  17.166 +				reinterpret_cast<IUnknown*>(window),
  17.167 +				&swapChainDesc,
  17.168 +				nullptr, // Allow on all displays.
  17.169 +				&m_swapChain
  17.170 +				)
  17.171 +			);
  17.172 +			
  17.173 +		// Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
  17.174 +		// ensures that the application will only render after each VSync, minimizing power consumption.
  17.175 +		DX::ThrowIfFailed(
  17.176 +			dxgiDevice->SetMaximumFrameLatency(1)
  17.177 +			);
  17.178 +	}
  17.179 +	
  17.180 +	// Set the proper orientation for the swap chain, and generate the
  17.181 +	// 3D matrix transformation for rendering to the rotated swap chain.
  17.182 +	DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
  17.183 +	switch (m_orientation)
  17.184 +	{
  17.185 +		case DisplayOrientations::Landscape:
  17.186 +			rotation = DXGI_MODE_ROTATION_IDENTITY;
  17.187 +			m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
  17.188 +				1.0f, 0.0f, 0.0f, 0.0f,
  17.189 +				0.0f, 1.0f, 0.0f, 0.0f,
  17.190 +				0.0f, 0.0f, 1.0f, 0.0f,
  17.191 +				0.0f, 0.0f, 0.0f, 1.0f
  17.192 +				);
  17.193 +			break;
  17.194 +
  17.195 +		case DisplayOrientations::Portrait:
  17.196 +			rotation = DXGI_MODE_ROTATION_ROTATE270;
  17.197 +			m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
  17.198 +				0.0f, 1.0f, 0.0f, 0.0f,
  17.199 +				-1.0f, 0.0f, 0.0f, 0.0f,
  17.200 +				0.0f, 0.0f, 1.0f, 0.0f,
  17.201 +				0.0f, 0.0f, 0.0f, 1.0f
  17.202 +				);
  17.203 +			break;
  17.204 +
  17.205 +		case DisplayOrientations::LandscapeFlipped:
  17.206 +			rotation = DXGI_MODE_ROTATION_ROTATE180;
  17.207 +			m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
  17.208 +				-1.0f, 0.0f, 0.0f, 0.0f,
  17.209 +				0.0f, -1.0f, 0.0f, 0.0f,
  17.210 +				0.0f, 0.0f, 1.0f, 0.0f,
  17.211 +				0.0f, 0.0f, 0.0f, 1.0f
  17.212 +				);
  17.213 +			break;
  17.214 +
  17.215 +		case DisplayOrientations::PortraitFlipped:
  17.216 +			rotation = DXGI_MODE_ROTATION_ROTATE90;
  17.217 +			m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
  17.218 +				0.0f, -1.0f, 0.0f, 0.0f,
  17.219 +				1.0f, 0.0f, 0.0f, 0.0f,
  17.220 +				0.0f, 0.0f, 1.0f, 0.0f,
  17.221 +				0.0f, 0.0f, 0.0f, 1.0f
  17.222 +				);
  17.223 +			break;
  17.224 +
  17.225 +		default:
  17.226 +			throw ref new Platform::FailureException();
  17.227 +	}
  17.228 +
  17.229 +	DX::ThrowIfFailed(
  17.230 +		m_swapChain->SetRotation(rotation)
  17.231 +		);
  17.232 +
  17.233 +	// Create a render target view of the swap chain back buffer.
  17.234 +	ComPtr<ID3D11Texture2D> backBuffer;
  17.235 +	DX::ThrowIfFailed(
  17.236 +		m_swapChain->GetBuffer(
  17.237 +			0,
  17.238 +			__uuidof(ID3D11Texture2D),
  17.239 +			&backBuffer
  17.240 +			)
  17.241 +		);
  17.242 +
  17.243 +	DX::ThrowIfFailed(
  17.244 +		m_d3dDevice->CreateRenderTargetView(
  17.245 +			backBuffer.Get(),
  17.246 +			nullptr,
  17.247 +			&m_renderTargetView
  17.248 +			)
  17.249 +		);
  17.250 +
  17.251 +	// Create a depth stencil view.
  17.252 +	CD3D11_TEXTURE2D_DESC depthStencilDesc(
  17.253 +		DXGI_FORMAT_D24_UNORM_S8_UINT, 
  17.254 +		static_cast<UINT>(m_renderTargetSize.Width),
  17.255 +		static_cast<UINT>(m_renderTargetSize.Height),
  17.256 +		1,
  17.257 +		1,
  17.258 +		D3D11_BIND_DEPTH_STENCIL
  17.259 +		);
  17.260 +
  17.261 +	ComPtr<ID3D11Texture2D> depthStencil;
  17.262 +	DX::ThrowIfFailed(
  17.263 +		m_d3dDevice->CreateTexture2D(
  17.264 +			&depthStencilDesc,
  17.265 +			nullptr,
  17.266 +			&depthStencil
  17.267 +			)
  17.268 +		);
  17.269 +
  17.270 +	CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
  17.271 +	DX::ThrowIfFailed(
  17.272 +		m_d3dDevice->CreateDepthStencilView(
  17.273 +			depthStencil.Get(),
  17.274 +			&depthStencilViewDesc,
  17.275 +			&m_depthStencilView
  17.276 +			)
  17.277 +		);
  17.278 +
  17.279 +	// Set the rendering viewport to target the entire window.
  17.280 +	CD3D11_VIEWPORT viewport(
  17.281 +		0.0f,
  17.282 +		0.0f,
  17.283 +		m_renderTargetSize.Width,
  17.284 +		m_renderTargetSize.Height
  17.285 +		);
  17.286 +
  17.287 +	m_d3dContext->RSSetViewports(1, &viewport);
  17.288 +}
  17.289 +
  17.290 +// This method is called in the event handler for the SizeChanged event.
  17.291 +void Direct3DBase::UpdateForWindowSizeChange()
  17.292 +{
  17.293 +	if (m_window->Bounds.Width  != m_windowBounds.Width ||
  17.294 +		m_window->Bounds.Height != m_windowBounds.Height ||
  17.295 +		m_orientation != DisplayProperties::CurrentOrientation)
  17.296 +	{
  17.297 +		ID3D11RenderTargetView* nullViews[] = {nullptr};
  17.298 +		m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
  17.299 +		m_renderTargetView = nullptr;
  17.300 +		m_depthStencilView = nullptr;
  17.301 +		m_d3dContext->Flush();
  17.302 +		CreateWindowSizeDependentResources();
  17.303 +	}
  17.304 +}
  17.305 +
  17.306 +// Method to deliver the final image to the display.
  17.307 +void Direct3DBase::Present()
  17.308 +{
  17.309 +	// The application may optionally specify "dirty" or "scroll"
  17.310 +	// rects to improve efficiency in certain scenarios.
  17.311 +	DXGI_PRESENT_PARAMETERS parameters = {0};
  17.312 +	parameters.DirtyRectsCount = 0;
  17.313 +	parameters.pDirtyRects = nullptr;
  17.314 +	parameters.pScrollRect = nullptr;
  17.315 +	parameters.pScrollOffset = nullptr;
  17.316 +	
  17.317 +	// The first argument instructs DXGI to block until VSync, putting the application
  17.318 +	// to sleep until the next VSync. This ensures we don't waste any cycles rendering
  17.319 +	// frames that will never be displayed to the screen.
  17.320 +	HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
  17.321 +
  17.322 +	// Discard the contents of the render target.
  17.323 +	// This is a valid operation only when the existing contents will be entirely
  17.324 +	// overwritten. If dirty or scroll rects are used, this call should be removed.
  17.325 +	m_d3dContext->DiscardView(m_renderTargetView.Get());
  17.326 +
  17.327 +	// Discard the contents of the depth stencil.
  17.328 +	m_d3dContext->DiscardView(m_depthStencilView.Get());
  17.329 +
  17.330 +	// If the device was removed either by a disconnect or a driver upgrade, we 
  17.331 +	// must recreate all device resources.
  17.332 +	if (hr == DXGI_ERROR_DEVICE_REMOVED)
  17.333 +	{
  17.334 +		HandleDeviceLost();
  17.335 +	}
  17.336 +	else
  17.337 +	{
  17.338 +		DX::ThrowIfFailed(hr);
  17.339 +	}
  17.340 +}
  17.341 +
  17.342 +// Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
  17.343 +float Direct3DBase::ConvertDipsToPixels(float dips)
  17.344 +{
  17.345 +	static const float dipsPerInch = 96.0f;
  17.346 +	return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
  17.347 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/windowsrt/Direct3DBase.h	Sat Oct 27 21:20:00 2012 -0400
    18.3 @@ -0,0 +1,38 @@
    18.4 +#pragma once
    18.5 +
    18.6 +#include "DirectXHelper.h"
    18.7 +
    18.8 +// Helper class that initializes DirectX APIs for 3D rendering.
    18.9 +ref class Direct3DBase abstract
   18.10 +{
   18.11 +internal:
   18.12 +	Direct3DBase();
   18.13 +
   18.14 +public:
   18.15 +	virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
   18.16 +	virtual void HandleDeviceLost();
   18.17 +	virtual void CreateDeviceResources();
   18.18 +	virtual void CreateWindowSizeDependentResources();
   18.19 +	virtual void UpdateForWindowSizeChange();
   18.20 +	virtual void Render() = 0;
   18.21 +	virtual void Present();
   18.22 +	virtual float ConvertDipsToPixels(float dips);
   18.23 +
   18.24 +protected private:
   18.25 +	// Direct3D Objects.
   18.26 +	Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
   18.27 +	Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
   18.28 +	Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
   18.29 +	Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
   18.30 +	Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
   18.31 +
   18.32 +	// Cached renderer properties.
   18.33 +	D3D_FEATURE_LEVEL m_featureLevel;
   18.34 +	Windows::Foundation::Size m_renderTargetSize;
   18.35 +	Windows::Foundation::Rect m_windowBounds;
   18.36 +	Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
   18.37 +	Windows::Graphics::Display::DisplayOrientations m_orientation;
   18.38 +
   18.39 +	// Transform used for display orientation.
   18.40 +	DirectX::XMFLOAT4X4 m_orientationTransform3D;
   18.41 +};
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/windowsrt/DirectXHelper.h	Sat Oct 27 21:20:00 2012 -0400
    19.3 @@ -0,0 +1,36 @@
    19.4 +#pragma once
    19.5 +
    19.6 +#include <wrl/client.h>
    19.7 +#include <ppl.h>
    19.8 +#include <ppltasks.h>
    19.9 +
   19.10 +namespace DX
   19.11 +{
   19.12 +	inline void ThrowIfFailed(HRESULT hr)
   19.13 +	{
   19.14 +		if (FAILED(hr))
   19.15 +		{
   19.16 +			// Set a breakpoint on this line to catch Win32 API errors.
   19.17 +			throw Platform::Exception::CreateException(hr);
   19.18 +		}
   19.19 +	}
   19.20 +
   19.21 +	// Function that reads from a binary file asynchronously.
   19.22 +	inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
   19.23 +	{
   19.24 +		using namespace Windows::Storage;
   19.25 +		using namespace Concurrency;
   19.26 +		
   19.27 +		auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
   19.28 +		
   19.29 +		return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file) 
   19.30 +		{
   19.31 +			return FileIO::ReadBufferAsync(file);
   19.32 +		}).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^ 
   19.33 +		{
   19.34 +			auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
   19.35 +			Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
   19.36 +			return fileData;
   19.37 +		});
   19.38 +	}
   19.39 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Sat Oct 27 21:20:00 2012 -0400
    20.3 @@ -0,0 +1,152 @@
    20.4 +#include "SDLmain_WinRT_common.h"
    20.5 +#include "SDL_WinRTApp.h"
    20.6 +#include "BasicTimer.h"
    20.7 +
    20.8 +using namespace Windows::ApplicationModel;
    20.9 +using namespace Windows::ApplicationModel::Core;
   20.10 +using namespace Windows::ApplicationModel::Activation;
   20.11 +using namespace Windows::UI::Core;
   20.12 +using namespace Windows::System;
   20.13 +using namespace Windows::Foundation;
   20.14 +using namespace Windows::Graphics::Display;
   20.15 +using namespace concurrency;
   20.16 +
   20.17 +SDL_WinRTApp::SDL_WinRTApp() :
   20.18 +	m_windowClosed(false),
   20.19 +	m_windowVisible(true)
   20.20 +{
   20.21 +}
   20.22 +
   20.23 +void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
   20.24 +{
   20.25 +	applicationView->Activated +=
   20.26 +        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
   20.27 +
   20.28 +	CoreApplication::Suspending +=
   20.29 +        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
   20.30 +
   20.31 +	CoreApplication::Resuming +=
   20.32 +        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
   20.33 +
   20.34 +	m_renderer = ref new CubeRenderer();
   20.35 +}
   20.36 +
   20.37 +void SDL_WinRTApp::SetWindow(CoreWindow^ window)
   20.38 +{
   20.39 +	window->SizeChanged += 
   20.40 +        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
   20.41 +
   20.42 +	window->VisibilityChanged +=
   20.43 +		ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
   20.44 +
   20.45 +	window->Closed += 
   20.46 +        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
   20.47 +
   20.48 +	window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
   20.49 +
   20.50 +	window->PointerPressed +=
   20.51 +		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
   20.52 +
   20.53 +	window->PointerMoved +=
   20.54 +		ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
   20.55 +
   20.56 +	m_renderer->Initialize(CoreWindow::GetForCurrentThread());
   20.57 +}
   20.58 +
   20.59 +void SDL_WinRTApp::Load(Platform::String^ entryPoint)
   20.60 +{
   20.61 +}
   20.62 +
   20.63 +#include "SDL.h"
   20.64 +
   20.65 +void SDL_WinRTApp::Run()
   20.66 +{
   20.67 +    SDL_Init(0);
   20.68 +
   20.69 +	BasicTimer^ timer = ref new BasicTimer();
   20.70 +
   20.71 +	while (!m_windowClosed)
   20.72 +	{
   20.73 +		if (m_windowVisible)
   20.74 +		{
   20.75 +			timer->Update();
   20.76 +			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
   20.77 +			m_renderer->Update(timer->Total, timer->Delta);
   20.78 +			m_renderer->Render();
   20.79 +			m_renderer->Present(); // This call is synchronized to the display frame rate.
   20.80 +		}
   20.81 +		else
   20.82 +		{
   20.83 +			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
   20.84 +		}
   20.85 +	}
   20.86 +}
   20.87 +
   20.88 +void SDL_WinRTApp::Uninitialize()
   20.89 +{
   20.90 +}
   20.91 +
   20.92 +void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
   20.93 +{
   20.94 +	m_renderer->UpdateForWindowSizeChange();
   20.95 +}
   20.96 +
   20.97 +void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   20.98 +{
   20.99 +	m_windowVisible = args->Visible;
  20.100 +}
  20.101 +
  20.102 +void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
  20.103 +{
  20.104 +	m_windowClosed = true;
  20.105 +}
  20.106 +
  20.107 +void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
  20.108 +{
  20.109 +	// Insert your code here.
  20.110 +}
  20.111 +
  20.112 +void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
  20.113 +{
  20.114 +	// Insert your code here.
  20.115 +}
  20.116 +
  20.117 +void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
  20.118 +{
  20.119 +	CoreWindow::GetForCurrentThread()->Activate();
  20.120 +}
  20.121 +
  20.122 +void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
  20.123 +{
  20.124 +	// Save app state asynchronously after requesting a deferral. Holding a deferral
  20.125 +	// indicates that the application is busy performing suspending operations. Be
  20.126 +	// aware that a deferral may not be held indefinitely. After about five seconds,
  20.127 +	// the app will be forced to exit.
  20.128 +	SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
  20.129 +
  20.130 +	create_task([this, deferral]()
  20.131 +	{
  20.132 +		// Insert your code here.
  20.133 +
  20.134 +		deferral->Complete();
  20.135 +	});
  20.136 +}
  20.137 + 
  20.138 +void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
  20.139 +{
  20.140 +	// Restore any data or state that was unloaded on suspend. By default, data
  20.141 +	// and state are persisted when resuming from suspend. Note that this event
  20.142 +	// does not occur if the app was previously terminated.
  20.143 +}
  20.144 +
  20.145 +IFrameworkView^ Direct3DApplicationSource::CreateView()
  20.146 +{
  20.147 +    return ref new SDL_WinRTApp();
  20.148 +}
  20.149 +
  20.150 +__declspec(dllexport) int SDL_WinRT_RunApplication(/*Platform::Array<Platform::String^>^*/)
  20.151 +{
  20.152 +	auto direct3DApplicationSource = ref new Direct3DApplicationSource();
  20.153 +	CoreApplication::Run(direct3DApplicationSource);
  20.154 +	return 0;
  20.155 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/video/windowsrt/SDL_WinRTApp.h	Sat Oct 27 21:20:00 2012 -0400
    21.3 @@ -0,0 +1,40 @@
    21.4 +#pragma once
    21.5 +
    21.6 +#include "SDLmain_WinRT_common.h"
    21.7 +#include "CubeRenderer.h"
    21.8 +
    21.9 +ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
   21.10 +{
   21.11 +public:
   21.12 +	SDL_WinRTApp();
   21.13 +	
   21.14 +	// IFrameworkView Methods.
   21.15 +	virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
   21.16 +	virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
   21.17 +	virtual void Load(Platform::String^ entryPoint);
   21.18 +	virtual void Run();
   21.19 +	virtual void Uninitialize();
   21.20 +
   21.21 +protected:
   21.22 +	// Event Handlers.
   21.23 +	void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
   21.24 +	void OnLogicalDpiChanged(Platform::Object^ sender);
   21.25 +	void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
   21.26 +	void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
   21.27 +	void OnResuming(Platform::Object^ sender, Platform::Object^ args);
   21.28 +	void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
   21.29 +	void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
   21.30 +	void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   21.31 +	void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   21.32 +
   21.33 +private:
   21.34 +	CubeRenderer^ m_renderer;
   21.35 +	bool m_windowClosed;
   21.36 +	bool m_windowVisible;
   21.37 +};
   21.38 +
   21.39 +ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
   21.40 +{
   21.41 +public:
   21.42 +	virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
   21.43 +};
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/video/windowsrt/SDLmain_WinRT_common.h	Sat Oct 27 21:20:00 2012 -0400
    22.3 @@ -0,0 +1,7 @@
    22.4 +#pragma once
    22.5 +
    22.6 +#include <wrl/client.h>
    22.7 +#include <d3d11_1.h>
    22.8 +#include <DirectXMath.h>
    22.9 +#include <memory>
   22.10 +#include <agile.h>
   22.11 \ No newline at end of file
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/src/video/windowsrt/SimplePixelShader.hlsl	Sat Oct 27 21:20:00 2012 -0400
    23.3 @@ -0,0 +1,10 @@
    23.4 +struct PixelShaderInput
    23.5 +{
    23.6 +	float4 pos : SV_POSITION;
    23.7 +	float3 color : COLOR0;
    23.8 +};
    23.9 +
   23.10 +float4 main(PixelShaderInput input) : SV_TARGET
   23.11 +{
   23.12 +	return float4(input.color,1.0f);
   23.13 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/src/video/windowsrt/SimpleVertexShader.hlsl	Sat Oct 27 21:20:00 2012 -0400
    24.3 @@ -0,0 +1,35 @@
    24.4 +cbuffer ModelViewProjectionConstantBuffer : register(b0)
    24.5 +{
    24.6 +	matrix model;
    24.7 +	matrix view;
    24.8 +	matrix projection;
    24.9 +};
   24.10 +
   24.11 +struct VertexShaderInput
   24.12 +{
   24.13 +	float3 pos : POSITION;
   24.14 +	float3 color : COLOR0;
   24.15 +};
   24.16 +
   24.17 +struct VertexShaderOutput
   24.18 +{
   24.19 +	float4 pos : SV_POSITION;
   24.20 +	float3 color : COLOR0;
   24.21 +};
   24.22 +
   24.23 +VertexShaderOutput main(VertexShaderInput input)
   24.24 +{
   24.25 +	VertexShaderOutput output;
   24.26 +	float4 pos = float4(input.pos, 1.0f);
   24.27 +
   24.28 +	// Transform the vertex position into projected space.
   24.29 +	pos = mul(pos, model);
   24.30 +	pos = mul(pos, view);
   24.31 +	pos = mul(pos, projection);
   24.32 +	output.pos = pos;
   24.33 +
   24.34 +	// Pass through the color without modification.
   24.35 +	output.color = input.color;
   24.36 +
   24.37 +	return output;
   24.38 +}