Skip to main content
edited body
Source Link
Quest
  • 2.9k
  • 1
  • 26
  • 51

How can I render my objects with DirectX objects into 2 separated windows?

How can I render with DirectX objects into 2 separated windows?

How can I render my objects with DirectX into 2 separated windows?

deleted 1179 characters in body
Source Link
Quest
  • 2.9k
  • 1
  • 26
  • 51

I've been looking for some 2 window rendering tutorial on google but I've found nothing so I've decided to find it by myself and I got it ;) I want to share my results so here they are:

1 if u created your device via CreateDeviceAndSwapChain method 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 youHow can now create additional swap chain 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!

I hope this has been helpful.

Best regards Quest :)render with DirectX objects into 2 separated windows?

I've been looking for some 2 window rendering tutorial on google but I've found nothing so I've decided to find it by myself and I got it ;) I want to share my results so here they are:

1 if u created your device via CreateDeviceAndSwapChain method 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 now create additional swap chain 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!

I hope this has been helpful.

Best regards Quest :)

How can I render with DirectX objects into 2 separated windows?

Source Link
Quest
  • 2.9k
  • 1
  • 26
  • 51

DirectX11 2 window rendering

I've been looking for some 2 window rendering tutorial on google but I've found nothing so I've decided to find it by myself and I got it ;) I want to share my results so here they are:

1 if u created your device via CreateDeviceAndSwapChain method 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 now create additional swap chain 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!

I hope this has been helpful.

Best regards Quest :)