2

I've noticed that calling GetSize() on ID2D1HwndRenderTarget returns 0,0 if this call is made after a BeginDraw() call. It returns the correct value otherwise.

Is this "normal" behaviour? I haven't seen it documented in any examples. I did spend a few hours scratching my head over this.

Robinson
  • 9,666
  • 16
  • 71
  • 115

1 Answers1

3

This is a normal behaviour.

In your case, the method returns its const defined return value.

virtual D2D1_SIZE_F GetSize() const = 0;

Most probably, the method fails inside, because the render target could not be "acquired" inside a BeginDraw/EndDraw loop.

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.

Remarks section: ID2D1RenderTarget::BeginDraw method

Peter Kostov
  • 941
  • 1
  • 6
  • 15
  • 1
    The "= 0" at the end of the declaration of GetSize isn't a default return value. It indicates that the member is [pure virtual](http://stackoverflow.com/a/1306837/1396177). – Buster Dec 23 '15 at 12:41