示例#1
0
// Render the help and statistics text
void RenderText()
{
    UINT nBackBufferHeight = ( DXUTIsAppRenderingWithD3D9() ) ? DXUTGetD3D9BackBufferSurfaceDesc()->Height :
            DXUTGetDXGIBackBufferSurfaceDesc()->Height;

    gTxtHelper->Begin();
    gTxtHelper->SetInsertionPos( 2, 0 );
    gTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    gTxtHelper->DrawTextLine( DXUTGetFrameStats( false ) );
    gTxtHelper->DrawTextLine( DXUTGetDeviceStats() );

    // Draw help
    if( gShowHelp )
    {
        gTxtHelper->SetInsertionPos( 2, nBackBufferHeight - 20 * 6 );
        gTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) );
        gTxtHelper->DrawTextLine( L"Controls:" );

        gTxtHelper->SetInsertionPos( 20, nBackBufferHeight - 20 * 5 );
        gTxtHelper->DrawTextLine(	L"Switch Compressed/Uncompressed views: TAB\n"
									L"Hide help: F1\n"
                                    L"Quit: ESC\n" );
    }
    else
    {
        gTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        gTxtHelper->DrawTextLine( L"Press F1 for help" );
    }

    gTxtHelper->End();
}
示例#2
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos( 5, 5 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    txtHelper.DrawTextLine( DXUTGetDeviceStats() );

    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );

    // Draw help
    const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetD3D9BackBufferSurfaceDesc();
    txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height - 15 * 6 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( L"Controls:" );
    txtHelper.SetInsertionPos( 40, pd3dsdBackBuffer->Height - 15 * 5 );
    txtHelper.DrawTextLine( L"Rotate model: Left mouse button\n"
                            L"Rotate camera: Right mouse button\n"
                            L"Zoom camera: Mouse wheel scroll\n"
                            L"Quit: ESC" );
    txtHelper.End();
}
示例#3
0
void RenderText()
{
    const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetD3D9BackBufferSurfaceDesc();
    CDXUTTextHelper txtHelper(g_pFont, g_pTextSprite, 15);

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos(5, 5);
    txtHelper.SetForegroundColor(D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f));
    txtHelper.DrawTextLine(DXUTGetFrameStats());
    txtHelper.DrawTextLine(DXUTGetDeviceStats());

    txtHelper.SetForegroundColor(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
    txtHelper.DrawTextLine(L"Put whatever misc status here");

    if(g_bShowHelp)
    {
        txtHelper.SetInsertionPos(10, pd3dsdBackBuffer->Height - 15 * 6);
        txtHelper.SetForegroundColor(D3DXCOLOR(1.0f, 0.75f, 0.0f, 1.0f));
        txtHelper.DrawTextLine(L"Controls (F1 to hide):");

        txtHelper.SetInsertionPos(40, pd3dsdBackBuffer->Height - 15 * 5);
        txtHelper.DrawTextLine(L"Blah: X\n"
                                L"Quit: ESC");
    }
    else
    {
        txtHelper.SetInsertionPos(10, pd3dsdBackBuffer->Height - 15 * 2);
        txtHelper.SetForegroundColor(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
        txtHelper.DrawTextLine(L"Press F1 for help");
    }
    txtHelper.End();
}
//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                 float fElapsedTime, void* pUserContext )
{
    XMMATRIX matView = XMLoadFloat4x4A( &g_matView );
    XMMATRIX matProj = XMLoadFloat4x4A( &g_matProjection );
    XMMATRIX matVP = matView * matProj;

    RenderPreFrame( pd3dDevice, pd3dImmediateContext, matView, matProj, fElapsedTime );

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    if( g_bDrawTerrain )
    {
        g_pTerrainView->Render( pd3dImmediateContext );
    }
    else
    {
        RenderTestObjects( pd3dImmediateContext, matVP );
    }

    RenderHUD( pd3dImmediateContext, fElapsedTime );

    static DWORD dwTimefirst = GetTickCount();
    if ( GetTickCount() - dwTimefirst > 5000 )
    {    
        OutputDebugString( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
        OutputDebugString( L"\n" );
        dwTimefirst = GetTickCount();
    }
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text
//--------------------------------------------------------------------------------------
void RenderText()
{
    UINT nBackBufferHeight = DXUTGetDXGIBackBufferSurfaceDesc()->Height;

    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos(2, 0);
    g_pTxtHelper->SetForegroundColor(XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f));
    g_pTxtHelper->DrawTextLine(DXUTGetFrameStats(DXUTIsVsyncEnabled()));
    g_pTxtHelper->DrawTextLine(DXUTGetDeviceStats());

    // Draw help
    if (g_bShowHelp)
    {
        g_pTxtHelper->SetInsertionPos(2, nBackBufferHeight - 20 * 6);
        g_pTxtHelper->SetForegroundColor(XMFLOAT4(1.0f, 0.75f, 0.0f, 1.0f));
        g_pTxtHelper->DrawTextLine(L"Controls:");

        g_pTxtHelper->SetInsertionPos(20, nBackBufferHeight - 20 * 5);
        g_pTxtHelper->DrawTextLine(L"Move forward and backward with 'E' and 'D'\n"
            L"Move left and right with 'S' and 'D' \n"
            L"Click the mouse button to roate the camera\n");

        g_pTxtHelper->SetInsertionPos(350, nBackBufferHeight - 20 * 5);
        g_pTxtHelper->DrawTextLine(L"Hide help: F1\n"
            L"Quit: ESC\n");
    }
    else
    {
        g_pTxtHelper->SetForegroundColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
        g_pTxtHelper->DrawTextLine(L"Press F1 for help");
    }

    g_pTxtHelper->End();
}
示例#6
0
void Gui::OnD3D11FrameRender( float fElapsedTime )
{
	hud.OnRender( fElapsedTime );
	sampleUI.OnRender( fElapsedTime );
	debugText->RenderSingleLine(DXUTGetFrameStats( DXUTIsVsyncEnabled() ), 5, 5, 1.0f, 1.0f, 0.0f);
	debugText->RenderSingleLine(DXUTGetDeviceStats(), 5, 20, 1.0f, 1.0f, 0.0f);
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text
//--------------------------------------------------------------------------------------
void RenderText()
{
    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 2, 0 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 0.0f, 0.6f, 0.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
    g_pTxtHelper->End();
}
示例#8
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 5, 5 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( true ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
    g_pTxtHelper->End();
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text
//--------------------------------------------------------------------------------------
void RenderText()
{
	g_pTxtHelper->Begin();
	g_pTxtHelper->SetInsertionPos(2, 0);
	g_pTxtHelper->SetForegroundColor(D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f));
	g_pTxtHelper->DrawTextLine(DXUTGetFrameStats(true));
//  g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
//	g_pTxtHelper->DrawFormattedTextLine( L"Pixel fill ratio: %f", g_vsObj->m_fillRatio );
	g_pTxtHelper->End();
}
示例#10
0
static void RenderText()
{
    CDXUTTextHelper txtHelper( g_pFont10, g_pSprite10, 15 );
    txtHelper.Begin();
    txtHelper.SetInsertionPos( 5, 5 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( DXUTGetFrameStats(true) );
    txtHelper.DrawTextLine( DXUTGetDeviceStats() );
	txtHelper.DrawTextLine( L"use W A S D Q E to move camera, uncheck MoveCamera and then use UP DOWN LEFT RIGHT R F to move light" );
    txtHelper.End();
}
示例#11
0
文件: CustomUI.cpp 项目: KNeal/Oculus
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos( 5, 5 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    txtHelper.DrawTextLine( DXUTGetDeviceStats() );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    txtHelper.DrawTextLine( L"Press ESC to quit" );
    txtHelper.End();
}
示例#12
0
//--------------------------------------------------------------------------------------
// Render the FPS and statistics text
//--------------------------------------------------------------------------------------
void RenderText( double fTime )
{
	// Output statistics
	g_pTxtHelper->Begin();
	g_pTxtHelper->SetInsertionPos( 2, 0 );
	g_pTxtHelper->SetForegroundColor( DirectX::Colors::White );
	g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
	g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );

	g_pTxtHelper->SetForegroundColor( DirectX::Colors::White );
	g_pTxtHelper->DrawFormattedTextLine( L"Particles: %i", FLUID->Size() );
	g_pTxtHelper->DrawFormattedTextLine( L"Step: %i", FLUID->Step() );

	g_pTxtHelper->End();
}
示例#13
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
	static WCHAR buffer[255];
    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos(5, 5);
    txtHelper.SetForegroundColor(D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ));
    txtHelper.DrawTextLine(DXUTGetFrameStats(true));
    txtHelper.DrawTextLine(DXUTGetDeviceStats());
//	swprintf_s(buffer, 256, L"window I= %d, J= %d", g_CurrPatch.GetI(), g_CurrPatch.GetJ());
//	txtHelper.DrawTextLine(buffer);
    txtHelper.End();
}
示例#14
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText(double fTime)
{
	// The helper object simply helps keep track of text position, and color
	// and then it calls pFont->DrawText(m_pSprite, strMsg, -1, &rc, DT_NOCLIP, m_clr);
	// If NULL is passed in as the sprite object, then it will work fine however the 
	// pFont->DrawText() will not be batched together.  Batching calls will improves perf.
	CDXUTTextHelper txtHelper(g_pFont, g_pSprite, 15);

	// Output statistics
	txtHelper.Begin();
	txtHelper.SetInsertionPos(2, 0);
	txtHelper.SetForegroundColor(D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f));
	txtHelper.DrawTextLine(DXUTGetFrameStats(DXUTIsVsyncEnabled()));
	txtHelper.End();
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 5, 5 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );

    WCHAR strText[200];

    const ResidencyStats& RS = g_pTitleResidencyManager->GetStats();
    swprintf_s( strText, L"Tile Tracker: %d tracked, %d loaded, %d queued for load, %d unused, %d loader threads%s", RS.NumTilesTracked, RS.NumTilesLoaded, RS.NumTilesQueuedForLoad, RS.NumTilesUnused, RS.LoaderThreadCount, RS.OutOfPhysicalTiles ? L", out of physical pages" : L"" );
    g_pTxtHelper->DrawTextLine( strText );

    D3D11_TILED_MEMORY_USAGE MemUsage;
    g_pTilePool->GetMemoryUsage( &MemUsage );
    swprintf_s( strText, L"%u resources, %0.3f GB resource VA space, %0.3f MB resource video mem, %d tile pools, %0.1f MB page video mem", 
        MemUsage.ResourceCount,
        (DOUBLE)MemUsage.ResourceVirtualBytesAllocated / (1073741824.0),
        (DOUBLE)MemUsage.ResourceTextureMemoryBytesAllocated / (1048576.0),
        MemUsage.FormatPoolsActive,
        (DOUBLE)MemUsage.TileTextureMemoryBytesAllocated / (1048576.0) );
    g_pTxtHelper->DrawTextLine( strText );

    if( g_pInspectionTexture != NULL )
    {
        D3D11_TILED_TEXTURE2D_DESC TexDesc;
        g_pInspectionTexture->GetDesc( &TexDesc );

        swprintf_s( strText, L"Tiled texture: format %S width %d height %d mip levels %d array size %d quilt width %d quilt height %d",
            TiledRuntimeTest::GetFormatName( TexDesc.Format ),
            TexDesc.Width,
            TexDesc.Height,
            TexDesc.MipLevels,
            TexDesc.ArraySize,
            TexDesc.QuiltWidth,
            TexDesc.QuiltHeight );

        g_pTxtHelper->DrawTextLine( strText );
    }

    if( g_bDrawTerrain && !g_pTerrainView->IsLoaded() )
    {
        g_pTxtHelper->DrawTextLine( L"Missing content for terrain view.  Please ensure s_diffuse.sp, s_heightmap.sp, and s_normalmap.sp are in the working directory." );
    }

    g_pTxtHelper->End();
}
示例#16
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    // The helper object simply helps keep track of text position, and color
    // and then it calls pFont->DrawText( m_pSprite, strMsg, -1, &rc, DT_NOCLIP, m_clr );
    // If NULL is passed in as the sprite object, then it will work however the 
    // pFont->DrawText() will not be batched together.  Batching calls will improves performance.
    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos( 5, 5 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    txtHelper.DrawTextLine( DXUTGetDeviceStats() );

    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    txtHelper.DrawTextLine( g_strFileSaveMessage );

    // Draw help
    if( g_bShowHelp )
    {
        const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetD3D9BackBufferSurfaceDesc();
        txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height - 15 * 5 );
        txtHelper.SetForegroundColor( D3DCOLOR_ARGB( 200, 50, 50, 50 ) );
        txtHelper.DrawTextLine( L"Controls (F1 to hide):" );

        txtHelper.SetInsertionPos( 20, pd3dsdBackBuffer->Height - 15 * 4 );
        txtHelper.DrawTextLine( L"Rotate model: Left mouse button\n"
                                L"Rotate camera: Right mouse button\n"
                                L"Zoom camera: Mouse wheel scroll\n" );

        txtHelper.SetInsertionPos( 250, pd3dsdBackBuffer->Height - 15 * 4 );
        txtHelper.DrawTextLine( L"Hide help: F1\n" );
        txtHelper.DrawTextLine( L"Quit: ESC\n" );
    }
    else
    {
        txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        txtHelper.DrawTextLine( L"Press F1 for help" );
    }

    txtHelper.End();
}
示例#17
0
void HUD::draw(ID3D11Device* graphicsDevice, Game* game)
{
	dialog.OnRender(DXUTGetElapsedTime());

	if (!textVisible)
		return;

	Terrain* terrain = game->terrain;

	textHelper.Begin();

	textHelper.SetInsertionPos(5, 5);
	textHelper.SetForegroundColor(D3DXCOLOR(1, 1, 0, 1));
	textHelper.DrawFormattedTextLine(DXUTGetFrameStats(true));
	textHelper.DrawFormattedTextLine(DXUTGetDeviceStats());
	textHelper.DrawFormattedTextLine(L"Terrain Resolution: %d x %d", terrain->getWidth(), terrain->getLength());
	textHelper.DrawFormattedTextLine(L"Node Size: %d x %d", terrain->getNodeSize(), terrain->getNodeSize());

	textHelper.End();
}
示例#18
0
//--------------------------------------------------------------------------------------
// Render text part of the GUI
//--------------------------------------------------------------------------------------
void RenderText()
{
    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 2, 0 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 0.0f, 1.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
    g_pTxtHelper->DrawTextLine( L"'G' key toggles display of GUI" );

    g_pTxtHelper->End();
 
    if( g_pScenePS == NULL )
    {
        g_pTxtHelper1->Begin();
        g_pTxtHelper1->SetInsertionPos( ( DXUTGetDXGIBackBufferSurfaceDesc()->Width - 300 )/2,
                                          DXUTGetDXGIBackBufferSurfaceDesc()->Height / 2 );
        g_pTxtHelper1->SetForegroundColor( D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ) );
        g_pTxtHelper1->DrawTextLine( L"Compiling shaders ..." );
        g_pTxtHelper1->End();
    }
 }
