This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WinRT: created SDLmain library using most of VC++ 2012's template for…
… Direct3D 11 apps. Most of this will be moved into SDL itself.
- Loading branch information
Showing
with
1,233 additions
and 0 deletions.
- +199 −0 VisualC/SDLmain/SDLmain_VS2012_WinRT.vcxproj
- +76 −0 src/main/windowsrt/BasicTimer.h
- +256 −0 src/main/windowsrt/CubeRenderer.cpp
- +44 −0 src/main/windowsrt/CubeRenderer.h
- +344 −0 src/main/windowsrt/Direct3DBase.cpp
- +38 −0 src/main/windowsrt/Direct3DBase.h
- +36 −0 src/main/windowsrt/DirectXHelper.h
- +148 −0 src/main/windowsrt/SDL_WinRTApp.cpp
- +40 −0 src/main/windowsrt/SDL_WinRTApp.h
- +7 −0 src/main/windowsrt/SDLmain_WinRT_common.h
- +10 −0 src/main/windowsrt/SimplePixelShader.hlsl
- +35 −0 src/main/windowsrt/SimpleVertexShader.hlsl
@@ -0,0 +1,199 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|ARM"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>ARM</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|ARM"> | ||
<Configuration>Release</Configuration> | ||
<Platform>ARM</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="..\..\src\main\windowsrt\BasicTimer.h" /> | ||
<ClInclude Include="..\..\src\main\windowsrt\CubeRenderer.h" /> | ||
<ClInclude Include="..\..\src\main\windowsrt\Direct3DBase.h" /> | ||
<ClInclude Include="..\..\src\main\windowsrt\DirectXHelper.h" /> | ||
<ClInclude Include="..\..\src\main\windowsrt\SDLmain_WinRT_common.h" /> | ||
<ClInclude Include="..\..\src\main\windowsrt\SDL_WinRTApp.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="..\..\src\main\windowsrt\CubeRenderer.cpp" /> | ||
<ClCompile Include="..\..\src\main\windowsrt\Direct3DBase.cpp" /> | ||
<ClCompile Include="..\..\src\main\windowsrt\SDL_WinRTApp.cpp" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{48666378-b527-43f5-8968-f867a6f8d2a3}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectName>SDLmain_VS2012_WinRT</ProjectName> | ||
<RootNamespace>SDLmain_VS2012_WinRT</RootNamespace> | ||
<DefaultLanguage>en-US</DefaultLanguage> | ||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> | ||
<AppContainerApplication>true</AppContainerApplication> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<PlatformToolset>v110</PlatformToolset> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<CompileAsWinRT>true</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<CompileAsWinRT>true</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<CompileAsWinRT>false</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<CompileAsWinRT>false</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<CompileAsWinRT>false</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<CompileAsWinRT>false</CompileAsWinRT> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
@@ -0,0 +1,76 @@ | ||
#pragma once | ||
|
||
#include <wrl.h> | ||
|
||
// Helper class for basic timing. | ||
ref class BasicTimer sealed | ||
{ | ||
public: | ||
// Initializes internal timer values. | ||
BasicTimer() | ||
{ | ||
if (!QueryPerformanceFrequency(&m_frequency)) | ||
{ | ||
throw ref new Platform::FailureException(); | ||
} | ||
Reset(); | ||
} | ||
|
||
// Reset the timer to initial values. | ||
void Reset() | ||
{ | ||
Update(); | ||
m_startTime = m_currentTime; | ||
m_total = 0.0f; | ||
m_delta = 1.0f / 60.0f; | ||
} | ||
|
||
// Update the timer's internal values. | ||
void Update() | ||
{ | ||
if (!QueryPerformanceCounter(&m_currentTime)) | ||
{ | ||
throw ref new Platform::FailureException(); | ||
} | ||
|
||
m_total = static_cast<float>( | ||
static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) / | ||
static_cast<double>(m_frequency.QuadPart) | ||
); | ||
|
||
if (m_lastTime.QuadPart == m_startTime.QuadPart) | ||
{ | ||
// If the timer was just reset, report a time delta equivalent to 60Hz frame time. | ||
m_delta = 1.0f / 60.0f; | ||
} | ||
else | ||
{ | ||
m_delta = static_cast<float>( | ||
static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) / | ||
static_cast<double>(m_frequency.QuadPart) | ||
); | ||
} | ||
|
||
m_lastTime = m_currentTime; | ||
} | ||
|
||
// Duration in seconds between the last call to Reset() and the last call to Update(). | ||
property float Total | ||
{ | ||
float get() { return m_total; } | ||
} | ||
|
||
// Duration in seconds between the previous two calls to Update(). | ||
property float Delta | ||
{ | ||
float get() { return m_delta; } | ||
} | ||
|
||
private: | ||
LARGE_INTEGER m_frequency; | ||
LARGE_INTEGER m_currentTime; | ||
LARGE_INTEGER m_startTime; | ||
LARGE_INTEGER m_lastTime; | ||
float m_total; | ||
float m_delta; | ||
}; |
Oops, something went wrong.