Direct3D改变分辨率&真假全屏

    BOOL bRet = FALSE;

    m_d3dpp.BackBufferWidth = 0; 
    m_d3dpp.BackBufferHeight = 0;

    GetWindowRect(hwnd, &m_rcWindow);
    RECT rect = {0, 0, nWidth, nHeight};
    AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), 
        FALSE, GetWindowLong(hwnd, GWL_EXSTYLE));

    SetWindowPos(hwnd, HWND_NOTOPMOST, m_rcWindow.left, m_rcWindow.top, 
        rect.right - rect.left, rect.bottom - rect.top, 
        SWP_SHOWWINDOW);

    //务必释放dx资源
    OnDeviceLost();

    HRESULT hResult = m_d3d_Device->Reset(&m_d3dpp);
        
    if(!FAILED(hResult))
    {
        //重新设定dx资源
        SetupResource();
        bRet = TRUE;
    }

    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);
    return bRet;


    真假全屏

    m_bFullScreen = TRUE;
    m_d3dpp.Windowed = !bRealFullScreen;

    m_d3dpp.BackBufferWidth = GetSystemMetrics(SM_CXSCREEN);
    m_d3dpp.BackBufferHeight = GetSystemMetrics(SM_CYSCREEN);

    ::SetWindowLong(hwnd, GWL_STYLE, WS_EX_TOPMOST | WS_POPUP);
    ::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 
        GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 
        SWP_SHOWWINDOW);
    OnDeviceLost();

    HRESULT hResult = m_d3d_Device->Reset(&m_d3dpp);
        
    if(!FAILED(hResult))
    {
        //重新设定dx资源
        SetupResource();
        bRet = TRUE;
    }


阅读更多
文章标签: direct3d
想对作者说点什么? 我来说一句

winform窗体大小随分辨率改变

2010年10月31日 456B 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