• Advertisement
Sign in to follow this  

SwapChain.Present and Rectangles

This topic is 4360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having some issues with Present and using rectangles for indicating my dirty region. This is what I am trying to accomplish: 1) Part of my control is invalidated, e.g. by dragging a window over a part of the control. 2) This leads to an OnPaint event, with a rectangle indicating the part of the control that needs redrawing. 3) Do Present on my swapchain, passing the rectangle corresponding to the dirty region. I do *not* want to Present the entire surface, as this forces me to redo alot of other operations I'd really like to avoid. The problem is that I cannot get this to work properly. When dragging a window over my control I get lots of trails, it seems that the entire region is not always repainted after all. To test this I first fill the entire dirty rectangle using the GDI FillRectangle (blue). After Present only a smaller rectangle in the top left corner of my region has been replaced with the info in my D3D back buffer (white). The remaining part still shows my filler color (blue). Image Hosted by ImageShack.us Should the rectangle arguments passed to Present perhaps be in some other coordinate system? I have tried some different arguments to Present without success, as well as messed with presentation parameters. Any hints?

Share this post


Link to post
Share on other sites
Advertisement
I found the solution myself.
Here it goes, in case anyone runs into the same issue:

This was caused by a bug in the way the Rectangle arguments are interpreted by DirectX.
A Drawing.Rectangle at point 100,100 and WxH of 200 is normally created using:

new Rectangle(100,100,200,200);

Unfortunately the Present method interprets this rectangle as having WxH of 100.
I guess the width/height is believed to be bottom/right coordinates instead.

Anyway, creating a new rectangle in the (incorrect) format did it for me.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement