读书人

为啥字打印不出来呢

发布时间: 2013-01-11 11:57:35 作者: rapoo

为什么字打印不出来呢?


#include "DXUT.h"
#include "windows.h"
#include "Ctrl.h"

bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed,
void* pUserContext );
bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext );
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext );
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext );
void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext );
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing,
void* pUserContext );
void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
void CALLBACK OnLostDevice( void* pUserContext );
void CALLBACK OnDestroyDevice( void* pUserContext );

void First( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,BYTE ID );
void F1( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,BYTE ID );
void ScreenPro( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,BYTE ID );

LPD3DXFONT ObjFont;

INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

// DXUT will create and use the best device (either D3D9 or D3D10)
// that is available on the system depending on which D3D callbacks are set below

// Set DXUT callbacks
//DXUTSetCallbackD3D9DeviceAcceptable( IsDeviceAcceptable );
DXUTSetCallbackD3D9DeviceCreated( OnCreateDevice );
DXUTSetCallbackD3D9DeviceReset( OnResetDevice );
DXUTSetCallbackD3D9FrameRender( OnFrameRender );


DXUTSetCallbackD3D9DeviceLost( OnLostDevice );
DXUTSetCallbackD3D9DeviceDestroyed( OnDestroyDevice );
DXUTSetCallbackKeyboard( KeyboardProc );
DXUTSetCallbackFrameMove( OnFrameMove );
//DXUTSetCallbackDeviceChanging( ModifyDeviceSettings );

//DXUTSetCursorSettings( true, true );

DXUTInit( true, true ); // Parse the command line and show msgboxes
//DXUTSetHotkeyHandling( true, true, true );
DXUTCreateWindow( L"UIControl" );
DXUTCreateDevice( true, 640, 480 );


DXUTMainLoop();

return DXUTGetExitCode();

}

bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext )
{
return true;
}
bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext )
{
return true;
}
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,void* pUserContext )
{

D3DXCreateFont (pd3dDevice,0,0,0,false,0,0,0,0,0,L"Arial",&ObjFont);

DXUTSetCallbackMsgProc( MsgProc );
/****************************************************************************/
return 0;
}
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,void* pUserContext )
{
return 0;
}

void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
pd3dDevice->Clear ( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 255, 0, 0, 0 ), 1.0f, 0 );
pd3dDevice->BeginScene();

LPCTSTR S = L"test";
RECT r = {10,10,0,0};

ObjFont->DrawTextW(NULL, S,-1,&r,DT_LEFT | DT_TOP,D3DCOLOR_ARGB( 255, 255, 255, 255 ));

pd3dDevice->EndScene();

}
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing,void* pUserContext )
{

//MyCtrl.MsgProcess ( hWnd, uMsg, wParam, lParam);
return 0;
}


[解决办法]
应该是你那个font有问题吧!
[解决办法]
RECT r = {10,10,0,0};
改大点,比如:
RECT r = {10,10,200,200};

读书人网 >网络游戏

热点推荐