1
Vote

DXUT and a full screen mode problem

description

Hi!

I have a problem with the DXUT framework (the latest).
Could someone help me, please?

I render the 3D world in the full screen mode.
Connecting or disconecting a second monitor causes the application's problem.
The 3D world is no longer rendered.
The OnD3D11FrameRender function is called, but with no visual effect.
What could be done in such situation?

P. S.
DXUT does not recreate the device (this is the second monitor).

// File: Main.cpp
//
//--------------------------------------------------------------------------------------

#include "pch.h"
#include "DXUT.h"

//--------------------------------------------------------------------------------------
// Reject any D3D11 devices that aren't acceptable by returning false
//--------------------------------------------------------------------------------------
bool CALLBACK IsD3D11DeviceAcceptable(
    _In_ const CD3D11EnumAdapterInfo *AdapterInfo, _In_ UINT Output, _In_ const CD3D11EnumDeviceInfo *DeviceInfo,
    _In_ DXGI_FORMAT BackBufferFormat, _In_ bool bWindowed, _In_opt_ void* pUserContext)
{
#pragma region Region Unreferenced
    UNREFERENCED_PARAMETER(pUserContext);
    UNREFERENCED_PARAMETER(AdapterInfo);
    UNREFERENCED_PARAMETER(Output);
    UNREFERENCED_PARAMETER(DeviceInfo);
    UNREFERENCED_PARAMETER(BackBufferFormat);
    UNREFERENCED_PARAMETER(bWindowed);
#pragma endregion
    if (bWindowed)
        return false;
    return true;
}

//--------------------------------------------------------------------------------------
// This callback function is called immediately before a device is created to allow the 
// application to modify the device settings. The supplied pDeviceSettings parameter 
// contains the settings that the framework has selected for the new device, and the 
// application can make any desired changes directly to this structure.  Note however that 
// DXUT will not correct invalid device settings so care must be taken 
// to return valid device settings, otherwise IDirect3D9::CreateDevice() will fail.  
//--------------------------------------------------------------------------------------
bool CALLBACK ModifyDeviceSettings(_In_ DXUTDeviceSettings* pDeviceSettings, _In_opt_ void* pUserContext)
{
#pragma region Region Unreferenced
    UNREFERENCED_PARAMETER(pUserContext);
#pragma endregion

    pDeviceSettings->d3d11.SyncInterval = 1;
    pDeviceSettings->d3d11.sd.BufferDesc.Width = 1920;
    pDeviceSettings->d3d11.sd.BufferDesc.Height = 1080;
    pDeviceSettings->d3d11.sd.Windowed = FALSE;

    return true;
}

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender(_In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3dImmediateContext, _In_ double fTime, _In_ float fElapsedTime, _In_opt_ void* pUserContext) throw()
{
    UNREFERENCED_PARAMETER(pd3dDevice);
    UNREFERENCED_PARAMETER(pd3dImmediateContext);
    UNREFERENCED_PARAMETER(fTime);
    UNREFERENCED_PARAMETER(fElapsedTime);
    UNREFERENCED_PARAMETER(pUserContext);
    const float ClearColor[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
    pd3dImmediateContext->ClearRenderTargetView(DXUTGetD3D11RenderTargetView(), ClearColor);
    pd3dImmediateContext->ClearDepthStencilView(DXUTGetD3D11DepthStencilView(), D3D11_CLEAR_DEPTH, 1.0, 0);
}


INT wInternalWinMain(HINSTANCE hInstance) throw()
{
    INT Res = ERROR_SUCCESS;
    DXUTSetIsInGammaCorrectMode(true);

    DXUTSetCallbackDeviceChanging(ModifyDeviceSettings);

    DXUTSetCallbackD3D11DeviceAcceptable(IsD3D11DeviceAcceptable);
    DXUTSetCallbackD3D11FrameRender(OnD3D11FrameRender);

    // Initialize DXUT and create the desired Win32 window and Direct3D device for the application
    if (FAILED(DXUTInit(false, false))) // Parse the command line and show msgboxes
        Res = EXIT_FAILURE;
    else if (FAILED(DXUTCreateWindow(L"Test", hInstance)))
        Res = EXIT_FAILURE;
    else
    {
        if (FAILED(DXUTCreateDevice(
            D3D_FEATURE_LEVEL_9_3,
            false,
            1920,
            1080)))
            Res = EXIT_FAILURE;
        else if (FAILED(DXUTMainLoop()))
            Res = EXIT_FAILURE;
        DXUTShutdown(Res);
    }
    return Res;
}

INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int)
{
#ifndef DEBUG
#ifdef HARDWARE_EXCEPTIONS
    __try
    {
#endif
#else
    // _crtBreakAlloc = 64043;
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

    return wInternalWinMain(hInstance);

#ifndef DEBUG
#ifdef HARDWARE_EXCEPTIONS
    }
__except (1)
{
    return EXIT_FAILURE;
}
#endif
#endif
}

comments

walbourn wrote Jan 15, 2015 at 6:03 PM

Is this system using a single GPU with two output monitors, or multiple GPUs each with a different monitor output?

What version of the operating system are you using?

kubera wrote Jan 17, 2015 at 1:01 PM

This is the single NV GTX 770.OS: Windows 8.1.

Thank you very much