|
|
我用D3DXCreateText函数创造了一个3D字体的mesh,想要模拟windows自带的哪个3D字体的屏保的效果,程序没报错,运行起来却什么都没有显示,请高人指点。(矩阵变换也设置了)
程序代码: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-> resent( NULL, NULL, NULL, NULL );
}
lf是我定义的一个LOGFONT
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 );
} |
|