zoukankan      html  css  js  c++  java
  • 字体

    /************* ID3DXFont接口 *************/
    //创建一个ID3DXFont接口对象
    ID3DXFont* Font = 0;

    D3DXFONT_DESC df;
    ZeroMemory(
    &df, sizeof(D3DXFONT_DESC));
    df.Height
    = 25;
    df.Width
    = 12;
    df.Weight
    = 500;
    df.MipLevels
    = D3DX_DEFAULT;
    df.Italic
    = false;
    df.CharSet
    = DEFAULT_CHARSET;
    df.OutputPrecision
    = 0;
    df.Quality
    = 0;
    df.PitchAndFamily
    = 0;
    strcpy(df.FaceName,
    "Times New Rome");

    if(FAILED(D3DXCreateFontIndirect(Device, &df, &Font)))
    {
    ::MessageBox(
    0, "D3DXCreateFontIndirect() - FAILED", 0, 0);
    ::PostQuitMessage(
    0);
    }

    //绘制文本
    Device->BeginScene();

    RECT rect
    = {0, 0, width, heigth};
    Font
    ->DrawText(
    NULL,
    FPSString,
    -1,
    &rect,
    DT_TOP
    | DT_LEFT,
    0xffffffff);

    Device
    ->EndScene();

    //释放
    d3d::Release<ID3DXFont*>(Font);

    /************* CD3DFont类 *************/
    //使用此方法需要包含相应头文件
    //创建CD3DFont类实例
    CD3DFont* Font = 0;

    Font
    = new CD3DFont("Times New Roman", 16, 0);
    Font
    ->InitDeviceObjects( Device );
    Font
    ->RestoreDeviceObjects();

    //绘制
    if( Font )
    Font
    ->DrawText(20, 20, 0xff000000, FPSString);

    //释放
    if( Font )
    {
    Font
    ->InvalidateDeviceObjects();
    Font
    ->DeleteDeviceObjects();
    d3d::Delete
    <CD3DFont*>(Font);
    }

    /************* D3DXCreateText函数 *************/
    //用来存储所创建的3D文本的网格
    ID3DXMesh* Text = 0;

    LOGFONT lf;
    ZeroMemory(
    &lf, sizeof(LOGFONT));

    lf.lfHeight
    = 25; // in logical units
    lf.lfWidth = 12; // in logical units
    lf.lfEscapement = 0;
    lf.lfOrientation
    = 0;
    lf.lfWeight
    = 500; // boldness, range 0(light) - 1000(bold)
    lf.lfItalic = false;
    lf.lfUnderline
    = false;
    lf.lfStrikeOut
    = false;
    lf.lfCharSet
    = DEFAULT_CHARSET;
    lf.lfOutPrecision
    = 0;
    lf.lfClipPrecision
    = 0;
    lf.lfQuality
    = 0;
    lf.lfPitchAndFamily
    = 0;
    strcpy(lf.lfFaceName,
    "Times New Roman"); // font style

    hFont
    = CreateFontIndirect(&lf);
    hFontOld
    = (HFONT)SelectObject(hdc, hFont);

    D3DXCreateText(Device, hdc,
    "Direct3D",
    0.001f, 0.4f, &Text, 0, 0);

    SelectObject(hdc, hFontOld);
    DeleteObject( hFont );
    DeleteDC( hdc );

    //绘制
    Device->BeginScene();
    Text
    ->DrawSubset(0);
    Device
    ->EndScene();

    //释放
    d3d::Release<ID3DXMesh*>(Text);

  • 相关阅读:
    前端调用后台接口下载word文档的两种方法
    Layui form表单提交注意事项
    JavaScript_Util_01
    心理
    小例子
    SQL分割字符串
    绘制10种不同颜色的散点图
    绘制散点图
    subplot的使用
    绘制正弦余弦
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/1772566.html
Copyright © 2011-2022 走看看