How can I render my objects with DirectX into 2 separated windows?
- 3If you want to answer your own question, you should write an actual answer instead of putting the answer in the question.Borgleader– Borgleader2014-01-22 20:15:00 +00:00Commented Jan 22, 2014 at 20:15
- 1Okay sorry ... I'll remember thatQuest– Quest2014-01-22 20:17:24 +00:00Commented Jan 22, 2014 at 20:17
- 2No need to be sorry, I was just pointing it out.Borgleader– Borgleader2014-01-22 20:20:39 +00:00Commented Jan 22, 2014 at 20:20
- @Quest That's nice you'll remember that, but you should do that for this question, like right now. Move the answer into an answer and accept it, and change the question part to actually have a well worded question. Otherwise this feels incomplete, and I don't want to upvote a topic with poor formatting like this. Actually, I'm inclined to downvote and flag it unless this is done.leetNightshade– leetNightshade2014-02-21 00:24:12 +00:00Commented Feb 21, 2014 at 0:24
- @Quest I hope my comment didn't sound harsh. Thanks for following through! :)leetNightshade– leetNightshade2014-02-21 17:33:00 +00:00Commented Feb 21, 2014 at 17:33
Add a comment |
1 Answer
You need to create one SwapChain and RenderTargetView for every window.
1 if you created your device via CreateDeviceAndSwapChain you need to obtain IDXGIFactory first
IDXGIDevice * device; d3ddevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&device); IDXGIAdapter * adapter; device->GetParent(__uuidof(IDXGIAdapter), (void**)&adapter); IDXGIFactory * factory; adapter->GetParent(__uuidof(DDXGIFactory), (void**)&factory); With DXGIFactory you can create additional swapchain for new window
factory->CreateSwapChain(g_pd3dDevice, &sd, &g_pSwapChain2); then create a render target view
ID3D11Texture2D* pBackBuffer = NULL; hr = g_pSwapChain2->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); if( FAILED( hr ) ) return hr; hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); pBackBuffer->Release(); if( FAILED( hr ) ) return hr; And finally just set your render target(s) and Draw something!
g_immediateContext->OMSetRenderTargets(1, &g_RenderTargetView, NULL); .... I hope this has been helpful.
Best regards Quest :)