Graphics Reference
In-Depth Information
Within the
D3DAppViewProvider.Run
function, we initialize the dots per inch (dpi) for our
device resources and enter our main application message loop, invoking the event dispatcher
with a call to
CoreDispatcher.ProcessEvents
. After processing the events, we call the
D3DAppCoreWindowTarget.Render
method. The message loop here replaces the use of
the
D3DApplicationBase.Run
method we have used in the rest of this topic, necessitating
a few structural changes to our
D3DAppCoreWindowTarget
descendants, such as creating
renderer instances within the
CreateDeviceDependentResources
method. There is one
critical difference when rendering a frame with a flip model
swapchain
—and therefore all
Windows Store apps—it is that we must set the Output Merger render targets for every frame.
There's more…
Our C# DirectX Windows Store app implementation is very similar to how you would create a
DirectX Windows Store app in C++. Visual Studio provides two C++ DirectX templates, DirectX
App and DirectX App (XAML). This recipe is a roughly equivalent C# version of the C++
DirectX App template.
The ability to compile HLSL at runtime was unavailable in Windows Store apps on Windows
8, and manually copying the DLL to the build directory only worked within development
environments. However, Windows 8.1 now includes the latest version of
D3DCompiler
(47)
with the OS and is available for compiling HLSL at runtime within our Windows Store apps. The
downloadable source for this chapter includes the
HLSLCompiler
static class that provides
a wrapper for compiling shaders from HLSL files within a Windows Store app; this includes a
synchronous and asynchronous implementation. As the
D3DCompiler
binaries are part of
the OS, there is no need to include a post-build event to copy the
d3dcompiler_*.dll
ile
to the build directory. This should still be done for desktop applications under Windows 8.1.
See also
F
For more information about the setup of a custom view provider, and application
and windows events, see
How to set up your DirectX Windows Store app to display
a view
on
http://msdn.microsoft.com/en-us/library/windows/apps/
hh465077.aspx
F
The
Loading and compiling resources asynchronously
recipe includes an
implementation of compiling HLSL code from files asynchronously
Rendering to an XAML SwapChainPanel
In this recipe, we will render to an XAML
SwapChainPanel
. This panel allows us to efficiently
render using Direct2D/Direct3D within an XAML Windows Store app. By integrating Direct3D
into XAML we are able to use XAML to create flexible and dynamic UIs for our DirectX
application. Or we can use the power of DirectX to implement advanced 2D or 3D rendering
techniques within a wider XAML application.