Bleh, that title seemed a bit too long to me...couldn't really think of a shorter way of wording it though.
Right, I'll try and encapsulate the problem as best I can. I'm currently, as per the title, attempting to create a c++/DirectX multiple windowed swap chained system which can handle differing resolutions for each window.
I have the whole thing working EXCEPT for resizing of the master window. If it's larger then the rest of them or indeed, the same size, everything works fine. All of the child windows scale appropriately, even assigning them stupid resolutions like 10x800.
The issue comes when the master window is smaller then any of the other windows; it appears to crop the display picture of those subsequent child windows in accordance with the size of the master window.
For example:
Window 1 = 500x500
Window 2 = 1000x1000
The second window will only draw to the top left quarter of the window yet it appears as though it has stretched appropriately; only the top quarter of the PICTURE would be drawn in the quarter of the window. So it scales as though it's setup correctly. I have a light blue background for a non-directX clear background and dark blue for the DirectX clear command. In this instance, dark blue will only be drawn in the top-left so DirectX seems not to want to touch any portion of a window which would not fall within the boundaries of the master window.
I have checked all of my parameters going in but fear that is not where the issue lies. One work around could be to supply a large master window yet simply have it hidden from the user, thus all child windows could scale upto it but to be that feels more like putting a band-aid over the issue rather then tackling it properly.
Creation of the device:
//******************************************************//
// Create the DX9 device. //
//******************************************************//
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if(d3d == NULL)
return DDIS_ERR_INIT_CREATE_D3D9;
//Create d3d device connections with the default graphics adapter.
d3dDevice = NULL;
//******************************************************//
// Windowed mode setup. //
// This utilizes swap chains for faster rendering for //
// potentially any number of windows. //
//******************************************************//
else{
//Create the master display first.
if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &displayHandles.at(0).d3dpp, &d3dDevice)))
return DDIS_ERR_INIT_WNDCREATEDEVICE;
//With parameters and windows created, create swap chains relative to DISPLAY_HANDLEs.
for(int x = 0; x < (int)displayHandles.size(); x++){
displayHandles.at(x).swapChain = NULL;
//For the first display, just call up the swap chain.
if(x == 0){
if(FAILED(d3dDevice->GetSwapChain(0, &displayHandles.at(x).swapChain)))
return DDIS_ERR_INIT_WNDGETSWAPCHAIN;
}
//For all preceeding displays, call their presentation parameters.
else{
if(FAILED(d3dDevice->CreateAdditionalSwapChain(&displayHandles.at(x).d3dpp, &displayHandles.at(x).swapChain)))
return DDIS_ERR_INIT_WNDCREATESWAPCHAIN;
}
if(FAILED(displayHandles.at(x).swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &displayHandles.at(x).backBuffer)))
return DDIS_ERR_INIT_WNDGETBACKBUFFER;
}
}
return DDIS_OK;
Beginning of the scene:
//Set all appropriate rendering device properties.
if(FAILED(d3dDevice->SetRenderTarget(0, displayHandles.at(displayIdentifier).backBuffer)))
return DDIS_ERR_BEGC_WNDSETRENDERTARGET;
if(FAILED(d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,155,155), 1.0f, 0)))
return DDIS_ERR_BEGC_WNDCLEAR;
if(FAILED(d3dDevice->BeginScene()))
return DDIS_ERR_BEGC_WNDBEGINSCENE;
//Inform the class of the displayIdentifier.
currentActiveDevice = displayIdentifier;
Ending the scene:
//If windowed, end the scene, draw the swapChain and empty the buffers.
if(FAILED(d3dDevice->EndScene()))
return DDIS_ERR_ENDC_WNDENDSCENE;
if(FAILED(displayHandles.at(currentActiveDevice).swapChain->Present(NULL, NULL, displayHandles.at(currentActiveDevice).wndHandle, NULL, 0)))
return DDIS_ERR_ENDC_WNDPRESENT;
if(FAILED(displayHandles.at(currentActiveDevice).backBuffer->Release()))
return DDIS_ERR_ENDC_WNDRELEASE;
return DDIS_OK;
Alas I fear a quick fix may be too optimistic but if anyone has come across this issue before, please let me know. More information can be provided but displaying of the whole class seems a little pointless as it's mixed in with a lot of other stuff (none of which is active during windowed mode).
Thanks for your time.