关闭

Direct3D改变分辨率&真假全屏

标签: direct3d
1435人阅读 评论(0) 收藏 举报
    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;
    }


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:23396次
    • 积分:364
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:6篇
    • 译文:0篇
    • 评论:1条
    最新评论