I am having a difficult time finding details on the draw order of a DirectX 11 application when rendered in a Windows Form. I know that I can assign my SwapChain
to render to the handler of a control (such as a panel) which I have done already. The question here is more focused on being able to paint over the content that is rendered via DirectX in the same control. I already know that I can add controls to the panel and they will paint over the rendered content. I attempted utilizing the Paint
event for the panel and doing a simple draw:
private void panel1_Paint(object sender, PaintEventArgs e) {
using (Pen p = new Pen(Brushes.Red))
e.Graphics.FillEllipse(p, new Rectangle(0, 0, 250, 250));
}
However, I believe this is painting the requested content below the scene content rendered by DirectX. I haven't been able to find any details on the draw order and which events to utilize. If anyone has any ideas on which events to use to paint over the rendered scene, that would be helpful. If controls can be rendered on top of the scene, then I would like to believe custom painting could be achieved as well.
Maybe I'll have to go the long way around?
Update
I have found a post over on MSDN that doesn't fully answer the question at hand, but helps with my comprehension, and also sheds light on an alternate route which appears to require being done at the end of the render method for my engine (which makes sense seeing as rendering typically follows a FIFO system).
You can have GDI(+) calls on top of a DX render. The d3d device can return a Graphics g suitable to do gdi calls. At least, I've done it in windowed mode.
Microsoft.DirectX.Direct3D.Surface bb = device.GetBackBuffer(0, 0);
System.Drawing.Graphics g = bb.GetGraphics();
g.DrawRectangle(...); // or whatever
bb.ReleaseGraphics();
bb.Dispose();
Also, I don't see what's to stop somebody from adding controls to the panel one uses as the DX panel.
Clarified Question
My original question however, still remains. Does anyone know what the draw order is between Windows Forms and DirectX 11? Does anyone know of an event that can be utilized as part of this order to draw on top of the rendered content?