示例#19
0
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    // The helper object simply helps keep track of text position, and color
    // and then it calls pFont->DrawText( m_pSprite, strMsg, -1, &rc, DT_NOCLIP, m_clr );
    // If NULL is passed in as the sprite object, then it will work however the 
    // pFont->DrawText() will not be batched together.  Batching calls will improves performance.
    const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetD3D9BackBufferSurfaceDesc();
    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );

    // Output statistics
    txtHelper.Begin();
    txtHelper.SetInsertionPos( 5, 5 );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    txtHelper.DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    txtHelper.DrawTextLine( DXUTGetDeviceStats() );

    // Draw help
    if( g_bShowHelp )
    {
        txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height - 15 * 8 );
        txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) );
        txtHelper.DrawTextLine( L"Controls (F1 to hide):" );

        txtHelper.SetInsertionPos( 40, pd3dsdBackBuffer->Height - 15 * 7 );
        txtHelper.DrawTextLine( L"Rotate Model: Left Mouse" );
        txtHelper.DrawTextLine( L"Rotate Light: Middle Mouse" );
        txtHelper.DrawTextLine( L"Rotate Camera and Model: Right Mouse" );
        txtHelper.DrawTextLine( L"Rotate Camera: Ctrl + Right Mouse" );
        txtHelper.DrawTextLine( L"Wireframe: W" );
        txtHelper.DrawTextLine( L"Quit: ESC" );
    }
    else
    {
        txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height - 15 * 2 );
        txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        txtHelper.DrawTextLine( L"Press F1 for help" );
    }
    txtHelper.End();
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text. This function uses the ID3DXFont interface for 
// efficient text rendering.
//--------------------------------------------------------------------------------------
void RenderText()
{
    // Output statistics
    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 5, 5 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );

    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( g_strFileSaveMessage );

    // Draw help
    if( g_bShowHelp )
    {
        UINT nBackBufferHeight = DXUTGetDXGIBackBufferSurfaceDesc()->Height;
        g_pTxtHelper->SetInsertionPos( 10, nBackBufferHeight - 15 * 5 );
        g_pTxtHelper->SetForegroundColor( D3DCOLOR_ARGB( 200, 150, 150, 150 ) );
        g_pTxtHelper->DrawTextLine( L"Controls (F1 to hide):" );

        g_pTxtHelper->SetInsertionPos( 20, nBackBufferHeight - 15 * 4 );
        g_pTxtHelper->DrawTextLine( L"Rotate model: Left mouse button\n"
                                    L"Rotate camera: Right mouse button\n"
                                    L"Zoom camera: Mouse wheel scroll\n" );

        g_pTxtHelper->SetInsertionPos( 250, nBackBufferHeight - 15 * 4 );
        g_pTxtHelper->DrawTextLine( L"Hide help: F1\n" );
        g_pTxtHelper->DrawTextLine( L"Quit: ESC\n" );
    }
    else
    {
        g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        g_pTxtHelper->DrawTextLine( L"Press F1 for help" );
    }

    g_pTxtHelper->End();
}
//--------------------------------------------------------------------------------------
// Render the help and statistics text
//--------------------------------------------------------------------------------------
void RenderText()
{
    UINT nBackBufferHeight = ( DXUTIsAppRenderingWithD3D9() ) ? DXUTGetD3D9BackBufferSurfaceDesc()->Height :
            DXUTGetDXGIBackBufferSurfaceDesc()->Height;

    g_pTxtHelper->Begin();
    g_pTxtHelper->SetInsertionPos( 2, 0 );
    g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
    g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
    g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );

    // Draw help
    if( g_bShowHelp )
    {
        g_pTxtHelper->SetInsertionPos( 2, nBackBufferHeight - 20 * 6 );
        g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) );
        g_pTxtHelper->DrawTextLine( L"Controls:" );

        g_pTxtHelper->SetInsertionPos( 20, nBackBufferHeight - 20 * 5 );
        g_pTxtHelper->DrawTextLine( L"Rotate model: Left mouse button\n"
                                    L"Rotate light: Right mouse button\n"
                                    L"Rotate camera: Middle mouse button\n"
                                    L"Zoom camera: Mouse wheel scroll\n" );

        g_pTxtHelper->SetInsertionPos( 550, nBackBufferHeight - 20 * 5 );
        g_pTxtHelper->DrawTextLine( L"Hide help: F1\n"
                                    L"Quit: ESC\n" );
    }
    else
    {
        g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        g_pTxtHelper->DrawTextLine( L"Press F1 for help" );
    }

    g_pTxtHelper->End();
}
//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
	// If the settings dialog is being shown, then render it instead of rendering the app's scene
	if( g_SettingsDlg.IsActive() )
	{
		g_SettingsDlg.OnRender( fElapsedTime );
		return;
	}

	HRESULT hr;

	// Clear the render target and the zbuffer 
	V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x8dadd4, 1.0f, 0 ) );

	// Render the scene
	if( SUCCEEDED( pd3dDevice->BeginScene() ) )
	{
		freeCamera.Update( fElapsedTime );
		D3DXMATRIXA16 mtxView = freeCamera.GetView();

		// Get back buffer description and determine aspect ratio
		const D3DSURFACE_DESC* pBackBufferSurfaceDesc = DXUTGetD3D9BackBufferSurfaceDesc();
		float Width = (float)pBackBufferSurfaceDesc->Width;
		float Height = (float)pBackBufferSurfaceDesc->Height;
		float fAspectRatio = Width / Height;

		float fovHorizontal = D3DX_PI / 4.0f;
		float nearZ = 0.05f;
		float farZ = 500.0f;

		D3DXMATRIXA16 mtxProj;
		D3DXMatrixPerspectiveFovLH( &mtxProj, fovHorizontal, fAspectRatio, nearZ, farZ );

		// Convert projection matrix to right handed coordinate system
		D3DXMATRIX mtxMirror;
		D3DXMatrixScaling(&mtxMirror, -1.0, 1.0, 1.0);
		D3DXMatrixMultiply( &mtxProj, &mtxMirror, &mtxProj);

		// Build view projection matrix
		D3DXMATRIX mtxViewProj;
		D3DXMatrixMultiply( &mtxViewProj, &mtxView, &mtxProj );

		d3dFloor.Draw(mtxViewProj);
		d3dMesh.Draw(mtxViewProj, freeCamera.GetForward(), fElapsedTime);

		g_pTxtHelper->Begin();
		g_pTxtHelper->SetInsertionPos( 5, 5 );
		g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
		g_pTxtHelper->DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
		g_pTxtHelper->DrawTextLine( DXUTGetDeviceStats() );
		
		g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 0.9f, 0.0f, 1.0f ) );

		float frameTimeMs = DXUTGetElapsedTime() * 1000.0f;




		g_pTxtHelper->DrawFormattedTextLine(L"\n\n"
			L"Frame time : %3.2f ms\n\n"
			L"Navigation:\n"
			L" Click and Hold Right Mouse Button (RMB) and move the mouse to look around\n"
			L" As you hold Right Mouse Button (RMB) use the W A S D to movement", frameTimeMs);

		g_pTxtHelper->SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
		g_pTxtHelper->SetInsertionPos((int)Width - 350, 10);

		if (g_DisableSkining)
		{
			if (g_TechniqueIndex == 0)
			{
				g_pTxtHelper->DrawTextLine (L"Vertex size 56 bytes\n\n"
					L"struct Vertex\n"
					L"{\n"
					L"   float3 pos;\n"
					L"   float2 uv;\n"
					L"   float3 tangent;\n"
					L"   float3 normal;\n"
					L"   float3 binormal;\n"
					L"};\n");
			} else
			{
				if (g_TechniqueIndex == 1)
				{
					g_pTxtHelper->DrawTextLine (L"Vertex size 28 bytes\n\n"
						L"struct Vertex\n"
						L"{\n"
						L"   float3 pos;\n"
						L"   short2 uv;\n"
						L"   ubyte4 tangent;\n"
						L"   ubyte4 normal;\n"
						L"   ubyte4 binormal;\n"
						L"};\n");
				} else
				{
					if (g_TechniqueIndex == 2)
					{
						g_pTxtHelper->DrawTextLine (L"Vertex size 32 bytes\n\n"
							L"struct Vertex\n"
							L"{\n"
							L"   float3 pos;\n"
							L"   short2 uv;\n"
							L"   float4 tbn;\n"
							L"};\n");
					} else
					{
						if (g_TechniqueIndex == 3)
						{
							g_pTxtHelper->DrawTextLine (L"Vertex size 20 bytes\n\n"
								L"struct Vertex\n"
								L"{\n"
								L"   float3 pos;\n"
								L"   short2 uv;\n"
								L"   ubyte4 tbn;\n"
								L"};\n");
						}
					}
				}
			}
		} else
		{
			if (g_TechniqueIndex == 0)
			{
				g_pTxtHelper->DrawTextLine (L"Vertex size 76 bytes\n\n"
					L"struct Vertex\n"
					L"{\n"
					L"   float3 pos;\n"
					L"   float2 uv;\n"
					L"   float3 tangent;\n"
					L"   float3 normal;\n"
					L"   float3 binormal;\n"
					L"   float4 weights;\n"
					L"   ubyte4 indices;\n"
					L"};\n");
			} else
			{
				if (g_TechniqueIndex == 1)
				{
					g_pTxtHelper->DrawTextLine (L"Vertex size 40 bytes\n\n"
						L"struct Vertex\n"
						L"{\n"
						L"   float3 pos;\n"
						L"   short2 uv;\n"
						L"   ubyte4 tangent;\n"
						L"   ubyte4 normal;\n"
						L"   ubyte4 binormal;\n"
						L"   short4 weights;\n"
						L"   ubyte4 indices;\n"
						L"};\n");
				} else
				{
					if (g_TechniqueIndex == 2)
					{
						g_pTxtHelper->DrawTextLine (L"Vertex size 44 bytes\n\n"
							L"struct Vertex\n"
							L"{\n"
							L"   float3 pos;\n"
							L"   short2 uv;\n"
							L"   float4 tbn;\n"
							L"   short4 weights;\n"
							L"   ubyte4 indices;\n"
							L"};\n");
					} else
					{
						if (g_TechniqueIndex == 3)
						{
							g_pTxtHelper->DrawTextLine (L"Vertex size 32 bytes\n\n"
								L"struct Vertex\n"
								L"{\n"
								L"   float3 pos;\n"
								L"   short2 uv;\n"
								L"   ubyte4 tbn;\n"
								L"   short4 weights;\n"
								L"   ubyte4 indices;\n"
								L"};\n");
						}
					}
				}
			}
		}


		g_pTxtHelper->End();

		V( g_HUD.OnRender( fElapsedTime ) );
		V( g_SampleUI.OnRender( fElapsedTime ) );
		V( pd3dDevice->EndScene() );
	}
}
示例#23
0
文件: main.cpp 项目: NickABoen/Awe
void CALLBACK OnD3D11FrameRender(ID3D11Device* d3dDevice, ID3D11DeviceContext* d3dDeviceContext, double time,
                                 float elapsedTime, void* userContext)
{
	D3DXVECTOR3 cubePos;

    if (gZeroNextFrameTime) {
        elapsedTime = 0.0f;
    }
    gZeroNextFrameTime = false;

    if (gD3DSettingsDlg.IsActive()) {
        gD3DSettingsDlg.OnRender(elapsedTime);
        return;
    }

    // Lazily create the application if need be
    if (!gApp) {
        InitApp(d3dDevice);
    }

    // Lazily load scene
	/*!gMeshOpaque.IsLoaded() && !gMeshAlpha.IsLoaded() &&!gMeshOpaque2.IsLoaded()*/
    if (!sceneGraph.IsLoaded()) {
        InitScene(d3dDevice);
    }
	if(PXEngine)
	{
		for(int i = 0; i < cubeList->size(); i++)
		PXEngine->StepPhysX();
		if(cubeList)
		{
			for(int i = 0; i < cubeList->size(); i++)
			{
				if((*cubeList)[i]->id<0)
				{
					sceneGraph.SetInstancePosition(1,(*cubeList)[i]->id, (*cubeList)[i]->x, (*cubeList)[i]->y, (*cubeList)[i]->z);
				}
				else
				{
					sceneGraph.SetMeshPosition(0,(*cubeList)[i]->id, (*cubeList)[i]->x, (*cubeList)[i]->y, (*cubeList)[i]->z);
				}
			}
		}
	}

	//crosshair
	D3DRECT rec2 = {screenCenterX-20, screenCenterY, screenCenterX + 20, screenCenterY + 2};
	D3DRECT rec3 = {screenCenterX, screenCenterY - 20, screenCenterX + 2, screenCenterY + 20};

    ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
	
    
    D3D11_VIEWPORT viewport;
    viewport.Width    = static_cast<float>(DXUTGetDXGIBackBufferSurfaceDesc()->Width);
    viewport.Height   = static_cast<float>(DXUTGetDXGIBackBufferSurfaceDesc()->Height);
    viewport.MinDepth = 0.0f;
    viewport.MaxDepth = 1.0f;
    viewport.TopLeftX = 0.0f;
    viewport.TopLeftY = 0.0f;
	screenCenterX = viewport.Width / 2;
	screenCenterY = viewport.Height / 2;

	gViewPort.Width = viewport.Width;
	gViewPort.Height = viewport.Height;
	gViewPort.MaxZ = viewport.MaxDepth;
	gViewPort.MinZ = viewport.MinDepth;
	gViewPort.X = viewport.TopLeftX;
	gViewPort.Y = viewport.TopLeftY;


		 gApp->Render(d3dDeviceContext, pRTV, sceneGraph, gSkyboxSRV,
        gWorldMatrix, &gViewerCamera, &viewport, &gUIConstants);
	
		 
		 sceneGraph.SetMeshPosition(0,1, 100000, 100000, 100000);
    if (gDisplayUI) {
        d3dDeviceContext->RSSetViewports(1, &viewport);

        // Render HUDs in reverse order
        d3dDeviceContext->OMSetRenderTargets(1, &pRTV, 0);
        for (int i = HUD_NUM - 1; i >= 0; --i) {
            gHUD[i].OnRender(elapsedTime);
        }

        // Render text
        gTextHelper->Begin();

        gTextHelper->SetInsertionPos(2, 0);
        gTextHelper->SetForegroundColor(D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f));
        gTextHelper->DrawTextLine(DXUTGetFrameStats(DXUTIsVsyncEnabled()));
        //gTextHelper->DrawTextLine(DXUTGetDeviceStats());

        // Output frame time
        {
            std::wostringstream oss;
            oss << 1000.0f / DXUTGetFPS() << " ms / frame";
            gTextHelper->DrawTextLine(oss.str().c_str());
        }

        // Output light info
        {
            std::wostringstream oss;
            oss << "Lights: " << gApp->GetActiveLights();
            gTextHelper->DrawTextLine(oss.str().c_str());
        }
        
        gTextHelper->End();
    }
	
}