游戏中的其他地方使用TextOutA来输出串的,可是游戏中却不是用TextOutA,会是用DX提供的函数么?请指教

解决方案 »

  1.   

    ID3DXFont::DrawText()可以输出文字。
      

  2.   

    DX中要首先创建字体ID3DXFont,然后使用ID3DXFont::DrawText()输出文字!
      

  3.   

    void RenderText()
    {
        CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );    //显示当前Direct3D设备状态和渲染帧速率
        txtHelper.Begin();
        txtHelper.SetInsertionPos( 5, 5 );
        txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
        txtHelper.DrawTextLine( DXUTGetFrameStats(true) );
        txtHelper.DrawTextLine( DXUTGetDeviceStats() ); //显示其他简要信息
        txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
        txtHelper.DrawTextLine( L"Put whatever misc status here" );
        
        //显示简单帮助文本
        const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetBackBufferSurfaceDesc();
        if( g_bShowHelp )
        {
            txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height-15*6 );
            txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) );
            txtHelper.DrawTextLine( L"Controls (F1 to hide):" );        txtHelper.SetInsertionPos( 40, pd3dsdBackBuffer->Height-15*5 );
            txtHelper.DrawTextLine( L"Quit: ESC" );
        }
        else
        {
            txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height-15*2 );
            txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
            txtHelper.DrawTextLine( L"Press F1 for help" );
        }
        txtHelper.End();
    }
     V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
                                  OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                                  L"Arial", &g_pFont ) );
    用D3DXCreateFont预先创建一个g_pFont ,把RenderText()放到BeginScene() 和EndScene()之间就可以了
      

  4.   

    我感觉是通过这个函数D3DXCreateTexture来输出透明文字的(游戏中的就是透明的),我想HOOK掉这个函数,来输出中文,就是编译时老是报错
    文件开头是这样引用的
    #include <stdio.h>
    #include <windows.h>
    #include <Dbghelp.h>
    #include "d3dx9shape.h"
    #include "D3dx9tex.h"
    #pragma comment(lib,"Dbghelp.lib")
    #pragma comment(lib,"User32.lib")
    #pragma comment(lib,"d3dx9.lib")
    #pragma comment(lib,"d3d9.lib")



    D3DXCreateTexture



    报出 fatal error LNK1120: 1 个无法解析的外部命令,我感觉好像是引用.LIB文件的问题
    请指教
      

  5.   

    WINDBG就对这个函数有反应,其他的向DrawText等都没有反应,它会不会把文字写在了纹理上了?谢谢了
      

  6.   

    ID3DXSprite 
    D3DXCreateSprite() 
    Draw()把字体当精灵来画?
      

  7.   


    dx9.0,要用VC6编译.void LHxxCREATE_FONT(LPD3DXFONT &m_pFont_china,int fsize,char *name)
    {
    HDC hDC = GetDC( NULL );
        ReleaseDC( NULL, hDC );
      D3DXCreateFont( m_pd3dDevice,          // D3D device
                            fsize,               // Height
                             0,                     // Width
                             0,               // Weight 0 FW_BOLD
                             0,                     // MipLevels, 0 = autogen mipmaps
                             FALSE,                 // Italic
                             DEFAULT_CHARSET,       // CharSet
                             OUT_DEFAULT_PRECIS,    // OutputPrecision
                             DEFAULT_QUALITY,       // Quality
                             DEFAULT_PITCH | FF_SWISS, // PitchAndFamily FF_SWISS FF_DONTCARE
                             TEXT(name),              // pFaceName TEXT("Arial")黑体
                             &m_pFont_china);              // ppFont
          // Restore the fonts
        m_pFont_china->OnResetDevice();
    }void LHxxFREE_FONT(LPD3DXFONT &m_pFont_china)
    {
      if(m_pFont_china)
      {SAFE_DELETE( m_pFont_china );}
    }void LHxxSHOW_CHINATEXT(char *buf,int x,int y,LPD3DXFONT &m_pFont_china,float r,float g,float b)
    {
    RECT rc;SetRect( &rc, x, y, 0, 0 );
    m_pFont_china->DrawText( NULL,buf, -1, &rc, DT_NOCLIP, D3DXCOLOR( r, g, b, 1.0f ));
    // Draw_Text_GDI_WIN(C_input_name,0,0,RGB(255,255,0),SAVE_HWND);
    }//use
    _stprintf(Ibuf,"Tfolat[0]:%.2f,Tfolat[1]:%.2f,Tfolat[2]:%.2f",FRole.Tfolat[0],FRole.Tfolat[1],FRole.Tfolat[2]);
    LHxxSHOW_CHINATEXT(Ibuf,0,40,myfont1,1,1,1);
      

  8.   

    我是想HOOK 住游戏中使用的输出文字的函数,上面的代码中的函数都测试过了,不行。。