28/01/2014 MCAFEE SECURE 認證的網站

https://www.mcafeesecure.com/RatingVerify?ref=www.HongKongCupid.com

2013年6月27日 星期四

***DirectXGame*~GDC2013Game20%Templates~{ Microsoft Core Windows**& Core Windows & XAML }& download!!!!!

***DirectXGame*~GDC2013Game20%Templates~
{ Microsoft Core Windows** 
& Core Windows  & XAML & download..}!!!!!

**Microsoft Visual Studio Solution File,
 Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ignore", "ignore.vcxproj", "{E49409F5-74F2-409A-89D3-6609EDC00A42}"
EndProject
Global
 GlobalSection(SolutionConfigurationPlatforms) = preSolution
  Debug|ARM = Debug|ARM
  Debug|Win32 = Debug|Win32
  Debug|x64 = Debug|x64
  Release|ARM = Release|ARM
  Release|Win32 = Release|Win32
  Release|x64 = Release|x64
 EndGlobalSection
 GlobalSection(ProjectConfigurationPlatforms) = postSolution
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|ARM.ActiveCfg = Debug|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|ARM.Build.0 = Debug|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|ARM.Deploy.0 = Debug|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|Win32.ActiveCfg = Debug|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|Win32.Build.0 = Debug|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|Win32.Deploy.0 = Debug|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|x64.ActiveCfg = Debug|x64
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|x64.Build.0 = Debug|x64
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Debug|x64.Deploy.0 = Debug|x64
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|ARM.ActiveCfg = Release|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|ARM.Build.0 = Release|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|ARM.Deploy.0 = Release|ARM
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|Win32.ActiveCfg = Release|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|Win32.Build.0 = Release|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|Win32.Deploy.0 = Release|Win32
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|x64.ActiveCfg = Release|x64
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|x64.Build.0 = Release|x64
  {E49409F5-74F2-409A-89D3-6609EDC00A42}.Release|x64.Deploy.0 = Release|x64
 EndGlobalSection
 GlobalSection(SolutionProperties) = preSolution
  HideSolutionNode = FALSE
 EndGlobalSection
EndGlobal**

*****IGNORE**
**<?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|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>

    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{e49409f5-74f2-409a-89d3-6609edc00a42}</ProjectGuid>
    <RootNamespace>ignore</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>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <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" />
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
    <ClCompile>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)

</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Use</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
    <ClCompile>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)

</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Use</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
    </ClCompile>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>                                                                          *


**DIREXTXHELPER***
**//// THIS CODE AND INFORMATION IS PROVIDED "AS IS"
WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING

BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR

FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved

#pragma once
#include <wrl/client.h>
#include <ppl.h>
#include <ppltasks.h>
#include <d2d1_1.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)
  {
   return FileIO::ReadBufferAsync(file);
  }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
  {
   auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
   Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
   return fileData;
  });
 }

 inline void WicBitmapLoader(
  _In_ ID2D1DeviceContext* m_d2dContext,
  _In_reads_bytes_(dataSize) byte* data,
  _In_ uint32 dataSize,
  _Out_opt_ ID2D1Bitmap1** bitmap,
  _In_opt_ Platform::String^ debugName
  )
 {
  using namespace Microsoft::WRL;

  ComPtr<ID2D1Bitmap1> bitmap2D;
  if (m_d2dContext == nullptr)
  {
   // A D2D context is required to create a D2D bitmap. If
   // BasicLoader was not initialized with one, this operation
   // cannot be completed.
   if (bitmap != nullptr) *bitmap = nullptr;
   return;
  }

  ComPtr<IWICImagingFactory2> wicFactory;
  // A WIC factory object is required in order to load texture
  // assets stored in non-DDS formats.  If BasicLoader was not
  // initialized with one, create one as needed.
  DX::ThrowIfFailed(
   CoCreateInstance(
    CLSID_WICImagingFactory,
    nullptr,
    CLSCTX_INPROC_SERVER,
    IID_PPV_ARGS(&wicFactory)
    )
   );

  ComPtr<IWICStream> stream;
  DX::ThrowIfFailed(
   wicFactory->CreateStream(&stream)
   );

  DX::ThrowIfFailed(
   stream->InitializeFromMemory(
    data,
    dataSize
    )
   );

  ComPtr<IWICBitmapDecoder> bitmapDecoder;
  DX::ThrowIfFailed(
   wicFactory->CreateDecoderFromStream(
    stream.Get(),
    nullptr,
    WICDecodeMetadataCacheOnDemand,
    &bitmapDecoder
    )
   );

  ComPtr<IWICBitmapFrameDecode> bitmapFrame;
  DX::ThrowIfFailed(
   bitmapDecoder->GetFrame(0, &bitmapFrame)
   );

  ComPtr<IWICFormatConverter> formatConverter;
  DX::ThrowIfFailed(
   wicFactory->CreateFormatConverter(&formatConverter)
   );

  DX::ThrowIfFailed(
   formatConverter->Initialize(
    bitmapFrame.Get(),
    GUID_WICPixelFormat32bppPBGRA,
    WICBitmapDitherTypeNone,
    nullptr,
    0.0,
    WICBitmapPaletteTypeCustom
    )
   );

  uint32 width;
  uint32 height;
  DX::ThrowIfFailed(
   bitmapFrame->GetSize(&width, &height)
   );

  std::unique_ptr<byte[]> bitmapPixels(new byte[width * height * 4]);
  DX::ThrowIfFailed(
   formatConverter->CopyPixels(
    nullptr,
    width * 4,
    width * height * 4,
    bitmapPixels.get()
    )
   );

  D2D1_BITMAP_PROPERTIES1 properties;
  properties.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
  properties.pixelFormat.alphaMode = D2D1_ALPHA_

MODE_PREMULTIPLIED;
  properties.dpiX = 96.0f;
  properties.dpiY = 96.0f;
  properties.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET;
  properties.colorContext = nullptr;
  DX::ThrowIfFailed(
   m_d2dContext->CreateBitmap(
    D2D1::SizeU(
     static_cast<UINT32>(width * properties.dpiX / 96.0f),
     static_cast<UINT32>(height * properties.dpiY / 96.0f)
     ),
    (const void*)(bitmapPixels.get()),
    width * 4,
    &properties,
    &bitmap2D
    )
   );

  if (bitmap != nullptr)
  {
   *bitmap = bitmap2D.Detach();
  }
 }

}                                                                                                                           ***

***Package AppXmanifest**
**<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
  <Identity Name="$guid9$" Publisher=

"$XmlEscapedPublisherDistinguishedName$" Version="1.0.0.0" />
  <Properties>
    <DisplayName>$projectname$</DisplayName>
    <PublisherDisplayName>$XmlEscapedPublisher$</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="$safeprojectname$.App">
      <VisualElements DisplayName=

"$projectname$" Logo="Assets\Logo.png" SmallLogo=
"Assets\SmallLogo.png" Description=
"$projectname$" ForegroundText=
"light" BackgroundColor="#464646">
        <DefaultTile ShowName="allLogos" />
        <SplashScreen Image="Assets\SplashScreen.png" />
        <InitialRotationPreference>
          <Rotation Preference="portrait" />
          <Rotation Preference="landscape" />
          <Rotation Preference="portraitFlipped" />
          <Rotation Preference="landscapeFlipped" />
        </InitialRotationPreference>
      </VisualElements>
    </Application>
  </Applications>
</Package>***


***D2DOverlay**
***#include "pch.h"
#include "D2DOverlay.h"
#include "Common_DirectX\DirectXHelper.h"

using namespace Windows::UI::Core;
using namespace Windows::Foundation;
using namespace Microsoft::WRL;
using namespace Windows::UI::ViewManagement;
using namespace Windows::Graphics::Display;
using namespace D2D1;

D2DOverlay::D2DOverlay()
{
}

void D2DOverlay::Initialize(
 _In_ ID2D1Device*   d2dDevice,
 _In_ ID2D1DeviceContext*  d2dContext,
 _In_ IDWriteFactory*   dwriteFactory,
 _In_ D2D1::Matrix3x2F  displayOrientationTransform2D,
 _In_ Windows::Foundation::Rect windowBounds
 )
{
 // Use the same D2D device, window properties, etc.

 as the host rendering class
 m_dwriteFactory = dwriteFactory;
 m_d2dDevice = d2dDevice;
 m_d2dContext = d2dContext;
 m_displayOrientationTransform2D = displayOrientationTransform2D;
 m_windowBounds = windowBounds;

 ComPtr<ID2D1Factory> factory;
 d2dDevice->GetFactory(&factory);

 DX::ThrowIfFailed(
  factory.As(&m_d2dFactory)
  );
}


