Problems with D3DXCreateText
I'm trying to use D3DXCreateText to create a 3D text,just like the screen saver brought by windows,there's no error,but it displays nothing,please help.(Matrices are set)
VOID Render()
{
HDC hdc;
hdc = CreateCompatibleDC(0);
HFONT hfont;
HFONT hfontold;
hfont = CreateFontIndirect(&lf);
hfontold = (HFONT)SelectObject(hdc,hfont);
if( NULL == g_pd3dDevice )
return;
// Clear the backbuffer to a blue color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
D3DXCreateText(g_pd3dDevice, hdc,"Dai Bi Dai Si", 0.01f
,0.4f,&text,0,0);
text->DrawSubset(0);
// Rendering of scene objects can happen here
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
VOID SetupMatrices()
{
UINT iTime = timeGetTime() % 1000;
FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f;
D3DXMatrixRotationY( &matWorld, fAngle );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
When you say 'no error', do you mean from the compiler/executable or from the DX debug runtimes? If you use the DX debug runtimes you can get much more specific error messages for problems like this that don't necessarily halt execution. If you're getting no error messages this way either, then perhaps somebody can spot an error in the camera setup/clipping planes or sizing that might prevent the objects from being visible.
Quote:Original post by plum
the compiler says no error but what i expect is not displayed
The most likely thing I see is that you're nto clearing your Z-buffer.
Are you using the debug runtimes? Any relevant debug output?
How do you know the matrices are correct?
yeah i'm using the debug runtimes, visual c++
it says 0 error 0 warning
when the program is running , only the background is displayed, the 3D text did not appear. the matrices are right because it works well with some other mesh
it says 0 error 0 warning
when the program is running , only the background is displayed, the 3D text did not appear. the matrices are right because it works well with some other mesh
Quote:Original post by plumEven though you're not clearing the Z-buffer? Or is your actual code different from what you posted? Do you get any D3D output in the debug window? E.g. "(D3D) INFO: Using HAL Device" or anything similar? If not, then you don't have the debug runtimes set up correctly.
yeah i'm using the debug runtimes, visual c++
it says 0 error 0 warning
when the program is running , only the background is displayed, the 3D text did not appear. the matrices are right because it works well with some other mesh
Is the other mesh the same size as the mesh generated by D3DXCreateText? You can tell by locking the vertex buffer and finding the extents of it (The bounding box). It's possible that the mesh is 1 unit cubed, and the text is 10000, or something similar.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement