justinstenning / Direct3DHook

DirectX Capture and Overlays by using Direct3D API hooks
http://spazzarama.com/2011/03/14/c-screen-capture-and-overlays-for-direct3d-9-10-and-11-using-api-hooks
MIT License
580 stars 178 forks source link

D3D11 Device to 2D Context? #52

Open bestplay9384 opened 7 years ago

bestplay9384 commented 7 years ago

Hey I wonder if it's possible to get to 2D Context and render elements like in here (https://english.r2d2rigo.es/2012/07/04/basic-direct2d-drawing-with-sharpdx/). In my case i have D3D11Hook from your approach so i have

SharpDX.Direct3D11.Device _device; and SharpDX.DXGI.SwapChain _swapChain;

Is there any possibility to render in 2D using (or not) DXOverlayEngine via those variables? Thanks for help! :)

justinstenning commented 7 years ago

Yes, you create your own d2d device. The only reason I haven't used that approach here is to support pre windows 8.

bestplay9384 commented 7 years ago

@spazzarama can you provide any example? And is it necessary to use your Overlay Engine? It would be pretty nice to use some easy drawing functions like DrawLine or DrawCircle, but i haven't seen any tutorial how to do it with SharpDX.Direct3D11, maybe you can tell anything about it? :( Thanks for your time!

justinstenning commented 7 years ago

@bestplay9384 I use Direct2D in my book samples available here https://github.com/spazzarama/Direct3D-Rendering-Cookbook (specifically in the Common library)

No you do not need to use the overlay engine, although you could create a Direct2D renderer that fits within that framework if you wanted to.