Sign in to follow this  

multiple displays

This topic is 3501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, I am trying to experiment with displaying on multiple displays. I have an extended display setup where I have my laptop screen as primary display and another monitor as secondary display. I want to programatically switch between these displays and present the window that I have created. Basically, below are the steps I follow for a single monitor setup. 1) Create Device (specify Adapter as D3DADAPTER_DEFAULT) 2) Create Surface 3) Load Image 4) Copy Surface to Back Buffer 5) Present How do I create the device with multiple adapters? and switch between the adapters on the fly.

Share this post


Link to post
Share on other sites
Hi
First question is are you gonna use two (or more ) monitors in fullscreen or in windowed mode.

You can get adapter count as:

adapterCount = m_pD3D->GetAdapterCount();

Here is windowed mode rendering.


Fullscreen is made as:

Create as many windows as your adapter count is:


m_hWnd[0] = CreateWindowEx( NULL, D3D_WND_CLASS,
"win",
WS_POPUP | WS_VISIBLE,
0, 0, iWidth, iHeight, NULL, NULL, hInstance, NULL );
m_hWnd[1] = CreateWindowEx( NULL, D3D_WND_CLASS,
"win",
WS_POPUP | WS_VISIBLE,
0, 0, iWidth, iHeight, NULL, NULL, hInstance, NULL );




and create presentation parameters as:

// for dual head devices you need this
DWORD behaviorFlags = D3DCREATE_ADAPTERGROUP_DEVICE | D3DCREATE_HARDWARE_VERTEXPROCESSING;

D3DPRESENT_PARAMETERS *m_pPresentParams;

m_pPresentParams = new D3DPRESENT_PARAMETERS[m_Device.iNumAdapters];
memset( m_pPresentParams, 0, sizeof( D3DPRESENT_PARAMETERS ) * m_Device.iNumAdapters );

for (UINT i = 0; i < m_Device.iNumAdapters ; i++ )
{
MODE_INFO *mode = m_Device.Adapters[i].CurrMode;

m_pPresentParams[i].BackBufferWidth = iWidth;
m_pPresentParams[i].BackBufferHeight = iHeight;
m_pPresentParams[i].BackBufferFormat = D3DFMT_X8R8G8B8;
m_pPresentParams[i].BackBufferCount = 1;
m_pPresentParams[i].MultiSampleType = D3DMULTISAMPLE_NONE;
m_pPresentParams[i].MultiSampleQuality = 0;
m_pPresentParams[i].SwapEffect = D3DSWAPEFFECT_FLIP;
m_pPresentParams[i].hDeviceWindow = m_hWnd[i];
m_pPresentParams[i].Windowed = FALSE;//FALSE;
m_pPresentParams[i].EnableAutoDepthStencil = TRUE;
m_pPresentParams[i].AutoDepthStencilFormat = D3DFMT_D16;
m_pPresentParams[i].Flags = 0;
m_pPresentParams[i].FullScreen_RefreshRateInHz = 60;
m_pPresentParams[i].PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
}
// create device
m_pD3D->CreateDevice( 0, D3DDEVTYPE_HAL,
m_hWnd[0], behaviorFlags, m_pPresentParams,
&m_pd3dDevice );

// Get back buffer info
for ( UINT i = 0; i < m_Device.iNumAdapters; i++ )
{
LPDIRECT3DSWAPCHAIN9 pSwapChain = NULL;
m_pd3dDevice->GetSwapChain( i, &pSwapChain );
LPDIRECT3DSURFACE9 pBackBuffer = NULL;
pSwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
pBackBuffer->GetDesc( &m_Device.Adapters[i].sdBackBuffer );
SAFE_RELEASE( pBackBuffer );
SAFE_RELEASE( pSwapChain );
}




and rendering is made as:




LPDIRECT3DSURFACE9 pRenderTarget = NULL;
hr = m_pd3dDevice->GetRenderTarget( 0, &pRenderTarget );
LPDIRECT3DSURFACE9 pDepthStencil = NULL;

// Render each of the adapter swap chains
UINT numSwapChains = m_pd3dDevice->GetNumberOfSwapChains();

m_pd3dDevice->GetSwapChain( 0, &pSwapChain );
pSwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
m_pd3dDevice->SetRenderTarget( 0, pBackBuffer );

m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0, 1.0f, 0 );
m_pd3dDevice->BeginScene();
// draw

m_pd3dDevice->EndScene();

m_pd3dDevice->GetSwapChain(1, &pSwapChain );
pSwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
m_pd3dDevice->SetRenderTarget( 0, pBackBuffer );

m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0, 1.0f, 0 );
m_pd3dDevice->BeginScene();
// draw

m_pd3dDevice->EndScene();

hr = m_pd3dDevice->SetRenderTarget( 0, pRenderTarget );
SAFE_RELEASE( pRenderTarget );
m_pd3dDevice->Present(0,0,0,0);



Sorry for ugly code it is croped from one of my project [smile], but it works.

Share this post


Link to post
Share on other sites
Thanks for the response.

I understand that this can be accomplished by creating 2 windows.

But, is there no way of just creating one window, displaying it on one monitor and then switching the displayed window over to the secondary monitor. My intention is to create only one window.

Share this post


Link to post
Share on other sites

This topic is 3501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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