Archived

This topic is now archived and is closed to further replies.

Jackbunny

Unhandled Exception CD3DFont::InitDeviceObjects

Recommended Posts

I'm attempting to use the CD3DFont class included with the DXSDK samples. It compiles and links fine, but I get an unhandled exception message when I try to run it. I'm really at a loss as to what to do. Please help. Alright here's part of the code.
HRESULT InitD3D( HWND hWnd )
{

    if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    D3DDISPLAYMODE d3ddm;
    if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
        return E_FAIL;

    D3DPRESENT_PARAMETERS d3dpp; 
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    // Create the D3DDevice

    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Turn on the zbuffer

    g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

    // Turn on ambient lighting 

    g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

	m_pFont->InitDeviceObjects( g_pd3dDevice );
    m_pStatsFont->InitDeviceObjects( g_pd3dDevice );

    return S_OK;
}

And here is the class
   

HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice )
{
    HRESULT hr;

    // Keep a local copy of the device

    m_pd3dDevice = pd3dDevice; //ERRORS HERE!!!


    // Establish the font and texture size

    m_fTextScale  = 1.0f; // If I comment out previous line it will error here as well

Thanks to anyone who helps. UPDATE: I got past this (stupid me was forgetting to set my font to a new font), but now it errors on the draw text. I know I've seen other people with this problem, so hopefully I'll get it. [edited by - jackbunny on July 25, 2003 6:22:46 PM]

Share this post


Link to post
Share on other sites