Graphics Reference
In-Depth Information
Now we execute our first rendering command which is to clear renderTargetView with a
light blue color. This line is retrieving the immediate device context from the device and then
executing the ClearRenderTargetView command. As this is not a deferred context the
command is executed immediately.
Finally we tell the swap chain to present the back buffer (our renderTargetView that we
just set to light blue) to the front buffer.
Finalization
The finalization stage is quite straight forward. After the RenderLoop exits, we clean up any
resources that we have created and dispose of the device and swap chain.
All SharpDX classes that represent Direct3D objects implement the IDisposable interface
and should be disposed off to release unmanaged resources.
There's moreā€¦
To make the example a little more interesting, try using a Linear interpolation (LERP) of
the color that is being passed to the ClearRenderTargetView command. For example,
the following code will interpolate the color between light and dark blue over 2 seconds:
var lerpColor = SharpDX.Color.Lerp(SharpDX.Color.LightBlue,
SharpDX.Color.DarkBlue,
(float)(totalSeconds / 2.0 % 1.0));
device.ImmediateContext.ClearRenderTargetView(
renderTargetView,
lerpColor);
You will have noticed that there are a number of other SharpDX assemblies available within
the SharpDX binaries directory.
The SharpDX.Direct2D1.dll assembly provides you with the Direct2D API. SharpDX.
D3DCompiler.dll provides runtime shader compilation, which we will be using to compile
our shaders in later chapters. SharpDX.XAudio2.dll exposes the XAudio2 API for mixing
voices and SharpDX.RawInput.dll provides access to the raw data sent from user
input devices, such as the keyboard, mouse, and gamepads or joysticks. The Microsoft
Media Foundation, for dealing with audio/video playback, is wrapped by the SharpDX.
MediaFoundation.dll assembly.
 
Search WWH ::




Custom Search