summaryrefslogtreecommitdiffstats
path: root/Tests/VSWinStorePhone
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/VSWinStorePhone')
-rw-r--r--Tests/VSWinStorePhone/CMakeLists.txt160
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt3
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp8
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/cxxdll.h5
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/.gitattributes1
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.pngbin0 -> 2335 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.pngbin0 -> 488 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.pngbin0 -> 167 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.pngbin0 -> 265 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.pngbin0 -> 909 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.pngbin0 -> 227 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.pngbin0 -> 2953 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.pngbin0 -> 2767 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.pngbin0 -> 1397 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.pngbin0 -> 893 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.pngbin0 -> 516 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h71
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp186
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.h44
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp167
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h57
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1_TemporaryKey.pfxbin0 -> 2560 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp336
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h39
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h44
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.csobin0 -> 12796 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl14
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.csobin0 -> 16336 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl39
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Strings/en-US/Resources.resw123
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/pch.cpp1
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/pch.h8
-rw-r--r--Tests/VSWinStorePhone/EnsurePropertiesSet.cmake45
-rw-r--r--Tests/VSWinStorePhone/VerifyAppPackage.cmake34
-rw-r--r--Tests/VSWinStorePhone/WinRT/Batman.cpp14
-rw-r--r--Tests/VSWinStorePhone/WinRT/Batman.h12
-rw-r--r--Tests/VSWinStorePhone/WinRT/CMakeLists.txt13
-rw-r--r--Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in24
-rw-r--r--Tests/VSWinStorePhone/cmake/Package_vc11.wp.appxmanifest.in35
-rw-r--r--Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in34
-rw-r--r--Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in36
-rw-r--r--Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in36
42 files changed, 1589 insertions, 0 deletions
diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt
new file mode 100644
index 0000000..558d5de
--- /dev/null
+++ b/Tests/VSWinStorePhone/CMakeLists.txt
@@ -0,0 +1,160 @@
+cmake_minimum_required(VERSION 3.0)
+project(VSWinStorePhone)
+if(MSVC_VERSION GREATER 1899)
+ set(COMPILER_VERSION "14")
+elseif(MSVC_VERSION GREATER 1700)
+ set(COMPILER_VERSION "12")
+elseif(MSVC_VERSION GREATER 1600)
+ set(COMPILER_VERSION "11")
+endif()
+
+add_subdirectory(WinRT)
+add_subdirectory(CxxDLL)
+
+set (APP_MANIFEST_NAME Package.appxmanifest)
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone")
+ set(PLATFORM WP)
+ add_definitions("-DPHONE")
+ if("${CMAKE_SYSTEM_VERSION}" STREQUAL "8.0")
+ set(APP_MANIFEST_NAME WMAppManifest.xml)
+ set(WINDOWS_PHONE8 1)
+ endif()
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+ set(PLATFORM STORE)
+else()
+ set(PLATFORM DESKTOP)
+ message(FATAL_ERROR "This app supports Store / Phone only. Please edit the target platform.")
+endif()
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+set(EXE_NAME Direct3DApp1)
+set(SHORT_NAME ${EXE_NAME})
+set(PACKAGE_GUID "6514377e-dfd4-4cdb-80df-4e0366346efc")
+
+if (NOT "${PLATFORM}" STREQUAL "DESKTOP")
+ configure_file(
+ cmake/Package_vc${COMPILER_VERSION}.${PLATFORM}.appxmanifest.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME}
+ @ONLY)
+endif()
+
+set(SOURCE_FILES
+ Direct3DApp1/CubeRenderer.cpp
+ Direct3DApp1/Direct3DApp1.cpp
+ Direct3DApp1/Direct3DBase.cpp
+ Direct3DApp1/pch.cpp
+ )
+
+set(HEADER_FILES
+ Direct3DApp1/BasicTimer.h
+ Direct3DApp1/CubeRenderer.h
+ Direct3DApp1/Direct3DApp1.h
+ Direct3DApp1/Direct3DBase.h
+ Direct3DApp1/DirectXHelper.h
+ Direct3DApp1/pch.h
+ )
+
+set(PIXELSHADER_FILES
+ Direct3DApp1/SimplePixelShader.hlsl
+ )
+
+set(VERTEXSHADER_FILES
+ Direct3DApp1/SimpleVertexShader.hlsl
+ )
+
+set(CONTENT_FILES ${PIXELSHADER_FILES} ${VERTEXSHADER_FILES})
+
+if (WINDOWS_PHONE8)
+ set(CONTENT_FILES ${CONTENT_FILES}
+ ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME}
+ Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
+ Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
+ Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
+ Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
+ Direct3DApp1/Assets/Tiles/IconicTileSmall.png
+ Direct3DApp1/Assets/ApplicationIcon.png
+ )
+ # Windows Phone 8.0 needs to copy all the images.
+ # It doesn't know to use relative paths.
+ file(COPY
+ Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
+ Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
+ Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
+ Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
+ Direct3DApp1/Assets/Tiles/IconicTileSmall.png
+ Direct3DApp1/Assets/ApplicationIcon.png
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+elseif (NOT "${PLATFORM}" STREQUAL "DESKTOP")
+ set(CONTENT_FILES ${CONTENT_FILES}
+ ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME}
+ )
+
+ set(ASSET_FILES ${ASSET_FILES}
+ Direct3DApp1/Assets/Logo.png
+ Direct3DApp1/Assets/SmallLogo.png
+ Direct3DApp1/Assets/SmallLogo44x44.png
+ Direct3DApp1/Assets/SplashScreen.png
+ Direct3DApp1/Assets/StoreLogo.png
+ )
+endif()
+
+set(STRING_FILES
+ Direct3DApp1/Strings/en-US/Resources.resw)
+
+set(RESOURCE_FILES
+ ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} ${STRING_FILES}
+ Direct3DApp1/Direct3DApp1_TemporaryKey.pfx)
+
+set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
+set_property(SOURCE ${STRING_FILES} PROPERTY VS_TOOL_OVERRIDE "PRIResource")
+set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<CONFIG:Debug>)
+set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
+ VS_DEPLOYMENT_CONTENT $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>)
+
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
+
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex)
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS)
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SETTINGS "$<$<CONFIG:DEBUG>:SourceProperty1=SourceProperty1Value>")
+
+source_group("Source Files" FILES ${SOURCE_FILES})
+source_group("Header Files" FILES ${HEADER_FILES})
+source_group("Resource Files" FILES ${RESOURCE_FILES})
+
+add_executable(${EXE_NAME} WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES})
+set_property(TARGET ${EXE_NAME} PROPERTY VS_WINRT_COMPONENT TRUE)
+set_property(TARGET ${EXE_NAME} PROPERTY VS_SOURCE_SETTINGS_FXCompile
+ "TargetProperty1=$<$<CONFIG:DEBUG>:TargetProperty1ValueDebug>$<$<CONFIG:RELEASE>:TargetProperty1ValueRelease>")
+
+add_custom_command(TARGET ${EXE_NAME} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -Dvcxproj="${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.vcxproj" -P "${CMAKE_CURRENT_SOURCE_DIR}/EnsurePropertiesSet.cmake")
+
+string(SUBSTRING "${CMAKE_SYSTEM_VERSION}" 0, 4, SHORT_VERSION)
+
+if("${SHORT_VERSION}" STREQUAL "10.0")
+ message(STATUS "Targeting Windows 10. Setting Extensions to version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+ set_property(TARGET ${EXE_NAME} PROPERTY VS_DESKTOP_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+ set_property(TARGET ${EXE_NAME} PROPERTY VS_MOBILE_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+
+ # The last IOT reference is on 10.0.17134.0, so only add it if supported
+ if("${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" VERSION_LESS "10.0.17135.0")
+ set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+ endif()
+
+ # Add a reference to an SDK
+ set_property(TARGET ${EXE_NAME} PROPERTY VS_SDK_REFERENCES "Microsoft.UniversalCRT.Debug, Version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+endif()
+
+target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT CxxDll)
diff --git a/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt
new file mode 100644
index 0000000..6bd32a2
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(CxxDll CXX)
+
+add_library(CxxDll SHARED cxxdll.cpp)
diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp
new file mode 100644
index 0000000..1438e8a
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp
@@ -0,0 +1,8 @@
+#include "cxxdll.h"
+
+#include <iostream>
+
+void CxxDllClass::SomeMethod()
+{
+ std::cout << "CxxDllClass::SomeMethod\n";
+}
diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.h b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h
new file mode 100644
index 0000000..86edceb
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h
@@ -0,0 +1,5 @@
+class __declspec(dllexport) CxxDllClass
+{
+public:
+ static void SomeMethod();
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes
new file mode 100644
index 0000000..78a5469
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes
@@ -0,0 +1 @@
+Direct3DApp1.cpp -format.clang-format-6.0
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png
new file mode 100644
index 0000000..c715e1b
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png
new file mode 100644
index 0000000..65f91ac
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png
new file mode 100644
index 0000000..460c022
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
new file mode 100644
index 0000000..c237458
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png
new file mode 100644
index 0000000..8342565
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png
new file mode 100644
index 0000000..508c8a8
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
new file mode 100644
index 0000000..fcdbaf4
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
new file mode 100644
index 0000000..06425c4
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
new file mode 100644
index 0000000..4cef0eb
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
new file mode 100644
index 0000000..253503f
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png
new file mode 100644
index 0000000..2ef050f
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h
new file mode 100644
index 0000000..56bd398
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h
@@ -0,0 +1,71 @@
+#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;
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
new file mode 100644
index 0000000..595f553
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
@@ -0,0 +1,186 @@
+// clang-format off
+#include "pch.h"
+
+#include "CubeRenderer.h"
+// clang-format on
+
+using namespace DirectX;
+using namespace Microsoft::WRL;
+using namespace Windows::Foundation;
+using namespace Windows::UI::Core;
+using namespace JusticeLeagueWinRT;
+
+CubeRenderer::CubeRenderer()
+ : m_loadingComplete(false)
+ , m_indexCount(0)
+{
+ // Create a new WinRT object to validate that we can link properly
+ Batman ^ hero = ref new Batman();
+ hero->savePeople();
+}
+
+void CubeRenderer::CreateDeviceResources()
+{
+ Direct3DBase::CreateDeviceResources();
+
+ auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
+ auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
+
+ auto createVSTask =
+ loadVSTask.then([this](Platform::Array<byte> ^ fileData) {
+ DX::ThrowIfFailed(m_d3dDevice->CreateVertexShader(
+ fileData->Data, fileData->Length, nullptr, &m_vertexShader));
+
+ const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,
+ D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12,
+ D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+
+ DX::ThrowIfFailed(m_d3dDevice->CreateInputLayout(
+ vertexDesc, ARRAYSIZE(vertexDesc), fileData->Data, fileData->Length,
+ &m_inputLayout));
+ });
+
+ auto createPSTask =
+ loadPSTask.then([this](Platform::Array<byte> ^ fileData) {
+ DX::ThrowIfFailed(m_d3dDevice->CreatePixelShader(
+ fileData->Data, fileData->Length, nullptr, &m_pixelShader));
+
+ CD3D11_BUFFER_DESC constantBufferDesc(
+ sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
+ DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(&constantBufferDesc, nullptr,
+ &m_constantBuffer));
+ });
+
+ auto createCubeTask = (createPSTask && createVSTask).then([this]() {
+ VertexPositionColor cubeVertices[] = {
+ { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) },
+ { XMFLOAT3(-0.5f, -0.5f, 0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) },
+ { XMFLOAT3(-0.5f, 0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) },
+ { XMFLOAT3(-0.5f, 0.5f, 0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) },
+ { XMFLOAT3(0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) },
+ { XMFLOAT3(0.5f, -0.5f, 0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) },
+ { XMFLOAT3(0.5f, 0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) },
+ { XMFLOAT3(0.5f, 0.5f, 0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) },
+ };
+
+ D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };
+ vertexBufferData.pSysMem = cubeVertices;
+ vertexBufferData.SysMemPitch = 0;
+ vertexBufferData.SysMemSlicePitch = 0;
+ CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices),
+ D3D11_BIND_VERTEX_BUFFER);
+ DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(
+ &vertexBufferDesc, &vertexBufferData, &m_vertexBuffer));
+
+ unsigned short cubeIndices[] = {
+ 0, 2, 1, // -x
+ 1, 2, 3,
+
+ 4, 5, 6, // +x
+ 5, 7, 6,
+
+ 0, 1, 5, // -y
+ 0, 5, 4,
+
+ 2, 6, 7, // +y
+ 2, 7, 3,
+
+ 0, 4, 6, // -z
+ 0, 6, 2,
+
+ 1, 3, 7, // +z
+ 1, 7, 5,
+ };
+
+ m_indexCount = ARRAYSIZE(cubeIndices);
+
+ D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };
+ indexBufferData.pSysMem = cubeIndices;
+ indexBufferData.SysMemPitch = 0;
+ indexBufferData.SysMemSlicePitch = 0;
+ CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices),
+ D3D11_BIND_INDEX_BUFFER);
+ DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(
+ &indexBufferDesc, &indexBufferData, &m_indexBuffer));
+ });
+
+ createCubeTask.then([this]() { m_loadingComplete = true; });
+}
+
+void CubeRenderer::CreateWindowSizeDependentResources()
+{
+ Direct3DBase::CreateWindowSizeDependentResources();
+
+ float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
+ float fovAngleY = 70.0f * XM_PI / 180.0f;
+ if (aspectRatio < 1.0f) {
+ fovAngleY /= aspectRatio;
+ }
+
+ // Note that the m_orientationTransform3D matrix is post-multiplied here
+ // in order to correctly orient the scene to match the display orientation.
+ // This post-multiplication step is required for any draw calls that are
+ // made to the swap chain render target. For draw calls to other targets,
+ // this transform should not be applied.
+ XMStoreFloat4x4(
+ &m_constantBufferData.projection,
+ XMMatrixTranspose(XMMatrixMultiply(
+ XMMatrixPerspectiveFovRH(fovAngleY, aspectRatio, 0.01f, 100.0f),
+ XMLoadFloat4x4(&m_orientationTransform3D))));
+}
+
+void CubeRenderer::Update(float timeTotal, float timeDelta)
+{
+ (void)timeDelta; // Unused parameter.
+
+ XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);
+ XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);
+ XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
+
+ XMStoreFloat4x4(&m_constantBufferData.view,
+ XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
+ XMStoreFloat4x4(&m_constantBufferData.model,
+ XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
+}
+
+void CubeRenderer::Render()
+{
+ const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f };
+ m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), midnightBlue);
+
+ m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(),
+ D3D11_CLEAR_DEPTH, 1.0f, 0);
+
+ // Only draw the cube once it is loaded (loading is asynchronous).
+ if (!m_loadingComplete) {
+ return;
+ }
+
+ m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(),
+ m_depthStencilView.Get());
+
+ m_d3dContext->UpdateSubresource(m_constantBuffer.Get(), 0, NULL,
+ &m_constantBufferData, 0, 0);
+
+ UINT stride = sizeof(VertexPositionColor);
+ UINT offset = 0;
+ m_d3dContext->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(),
+ &stride, &offset);
+
+ m_d3dContext->IASetIndexBuffer(m_indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
+
+ m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+
+ m_d3dContext->IASetInputLayout(m_inputLayout.Get());
+
+ m_d3dContext->VSSetShader(m_vertexShader.Get(), nullptr, 0);
+
+ m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf());
+
+ m_d3dContext->PSSetShader(m_pixelShader.Get(), nullptr, 0);
+
+ m_d3dContext->DrawIndexed(m_indexCount, 0, 0);
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.h b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.h
new file mode 100644
index 0000000..68cb188
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "Direct3DBase.h"
+
+struct ModelViewProjectionConstantBuffer
+{
+ DirectX::XMFLOAT4X4 model;
+ DirectX::XMFLOAT4X4 view;
+ DirectX::XMFLOAT4X4 projection;
+};
+
+struct VertexPositionColor
+{
+ DirectX::XMFLOAT3 pos;
+ DirectX::XMFLOAT3 color;
+};
+
+// This class renders a simple spinning cube.
+ref class CubeRenderer sealed : public Direct3DBase
+{
+public:
+ CubeRenderer();
+
+ // Direct3DBase methods.
+ virtual void CreateDeviceResources() override;
+ virtual void CreateWindowSizeDependentResources() override;
+ virtual void Render() override;
+
+ // Method for updating time-dependent objects.
+ void Update(float timeTotal, float timeDelta);
+
+private:
+ bool m_loadingComplete;
+
+ Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
+ Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
+ Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
+ Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
+ Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
+ Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
+
+ uint32 m_indexCount;
+ ModelViewProjectionConstantBuffer m_constantBufferData;
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp
new file mode 100644
index 0000000..ddcd8bd
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp
@@ -0,0 +1,167 @@
+#include "pch.h"
+
+#include "BasicTimer.h"
+#include "Direct3DApp1.h"
+
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Core;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::UI::Core;
+using namespace Windows::System;
+using namespace Windows::Foundation;
+using namespace Windows::Graphics::Display;
+using namespace concurrency;
+
+Direct3DApp1::Direct3DApp1()
+ : m_windowClosed(false)
+ , m_windowVisible(true)
+{
+}
+
+void Direct3DApp1::Initialize(CoreApplicationView ^ applicationView)
+{
+ applicationView->Activated +=
+ ref new TypedEventHandler<CoreApplicationView ^, IActivatedEventArgs ^>(
+ this, &Direct3DApp1::OnActivated);
+
+ CoreApplication::Suspending += ref new EventHandler<SuspendingEventArgs ^>(
+ this, &Direct3DApp1::OnSuspending);
+
+ CoreApplication::Resuming +=
+ ref new EventHandler<Platform::Object ^>(this, &Direct3DApp1::OnResuming);
+
+ m_renderer = ref new CubeRenderer();
+}
+
+void Direct3DApp1::SetWindow(CoreWindow ^ window)
+{
+ window->SizeChanged +=
+ ref new TypedEventHandler<CoreWindow ^, WindowSizeChangedEventArgs ^>(
+ this, &Direct3DApp1::OnWindowSizeChanged);
+
+ window->VisibilityChanged +=
+ ref new TypedEventHandler<CoreWindow ^, VisibilityChangedEventArgs ^>(
+ this, &Direct3DApp1::OnVisibilityChanged);
+
+ window->Closed +=
+ ref new TypedEventHandler<CoreWindow ^, CoreWindowEventArgs ^>(
+ this, &Direct3DApp1::OnWindowClosed);
+
+#ifndef PHONE
+ window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
+#endif
+
+ window->PointerPressed +=
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(
+ this, &Direct3DApp1::OnPointerPressed);
+
+ window->PointerMoved +=
+ ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(
+ this, &Direct3DApp1::OnPointerMoved);
+
+ m_renderer->Initialize(CoreWindow::GetForCurrentThread());
+}
+
+void Direct3DApp1::Load(Platform::String ^ entryPoint)
+{
+}
+
+void Direct3DApp1::Run()
+{
+ BasicTimer ^ timer = ref new BasicTimer();
+
+ while (!m_windowClosed) {
+ if (m_windowVisible) {
+ timer->Update();
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(
+ CoreProcessEventsOption::ProcessAllIfPresent);
+ m_renderer->Update(timer->Total, timer->Delta);
+ m_renderer->Render();
+ m_renderer
+ ->Present(); // This call is synchronized to the display frame rate.
+ } else {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(
+ CoreProcessEventsOption::ProcessOneAndAllPending);
+ }
+ }
+}
+
+void Direct3DApp1::Uninitialize()
+{
+}
+
+void Direct3DApp1::OnWindowSizeChanged(CoreWindow ^ sender,
+ WindowSizeChangedEventArgs ^ args)
+{
+ m_renderer->UpdateForWindowSizeChange();
+}
+
+void Direct3DApp1::OnVisibilityChanged(CoreWindow ^ sender,
+ VisibilityChangedEventArgs ^ args)
+{
+ m_windowVisible = args->Visible;
+}
+
+void Direct3DApp1::OnWindowClosed(CoreWindow ^ sender,
+ CoreWindowEventArgs ^ args)
+{
+ m_windowClosed = true;
+}
+
+void Direct3DApp1::OnPointerPressed(CoreWindow ^ sender,
+ PointerEventArgs ^ args)
+{
+ // Insert your code here.
+}
+
+void Direct3DApp1::OnPointerMoved(CoreWindow ^ sender, PointerEventArgs ^ args)
+{
+ // Insert your code here.
+}
+
+void Direct3DApp1::OnActivated(CoreApplicationView ^ applicationView,
+ IActivatedEventArgs ^ args)
+{
+ CoreWindow::GetForCurrentThread()->Activate();
+}
+
+void Direct3DApp1::OnSuspending(Platform::Object ^ sender,
+ SuspendingEventArgs ^ args)
+{
+ // Save app state asynchronously after requesting a deferral. Holding a
+ // deferral
+ // indicates that the application is busy performing suspending operations.
+ // Be
+ // aware that a deferral may not be held indefinitely. After about five
+ // seconds,
+ // the app will be forced to exit.
+ SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral();
+ m_renderer->ReleaseResourcesForSuspending();
+
+ create_task([this, deferral]() {
+ // Insert your code here.
+
+ deferral->Complete();
+ });
+}
+
+void Direct3DApp1::OnResuming(Platform::Object ^ sender,
+ Platform::Object ^ args)
+{
+ // Restore any data or state that was unloaded on suspend. By default, data
+ // and state are persisted when resuming from suspend. Note that this event
+ // does not occur if the app was previously terminated.
+ m_renderer->CreateWindowSizeDependentResources();
+}
+
+IFrameworkView ^ Direct3DApplicationSource::CreateView()
+{
+ return ref new Direct3DApp1();
+}
+
+[Platform::MTAThread] int main(Platform::Array<Platform::String ^> ^)
+{
+ auto direct3DApplicationSource = ref new Direct3DApplicationSource();
+ CoreApplication::Run(direct3DApplicationSource);
+ return 0;
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
new file mode 100644
index 0000000..79b9070
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
@@ -0,0 +1,57 @@
+#pragma once
+
+// clang-format off
+#include "pch.h"
+
+#include "CubeRenderer.h"
+// clang-format on
+
+ref class Direct3DApp1 sealed
+ : public Windows::ApplicationModel::Core::IFrameworkView
+{
+public:
+ Direct3DApp1();
+
+ // IFrameworkView Methods.
+ virtual void Initialize(
+ Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView);
+ virtual void SetWindow(Windows::UI::Core::CoreWindow ^ window);
+ virtual void Load(Platform::String ^ entryPoint);
+ virtual void Run();
+ virtual void Uninitialize();
+
+protected:
+ // Event Handlers.
+ void OnWindowSizeChanged(Windows::UI::Core::CoreWindow ^ sender,
+ Windows::UI::Core::WindowSizeChangedEventArgs ^
+ args);
+ void OnLogicalDpiChanged(Platform::Object ^ sender);
+ void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView ^
+ applicationView,
+ Windows::ApplicationModel::Activation::IActivatedEventArgs ^
+ args);
+ void OnSuspending(Platform::Object ^ sender,
+ Windows::ApplicationModel::SuspendingEventArgs ^ args);
+ void OnResuming(Platform::Object ^ sender, Platform::Object ^ args);
+ void OnWindowClosed(Windows::UI::Core::CoreWindow ^ sender,
+ Windows::UI::Core::CoreWindowEventArgs ^ args);
+ void OnVisibilityChanged(Windows::UI::Core::CoreWindow ^ sender,
+ Windows::UI::Core::VisibilityChangedEventArgs ^
+ args);
+ void OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender,
+ Windows::UI::Core::PointerEventArgs ^ args);
+ void OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender,
+ Windows::UI::Core::PointerEventArgs ^ args);
+
+private:
+ CubeRenderer ^ m_renderer;
+ bool m_windowClosed;
+ bool m_windowVisible;
+};
+
+ref class Direct3DApplicationSource sealed
+ : Windows::ApplicationModel::Core::IFrameworkViewSource
+{
+public:
+ virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView();
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1_TemporaryKey.pfx b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1_TemporaryKey.pfx
new file mode 100644
index 0000000..1cad999
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1_TemporaryKey.pfx
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
new file mode 100644
index 0000000..f24ce28
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
@@ -0,0 +1,336 @@
+// clang-format off
+#include "pch.h"
+
+#include "Direct3DBase.h"
+// clang-format on
+
+using namespace DirectX;
+using namespace Microsoft::WRL;
+using namespace Windows::UI::Core;
+using namespace Windows::Foundation;
+using namespace Windows::Graphics::Display;
+
+// Constructor.
+Direct3DBase::Direct3DBase()
+{
+}
+
+// Initialize the Direct3D resources required to run.
+void Direct3DBase::Initialize(CoreWindow ^ window)
+{
+ m_window = window;
+
+ CreateDeviceResources();
+ CreateWindowSizeDependentResources();
+}
+
+// Recreate all device resources and set them back to the current state.
+void Direct3DBase::HandleDeviceLost()
+{
+ // Reset these member variables to ensure that UpdateForWindowSizeChange
+ // recreates all resources.
+ m_windowBounds.Width = 0;
+ m_windowBounds.Height = 0;
+ m_swapChain = nullptr;
+
+ CreateDeviceResources();
+ UpdateForWindowSizeChange();
+}
+
+// These are the resources that depend on the device.
+void Direct3DBase::CreateDeviceResources()
+{
+ // This flag adds support for surfaces with a different color channel
+ // ordering
+ // than the API default. It is required for compatibility with Direct2D.
+ UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
+
+#if defined(_DEBUG)
+ // If the project is in a debug build, enable debugging via SDK Layers with
+ // this flag.
+ creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
+#endif
+
+ // This array defines the set of DirectX hardware feature levels this app
+ // will support.
+ // Note the ordering should be preserved.
+ // Don't forget to declare your application's minimum required feature level
+ // in its
+ // description. All applications are assumed to support 9.1 unless otherwise
+ // stated.
+ D3D_FEATURE_LEVEL featureLevels[] = {
+ D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1,
+ D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2,
+ D3D_FEATURE_LEVEL_9_1
+ };
+
+ // Create the Direct3D 11 API device object and a corresponding context.
+ ComPtr<ID3D11Device> device;
+ ComPtr<ID3D11DeviceContext> context;
+ DX::ThrowIfFailed(D3D11CreateDevice(
+ nullptr, // Specify nullptr to use the default adapter.
+ D3D_DRIVER_TYPE_HARDWARE, nullptr,
+ creationFlags, // Set set debug and Direct2D compatibility flags.
+ featureLevels, // List of feature levels this app can support.
+ ARRAYSIZE(featureLevels),
+ D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows
+ // Store apps.
+ &device, // Returns the Direct3D device created.
+ &m_featureLevel, // Returns feature level of device created.
+ &context // Returns the device immediate context.
+ ));
+
+ // Get the Direct3D 11.1 API device and context interfaces.
+ DX::ThrowIfFailed(device.As(&m_d3dDevice));
+
+ DX::ThrowIfFailed(context.As(&m_d3dContext));
+}
+
+// Allocate all memory resources that change on a window SizeChanged event.
+void Direct3DBase::CreateWindowSizeDependentResources()
+{
+ // Store the window bounds so the next time we get a SizeChanged event we can
+ // avoid rebuilding everything if the size is identical.
+ m_windowBounds = m_window->Bounds;
+
+ // Calculate the necessary swap chain and render target size in pixels.
+ float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
+ float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
+
+// The width and height of the swap chain must be based on the window's
+// landscape-oriented width and height. If the window is in a portrait
+// orientation, the dimensions must be reversed.
+#if WINVER > 0x0602
+ m_orientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
+#else
+# if PHONE
+ // WP8 doesn't support rotations so always make it landscape
+ m_orientation = DisplayOrientations::Landscape;
+# else
+ m_orientation = DisplayProperties::CurrentOrientation;
+# endif
+#endif
+ bool swapDimensions = m_orientation == DisplayOrientations::Portrait ||
+ m_orientation == DisplayOrientations::PortraitFlipped;
+ m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
+ m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
+
+ if (m_swapChain != nullptr) {
+ // If the swap chain already exists, resize it.
+ DX::ThrowIfFailed(
+ m_swapChain->ResizeBuffers(2, // Double-buffered swap chain.
+ static_cast<UINT>(m_renderTargetSize.Width),
+ static_cast<UINT>(m_renderTargetSize.Height),
+ DXGI_FORMAT_B8G8R8A8_UNORM, 0));
+ } else {
+ // Otherwise, create a new one using the same adapter as the existing
+ // Direct3D device.
+ DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
+ swapChainDesc.Width = static_cast<UINT>(
+ m_renderTargetSize.Width); // Match the size of the window.
+ swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
+ swapChainDesc.Format =
+ DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
+ swapChainDesc.Stereo = false;
+ swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
+ swapChainDesc.SampleDesc.Quality = 0;
+ swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+#if PHONE && WINVER <= 0x0602
+ swapChainDesc.BufferCount = 1; // Use double-buffering to minimize latency.
+ swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and
+ // aspect-ratio stretch
+ // scaling are allowed.
+ swapChainDesc.SwapEffect =
+ DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported.
+#else
+ swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
+ swapChainDesc.Scaling = DXGI_SCALING_NONE;
+ swapChainDesc.SwapEffect =
+ DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this
+ // SwapEffect.
+#endif
+ swapChainDesc.Flags = 0;
+
+ ComPtr<IDXGIDevice1> dxgiDevice;
+ DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice));
+
+ ComPtr<IDXGIAdapter> dxgiAdapter;
+ DX::ThrowIfFailed(dxgiDevice->GetAdapter(&dxgiAdapter));
+
+ ComPtr<IDXGIFactory2> dxgiFactory;
+ DX::ThrowIfFailed(
+ dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory));
+
+ Windows::UI::Core::CoreWindow ^ window = m_window.Get();
+ DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow(
+ m_d3dDevice.Get(), reinterpret_cast<IUnknown*>(window), &swapChainDesc,
+ nullptr, // Allow on all displays.
+ &m_swapChain));
+
+ // Ensure that DXGI does not queue more than one frame at a time. This both
+ // reduces latency and
+ // ensures that the application will only render after each VSync,
+ // minimizing power consumption.
+ DX::ThrowIfFailed(dxgiDevice->SetMaximumFrameLatency(1));
+ }
+
+ // Set the proper orientation for the swap chain, and generate the
+ // 3D matrix transformation for rendering to the rotated swap chain.
+ DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
+ switch (m_orientation) {
+ case DisplayOrientations::Landscape:
+ rotation = DXGI_MODE_ROTATION_IDENTITY;
+ m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+
+ case DisplayOrientations::Portrait:
+ rotation = DXGI_MODE_ROTATION_ROTATE270;
+ m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
+ 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+
+ case DisplayOrientations::LandscapeFlipped:
+ rotation = DXGI_MODE_ROTATION_ROTATE180;
+ m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
+ -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+
+ case DisplayOrientations::PortraitFlipped:
+ rotation = DXGI_MODE_ROTATION_ROTATE90;
+ m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
+ 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+ break;
+
+ default:
+ throw ref new Platform::FailureException();
+ }
+
+#if !PHONE || WINVER > 0x0602
+ DX::ThrowIfFailed(m_swapChain->SetRotation(rotation));
+#endif // !PHONE
+
+ // Create a render target view of the swap chain back buffer.
+ ComPtr<ID3D11Texture2D> backBuffer;
+ DX::ThrowIfFailed(
+ m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &backBuffer));
+
+ DX::ThrowIfFailed(m_d3dDevice->CreateRenderTargetView(
+ backBuffer.Get(), nullptr, &m_renderTargetView));
+
+ // Create a depth stencil view.
+ CD3D11_TEXTURE2D_DESC depthStencilDesc(
+ DXGI_FORMAT_D24_UNORM_S8_UINT, static_cast<UINT>(m_renderTargetSize.Width),
+ static_cast<UINT>(m_renderTargetSize.Height), 1, 1,
+ D3D11_BIND_DEPTH_STENCIL);
+
+ ComPtr<ID3D11Texture2D> depthStencil;
+ DX::ThrowIfFailed(
+ m_d3dDevice->CreateTexture2D(&depthStencilDesc, nullptr, &depthStencil));
+
+ CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
+ D3D11_DSV_DIMENSION_TEXTURE2D);
+ DX::ThrowIfFailed(m_d3dDevice->CreateDepthStencilView(
+ depthStencil.Get(), &depthStencilViewDesc, &m_depthStencilView));
+
+ // Set the rendering viewport to target the entire window.
+ CD3D11_VIEWPORT viewport(0.0f, 0.0f, m_renderTargetSize.Width,
+ m_renderTargetSize.Height);
+
+ m_d3dContext->RSSetViewports(1, &viewport);
+}
+
+// This method is called in the event handler for the SizeChanged event.
+void Direct3DBase::UpdateForWindowSizeChange()
+{
+ if (m_window->Bounds.Width != m_windowBounds.Width ||
+ m_window->Bounds.Height != m_windowBounds.Height ||
+#if WINVER > 0x0602
+ m_orientation !=
+ DisplayInformation::GetForCurrentView()->CurrentOrientation)
+#else
+ m_orientation != DisplayProperties::CurrentOrientation)
+#endif
+ {
+ ID3D11RenderTargetView* nullViews[] = { nullptr };
+ m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
+ m_renderTargetView = nullptr;
+ m_depthStencilView = nullptr;
+ m_d3dContext->Flush();
+ CreateWindowSizeDependentResources();
+ }
+}
+
+void Direct3DBase::ReleaseResourcesForSuspending()
+{
+ // Phone applications operate in a memory-constrained environment, so when
+ // entering
+ // the background it is a good idea to free memory-intensive objects that
+ // will be
+ // easy to restore upon reactivation. The swapchain and backbuffer are good
+ // candidates
+ // here, as they consume a large amount of memory and can be reinitialized
+ // quickly.
+ m_swapChain = nullptr;
+ m_renderTargetView = nullptr;
+ m_depthStencilView = nullptr;
+}
+
+// Method to deliver the final image to the display.
+void Direct3DBase::Present()
+{
+// The first argument instructs DXGI to block until VSync, putting the
+// application
+// to sleep until the next VSync. This ensures we don't waste any cycles
+// rendering
+// frames that will never be displayed to the screen.
+#if PHONE && WINVER <= 0x0602
+ HRESULT hr = m_swapChain->Present(1, 0);
+#else
+ // The application may optionally specify "dirty" or "scroll"
+ // rects to improve efficiency in certain scenarios.
+ DXGI_PRESENT_PARAMETERS parameters = { 0 };
+ parameters.DirtyRectsCount = 0;
+ parameters.pDirtyRects = nullptr;
+ parameters.pScrollRect = nullptr;
+ parameters.pScrollOffset = nullptr;
+
+ HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
+#endif
+
+ // Discard the contents of the render target.
+ // This is a valid operation only when the existing contents will be entirely
+ // overwritten. If dirty or scroll rects are used, this call should be
+ // removed.
+ m_d3dContext->DiscardView(m_renderTargetView.Get());
+
+ // Discard the contents of the depth stencil.
+ m_d3dContext->DiscardView(m_depthStencilView.Get());
+
+ // If the device was removed either by a disconnect or a driver upgrade, we
+ // must recreate all device resources.
+ if (hr == DXGI_ERROR_DEVICE_REMOVED) {
+ HandleDeviceLost();
+ } else {
+ DX::ThrowIfFailed(hr);
+ }
+}
+
+// Method to convert a length in device-independent pixels (DIPs) to a length
+// in physical pixels.
+float Direct3DBase::ConvertDipsToPixels(float dips)
+{
+ static const float dipsPerInch = 96.0f;
+#if WINVER > 0x0602
+ return floor(dips * DisplayInformation::GetForCurrentView()->LogicalDpi /
+ dipsPerInch +
+ 0.5f); // Round to nearest integer.
+#else
+ return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch +
+ 0.5f); // Round to nearest integer.
+#endif
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h
new file mode 100644
index 0000000..f373f00
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "DirectXHelper.h"
+
+// Helper class that initializes DirectX APIs for 3D rendering.
+ref class Direct3DBase abstract
+{
+ internal : Direct3DBase();
+
+public:
+ virtual void Initialize(Windows::UI::Core::CoreWindow ^ window);
+ virtual void HandleDeviceLost();
+ virtual void CreateDeviceResources();
+ virtual void CreateWindowSizeDependentResources();
+ virtual void UpdateForWindowSizeChange();
+ virtual void ReleaseResourcesForSuspending();
+ virtual void Render() = 0;
+ virtual void Present();
+ virtual float ConvertDipsToPixels(float dips);
+
+protected
+private:
+ // Direct3D Objects.
+ Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
+ Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
+ Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
+ Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
+ Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
+
+ // Cached renderer properties.
+ D3D_FEATURE_LEVEL m_featureLevel;
+ Windows::Foundation::Size m_renderTargetSize;
+ Windows::Foundation::Rect m_windowBounds;
+ Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
+ Windows::Graphics::Display::DisplayOrientations m_orientation;
+
+ // Transform used for display orientation.
+ DirectX::XMFLOAT4X4 m_orientationTransform3D;
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h b/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h
new file mode 100644
index 0000000..c991dbb
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <ppl.h>
+#include <ppltasks.h>
+#include <wrl/client.h>
+
+namespace DX {
+inline void ThrowIfFailed(HRESULT hr)
+{
+ if (FAILED(hr)) {
+ // Set a breakpoint on this line to catch Win32 API errors.
+ throw Platform::Exception::CreateException(hr);
+ }
+}
+
+// Function that reads from a binary file asynchronously.
+inline Concurrency::task<Platform::Array<byte> ^> ReadDataAsync(
+ Platform::String ^ filename)
+{
+ using namespace Windows::Storage;
+ using namespace Concurrency;
+
+ auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
+
+ return create_task(folder->GetFileAsync(filename))
+ .then([](StorageFile ^ file) {
+#if !PHONE
+ return FileIO::ReadBufferAsync(file);
+#else
+ return file->OpenReadAsync();
+ }).then([](Streams::IRandomAccessStreamWithContentType^ stream)
+ {
+ unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
+ auto fileBuffer = ref new Streams::Buffer(bufferSize);
+ return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
+#endif
+ })
+ .then([](Streams::IBuffer ^ fileBuffer) -> Platform::Array<byte> ^ {
+ auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
+ Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
+ return fileData;
+ });
+}
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.cso b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.cso
new file mode 100644
index 0000000..56f9c17
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.cso
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl
new file mode 100644
index 0000000..b2fe7be
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl
@@ -0,0 +1,14 @@
+#if !defined(FLAGS_ADDED)
+# error FLAGS_ADDED not defined
+#endif
+
+struct PixelShaderInput
+{
+ float4 pos : SV_POSITION;
+ float3 color : COLOR0;
+};
+
+float4 mainPS(PixelShaderInput input) : SV_TARGET
+{
+ return float4(input.color,1.0f);
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.cso b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.cso
new file mode 100644
index 0000000..ea80258
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.cso
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl
new file mode 100644
index 0000000..3f9a4eb
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl
@@ -0,0 +1,39 @@
+#if !defined(FLAGS_ADDED)
+# error FLAGS_ADDED not defined
+#endif
+
+cbuffer ModelViewProjectionConstantBuffer : register(b0)
+{
+ matrix model;
+ matrix view;
+ matrix projection;
+};
+
+struct VertexShaderInput
+{
+ float3 pos : POSITION;
+ float3 color : COLOR0;
+};
+
+struct VertexShaderOutput
+{
+ float4 pos : SV_POSITION;
+ float3 color : COLOR0;
+};
+
+VertexShaderOutput mainVS(VertexShaderInput input)
+{
+ VertexShaderOutput output;
+ float4 pos = float4(input.pos, 1.0f);
+
+ // Transform the vertex position into projected space.
+ pos = mul(pos, model);
+ pos = mul(pos, view);
+ pos = mul(pos, projection);
+ output.pos = pos;
+
+ // Pass through the color without modification.
+ output.color = input.color;
+
+ return output;
+}
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Strings/en-US/Resources.resw b/Tests/VSWinStorePhone/Direct3DApp1/Strings/en-US/Resources.resw
new file mode 100644
index 0000000..8c2c8ae
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Strings/en-US/Resources.resw
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="TestString" xml:space="preserve">
+ <value>Test String</value>
+ </data>
+</root>
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/pch.cpp b/Tests/VSWinStorePhone/Direct3DApp1/pch.cpp
new file mode 100644
index 0000000..1d9f38c
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/pch.cpp
@@ -0,0 +1 @@
+#include "pch.h"
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/pch.h b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
new file mode 100644
index 0000000..d80cdb7
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include <memory>
+
+#include <DirectXMath.h>
+#include <agile.h>
+#include <d3d11_1.h>
+#include <wrl/client.h>
diff --git a/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake b/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake
new file mode 100644
index 0000000..528c46f
--- /dev/null
+++ b/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake
@@ -0,0 +1,45 @@
+macro(ensure_props_set projectFile)
+ if(NOT EXISTS "${projectFile}")
+ message(FATAL_ERROR "Project file ${projectFile} does not exist.")
+ return()
+ endif()
+
+ set(SourcePropertyFound FALSE)
+ set(DebugTargetPropertyFound FALSE)
+ set(ReleaseTargetPropertyFound FALSE)
+
+ file(STRINGS "${projectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "<SourceProperty1.*Debug.*>SourceProperty1Value</SourceProperty1>")
+ message("SourceProperty1 setting found")
+ set(SourcePropertyFound TRUE)
+ endif()
+
+ if(line MATCHES "<TargetProperty1.*Debug.*>TargetProperty1ValueDebug</TargetProperty1>")
+ message("Debug TargetProperty1 setting found")
+ set(DebugTargetPropertyFound TRUE)
+ endif()
+
+ if(line MATCHES "<TargetProperty1.*Release.*>TargetProperty1ValueRelease</TargetProperty1>")
+ message("Release TargetProperty1 setting found")
+ set(ReleaseTargetPropertyFound TRUE)
+ endif()
+ endforeach()
+
+ if (NOT SourcePropertyFound)
+ message(FATAL_ERROR "SourceProperty1 setting not found")
+ return()
+ endif()
+
+ if (NOT DebugTargetPropertyFound)
+ message(FATAL_ERROR "Debug TargetProperty1 setting not found")
+ return()
+ endif()
+
+ if (NOT ReleaseTargetPropertyFound)
+ message(FATAL_ERROR "Release TargetProperty1 setting not found")
+ return()
+ endif()
+endmacro()
+
+ensure_props_set("${vcxproj}")
diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake
new file mode 100644
index 0000000..f9440d7
--- /dev/null
+++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake
@@ -0,0 +1,34 @@
+set(APP_PKG_NAME Direct3DApp1)
+
+# List of files that are expected to be present in the generated app package
+set(EXPECTED_APP_PKG_CONTENT
+ ${APP_PKG_NAME}.exe
+ CxxDll.dll
+ JusticeLeagueWinRT.winmd
+ JusticeLeagueWinRT.dll
+)
+
+# Windows app package formats can be either msix, appx or xap
+file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR} ${APP_PKG_NAME}*.msix ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.xap)
+
+# There can be only one generated app package
+list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT)
+if(NOT APP_PKG_COUNT EQUAL 1)
+ message(FATAL_ERROR "Expected 1 generated app package, but detected ${APP_PKG_COUNT}: ${ALL_APP_PKG_FILES}")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${ALL_APP_PKG_FILES}
+ OUTPUT_VARIABLE APP_PKG_CONTENT_OUTPUT
+ ERROR_VARIABLE error
+ RESULT_VARIABLE result)
+
+if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Listing app package content failed with: ${error}")
+endif()
+
+foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT})
+ string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found)
+ if(_found EQUAL -1)
+ message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}")
+ endif()
+endforeach()
diff --git a/Tests/VSWinStorePhone/WinRT/Batman.cpp b/Tests/VSWinStorePhone/WinRT/Batman.cpp
new file mode 100644
index 0000000..e092258
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/Batman.cpp
@@ -0,0 +1,14 @@
+#include "Batman.h"
+
+using namespace JusticeLeagueWinRT;
+using namespace Platform;
+
+Batman::Batman()
+{
+}
+
+void Batman::savePeople()
+{
+ int i = 0;
+ i++;
+}
diff --git a/Tests/VSWinStorePhone/WinRT/Batman.h b/Tests/VSWinStorePhone/WinRT/Batman.h
new file mode 100644
index 0000000..e2dcabc
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/Batman.h
@@ -0,0 +1,12 @@
+#pragma once
+
+namespace JusticeLeagueWinRT {
+public
+ref class Batman sealed
+{
+public:
+ Batman();
+
+ void savePeople();
+};
+}
diff --git a/Tests/VSWinStorePhone/WinRT/CMakeLists.txt b/Tests/VSWinStorePhone/WinRT/CMakeLists.txt
new file mode 100644
index 0000000..bb93333
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(JusticeLeagueWinRT CXX)
+
+# create project
+add_library(JusticeLeagueWinRT SHARED
+ "${CMAKE_CURRENT_SOURCE_DIR}/Batman.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Batman.h"
+)
+
+set_target_properties(JusticeLeagueWinRT PROPERTIES
+ VS_WINRT_COMPONENT TRUE
+ VS_GLOBAL_ROOTNAMESPACE "JusticeLeagueWinRT"
+ OUTPUT_NAME "JusticeLeagueWinRT"
+)
diff --git a/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in
new file mode 100644
index 0000000..68172fa
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
+ <Identity Name="@PACKAGE_GUID@" Publisher="CN=mgong" Version="1.0.0.0" />
+ <Properties>
+ <DisplayName>@SHORT_NAME@</DisplayName>
+ <PublisherDisplayName>mgong</PublisherDisplayName>
+ <Logo>Assets/StoreLogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.2.1</OSMinVersion>
+ <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App">
+ <VisualElements DisplayName="@SHORT_NAME@" Description="@SHORT_NAME@" BackgroundColor="#336699" ForegroundText="light" Logo="Assets/Logo.png" SmallLogo="Assets/SmallLogo.png">
+ <DefaultTile ShowName="allLogos" ShortName="@SHORT_NAME@" />
+ <SplashScreen Image="Assets/SplashScreen.png" />
+ </VisualElements>
+ </Application>
+ </Applications>
+</Package>
diff --git a/Tests/VSWinStorePhone/cmake/Package_vc11.wp.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc11.wp.appxmanifest.in
new file mode 100644
index 0000000..70f3abf
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc11.wp.appxmanifest.in
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
+ <DefaultLanguage xmlns="" code="en-US"/>
+ <App xmlns="" ProductID="{@PACKAGE_GUID@}" Title="@SHORT_NAME@" RuntimeType="Modern Native" Version="1.0.0.0" Genre="apps.normal" Author="mgong" Description="Simple Direct3D application" Publisher="@SHORT_NAME@" PublisherID="{c618991e-1d39-41c2-a881-d3310705a091}">
+ <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
+ <Capabilities>
+ <Capability Name="ID_CAP_NETWORKING" />
+ <Capability Name="ID_CAP_MEDIALIB_AUDIO" />
+ <Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
+ </Capabilities>
+ <Tasks>
+ <DefaultTask Name="_default" ImagePath="@SHORT_NAME@.exe" ImageParams="" />
+ </Tasks>
+ <Tokens>
+ <PrimaryToken TokenID="@SHORT_NAME@Token" TaskName="_default">
+ <TemplateFlip>
+ <SmallImageURI IsRelative="true" IsResource="false">FlipCycleTileSmall.png</SmallImageURI>
+ <Count>0</Count>
+ <BackgroundImageURI IsRelative="true" IsResource="false">FlipCycleTileMedium.png</BackgroundImageURI>
+ <Title>@SHORT_NAME@</Title>
+ <BackContent></BackContent>
+ <BackBackgroundImageURI></BackBackgroundImageURI>
+ <BackTitle></BackTitle>
+ <DeviceLockImageURI></DeviceLockImageURI>
+ <HasLarge></HasLarge>
+ </TemplateFlip>
+ </PrimaryToken>
+ </Tokens>
+ <ScreenResolutions>
+ <ScreenResolution Name="ID_RESOLUTION_WVGA" />
+ <ScreenResolution Name="ID_RESOLUTION_WXGA" />
+ <ScreenResolution Name="ID_RESOLUTION_HD720P" />
+ </ScreenResolutions>
+ </App>
+</Deployment>
diff --git a/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in
new file mode 100644
index 0000000..08205f5
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
+ <Identity Name="@PACKAGE_GUID@" Publisher="CN=mgong" Version="1.1.0.0" />
+ <Properties>
+ <DisplayName>@SHORT_NAME@</DisplayName>
+ <PublisherDisplayName>mgong</PublisherDisplayName>
+ <Logo>Assets/StoreLogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.3</OSMinVersion>
+ <OSMaxVersionTested>6.3</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App">
+ <m2:VisualElements
+ DisplayName="@SHORT_NAME@"
+ Description="@SHORT_NAME@"
+ BackgroundColor="#336699"
+ ForegroundText="light"
+ Square150x150Logo="Assets/Logo.png"
+ Square30x30Logo="Assets/SmallLogo.png">
+ <m2:DefaultTile ShortName="@SHORT_NAME@">
+ <m2:ShowNameOnTiles>
+ <m2:ShowOn Tile="square150x150Logo" />
+ </m2:ShowNameOnTiles>
+ </m2:DefaultTile>
+ <m2:SplashScreen Image="Assets/SplashScreen.png" />
+ </m2:VisualElements>
+ </Application>
+ </Applications>
+</Package>
diff --git a/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in
new file mode 100644
index 0000000..d47d43c
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
+ <Identity Name="@PACKAGE_GUID@" Publisher="CN=mgong" Version="1.1.0.0" />
+ <mp:PhoneIdentity PhoneProductId="@PACKAGE_GUID@" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
+
+ <Properties>
+ <DisplayName>@SHORT_NAME@</DisplayName>
+ <PublisherDisplayName>mgong</PublisherDisplayName>
+ <Logo>Assets/StoreLogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.3.1</OSMinVersion>
+ <OSMaxVersionTested>6.3.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App">
+ <m2:VisualElements
+ DisplayName="@SHORT_NAME@"
+ Description="@SHORT_NAME@"
+ BackgroundColor="#336699"
+ ForegroundText="light"
+ Square150x150Logo="Assets/Logo.png"
+ Square30x30Logo="Assets/SmallLogo.png">
+ <m2:DefaultTile ShortName="@SHORT_NAME@">
+ <m2:ShowNameOnTiles>
+ <m2:ShowOn Tile="square150x150Logo" />
+ </m2:ShowNameOnTiles>
+ </m2:DefaultTile>
+ <m2:SplashScreen Image="Assets/SplashScreen.png" />
+ </m2:VisualElements>
+ </Application>
+ </Applications>
+</Package>
diff --git a/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in
new file mode 100644
index 0000000..6b27ab7
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package
+ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
+ xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
+ xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
+ IgnorableNamespaces="uap mp">
+
+ <Identity Name="@PACKAGE_GUID@" Publisher="CN=mgong" Version="1.1.0.0" />
+ <mp:PhoneIdentity PhoneProductId="@PACKAGE_GUID@" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
+
+ <Properties>
+ <DisplayName>@SHORT_NAME@</DisplayName>
+ <PublisherDisplayName>mgong</PublisherDisplayName>
+ <Logo>Assets/StoreLogo.png</Logo>
+ </Properties>
+
+ <Dependencies>
+ <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.65535.65535" />
+ </Dependencies>
+
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App">
+ <uap:VisualElements
+ DisplayName="@SHORT_NAME@"
+ Description="@SHORT_NAME@"
+ BackgroundColor="#336699"
+ Square150x150Logo="Assets/Logo.png"
+ Square44x44Logo="Assets/SmallLogo44x44.png">
+ <uap:SplashScreen Image="Assets/SplashScreen.png" />
+ </uap:VisualElements>
+ </Application>
+ </Applications>
+</Package>