I am using ffmpeg, hardware acceleration and directx 9 for video stream application. The application includes c# for user interface and c++ for rendering. At the beginning, I used directx for simple overlays like line, rectangle, polygon, triangle, text etc. But now, I need more complex overlays. Then, I think to use directx for video and GDI for overlays.
I tried to call GDI fuction in c# side for the same handle when directx Present is finished. Actually it works but overlay, that is drawn by GDI, is flickering.
I changed PresentationInterval in D3DPRESENT_PARAMETERS
to D3DPRESENT_INTERVAL_TWO
and D3DPRESENT_INTERVAL_THREE
. Result is application crashed.
I called LockWindowUpdate(myHandle)
before directx Present and called LockWindowUpdate(IntPtr.Zero)
after GDI function. Result is application crashed.
1.Is drawing overlay with GDI on directx a nice solution?
If YES, is there a way to do it without flickering?
If NO, should i do all work with directx?
Update: Panel control , that displays video, is already set DoubleBuffered
System.Reflection.PropertyInfo prop =
typeof(System.Windows.Forms.Control).GetProperty(
"DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
prop.SetValue(displayPnl,true,null);