XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Problem with Drawing Text

Last post 03-03-2008 1:48 PM by Patrick Polzin. 2 replies.
  • 03-02-2008 12:50 PM

    Problem with Drawing Text

    I am trying to get my program to draw text to the screen, but for whatever reason it doesn't draw it even though none of the functions that I use actually fail. Here is my code in the while loop of my program:

     

    1
    2
    3
    4
    5
    6
    7
    8
    float color[] = { 0.f, 0.125f, 0.6f, 1.f };
    dx10Device->ClearRenderTargetView(renderView, color);
    swapChain->Present(0, 0);

    HRESULT hr;
    RECT rc;
    SetRect(&rc, 0, 0, 640, 480);
    hr = someFont->DrawTextA(NULL, "hello", 5, &rc, DT_CENTER
        | DT_VCENTER, D3DXCOLOR(0.f, 0.125f, 0.f, 1.f));

     

    And here is my code to create the font:

    1
    2
    3
    4
    5
    6
    HRESULT hr;

    hr = D3DX10CreateFontA(dx10Device, 30, 0, FW_NORMAL, 1, true, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
          DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &someFont);
        if( FAILED(hr) )
          MessageBoxA(NULL, "D3DX10CreateFontA failed", "Error",
    MB_OK);
     
    Any ideas?
  • 03-03-2008 1:48 PM In reply to

    Re: Problem with Drawing Text

    1
    2
    3
    4
    5
    6
    7
    8
    float color[] = { 0.f, 0.125f, 0.6f, 1.0f };
    dx10Device->ClearRenderTargetView(renderView, color);
    swapChain->Present(0, 0);

    HRESULT hr;
    RECT rc;
    SetRect(&rc, 0, 0, 640, 480);
    hr = someFont->DrawTextA(NULL, "hello", 5, &rc, DT_CENTER|DT_VCENTER, D3DXCOLOR(0.f, 0.125f, 0.0f, 1.0f));

    Are you sure to
    1. Present the scene before drawing text?
    2. Set the color of the text equal not for reading (bad color mean to back buffer)?
    Nice greets,
    Patrick Polzin

  • 03-03-2008 1:48 PM In reply to

    Re: Problem with Drawing Text

    1
    2
    3
    4
    5
    6
    7
    8
    float color[] = { 0.f, 0.125f, 0.6f, 1.0f };
    dx10Device->ClearRenderTargetView(renderView, color);
    swapChain->Present(0, 0);

    HRESULT hr;
    RECT rc;
    SetRect(&rc, 0, 0, 640, 480);
    hr = someFont->DrawTextA(NULL, "hello", 5, &rc, DT_CENTER|DT_VCENTER, D3DXCOLOR(0.f, 0.125f, 0.0f, 1.0f));

    Are you sure to
    1. Present the scene before drawing text?
    2. Set the color of the text equal not for reading (bad color mean to back buffer)?
    Nice greets,
    Patrick Polzin

Page 1 of 1 (3 items) Previous Next