June 20th, 2011, 10:58 AM
Draw on Exiting Screen Content with D3D9
I have an application that requires me to draw simple 2D points/lines on top of existing Window content. The existing Window content is created by another application, and must be left intact when my drawing is presented. The application currently uses the GDI to draw the points/lines onto the existing Window content, which has been working very well for many years.
With Windows 7, the GDI performance has become very poor and I am looking at alternative methods of drawing onto the window.
I figured the best bet was to look into Direct3D 9 (we want to support Windows XP at a minimum). I am entirely new to Direct3D 9 and also to graphics programming in general.
I was able to pretty easily figure out how to initialize a D3D9 device to the existing window, and also to how to draw my points/lines onto the window.
However, I have no idea how to get my drawing onto the window without first clearing the existing application content in D3D9. It seems that any time the back buffer is presented, it replaces the front buffer completely.
I was able to figure out how to update only portions of the window by using the rectangle parameters on the Present() call. However, this is not a workable solution in my application because it is working at the level of plotting individual points, which could be all over the screen. Also, some original screen content can appear inside of the rectangular area my application has drawn onto. The only way to use this option would be to perform a Present() operation for each pixel plotted, with the rectangle being the single pixel. Obviously, this does not perform well at all.
In GDI, the application just plots wherever it wants and it always goes right onto the screen without clearing anything that was already there.
Any idea on how to achieve the same effect in D3D9? I need to plot the points/lines anywhere I need to on the screen, without clearing any of the existing window content.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!