Represents a cubic bezier segment drawn between two points.ĭescribes the extend modes and the interpolation mode of an ID2D1BitmapBrush.ĭescribes the pixel format and dpi of a bitmap. Stores an ordered pair of integers, typically the width and height of a rectangle.Ī 2D vector that consists of two single-precision floating-point values (x, y).Ī 3D vector that consists of three single-precision floating-point values (x, y, z).Ī 4D vector that consists of four single-precision floating-point values (x, y, z, w).ĭescribes an elliptical arc between two points. Stores an ordered pair of floating-point values, typically the width and height of a rectangle. These coordinates are expressed as a 32-bit integer values. Represents a rectangle defined by the upper-left corner pair of coordinates (left,top) and the lower-right corner pair of coordinates (right, bottom). The D2D_RECT_L structure defines the coordinates of the upper-left and lower-right corners of a rectangle. Represents a rectangle defined by the coordinates of the upper-left corner (left, top) and the coordinates of the lower-right corner (right, bottom). Represents an x-coordinate and y-coordinate pair, expressed as an unsigned 32-bit integer value, in two-dimensional space. The D2D_POINT_2L structure defines the x- and y- coordinates of a point. Represents an x-coordinate and y-coordinate pair, expressed as floating-point values, in two-dimensional space. In this section Topicĭescribes the red, green, blue, and alpha components of a color.ĭescribes a 4-by-3 floating point matrix.ĭescribes a 4-by-4 floating point matrix.ĭescribes a 5-by-4 floating point matrix. Additional structures are defined in the D2D1 Namespace. rc.top is stored directly after rc.left and this forms a POINT structĬlientToScreen(hWnd, reinterpret_cast(&rc.left)) ĬlientToScreen(hWnd, reinterpret_cast(&rc.Direct2D provides the following structures. Rectf.height = static_cast(rc.bottom - rc.top) Rectf.width = static_cast(rc.right - rc.left) PixelSpace Conversion Vector3f ConvertPixelSpace(HWND hWnd, float x, float y, PixelSpace curSpace, PixelSpace newSpace) Vector3f centre = ConvertPixelSpace(this->gfx.hWnd, centreX, centreY, ps, PixelSpace::Client) Return ConvertPixelSpace(this->hWnd, (float)pt.x, (float)pt.x, PixelSpace::Screen, PixelSpace::Client) ĭirect2D void DrawCircle(const Colour& c, float centreX, float centreY, float radius, PixelSpace ps) Convert from screen pixels to client pixels I want to know how I can fix my code so that it will draw the circle at the position given by GetCursorPos().ĭriver code Vector3f cursPos = input.GetCursorPos() ĭrawCircle(Colour::Green, cursPos.x, cursPos.y, 3/*radius*/) Here, dpiX and dpiY become 96 which I notice is also the constant that GetDpiForWindow() from the windows API returns when it is not dpi aware. ), "Failed to create D2D render target") This->factory->GetDesktopDpi(&dpiX, &dpiY) ĭ2D1_RENDER_TARGET_PROPERTIES rtDesc = D2D1::RenderTargetProperties(ĭ2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),ĪssertHResult(this->factory->CreateDxgiSurfaceRenderTarget( This is the code for creating the D2D render target from the DXGI surface I obtained from the swapchain in my D3D11 code. I noticed changing the dpi for the D2D1_RENDER_TARGET_PROPERTIES affects this 'scaling' so I suspect the problem has something to do with dpi. The screen to client coordinates work perfectly but for some reason D2D draws the circle a small distance from the expected location (tens of pixels) as if the coordinate had been scaled by a small factor so that the error gets larger as the circle is drawn further from (0, 0). I have some code that uses GetCursorpos() from the windows API which is then converted to client coordinates and then draws a small circle at this position using D2D FillEllipse().
0 Comments
Leave a Reply. |