// Hud class
Hud::Hud() : D2DOverlay()
 , m_loadingComplete(false)
 , m_drawFrameInfo(true)
 , m_inputDisplayStr("")
 , m_fpsDisplayStr("")
{
 ZeroMemory(&m_fpsMetrics, sizeof(DWRITE_TEXT_METRICS));
 ZeroMemory(&m_inputCoordsMetrics, sizeof(DWRITE_TEXT_METRICS));
 ZeroMemory(&m_titleMetrics, sizeof(DWRITE_TEXT_METRICS));
}
void Hud::Initialize(
 _In_ ID2D1Device*    d2dDevice,
 _In_ ID2D1DeviceContext*  d2dContext,
 _In_ IDWriteFactory*   dwriteFactory,
 _In_ D2D1::Matrix3x2F   displayOrientationTransform2D,
 _In_ Windows::Foundation::Rect windowBounds,
 _In_ Platform::String^   titleStr,
 _In_ Platform::String^   bitmapFileNameStr
 )
{
 D2DOverlay::Initialize(d2dDevice,
         d2dContext,
         dwriteFactory,
         displayOrientationTransform2D,
         windowBounds);
 m_title = titleStr;
 m_bitmapFileName = bitmapFileNameStr;
 m_textVerticalOffset = 5.0f;
 m_loadingComplete = false;
 ResetDirectXResources();
}
void Hud::Update(
 Platform::String^ inputDisplayStr,
 Platform::String^ fpsDisplayStr
 )
{
 if (inputDisplayStr != nullptr)
 {
  // Update input display text
  m_inputDisplayStr = inputDisplayStr;

  DX::ThrowIfFailed(
   m_textFormat->SetTextAlignment(DWRITE_TEXT_
ALIGNMENT_LEADING)
   );
  DX::ThrowIfFailed(
   m_dwriteFactory->CreateTextLayout(
    m_inputDisplayStr->Data(),
    m_inputDisplayStr->Length(),
    m_textFormat.Get(),
    400, // Max width of the input text.
    50, // Max height of the input text.
    &m_textLayoutInputCoordsDisplay
    )
   );
  DX::ThrowIfFailed(
   m_textLayoutInputCoordsDisplay->
GetMetrics(&m_inputCoordsMetrics)
   );
 }
 if (fpsDisplayStr != nullptr)
 {
  // Update FPS display text
  m_fpsDisplayStr = fpsDisplayStr;

  DX::ThrowIfFailed(
   m_textFormat->SetTextAlignment(DWRITE_TEXT_
ALIGNMENT_TRAILING)
   );
  DX::ThrowIfFailed(
   m_dwriteFactory->CreateTextLayout(
    m_fpsDisplayStr->Data(),
    m_fpsDisplayStr->Length(),
    m_textFormat.Get(),
    240, // Max width of the FPS text.
    50, // Max height of the FPS text.
    &m_textLayoutFpsDisplay
    )
   );
  DX::ThrowIfFailed(
   m_textLayoutFpsDisplay->GetMetrics(&m_fpsMetrics)
   );
 }
}

void Hud::Render()
{
 if (!m_loadingComplete)
 {
  return;
 }
 m_d2dContext->SaveDrawingState(m_stateBlock.Get());
 m_d2dContext->BeginDraw();
 // Position the title text.
 D2D1::Matrix3x2F screenTranslationTitle =
 D2D1::Matrix3x2F::Translation(
  (m_windowBounds.Width - m_titleMetrics.layoutWidth) / 2,
  m_textVerticalOffset
  );

 // Note that the transform matrix is post-multiplied here
 // in order to correctly orient the text to match the display orientation.
 // This post-multiplication step is required for any draw calls that are
 // made to the swap chain's target bitmap. For draw calls to other targets,
 // this transform should not be applied.
 m_d2dContext->SetTransform(screenTranslationTitle * m_
displayOrientationTransform2D);
 m_d2dContext->DrawTextLayout(
  Point2F(0.f, 0.f),
  m_textLayoutTitle.Get(),
  m_whiteBrush.Get()
  );
 // Position the input text.
 D2D1::Matrix3x2F screenTranslationInputCoords =
D2D1::Matrix3x2F::Translation(
  0.f,
  m_windowBounds.Height - m_inputCoordsMetrics.height
  );

 m_d2dContext->SetTransform(screenTranslationInputCoords * m_displayOrientationTransform2D);

 m_d2dContext->DrawTextLayout(
  Point2F(0.f, 0.f),
  m_textLayoutInputCoordsDisplay.Get(),
  m_whiteBrush.Get()
  );
 if (m_drawFrameInfo)
 {
  // Position the FPS text.
  D2D1::Matrix3x2F screenTranslationFPS =
 D2D1::Matrix3x2F::Translation(
   m_windowBounds.Width - m_fpsMetrics.layoutWidth,
   m_windowBounds.Height - m_fpsMetrics.height
   );
  m_d2dContext->SetTransform(screenTranslationFPS * m_
displayOrientationTransform2D);
  m_d2dContext->DrawTextLayout(
   Point2F(0.f, 0.f),
   m_textLayoutFpsDisplay.Get(),
   m_whiteBrush.Get()
   );
 }
 if (m_bitmap != nullptr)
 {
  D2D1_RECT_F size = {0};
  size.bottom = 2 * m_bitmap->GetSize().height;
  size.right = 2 * m_bitmap->GetSize().width;
  m_d2dContext->SetTransform(m_displayOrientationTransform2D);
  m_d2dContext->DrawBitmap(
   m_bitmap.Get(),
   size,
   1.0f,
   D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
   nullptr);
 }
 // We ignore D2DERR_RECREATE_TARGET here.
This error indicates that the device
 // is lost. It will be handled during the next call to Present.
 HRESULT hr = m_d2dContext->EndDraw();
 if (hr != D2DERR_RECREATE_TARGET)
 {
  DX::ThrowIfFailed(hr);
 }
 m_d2dContext->RestoreDrawingState(m_stateBlock.Get());
}
void Hud::ResetDirectXResources()
{
 DX::ThrowIfFailed(
  m_d2dContext->CreateSolidColorBrush(ColorF(ColorF::White),
&m_whiteBrush)
  );
 double dpiX = 96.0f;
 double dpiY = 96.0f;
 DX::ThrowIfFailed(
  m_dwriteFactory->CreateTextFormat(
   L"Segoe UI",
   nullptr,
   DWRITE_FONT_WEIGHT_LIGHT,
   DWRITE_FONT_STYLE_NORMAL,
   DWRITE_FONT_STRETCH_NORMAL,
   32.0f,
   L"en-US",
   &m_textFormat
   )
  );
 DX::ThrowIfFailed(
  m_textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)
  );

 DX::ThrowIfFailed(
  m_textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER)
  );
 DX::ThrowIfFailed(
  m_dwriteFactory->CreateTextLayout(
   m_title->Data(),
   m_title->Length(),
   m_textFormat.Get(),
   500.f,
   50.f,
   &m_textLayoutTitle
   )
  );
 DX::ThrowIfFailed(
  m_textLayoutTitle->GetMetrics(&m_titleMetrics)
  );
 // TODO: Is the state block save/load still necessary?
 DX::ThrowIfFailed(
  m_d2dFactory->CreateDrawingStateBlock(&m_stateBlock)
  );
 auto readTextureTask = DX::ReadDataAsync(m_bitmapFileName);
 readTextureTask.then([this](Platform::Array<unsigned char, 1U>^ data)
  {
   if (data->Length > 0)
   {
    DX::WicBitmapLoader(m_d2dContext.Get(), data->Data, data->
Length, &m_bitmap, "HUD");
   }
   m_loadingComplete = true;
  });
}
// PauseScreen class
PauseScreen::PauseScreen() : D2DOverlay()
 , m_pauseMessage("")
{
 ZeroMemory(&m_pauseMessageMetrics, sizeof(DWRITE_
TEXT_METRICS));
}
void PauseScreen::Initialize(
  _In_ ID2D1Device*    d2dDevice,
  _In_ ID2D1DeviceContext*  d2dContext,
  _In_ IDWriteFactory*   dwriteFactory,
  _In_ D2D1::Matrix3x2F   displayOrientationTransform2D,
  _In_ Windows::Foundation::Rect windowBounds,
  _In_ Platform::String^   pauseMessage
  )
{
 D2DOverlay::Initialize(d2dDevice,
         d2dContext,
         dwriteFactory,
         displayOrientationTransform2D,
         windowBounds);
 m_pauseMessage = pauseMessage;
 m_textVerticalOffset = 5.0f;
 ResetDirectXResources();
}
void PauseScreen::Update(
 _In_ Platform::String^ pauseMessage
 )
{
 if (pauseMessage != nullptr)
 {
  // Update input display text
  m_pauseMessage = pauseMessage;
 }
 else
 {
  m_pauseMessage = "APP PAUSED";
 }

 DX::ThrowIfFailed(
  m_dwriteFactory->CreateTextLayout(
   m_pauseMessage->Data(),
   m_pauseMessage->Length(),
   m_textFormat.Get(),
   400, // Max width of the input text.
   50, // Max height of the input text.
   &m_textLayoutPauseMessage
   )
  );
 DX::ThrowIfFailed(
  m_textLayoutPauseMessage->GetMetrics(&m_pauseMessageMetrics)
  );
}
void PauseScreen::Render()
{
 m_d2dContext->SaveDrawingState(m_stateBlock.Get());
 m_d2dContext->BeginDraw();
 // Position the title text.
 D2D1::Matrix3x2F translationTitle = D2D1::Matrix3x2F::Translation(
  (m_windowBounds.Width - m_pauseMessageMetrics.layoutWidth) / 2,
  m_textVerticalOffset
  );

 // Note that the transform matrix is post-multiplied here
 // in order to correctly orient the text to match the display orientation.
 // This post-multiplication step is required for any draw calls that are
 // made to the swap chain's target bitmap. For draw calls to other targets,
 // this transform should not be applied.
 m_d2dContext->SetTransform(translationTitle * m_displayOrientationTransform2D);
 m_d2dContext->DrawTextLayout(
  Point2F(0.f, 0.f),
  m_textLayoutPauseMessage.Get(),
  m_whiteBrush.Get()
  );
 // We ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
 // is lost. It will be handled during the next call to Present.
 HRESULT hr = m_d2dContext->EndDraw();
 if (hr != D2DERR_RECREATE_TARGET)
 {
  DX::ThrowIfFailed(hr);
 }
 m_d2dContext->RestoreDrawingState(m_stateBlock.Get());
}
void PauseScreen::ResetDirectXResources()
{
 DX::ThrowIfFailed(
  m_d2dContext->CreateSolidColorBrush(ColorF(ColorF::White), &m_whiteBrush)
  );
 double dpiX = 96.0f;
 double dpiY = 96.0f;
 DX::ThrowIfFailed(
  m_dwriteFactory->CreateTextFormat(
   L"Segoe UI",
   nullptr,
   DWRITE_FONT_WEIGHT_LIGHT,
   DWRITE_FONT_STYLE_NORMAL,
   DWRITE_FONT_STRETCH_NORMAL,
   32.0f,
   L"en-US",
   &m_textFormat
   )
  );
 DX::ThrowIfFailed(
  m_textFormat->SetParagraphAlignment(DWRITE_
PARAGRAPH_ALIGNMENT_NEAR)
  );
 DX::ThrowIfFailed(
  m_textFormat->SetTextAlignment(DWRITE_TEXT_
ALIGNMENT_CENTER)
  );
 DX::ThrowIfFailed(
  m_dwriteFactory->CreateTextLayout(
   m_pauseMessage->Data(),
   m_pauseMessage->Length(),
   m_textFormat.Get(),
   500.f,
   50.f,
   &m_textLayoutPauseMessage
   )
  );
 DX::ThrowIfFailed(
  m_textLayoutPauseMessage->GetMetrics(&m_pauseMessageMetrics)
  );
 // TODO: Is the state block save/load still necessary?
 DX::ThrowIfFailed(
  m_d2dFactory->CreateDrawingStateBlock(&m_stateBlock)
  );
}                                                                                                          **

