当前位置: 首页>>代码示例>>C++>>正文


C++ IDirect3DSwapChain9::QueryInterface方法代码示例

本文整理汇总了C++中IDirect3DSwapChain9::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSwapChain9::QueryInterface方法的具体用法?C++ IDirect3DSwapChain9::QueryInterface怎么用?C++ IDirect3DSwapChain9::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirect3DSwapChain9的用法示例。


在下文中一共展示了IDirect3DSwapChain9::QueryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render


//.........这里部分代码省略.........
        pDev->SetStreamSource( 0, g_pScreenVB, 0, sizeof(SCREENVERTEX) );
        pDev->SetFVF( D3DFVF_SCREENVERTEX );

        // draw
        pDev->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );


        //
        // Render the cursor
        //

        pDev->SetTexture( 0, NULL );

        // set the texture stage states
        pDev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
        pDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );

        // stream sources
        pDev->SetStreamSource( 0, g_pCursorVB, 0, sizeof(CURSORVERTEX) );
        pDev->SetFVF( D3DFVF_CURSORVERTEX );

        // draw
        pDev->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

        // render text
        RenderText( pDev );

        // End the scene
        pDev->EndScene();
    }
    else if( g_bSkipRendering )
        Sleep(20);	//don't hog the entire CPU

    // Present the backbuffer contents to the display
    HRESULT hr = pDev->Present( NULL, NULL, NULL, NULL );

    // Handle Occluded, DeviceReset, or Mode Changes
    if( S_PRESENT_OCCLUDED == hr )
    {
        g_bSkipRendering = true;
    }
    else if( D3DERR_DEVICELOST == hr )
    {
        if(FAILED( Reset( pDev ) ) )
            g_bSkipRendering = true;	
    }
    else if( S_PRESENT_MODE_CHANGED == hr )
    {
        //
        // Reenumerate modes by calling IDirect3D9::GetAdapterModeCountEx
        //
        D3DDISPLAYMODEFILTER DisplayModeFilter;

        ZeroMemory(&DisplayModeFilter, sizeof(DisplayModeFilter));

        DisplayModeFilter.Size			   = sizeof(DisplayModeFilter);
        DisplayModeFilter.Format		   = D3DFMT_UNKNOWN;
        DisplayModeFilter.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;

        UINT ModeCount = g_pD3D9->GetAdapterModeCountEx(D3DADAPTER_DEFAULT, &DisplayModeFilter);

        if(FAILED( Reset( pDev ) ) )
            g_bSkipRendering = true;	
    }
    else if( D3DERR_DEVICEHUNG == hr )
    {
        MessageBox( g_hWnd,
                    L"This application has caused the graphics adapter to hang, check with the hardware vendor for a new driver.",
                    L"Graphics Adapter Hang",
                    MB_OK );

        PostQuitMessage(0);
        g_bSkipRendering = true;
    }
    else
    {
        g_bSkipRendering = false;
    }

    // Get some presents stats
    IDirect3DSwapChain9* pSwapChain;
    if( SUCCEEDED( pDev->GetSwapChain( 0, &pSwapChain ) ) )
    {
        IDirect3DSwapChain9Ex* pSwapChainEx;
        if( SUCCEEDED( pSwapChain->QueryInterface( IID_IDirect3DSwapChain9Ex, (void**)&pSwapChainEx ) ) )
        {
            hr = pSwapChainEx->GetLastPresentCount( &g_PresentStats.PresentCount );
            if( SUCCEEDED( hr ) )
                hr = pSwapChainEx->GetPresentStats( &g_PresentStats );
            pSwapChainEx->Release();
        }
        pSwapChain->Release();
    }

    // Get the time
    LARGE_INTEGER liCurrentTime;
    QueryPerformanceCounter( &liCurrentTime );
    g_fLastFrameTime = (float)(liCurrentTime.QuadPart - g_liLastTimerUpdate.QuadPart) / (float)g_liTimerFrequency.QuadPart;
    g_liLastTimerUpdate.QuadPart = liCurrentTime.QuadPart;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:D3D9ExSample.cpp


注:本文中的IDirect3DSwapChain9::QueryInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。