• 字体


    /************* 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);

  • 相关阅读:
    【转】前端防止 JS 调试技巧
    反爬虫 js怎样判断是真实点击事件还是模拟点击事件?
    js 前端 滑动验证
    【转】pyspider运行卡死在result_worker starting 的解决办法
    【转】pyspider all命令报错如下:ImportError: cannot import name 'DispatcherMiddleware' from 'werkzeug.wsgi'
    【转】pyspider中async关键字问题
    【转】Windows python3.7 下安装运行pyspider
    如何修改11g RAC集群名称
    Exadata健康检查工具EXAchk
    XD刷机中执行reclaimdisks.sh的作用
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/1772566.html
Copyright © 2020-2023  润新知