Direct2d ID2D1HwndRenderTarget->GetSize() returns 零
Direct2d ID2D1HwndRenderTarget->GetSize() returns zero
我注意到如果此调用是在 BeginDraw() 调用之后进行的,则在 ID2D1HwndRenderTarget returns 0,0 上调用 GetSize()。它 returns 否则是正确的值。
这是"normal"行为吗?我没有在任何示例中看到它的记录。我确实花了几个小时挠头。
这是正常行为。
在您的例子中,方法 return 是其 const 定义的 return 值。
virtual D2D1_SIZE_F GetSize() const = 0;
最有可能的是,该方法在内部失败,因为渲染目标不能 "acquired" 在 BeginDraw/EndDraw
循环内。
BeginDraw and EndDraw are used to indicate that a render target is in
use by the Direct2D system. Different implementations of
ID2D1RenderTarget might behave differently when BeginDraw is called.
An ID2D1BitmapRenderTarget may be locked between BeginDraw/EndDraw
calls, a DXGI surface render target might be acquired on BeginDraw and
released on EndDraw, while an ID2D1HwndRenderTarget may begin batching
at BeginDraw and may present on EndDraw, for example.
我注意到如果此调用是在 BeginDraw() 调用之后进行的,则在 ID2D1HwndRenderTarget returns 0,0 上调用 GetSize()。它 returns 否则是正确的值。
这是"normal"行为吗?我没有在任何示例中看到它的记录。我确实花了几个小时挠头。
这是正常行为。
在您的例子中,方法 return 是其 const 定义的 return 值。
virtual D2D1_SIZE_F GetSize() const = 0;
最有可能的是,该方法在内部失败,因为渲染目标不能 "acquired" 在 BeginDraw/EndDraw
循环内。
BeginDraw and EndDraw are used to indicate that a render target is in use by the Direct2D system. Different implementations of ID2D1RenderTarget might behave differently when BeginDraw is called. An ID2D1BitmapRenderTarget may be locked between BeginDraw/EndDraw calls, a DXGI surface render target might be acquired on BeginDraw and released on EndDraw, while an ID2D1HwndRenderTarget may begin batching at BeginDraw and may present on EndDraw, for example.