**#include "pch.h"***
***//// THIS CODE AND INFORMATION IS PROVIDED "AS IS"
WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING
 BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#include "pch.h"
#include "RenderObject.h"
#include "Common_DirectX\StepTimer.h"  // for TICKS_PER_SECOND
#include "Common_DirectX\DirectXHelper.h" // for ThrowifFailed()
#include <windows.ui.xaml.media.dxinterop.h>
using namespace D2D1;
using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml::Controls;
RenderObject::RenderObject() :
 m_loadingComplete(false),
 m_degreesPerSecond(45),
 m_usePanel(false),
 m_projectDir(""),
 m_indexCount(0),
 m_dpi(-1.0f),
 m_ticks(0)
{
}
// These resources can be created before the DirectX device(s)
 are created. They persist
// even if the device has to be reset.
void RenderObject::CreateDeviceIndependentResources()
{
#ifdef TEMPLATE_USING_D2D
 D2D1_FACTORY_OPTIONS options;
 ZeroMemory(&options, sizeof(D2D1_FACTORY_OPTIONS));
#if defined(_DEBUG)
  // If the project is in a debug build, enable Direct2D debugging
 via SDK Layers.
 options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
#endif
 DX::ThrowIfFailed(
  D2D1CreateFactory(
   D2D1_FACTORY_TYPE_SINGLE_THREADED,
   __uuidof(ID2D1Factory1),
   &options,
   &m_d2dFactory
   )
  );
 DX::ThrowIfFailed(
  DWriteCreateFactory(
   DWRITE_FACTORY_TYPE_SHARED,
   __uuidof(IDWriteFactory),
   &m_dwriteFactory
   )
  );
 DX::ThrowIfFailed(
  CoCreateInstance(
   CLSID_WICImagingFactory,
   nullptr,
   CLSCTX_INPROC_SERVER,
   IID_PPV_ARGS(&m_wicFactory)
   )
  );
#endif
}
// These resources have to be re-initialized every time the DirectX
device(s) are recreated.
void RenderObject::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;
 ComPtr<IDXGIDevice> dxgiDevice;
#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
 // and 9.1 support is required for the ARM target platform.
 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> d3dContext;
 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.
   &d3dContext // Returns the device immediate context.
   )
  );
 // Get the Direct3D 11.1 API device and context interfaces.
 DX::ThrowIfFailed(
  device.As(&m_d3dDevice)
  );
 DX::ThrowIfFailed(
  d3dContext.As(&m_d3dContext)
  );
 // Get the underlying DXGI device of the Direct3D device.
 DX::ThrowIfFailed(
  m_d3dDevice.As(&dxgiDevice)
  );
#ifdef TEMPLATE_USING_D2D
 // Create the Direct2D device object and a corresponding context.
 DX::ThrowIfFailed(
  m_d2dFactory->CreateDevice(dxgiDevice.Get(), &m_d2dDevice)
  );
 DX::ThrowIfFailed(
  m_d2dDevice->CreateDeviceContext(
   D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
   &m_d2dContext
   )
  );
#endif
 auto loadVSTask = DX::ReadDataAsync(m_projectDir +
"SimpleVertexShader.cso");
 auto loadPSTask = DX::ReadDataAsync(m_projectDir +
"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;
 });
}
// These resources need to be recreated every time the
window size is changed.
void RenderObject::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.
 m_displayOrientation = DisplayProperties::CurrentOrientation;
 bool swapDimensions =
  m_displayOrientation == DisplayOrientations::Portrait ||
  m_displayOrientation == DisplayOrientations::PortraitFlipped;
 m_d3dRenderTargetSize.Width = swapDimensions ?
windowHeight : windowWidth;
 m_d3dRenderTargetSize.Height = swapDimensions ?
 windowWidth : windowHeight;
 if ((m_swapChainCoreWindow != nullptr) &&
 ((m_swapChainComposition != nullptr) || !m_panel))
 {
  HRESULT hr = S_OK;
  if (m_swapChainComposition != nullptr)
  {
   // If the swap chain already exists, resize it.
   hr = m_swapChainComposition->ResizeBuffers(
    2, // Double-buffered swap chain.
    static_cast<UINT>(m_d3dRenderTargetSize.Width),
    static_cast<UINT>(m_d3dRenderTargetSize.Height),
    DXGI_FORMAT_B8G8R8A8_UNORM,
    0
    );
  }
  // If the swap chain already exists, resize it.
  hr = m_swapChainCoreWindow->ResizeBuffers(
   2, // Double-buffered swap chain.
   static_cast<UINT>(m_d3dRenderTargetSize.Width),
   static_cast<UINT>(m_d3dRenderTargetSize.Height),
   DXGI_FORMAT_B8G8R8A8_UNORM,
   0
   );
  if (hr == DXGI_ERROR_DEVICE_REMOVED)
  {
   HandleDeviceLost();
   return;
  }
  else
  {
   DX::ThrowIfFailed(hr);
  }
 }
 else
 {
  // Otherwise, create a new one using the same adapter as the
existing Direct3D device.
  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
    )
   );
  DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
  swapChainDesc.Width = static_cast<UINT>
(m_d3dRenderTargetSize.Width); // Match the size of the window.
  swapChainDesc.Height = static_cast<UINT>
