新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     >>计算机科学论坛<<     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论高级C/C++编程、代码重构(Refactoring)、极限编程(XP)、泛型编程等话题
    [返回] 计算机科学论坛计算机技术与应用『 C/C++编程思想 』 → Direct3D中的字体与文本显示 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 11463 个阅读者浏览上一篇主题  刷新本主题   平板显示贴子 浏览下一篇主题
     * 贴子主题: Direct3D中的字体与文本显示 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     卷积内核 帅哥哟,离线,有人找我吗?
      
      
      威望:8
      头衔:总统
      等级:博士二年级(版主)
      文章:3942
      积分:27590
      门派:XML.ORG.CN
      注册:2004/7/21

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给卷积内核发送一个短消息 把卷积内核加入好友 查看卷积内核的个人资料 搜索卷积内核在『 C/C++编程思想 』的所有贴子 访问卷积内核的主页 引用回复这个贴子 回复这个贴子 查看卷积内核的博客楼主
    发贴心情 Direct3D中的字体与文本显示

    图形系统中为了获得当前运行程序的相关信息,往往需要在屏幕上显示文本,Direct3D的功能扩展接口ID3DXFont对此提供了方便的解决方法。

    创建ID3DXFont对象

    使用接口ID3DXFont绘制文本,首先需要通过函数D3DXCreateFont()创建ID3DXFont字体对象。ID3DXFont接口封装了Windows字体和Direct3D设备指针,D3DXCreateFont()函数通过Windows字体和Direct3D设备指针创建ID3DXFont对象,该函数的声明如下:

    Creates a font object for a device and font.

    HRESULT D3DXCreateFont(  LPDIRECT3DDEVICE9 pDevice,  INT Height,  UINT Width,  UINT Weight,  UINT MipLevels,  BOOL Italic,  DWORD CharSet,  DWORD OutputPrecision,  DWORD Quality,  DWORD PitchAndFamily,  LPCTSTR pFacename,  LPD3DXFONT * ppFont);
    Parameters
    pDevice
    [in] Pointer to an IDirect3DDevice9 interface, the device to be associated with the font object.
    Height
    [in] The height of the characters in logical units.
    Width
    [in] The width of the characters in logical units.
    Weight
    [in] Typeface weight. One example is bold.
    MipLevels
    [in] The number of mipmap levels.
    Italic
    [in] True for italic font, false otherwise.
    CharSet
    [in] The character set of the font.
    OutputPrecision
    [in] Specifies how Windows should attempt to match the desired font sizes and characteristics with actual fonts. Use OUT_TT_ONLY_PRECIS for instance, to ensure that you always get a TrueType font.
    Quality
    [in] Specifies how Windows should match the desired font with a real font. It applies to raster fonts only and should not affect TrueType fonts.
    PitchAndFamily
    [in] Pitch and family index.
    pFacename
    [in] String containing the typeface name. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR. See Remarks.
    ppFont
    [out] Returns a pointer to an ID3DXFont interface, representing the created font object.
    Return Values
    If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

    Remarks
    The creation of an ID3DXFont object requires that the device supports 32-bit color.

    The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCreateFontW. Otherwise, the function call resolves to D3DXCreateFontA because ANSI strings are being used.

    If you want more information about font parameters, see The Logical Font.

    示例代码如下:

    D3DXCreateFont(g_device, 50, 20, 20, 0, FALSE, DEFAULT_CHARSET, 0, 0, 0, "Arial", &g_font);


       收藏   分享  
    顶(0)
      




    ----------------------------------------------
    事业是国家的,荣誉是单位的,成绩是领导的,工资是老婆的,财产是孩子的,错误是自己的。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/11/25 15:27:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 C/C++编程思想 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/20 20:08:55

    本主题贴数3,分页: [1]

     *树形目录 (最近20个回帖) 顶端 
    主题:  Direct3D中的字体与文本显示(2565字) - 卷积内核,2008年11月25日
        回复:  [B]ID3DXFont其他相关接口函数[/B]函数ID3DXFont::GetDevice(..(4873字) - 卷积内核,2008年11月25日
        回复:  使用ID3DXFont对象绘制二维文本创建了ID3DXFont对象后,就可以使用其接口函数ID..(4391字) - 卷积内核,2008年11月25日

    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    1,734.375ms