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

  • 相关阅读:
    GAMES101作业1:旋转与投影
    ant design vue关于input组件设置只读
    使用事件代理解决v-html点击事件无效
    js替换字符串中的空格,换行符 或 替换成<br>
    vue中ref的使用(this.$refs获取为undefined)
    轮询锁在使用时遇到的问题与解决方案!
    死锁终结者:顺序锁和轮询锁!
    死锁的 4 种排查工具 !
    图解:为什么非公平锁的性能更高?
    抽奖动画
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/1772566.html
Copyright © 2011-2022 走看看