(m_d3dRenderTargetSize.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;
  swapChainDesc.BufferCount = 2; // Use double-buffering to
minimize latency.
  swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_
FLIP_SEQUENTIAL; // All Windows Store apps must
use this SwapEffect.
  swapChainDesc.Flags = 0;

  if (m_panel)
  {
   // The following two values are important for
Direct3D to interoperate with XAML.
   swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
   swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
   DX::ThrowIfFailed(
    dxgiFactory->CreateSwapChainForComposition(
     m_d3dDevice.Get(),
     &swapChainDesc,
     nullptr, // Allow on all displays.
     &m_swapChainComposition
     )
    );
   // Associate the new swap chain with the
SwapChainBackgroundPanel element.
   ComPtr<ISwapChainBackgroundPanelNative> panelNative;
   DX::ThrowIfFailed(
    reinterpret_cast<IUnknown*>(m_panel)->QueryInterface(IID_
PPV_ARGS(&panelNative))
    );

   DX::ThrowIfFailed(
    panelNative->SetSwapChain(m_swapChainComposition.Get())
    );
  }
  if (m_swapChainCoreWindow == nullptr)
  {
   // Also bind to the CoreWindow object. No scaling.
   swapChainDesc.Scaling = DXGI_SCALING_NONE;
   swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
   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_swapChainCoreWindow
     )
    );
  }
  // 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_displayOrientation)
 {
 case DisplayOrientations::Landscape:
  rotation = DXGI_MODE_ROTATION_IDENTITY;
  m_displayOrientationTransform3D = 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_displayOrientationTransform3D = 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_displayOrientationTransform3D = 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_displayOrientationTransform3D = 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 (m_panel != nullptr)
 {
  DX::ThrowIfFailed(
   m_swapChainComposition->SetRotation(rotation)
   );
  // Create a Direct3D render target view of the swap chain back buffer.
  ComPtr<ID3D11Texture2D> backBuffer1;
  DX::ThrowIfFailed(
   m_swapChainComposition->GetBuffer(0, IID_PPV_
ARGS(&backBuffer1))
   );
  DX::ThrowIfFailed(
   m_d3dDevice->CreateRenderTargetView(
    backBuffer1.Get(),
    nullptr,
    &m_d3dRenderTargetViewComp
    )
   );

  DX::ThrowIfFailed(
   m_swapChainComposition->SetRotation(rotation)
   );
 }

 if (m_d3dRenderTargetViewWin == nullptr)
 {
  DX::ThrowIfFailed(
   m_swapChainCoreWindow->SetRotation(rotation)
   );
  // Create a Direct3D render target view of the swap chain back buffer.
  ComPtr<ID3D11Texture2D> backBuffer2;
  DX::ThrowIfFailed(
   m_swapChainCoreWindow->GetBuffer(0, IID_PPV_
ARGS(&backBuffer2))
   );
  DX::ThrowIfFailed(
   m_d3dDevice->CreateRenderTargetView(
    backBuffer2.Get(),
    nullptr,
    &m_d3dRenderTargetViewWin
    )
   );
 }
 // Create a depth stencil view for use with 3D rendering if needed.
 CD3D11_TEXTURE2D_DESC depthStencilDesc(
  DXGI_FORMAT_D24_UNORM_S8_UINT,
  static_cast<UINT>(m_d3dRenderTargetSize.Width),
  static_cast<UINT>(m_d3dRenderTargetSize.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_d3dDepthStencilView
   )
  );
 // Set the 3D rendering viewport to target the entire window.
 CD3D11_VIEWPORT viewport(
  0.0f,
  0.0f,
  m_d3dRenderTargetSize.Width,
  m_d3dRenderTargetSize.Height
  );
 m_d3dContext->RSSetViewports(1, &viewport);
 float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
 float fovAngleY = 70.0f * XM_PI / 180.0f;
 // Note that the m_displayOrientationTransform3D 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_displayOrientationTransform3D)
    )
   )
  );
#ifdef TEMPLATE_USING_D2D
 // Generate the2D matrix transformation for rendering overlays.
 switch (rotation)
 {
 case DXGI_MODE_ROTATION_ROTATE270:
  m_displayOrientationTransform2D =
   Matrix3x2F::Rotation(270.0f) *
   Matrix3x2F::Translation(0.0f, m_windowBounds.Width);
  break;
 case DXGI_MODE_ROTATION_ROTATE180:
  m_displayOrientationTransform2D =
   Matrix3x2F::Rotation(180.0f) *
   Matrix3x2F::Translation(m_windowBounds.Width,
 m_windowBounds.Height);
  break;
 case DXGI_MODE_ROTATION_ROTATE90:
  m_displayOrientationTransform2D =
   Matrix3x2F::Rotation(90.0f) *
   Matrix3x2F::Translation(m_windowBounds.Height, 0.0f);
  break;

 case DXGI_MODE_ROTATION_IDENTITY:
 default:
  m_displayOrientationTransform2D = Matrix3x2F::Identity();
  break;
 }
 // Create a Direct2D target bitmap associated with the
 // swap chain back buffer and set it as the current target.
 D2D1_BITMAP_PROPERTIES1 bitmapProperties =
  BitmapProperties1(
   D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_
OPTIONS_CANNOT_DRAW,
   PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
   m_dpi,
   m_dpi
   );
 if (m_swapChainComposition != nullptr)
 {
  ComPtr<IDXGISurface> dxgiBackBuffer;
  DX::ThrowIfFailed(
   m_swapChainComposition->GetBuffer(0, IID_PPV_
ARGS(&dxgiBackBuffer))
   );
  DX::ThrowIfFailed(
   m_d2dContext->CreateBitmapFromDxgiSurface(
    dxgiBackBuffer.Get(),
    &bitmapProperties,
    &m_d2dTargetBitmapComposition
    )
   );
 }
 if (m_swapChainCoreWindow != nullptr)
 {
  ComPtr<IDXGISurface> dxgiBackBuffer;
  DX::ThrowIfFailed(
   m_swapChainCoreWindow->GetBuffer(0, IID_PPV_
ARGS(&dxgiBackBuffer))
   );
  DX::ThrowIfFailed(
   m_d2dContext->CreateBitmapFromDxgiSurface(
    dxgiBackBuffer.Get(),
    &bitmapProperties,
    &m_d2dTargetBitmapCoreWindow
    )
   );
 }
 m_hud.Initialize(
  m_d2dDevice.Get(),
  m_d2dContext.Get(),
  m_dwriteFactory.Get(),
  m_displayOrientationTransform2D,
  m_windowBounds,
  "Direct3D with D2D/CoreWindow",
  m_projectDir + "Assets\\sdklogo.png"
  );
 m_pause.Initialize(
  m_d2dDevice.Get(),
  m_d2dContext.Get(),
  m_dwriteFactory.Get(),
  m_displayOrientationTransform2D,
  m_windowBounds,
  "PAUSED"
  );
#endif
}
void RenderObject::Update(
 _In_ uint64 tickDelta,
 _In_ float timeDelta,
 _In_ float leftover,
 _In_ float lastFrameTime)
{
 m_fpsCounter.Update(timeDelta);
 // Eye is at (0,0.7,1.5), looking at point (0,-0.1,0) with the
up-vector along the y-axis.
 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);
 m_ticks += tickDelta;
 float animTicks = m_ticks + leftover;
 // ((convert degrees to radians) convert seconds to ticks)
 float radiansPerTick = XMConvertToRadians(safe_cast<float>
(m_degreesPerSecond)) / TICKS_PER_SECOND;
 float animRadians = animTicks * radiansPerTick;
 // Prepare to pass the view matrix, and updated model matrix,
 to the shader
 XMStoreFloat4x4(&m_constantBufferData.view,
XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
 XMStoreFloat4x4(&m_constantBufferData.model,
XMMatrixTranspose(XMMatrixRotationY(animRadians)));
#ifdef TEMPLATE_USING_D2D
 Platform::String^ fps = " - ";
 Platform::String^ frameTime = " - ";
 if (m_fpsCounter.Ready())
 {
  // The frame time-to-render data is a float, so we need to truncate
 it to something readable
  frameTime = ref new Platform::String(lastFrameTime.
ToString()->Begin(), 5);
  fps = (m_fpsCounter.FPS()).ToString();
 }
 m_hud.Update("Frame time:\n" + frameTime + " ms",
 fps + " FPS");
#endif
}
void RenderObject::Render()
{
 // Choose the swap chain for the current view
 ComPtr<ID3D11RenderTargetView> d3dRenderTargetView;
 if (m_usePanel) d3dRenderTargetView = m_d3dRenderTargetViewComp;
 else d3dRenderTargetView = m_d3dRenderTargetViewWin;
 // Clear the render target
 XMVECTORF32 midnightBlue = DirectX::Colors::MidnightBlue;
 m_d3dContext->ClearRenderTargetView(
  d3dRenderTargetView.Get(),
  midnightBlue
  );
 m_d3dContext->ClearDepthStencilView(
  m_d3dDepthStencilView.Get(),
  D3D11_CLEAR_DEPTH,
  1.0f,
  0
  );
 // Loading is asynchronous. Only draw geometry afeter it's loaded.
 if (!m_loadingComplete)
 {
  return;
 }
 // Set the render target for the draw operation.
 m_d3dContext->OMSetRenderTargets(
  1,
  d3dRenderTargetView.GetAddressOf(),
  m_d3dDepthStencilView.Get()
  );
 // Only update shader resources that have changed since the last frame.
 m_d3dContext->UpdateSubresource(
  m_constantBuffer.Get(),
  0,
  NULL,
  &m_constantBufferData,
  0,
  0
  );
 // Set up the IA stage corresponding to the current draw operation.
 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());
 // Set up the vertex shader corresponding to the current draw operation.
 m_d3dContext->VSSetShader(
  m_vertexShader.Get(),
  nullptr,
  0
  );
 m_d3dContext->VSSetConstantBuffers(
  0,
  1,
  m_constantBuffer.GetAddressOf()
  );
 // Set up the pixel shader corresponding to the current draw operation.
 m_d3dContext->PSSetShader(
  m_pixelShader.Get(),
  nullptr,
  0
  );
 m_d3dContext->DrawIndexed(
  m_indexCount,
  0,
  0
  );
}
#ifdef TEMPLATE_USING_D2D
void RenderObject::RenderHud(bool paused)
{
 // Choose the swap chain for the current view.
 if (m_usePanel) m_d2dContext->
SetTarget(m_d2dTargetBitmapComposition.Get());
 else   m_d2dContext->
SetTarget(m_d2dTargetBitmapCoreWindow.Get());

 // Grayscale text anti-aliasing is recommended for
 all Windows Store apps.
 m_d2dContext->
SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_
MODE_GRAYSCALE);

 // Render the correct overlay content.
 if (paused) m_pause.Render();
 else  m_hud.Render();
}
#endif
// Initialize the Direct3D resources required to run.
void RenderObject::Initialize( _In_ CoreWindow^ window )
{
 Initialize(window, nullptr);
}
// Initialize the Direct3D resources required to run.
void RenderObject::Initialize(
 _In_ CoreWindow^ window,
 _In_ SwapChainBackgroundPanel^ panel
 )
{
 m_window = window;
 if (panel != nullptr)
 {
  m_panel = panel;
  m_usePanel = true;
 }

 CreateDeviceIndependentResources();
 CreateDeviceResources();
 CreateWindowSizeDependentResources();
 SetDpi(DisplayProperties::LogicalDpi);
}
void RenderObject::SetPanel( _In_
SwapChainBackgroundPanel^ panel )
{
 m_panel = panel;
}
void RenderObject::SwitchToCoreWindow()
{
 m_usePanel = false;

 // Draw a frame on the CoreWindow so that the user doesn't notice the switch.
 Render();
 Present();
}
// Immediately switches to the SCBP swap chain and renders the current frame on it.
void RenderObject::SwitchToSCBP()
{
 if (m_panel == nullptr) return;
 m_usePanel = true;

 if (m_swapChainComposition == nullptr)
 {
  CreateWindowSizeDependentResources();
 }
 // Draw a frame on the SCBP so that the user doesn't notice the switch.
 Render();
 Present();
}
// Recreate all device resources and set them back to the current state.
void RenderObject::HandleDeviceLost()
{
    // Reset these member variables to ensure that
UpdateForWindowSizeChange recreates all resources.
    float dpi = m_dpi;
    m_dpi = -1.0f;
    m_windowBounds.Width = 0;
    m_windowBounds.Height = 0;
      
    DiscardViews();
    m_swapChainComposition = nullptr;
    m_swapChainCoreWindow = nullptr;
    m_d3dDevice = nullptr;
    m_d3dContext = nullptr;
 m_loadingComplete = false;
    CreateDeviceResources();
    SetDpi(dpi);
    UpdateForWindowSizeChange();
}
// Discard view resources. This is done before resizing the
window and before recreating the Direct3D device.
void RenderObject::DiscardViews()
{
    ID3D11RenderTargetView* nullViews[] = {nullptr};
    m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews),
