Game Development Reference
In-Depth Information
AlphaMode.Premultiplied);
WindowRenderTargetProperties properties = new
WindowRenderTargetProperties();
properties.Handle = FormObject.Handle;
properties.PixelSize = new Size(width, height);
m_RenderTarget = new
WindowRenderTarget(m_Factory, rtProperties,
properties);
m_DebugBrush = new
SolidColorBrush(m_RenderTarget, new
Color4(1.0f, 1.0f, 1.0f, 0.0f));
As we did in the program for creating a rectangle, we first create the factory object.
After that, things differ slightly. This time we need to create two properties objects in-
stead of one. The new one is a RenderTargetProperties object. We use it to set
the pixel format for our render target. As you can see, we are using a 32-bit format
with 8 bits for each of the four channels (blue, green, red, and alpha). Yes, this is
backwards from the ARGB format we've already discussed earlier. That's OK though
because our LoadBitmap() method will flip the ARGB format to BGRA for us. The
next line of code creates a WindowRenderTargetProperties object, just as we
did in the Rectangle program earlier in this chapter. We use this to specify the handle
of the window we want to draw on as well as the size of the window. And lastly, we
create the render target object and initialize our debug brush to be an opaque yellow
brush.
So,we'redoneinitializingstuffnow,right?Well,no;notyet.Westillhaveafewthings
that need to be initialized. But first, we need to create our LoadBitmap() method
so that we can load in our graphics! The following is the code:
public SlimDX.Direct2D.Bitmap LoadBitmap(string
filename)
{
// This will hold the Direct2D Bitmap that
we will return at the end of this
Search WWH ::




Custom Search