Exemple #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();
}
//--------------------------------------------------------------------------------------
// 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();
}
Exemple #3
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);
}
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();
}
Exemple #5
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();
}
//--------------------------------------------------------------------------------------
// 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();
}
Exemple #7
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();
}
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();
}
Exemple #9
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 ) );
    txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    txtHelper.DrawTextLine( L"Press ESC to quit" );
    txtHelper.End();
}
Exemple #10
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();
}
Exemple #11
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();
}
//--------------------------------------------------------------------------------------
// 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();
}
Exemple #13
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();
}
Exemple #14
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();
}
//--------------------------------------------------------------------------------------
// 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();
    }
 }
Exemple #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.
    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();
}
    void DrawText()
    {
        g_pTxtHelper->Begin();

        g_pTxtHelper->SetInsertionPos(5, 5);
        g_pTxtHelper->SetForegroundColor(D3DXCOLOR(0.f, 0.f, 0.f, 1.f));

        g_pTxtHelper->DrawTextLine(DXUTGetDeviceStats());
        g_pTxtHelper->DrawFormattedTextLine(L"FPS: %.1f, VSync: %s" , DXUTGetFPS(), !DXUTIsVsyncEnabled() ? L"On" : L"Off");
        g_pTxtHelper->DrawFormattedTextLine(L"AO Resolution: %d x %d", g_BackBufferWidth, g_BackBufferHeight);
        g_pTxtHelper->DrawFormattedTextLine(L"Allocated Video Memory: %d MB\n", g_AORenderer.GetAllocatedVideoMemoryBytes() / (1024*1024));

        g_pTxtHelper->DrawFormattedTextLine(L"GPU Times Per Frame (ms):");
        g_pTxtHelper->DrawFormattedTextLine(L"  RenderAO: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_TOTAL));
        g_pTxtHelper->DrawFormattedTextLine(L"    LinearZ: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_LINEAR_Z));
        g_pTxtHelper->DrawFormattedTextLine(L"    DeinterleaveZ: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_DEINTERLEAVE_Z));
        g_pTxtHelper->DrawFormattedTextLine(L"    ReconstructN: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_RECONSTRUCT_NORMAL));
        g_pTxtHelper->DrawFormattedTextLine(L"    GenerateAO: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_GENERATE_AO));
        g_pTxtHelper->DrawFormattedTextLine(L"    ReinterleaveAO: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_REINTERLEAVE_AO));
        g_pTxtHelper->DrawFormattedTextLine(L"    BlurX: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_BLURX));
        g_pTxtHelper->DrawFormattedTextLine(L"    BlurY: %.2f", g_AORenderer.GetGPUTimeInMS(GPU_TIME_BLURY));

        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() );
	}
}