nullViews, nullptr);
    m_d3dRenderTargetViewComp = nullptr;
    m_d3dRenderTargetViewWin = nullptr;
    m_d3dDepthStencilView = nullptr;

#ifdef TEMPLATE_USING_D2D
    m_d2dContext->SetTarget(nullptr);
    m_d2dTargetBitmapCoreWindow = nullptr;
    m_d2dTargetBitmapComposition = nullptr;
#endif
    m_d3dContext->Flush();
}

// This method is called in the event handler for the
LogicalDpiChanged event.
void RenderObject::SetDpi(float dpi)
{
 if (dpi != m_dpi)
 {
  // Save the updated DPI value.
  m_dpi = dpi;
#ifdef TEMPLATE_USING_D2D
  // Update Direct2D's stored DPI.
  m_d2dContext->SetDpi(m_dpi, m_dpi);
#endif
  // Often a DPI change implies a window size change.
In some cases Windows will issue
  // both a size changed event and a DPI changed event.
In this case, the resulting bounds
  // will not change, and the window resize code will only
 be executed once.
  UpdateForWindowSizeChange();
 }
}
// This method is called in the event handler for the SizeChanged event.
void RenderObject::UpdateForWindowSizeChange()
{
 // Only handle window size changed if there is no pending DPI change.
 if (m_dpi != DisplayProperties::LogicalDpi)
 {
  return;
 }
 if (m_window->Bounds.Width  != m_windowBounds.Width ||
  m_window->Bounds.Height != m_windowBounds.Height ||
  m_displayOrientation != DisplayProperties::CurrentOrientation)
 {
  DiscardViews();
  CreateWindowSizeDependentResources();
 }
}
// Method to deliver the final image to the display.
void RenderObject::Present()
{
 // The application may optionally specify "dirty" or "scroll"
 // rects to improve efficiency in certain scenarios.
 DXGI_PRESENT_PARAMETERS parameters = {0};

 // 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.
 HRESULT hr;
 if (m_usePanel)
 {
  hr = m_swapChainComposition->Present1(1, 0, &parameters);

  // 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_d3dRenderTargetViewComp.Get());
 }
 else
 {
  hr = m_swapChainCoreWindow->Present1(1, 0, &parameters);
  m_d3dContext->DiscardView(m_d3dRenderTargetViewWin.Get());
 }
 // Discard the contents of the depth stencil.
 m_d3dContext->DiscardView(m_d3dDepthStencilView.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 RenderObject::ConvertDipsToPixels( _In_ float dips )
{
 static const float dipsPerInch = 96.0f;
 return floorf(dips * DisplayProperties::LogicalDpi / dipsPerInch +
0.5f); // Round to nearest integer.
}                                                                                                          **

***SimpleDirect3DApps*))
***#include "pch.h"
#include "Common_DirectX\DirectXHelper.h"
#include "$safeprojectname$.h"
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::UI::ApplicationSettings;
using namespace Windows::UI::Core;
using namespace Windows::Foundation;
using namespace Microsoft::WRL;
using namespace DirectX;
// The main function is only used to initialize our IFrameworkView class.
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
 auto direct3DApplicationSource = ref new Direct3DApplicationSource();
 CoreApplication::Run(direct3DApplicationSource);
 return 0;
}
IFrameworkView^ Direct3DApplicationSource::CreateView()
{
    return ref new $safeprojectname$();
}
$safeprojectname$::$safeprojectname$() :
 m_visible(true),
 m_paused(true)
{
}
// The first method called when the IFrameworkView is being created.
void $safeprojectname$::Initialize(CoreApplicationView^ applicationView)
{
 // Register event handlers for app lifecycle. This example includes
Activated, so that we
 // can make the CoreWindow active and start rendering the cube.
 applicationView->Activated +=
        ref new TypedEventHandler<CoreApplicationView^,
IActivatedEventArgs^>(
  [this](Windows::ApplicationModel::Core::CoreApplicationView^
applicationView, Windows::ApplicationModel::
Activation::IActivatedEventArgs^ args)
  {
   // Run() won't start until the CoreWindow is activated.
   CoreWindow::GetForCurrentThread()->Activate();
  });
}
void $safeprojectname$::Load(Platform::String^ entryPoint)
{
}
// Called when the CoreWindow object is created (or re-created).
void $safeprojectname$::SetWindow(CoreWindow^ window)
{
 // Register event handlers with the CoreWindow object.
 window->SizeChanged +=
        ref new TypedEventHandler<CoreWindow^,
WindowSizeChangedEventArgs^>(
  [this](Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args)
  {
   // Notify the rendering controller to set up new swap chains (and so on).
   m_renderer.UpdateForWindowSizeChange();
  });
 window->VisibilityChanged +=
  ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(
  [this](CoreWindow^ sender, VisibilityChangedEventArgs^ args)
  {
   m_paused = !sender->Visible;
   m_visible = sender->Visible;
  });
 // Add an event handler to pause when the charms bar is activated.
 CoreWindow::GetForCurrentThread()->Activated +=
  ref new TypedEventHandler<CoreWindow^, WindowActivatedEventArgs^>(
  [this] (CoreWindow^ sender, Windows::UI::Core::WindowActivatedEventArgs^ args)
  {
   switch (args->WindowActivationState)
   {
   case Windows::UI::Core::CoreWindowActivation
State::Deactivated:
    m_paused = true;
    break;
  
   case CoreWindowActivationState::CodeActivated:
   case CoreWindowActivationState::PointerActivated:
    m_paused = false;
    break;
   }
  });
 // Add event handlers to recognize input.
 window->KeyDown += ref new TypedEventHandler
<CoreWindow^, KeyEventArgs^>(
  [this](CoreWindow^ sender, KeyEventArgs^ args)
  {
   switch (args->VirtualKey)
   {
   case Windows::System::VirtualKey::Escape:
    // For example, pause when the escape key is pressed.
    m_paused = !m_paused;
    break;
   default:
    m_paused = false;
    break;
   }
  });
 window->PointerPressed += ref new TypedEventHandler
<CoreWindow^, PointerEventArgs^>(
  [this](CoreWindow^ sender, PointerEventArgs^ args)
  {
   m_paused = false;
  });

 // If your app has internet-based functionality, uncomment the following
 // code to add a Settings charm for the privacy policy.
    /*
 SettingsPane::GetForCurrentView()->CommandsRequested +=
    ref new TypedEventHandler<SettingsPane^,
SettingsPaneCommandsRequestedEventArgs^>(
        [this](SettingsPane^ sender,
SettingsPaneCommandsRequestedEventArgs^ args)
        {
            args->Request->ApplicationCommands->Append(
                ref new SettingsCommand(
                        "privacyPolicy",
                        "Privacy Policy",
                        ref new Windows::UI::Popups::
UICommandInvokedHandler([=](Windows::UI::
Popups::IUICommand^ command)
                        {
                                // The URI to launch
                                // Be sure to replace this string with the URL
 to your privacy policy.
                                auto uri = ref new Windows::Foundation::
Uri("<insert web url to your privacy policy here>");
                                // Launch the URI
                                concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
                                launchUriOperation.then([](bool success){});
                        })));
        });
 */
 // If your app has an app bar, uncomment the following code
 to recognize
 // the app bar gesture.
 // If your DirectX app needs to use an app bar, you can create one by
 // drawing it on the screen, recognizing input, and adding appropriate
 // animations for showing/hiding the app bar.
 /*
 auto edgeGestures = Windows::UI::Input::Edge
Gesture::GetForCurrentView();
 edgeGestures->Completed += ref new TypedEventHandler
<Windows::UI::Input::EdgeGesture^, Windows::UI::Input::Edge
GestureEventArgs^>(
  [this](Windows::UI::Input::EdgeGesture^ gesture,
Windows::UI::Input::EdgeGestureEventArgs^ args)
  {
   // TODO: Add code here to raise your app bar implementation.
  });
 */
 // Set up rendering using Direct3D 11.1.
 m_renderer.Initialize(window);
 // Set initial conditions for animation.
 m_renderer.Update(0, 0, 0.f, 0.f);
}
// This method is called after the window becomes active.
void $safeprojectname$::Run()
{
 // Windows Store apps should not exit. App lifecycle events
 are used instead.
 while (true)
 {
  if (m_visible)
  {
   // Update the timer.
   m_timer.Update();
   if (!m_paused)
   {
    // Update the renderer if the animation isn't paused
    m_renderer.Update(m_timer.TickDelta(), m_timer.TimeDelta(),
 m_timer.LeftoverTime(), m_lastFrameTime);
   }
   // Process window events.
   CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
 
   // Render the frame.
   m_renderer.Render();
   // Measure how long the frame took to render before drawing the
 HUD and presenting the frame.
   m_lastFrameTime = m_timer.MeasureFrameTime();
   // Render the overlay.
   m_renderer.RenderHud(m_paused);
   // Swap the back buffer to the screen, and wait the app's
main thread until the next VSync.
   m_renderer.Present();
  }
  else
  {
   CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
  }
 }
}
// Required for IFrameworkView.
// Terminate events do not cause Uninitialize to be called.
It will be called if your IFrameworkView
// class is torn down while the app is in the foreground.
void $safeprojectname$::Uninitialize()
{
}                                                                                       ***

