// Draw a grid background.
int width = static_cast<int>(rtSize.width);
int height = static_cast<int>(rtSize.height);
for (int x = 0; x < width; x += 10)
{
m_pRenderTarget->DrawLine(
D2D1::Point2F(static_cast<FLOAT>(x), 0.0f),
D2D1::Point2F(static_cast<FLOAT>(x), rtSize.height),
m_pLightSlateGrayBrush,
0.5f
);
}
This is the sample in the documentation. I’ve included “D2d1.h”, I just don’t know how to create a “m_pRenderTarget”. I’m writing a Kinect project, I want to draw a line on the image. I’m really new, please help me.
Have you see this page?
Create an ID2D1HwndRenderTarget
The quick start tutorial has a detail steps of how to use Direct2D.
You can also download the Windows SDK, the samples contains Direct2D demo which has the full steps of how to create Direct2D render target
I have write a program to draw a rectangle, with a little change, it can draw a line, just for your reference