Sign in to follow this  
GeneralMeliante

D3D11 integration with MFC

Recommended Posts

Hi everyone!

 

I need to integrate a program in DirectX11 already done with the view window on an MFC application, could you guys help me out somehow?

Some examples any idea how I should tackle this situation because I'm pretty clueless here.

 

I did create the MFC application, I know that the .cpp I should focus is the one ending in view where there are kind of a start function for creating the object and OnDrawn and such but i have no idea how to get my already done program and add it to the MFC application.

 

Anything would help here, a simple example made (I was trying to make this integration with a simple draw the triangle from the D3D SDK), anything really!

 

Thanks very much in advance!

Edited by GeneralMeliante

Share this post


Link to post
Share on other sites
Quat    568

Just like in a Win32, your swap chain presents to the window you specify in the OutputWindow member of DXGI_SWAP_CHAIN_DESCDXGI_SWAP_CHAIN_DESC.  So in MFC, you will need to specify the hwnd to the MFC window you want to output to.  If I recall correctly, you will also need to tell MFC not to erase the background of the window you are drawing to (since you are using direct3d for all drawing).  A quick google search shows there are a lot of tutorials on this.

Share this post


Link to post
Share on other sites

Hi, thank you for your response but i actually did an extensive search on google e got nothing really helpful since i`m looking for MFC with D3D11, there is quite a lot on D9 and as i was told it is not adequate to use it.

 

Could you please provide me with any of your tutorials findings?

 

thank you very much!

Share this post


Link to post
Share on other sites
Jason Z    6434

You don't have to look any further than the Hieroglyph 3 repository :)  There is a sample program called MFCwithD3D11, and it should show you the basics of how to get it up and running.  If you have any specific questions after checking it out, just post here or shoot me an IM and I'll be happy to help.

Share this post


Link to post
Share on other sites

Hi Jason Z!

 

I actually looked on the Hieroglyph 3 repository and managed to put the MFCwithD3D11 to compile (it needed to be made a solution that really had the .cpp and another configuration necessary) and made it open but it only creates the 3 windows wasn't it suppose to draw a cube in each one of those windows?

 

Thank you very much i did find the examples on the Hieroglyph 3 really interesting but by now i only need to learn how to get my already done D3D11 program go to the view window on MFC.

 

Thanks!

Share this post


Link to post
Share on other sites
Jason Z    6434

Sorry about that - I hadn't added it to the solution when I converted over to VS2012...  I'll take a look at the example and get it updated soon.  If I recall correctly I just made a copy of the new project files for VS2012, but that project needs to be set up differently for using MFC.

 

However, you should be able to see how to associate a swap chain with a window handle from the code that is listed there.  This is ultimately no different than normal rendering - you create a swap chain with the target window's HWND as an input.  The way to do this can all be seen in the MFCwithD3D11View class.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this