***SimpleDirect3DApp.vcxproj.filters***
***<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Filter Include="Common_DirectX">
      <UniqueIdentifier>$guid2$</UniqueIdentifier>
    </Filter>
    <Filter Include="Assets">
      <UniqueIdentifier>$guid3$</UniqueIdentifier>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="Common_DirectX\DirectXHelper.h">
      <Filter>Common_DirectX</Filter>
    </ClInclude>
    <ClInclude Include="Common_DirectX\FpsCounter.h">
      <Filter>Common_DirectX</Filter>
    </ClInclude>
    <ClInclude Include="Common_DirectX\StepTimer.h">
      <Filter>Common_DirectX</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Image Include="Assets\Logo.png">
      <Filter>Assets</Filter>
    </Image>
    <Image Include="Assets\SmallLogo.png">
      <Filter>Assets</Filter>
    </Image>
    <Image Include="Assets\StoreLogo.png">
      <Filter>Assets</Filter>
    </Image>
    <Image Include="Assets\SplashScreen.png">
      <Filter>Assets</Filter>
    </Image>
    <Image Include="Assets\sdklogo.png">
      <Filter>Assets</Filter>
    </Image>
  </ItemGroup>
</Project>                                                                    ***

***SimpleDirect3DApp***
***#pragma once
#include "Common_DirectX\\StepTimer.h"
#include "RenderObject.h"
[Windows::Foundation::Metadata::WebHostHiddenAttribute]
ref class $safeprojectname$ sealed : public Windows::
ApplicationModel::Core::IFrameworkView
{
public:
 $safeprojectname$();

 // 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();
private:
 RenderObject m_renderer; // The rendering class.
 StepTimer  m_timer; // Rendering loop timer.
 bool m_windowClosed;
 bool m_paused;
 bool m_visible;
 float m_lastFrameTime;
};
[Windows::Foundation::Metadata::WebHostHiddenAttribute]
ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
 virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};                                                                                          ***

***SimplePixelShader.hlsl***
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
struct PixelShaderInput
{
 float4 pos : SV_POSITION;
 float3 color : COLOR0;
};
// A pass-through for the (blended) color data.
float4 main(PixelShaderInput input) : SV_TARGET
{
    return float4(input.color,1.0f);
}
  ****
**<PackageManifest Version="2.0.0" xmlns=
"http://schemas.microsoft.com/developer/vsx-schema/2011">
  <Metadata>
    <Identity Id="GDC2013GameTemplates..
282844d1-1219-4d9b-a990-8ed263e3159d" Version=
"1.01" Language="en-US" Publisher="Microsoft Windows SDK" />
    <DisplayName>GDC 2013 Game Templates</DisplayName>
    <Description xml:space="preserve">Create realtime,
graphics-intensive Windows Store games using DirectX and
native code.</Description>
    <License>ms-lpl-1.1.rtf</License>
    <GettingStartedGuide>http://go.microsoft.com/fwlink/?prd=
11966</GettingStartedGuide>
    <Icon>game_template.ico</Icon>
    <PreviewImage>GDC2013GameTemplates.png</PreviewImage>
    <Tags>Direct3D, Direct2D, DirectX, XAML, Windows Store,
app, game, template, graphics</Tags>
  </Metadata>
  <Installation>
    <InstallationTarget Version="[11.0,12.0)" Id=
"Microsoft.VisualStudio.Premium" />
    <InstallationTarget Version="[11.0,12.0)" Id=
"Microsoft.VisualStudio.Pro" />
    <InstallationTarget Version="[11.0,12.0)" Id=
"Microsoft.VisualStudio.VSWinExpress" />
    <InstallationTarget Version="[11.0,12.0)" Id=
"Microsoft.VisualStudio.Ultimate" />
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Windows.DevelopmentKit.Metro"
DisplayName="Microsoft Windows 8.0 Metro style app SDK"
Version="[8.0,9.0)" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path=
"ProjectTemplates" />
  </Assets>
</PackageManifest>                                                                                 ****
<?xml version="1.0" encoding="utf-8" ?>
- <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  <Default Extension="vsixmanifest" ContentType="text/xml" />
  <Default Extension="png" ContentType="application/octet-stream" />
  <Default Extension="ico" ContentType="application/octet-stream" />
  <Default Extension="rtf" ContentType="text/richtext" />
  <Default Extension="zip" ContentType="application/zip" />
  </Types>
***                                                                                                               *******

**

GDC 2013 Windows Developer

Content Direct3D Game Templates




Direct3D

Graphics, Graphics and 3D

Windows RT


en-US

3/25/2013

Introduction


The Windows Developer Content GDC 2013 Direct3D game templates are a set of Visual Studio 2012 templates for Windows Store Direct3D apps. The GDC 2013 versions of the content incorporate code from these templates in the coding examples.

The ZIP file includes a single VSIX with three templates:
  • DirectX game (CoreWindow). This template constructs a basic CoreWindow view provider with a game-development friendly layout that demonstrates DirectX 11.1 and C++ coding best practices for Windows Store apps.
  • DirectX game (XAML). This template uses the XAML framework with  SwapChainBackgroundPanel to display Direct3D 11.1 rendering output. It demonstrates DirectX 11.1 and C++ coding best practices for Windows Store apps with XAML.
  • DirectX game (XAML and CoreWindow). This template creates two swap chains – one with a CoreWindow view provider and the other with the XAML framework and SwapChainBackgroundPanel – and allows you to dynamically switch between the two based on game state or user input.

The following GDC 2013 documentation incorporates these samples:
    
Prepare your Windows Store DirectX game programming environment 
Port from DirectX 9 to Windows Store 
Port from OpenGL ES 2.0 to Direct3D 11.1 

Using the templates


To use these templates, download the ZIP file and open it. Extract the file GDC2013GameTemplates.vsix and double-click on it. This will install the templates. If Visual Studio 2012 was open when you ran the VSIX installer, close it and re-open it. When you go to FILE->New Project, the three templates will appear under the Visual C++ project node. 
NOTE   The VSIX installer must be extracted from the archive before installation. The SLN and VCXPROJ files exist only to meet validation requirements and can be ignored.


Source Code Files

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    *於*11-06*最新蘋果發佈-i*--iOS 7 Beta2*-&-全系列非BT下載 + ))**iOS 7 beta 1所有版本下載及勒體下載 (之)--{锋友iPad mini初体验 }~*+&+*{iPhone! }>>《Springtomize 2 - iOS 5+****简繁汉化版 )**系统调整專家~~^^~^^


    ***於*11-06*最新蘋果發佈-i*news--iOS 7 Beta2*-&-
    全系列非BT下載 +))**iOS 7 beta 1所有版本
    下載及勒體下載 (之)--{锋友iPad mini初体验 }~*+
    &+*{ iPhone! }>>《Springtomize 2 - iOS 5+ ****
     简繁汉化版 )**系统调整專家~~^^

    **果发布了 iOS 7 第二个测试版,满足了许多苦等--
    --新版本的用户朋友。而且更可喜的是,第二个测试版终于添加对--
     {{ iPad 2、iPad 3/ 4 以及 iPad mini }}的支持了!虽然只是测试版本,
    目前威锋网中已经有不少用户迫不及待地刷了 iOS 7 来尝尝鲜了**~~!!

    ````以下為文章全文:
    *******

    今天凌晨蘋果發布了iOS 7 第二個測試版,滿足了許多苦等--
    --新版本的用戶朋友。而且更可喜的是,第二個測試版終於--
    --添加對iPad 2、iPad 3/ 4 以及iPad mini的支持了!雖然只是--
    --測試版本,目前威鋒網論壇中已經有不少用戶迫不及待地>>>
    刷了iOS 7 來嚐嚐鮮了,當然也有一些持機觀望的鋒友。
    接下來我們不妨來看看刷了iOS 7 Beta 2 的--
    --iPad mini 鋒友用戶有什麼體驗:不少鋒友對於iOS 7 的整體設計還是挺滿意的,當然這是見仁智見智
    的事情。你如果還沒有刷iOS 7 的話也可以從以下鋒友分享的照片來
    了解iOS 7 在iPad mini 上的整體印象。鋒友zYYYYY16 表示,iPad mini 運行iOS 7 Beta 2 是有輕微的卡頓,
    沒有iOS 6 流暢(部分鋒友也發現了卡頓的問題,鋒友給出的建議是--
    --恢復全部設置可以解決卡頓問題)。不過可喜的是應用程序打開的--
    --速度提高了,清除已用程序也更快了`^^~!!

    ^^`
    ````



























    )))

    )**另外有锋友发现,安装 iOS 7 Beta 2 之后,iPad mini 拍照有--
    -- HDR 效果了。这个新特性,我们今早也已经介绍过(查看),
    不知道你是否发现了呢?使用起来感觉怎样呢?

     ***锋友UUU分享的 
    iOS 7 iPad mini 上的设置面板以及App Store界面
    ^^
    ^~iOS 7 Beta2之锋友iPad mini初体验~~
    *****
    **和我们共享的 iOS 7 在 iPad mini 上的整体效果,不知道你觉得--
    --这个整体效果如何呢?man22YY 的评价是很简洁,很漂亮 *^^
    )))~
    ***~~
    ^^^!!!
    ^^iPhone 5 用户中也有不少人已经升级到 iOS7Beta 2
    与 Beta 1 相比,流畅度以及耗电问题都有了大幅度的提高。
    可惜目前在论坛中,还没有 iPad mini 用户反映设备运行 iOS 7 之后,
    设备电池续航有怎样的变化。如果你的设备已经升级到 iOS 7Beta 2
    发现有什么新的变化或者问题也不妨和我们共享吧!!!^^
    ))这里我们要提醒大家的是,目前苹果发布的只是测试版本,
    目的就是要进行调适,所以在使用过程中会遇到各种问题也是--
    --难以避免的。苹果需要更多时间来完善,相信在 iOS 7 正式!!!!
    发布时我们会看到一个更优秀的系统 )`!!!

    `````````````````````````````````````````````````````````````````````````````````````````
    ```刚刚刷的IOS7 Beta,先来几张系统应用的界面
    ``````````
    ``````
    ````
    ))))))~~
    ))IOS 7 BETA2  全系列地址….非 BT ^))
    ))^weiphone的悲哀…..想找个下載翻半天没個是真正可用的…
    自己F^1ang出去找到了...给大家发福利…haha...
         http://gdeluxe.com/ios-7-download/   
    ~!!!

    ***華麗的 iOS 7 Beta *下載測試 ***新功能還蠻多的***!!!!!
    ))關注 WWDC 2013 大會中 APPLE 究竟會端出什麼樣的菜,在這次
    大會中端出的主菜相當的多,而其中在大會之後很多人對於這次
    華麗的 iOS 7 介面相當的有興趣,當然很快的就有人祭出
    刷成 iOS 7 Beta 版本的方式)))
    ^^將手上的 iPhone 5 刷成 iOS 7 beta,新的介面真的蠻華麗的,
    有部份新的功能也變的更好用,順手也錄製了一小段操作畫面,
    也讓各位看倌看看^^^
    ^)00))
    ````iOS 7 Beta 版 ipsw 下載: 
    File-40 File-41
    ```

    目前支援以下裝置,請至「這裡」選擇對應的裝置下載
    • iPhone 5 (Model A1429) - 台灣用戶請選這個
    • iPhone 5 (Model A1428)
    • iPhone 4S
    • iPhone 4 (GSM)
    • iPhone 4 (GSM Rev A)
    • iPhone 4 (CDMA)
    • iPod touch 5th Gen

    iOS 7 Beta 版測試注意事項:

    • 由於是 beta 版,而且是最初版,通常 bug 會很多,
    • 有可能會影響日常使用,如果你沒有十足的把握自己很
    • 懂的復原的話,不太建議,或者可以拿別隻手機不常用的來試玩。
    • 可能會有部份 APP 產生不相容問題。
    • 上面提供的 ipsw 檔案都是經過處理,所以不需要開發者帳號
    • 不適用已 JB 機種,請還原後再進行安裝

    iOS 7 Beta 刷機步驟:

    下載時會得到 dmg 檔案,建議可以用 7-zip 解壓縮,可能解了
    之後還是沒看到 ipsw 檔案,只要再找到 hfs 檔案,再解一次
    應該就會看到 ipsw 檔案。
    .......
    01```
    `刷機`教...**^住下看.......*^
    ``如何將 iOS 的 DMG 檔轉為 iPSW 格式````)
    ^
    然後開啟 itunes,連接你的設備,按住 Shift 鍵點擊
    「檢查更新項目」,再選擇剛剛解壓縮出來的 ipsw 檔案。
    註:請將 itunes 升級至最新版本,刷 iOS 7 beta 之前,
    建議可以使用「itools」先進行備份為佳。
    02
    然後就問你要不要進行更新,按下去吧,等待進度條跑完即可。
    03
    如果玩不下去了,想要還原回去的話,可以直接用 iTunes 點擊
    「回復 iPhone」即可。

    iOS 7 介紹:

    基本上大部份的新功能都可以在整理的 WWDC
    至於介面效果及操作,原則上需要 iPhone 5 以上較為順暢^*

    iOS 7 beta 1

    iOS 6.1 正式版

    iOS 6.0 正式版

    iOS 6 Golden Master

    iOS 6 beta 4

    iOS 6 beta 3

    iOS 6 beta 2(BT載點)

    iOS 6 beta 1(BT載點)

    iOS 5.1.1

     iOS 5.1

    iOS 5.0.1

    iOS 5.0

     iOS 4.3.5

    iOS 4.3.3

    ^^刷機````
    ISO的來源非常多,因此下載到的格式可能是 DMG 或者 iPSW 
    (最近釋出的iOS 7就有此情況,),不過在 Windows 的 iTunes 
    上進行 iOS 更新或回復必須使用 iPSW 檔才行,因此如果下載
    到 DMG 格式必須先轉為 iPSW 格式(事實上是提取檔案),
    這篇文章要告訴你如何用 UltraISO 進行這個操作。
    UltraISO 是一款光碟映像檔編輯軟體,可以將光碟或資料夾
    製作成ISO映像檔,也可以直接編輯及提取映像檔內的檔案,
    我們用到的就是其中檔案提取的功能。

    從 DMG 提取 iPSW 教學

    Step 1
    執行 UltraISO 後,點選「開啟舊檔」
    ultraiso-01
    Step 2
    選擇 DMG 檔案後按【Open】。
    ultraiso-02
    Step 3
    UltraISO 打開 DMG 檔後,檔案清單裡面就會看到 iPSW 檔。
    這時候在 iPSW 檔上按滑鼠右鍵,選擇「提取到」就可以把 iPSW
    檔提取到想要儲存的地方。
    ultraiso-03
    軟體名稱:UltraISO
    適用系統:Windows XP/ Vista / 7 / 8
    軟體下載:下載 UltraISO``````!!!!!!
    ***關於 iOS 7,超過40個 WWDC
    告訴你的細節更新***~~~
    ~~

    iOS 系統功能

    Spotlight 呼叫方式改變
    File-30
    ▲ 在主畫面任意位置(除了最上方)
    單指往下動
    就會出現 Spotlight 搜尋。
    訊號強度顯示方式改變
    File-31
    ▲ 手機用了數十年的訊號強度顯示方式在 iOS 7 變成
    五個燈(編按:抄襲五燈獎!)
    icon 資料夾容量擴增至無上限
    File-25
    ▲ 資料夾跟主畫面一樣可以左右滑動,單頁顯示9個 App icon,
    放置數量無上限。
    書報攤可放進資料夾收納
    File-33
    ▲ 以前要用密技才能把書報攤收起來,iOS 7 的書報攤跟
    一般 App 一樣可以收進資料夾。
    多工畫面支援多點觸控,可一次關閉3個 App
    File-34
    ▲ 畫面最多只能顯示三個 App 畫面,
    可以同時往上刷來關掉 App。
    輸入引號、括號等對稱符號時,輸入一半自動完整帶出
    File-18

    ▲ 自動輸入完整符號,
    還會把游標移
    到符號中間方便輸入。

    設定頁面選項

    設定頁面往右滑動可回到上一頁
    File-38
    ▲ 從螢幕左邊往右刷就可以直接返回上一頁。
    支援動態背景
    File-17
    ▲ 動態背景雖然酷,但卻是耗電的開端。
    藍芽可提高定位精準度
    File-36
    ▲ 難道是支援室內定位嗎?
    新增背景應用程式自動重新整理開關
    File-37
    ▲ 有些 App 會在背景持續更新,如此一來會增加電力的消耗,
    如果覺得該 App 不需要持續更新的話可以從這裡將它關閉持續更新,
    或者全面禁止所有 App 背景更新。
    新增控制中心於鎖定畫面顯示的開關
    File-26
    ▲ 控制中心可以直接把手機網路關閉或進入飛航模式,基於安全性
    考量可以將它關閉,不過就少了一些便利的功能。
    麥克風列入隱私項目
    File-39
    ▲ 有錄影、拍照功能的 App 必須要同意兩個權限才能使用了,
    一切都是基於安全性考量啊!
    電話、訊息、Facetime 支援封鎖名單
    File-42
    ▲ 加入封鎖名單之後對方就無法與您聯繫。只要從通訊錄中
    封鎖聯絡人就會自動同步到上述三個功能的封鎖清單中,
    不用個別設定。
    可設定地圖偏好路線
    File-43
    ▲ 讓地圖支援步行路線規劃就從這裡設定。
    整合 Flickr、Vimeo 及騰訊微博
    File-44
    - 行動網路
    可查得 App、漫遊期間的行動網路使用量
    File-45
    ▲ 有了這個功能出國就可以查詢漫遊
    使用的流量。
    可開關指定 App 的行動網路使用權
    File-47
    ▲ 一般不會用到這個功能,
    但如果你不想讓該 App 
    使用網路的話,可以從這裡關閉。
    - Safari
    新增不要追蹤隱私項目
    File-48
    新增搜尋建議及 Preload top hit(預先轉譯) 功能
    File-49
    ▲ 搜尋建議功能會根據你輸入的關鍵字自動判斷可能的
    完整字串;Preload Top Hit 則會在你搜尋關鍵字時,
    自動預先讀取搜尋結果的第一筆資料,當點連結的瞬間網頁
    就會「秒開」(原理參考)。
    - 通知中心
    可開關鎖定畫面的通知中心
    File-50
    新增今日顯示方式
    File-51
    ▲ 今日顯示方式會在通知中心的獨立頁籤中顯示這些開啟
    的資訊,方便使用者瀏覽,不需要的功能可以關閉。
    通知橫幅高度增加
    File-27
    ▲ 加大高度可以顯示更多通知內容,不過 iPhone 5 
    以下的螢幕空間就更少了。

    iOS 7 內建程式

    - 指南針
    新增角度測量功能
    File-11 File-12
    ▲ 在主畫面上點一下螢幕後旋轉手機
    就可看到轉了多少度。
    新增水平儀功能
    File-53
    ▲ 主畫面往左滑動可切換到水平儀模式,點一下螢幕可將
    目前手機的角度校正為0,方便測量角度。
    - 天氣
    大幅介面更新,更豐富的天氣資訊
    File-28 File-29
    ▲ 新的天氣 App 不僅顯示氣候狀態,也會顯示風向、
    溫濕度、降雨機率等資料。
    背景會根據氣候狀況出現動畫
    File-54
    ▲ 台北天氣顯示為陣雨,背景就會有下雨的動畫出現。
    支援摘要式顯示多地區天氣
    File-56
    ▲ 點擊主畫面右下角的驚嘆號按鈕就可以看到所有已加入
    追蹤地區的天氣,背景也會根據天氣有所變化。
    - 時鐘
    圖示會隨時間變更
    File-58
    ▲ 時鐘圖示上的指針會跟目前時間同步轉動。
    顯示與目前所在地的時差
    File-59
    ▲ 可以清楚的看到世界各地時間與台灣(或所在地)
    的差異,跨日也能得知。
    - 相機
    音量上下鍵都可作為快門鈕
    HDR 開關設計到相機主畫面上
    File-2
    格線開關移至設定項目內
    File-13
    ▲ 相機的格線(Grid)選項在 iOS 7 上
    得到設定項目才能開啟。
    - 地圖
    地圖配色調整,強調主要道路顏色
    File-7
    ▲ 主要道路會以黃色顯示,並加大省道、
    線道、國道等道路標誌。
    縮放時顯示比例尺
    File-8
    ▲ 比例尺只有在縮放地圖時才會瞥然一現。
    路線規劃時,顯示各建議路線所需時間
    File-9
    ▲ 走哪裡比較快,直接在地圖上就可以看到
    (結果僅供參考,畢竟還沒結合交通路況,
    距離短不代表沒塞車)。
    - App Store
    新增預購清單功能
    File-24 File-35
    ▲ 看到喜歡的 App 可以先加到預購清單,
    考慮好再下手(免費、付費 App 都適用)
    排行榜改為直式顯示,取消預顯示前99名限制
    File-57
    ▲ 直式顯示不僅方便捲動,瀏覽上也比較方便。順帶一提,
    觀看 App 介紹後回到排行榜時,畫面又從第一名開始的 bug 似乎解決了。
    主動通知 App 更新並自動下載新版 App
    File-19 File-60
    ▲ App 有更新時系統會先通知你然後再自動更新,
    但有時候自動更新並非好事,可以到
    設定選項裡面把功能關閉。
    自動清除搜尋欄位上次輸入的關鍵字
    File-61
    ▲ 不用每次搜尋都要先把上次輸入的結果清除,方便多了。
    新安裝的 App icon 上不再顯示藍色「新增」絲帶
    File-62
    ▲ UP、Moves 兩個新安裝的 App 已經沒有
    顯示「新增」的藍色絲帶。
    可同時下載數個App
    File-4
    ▲ 過去都只能一次下載1個 App,現在終於可以一次
    下載多個,爽度差很多!
    - Siri
    支援開關網路及連線設定
    File-14 File-15
    ▲ 用「打開藍芽」或「打開Wi-Fi」方式
    告訴 Siri 就可以馬上幫你設定。
    - 行事曆
    可以年曆形式顯示
    File-5
    可拖曳調整記事時間及日期
    File-6
    ▲ 按住記事之後可以往上下(調整時間)
    或左右(改變日期)拖曳。
    - Safari
    可直接在網址列上輸入關鍵字進行搜尋
    File-20
    ▲ 如同電腦上的 Firefox、Chrome 一樣,
    網址列可作為搜尋框的用途。
    取消分頁數量上限
    File-21
    ▲ 想開幾個分頁就開幾個,系統不再限制數量。
    - Passbook
    新增掃描條碼功能
    File-22
    ▲ 條碼掃描功能僅能掃描 Passbook 的條碼。
    您也發現了什麼沒有提到的特色嗎?~~~~~~))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


     Sleipnir是日本人認為世界第一的瀏覽器,它是以 IE 為核心,
    並整合 NetCaptor * Opera * Netsape  三家瀏覽器的--
    --優點於一身,變成功能超強的瀏覽器!!!



     iPhone 越狱用户自定义---
     ios***的全方面**~~!!

    ^^Springtomize 2是一款十分有--
    --人气的工具,它允许iPhone越狱 --
    --用户自定义iOS的方方面面。
    他有很多細微的設定,令你設備上的每一分寸--
    --都顯得更完美,
    Springtomize 2絕對是越獄後的必備插件
    ~***!!

    **~
    1.修復與iOS5.1的兼容性問題
    2.性能改進
    新增以下設定:
    1.隱藏特定軟件的右上角紅標
    2.狀態欄上的日期
    3.更容易控制圖標的大小
    ~^





    hehe^^
    ^安裝^ http://apt.weiphone.com/tutorial/tab3.html ~~****
    ^

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&