Direct3D 9学习笔记(9)文本绘制
2012-08-10 13:26
591 查看
一.使用ID3DXFont接口
创建一个ID3DXFont对象
D3DXFONT_DESC df; ZeroMemory(&df, sizeof(D3DXFONT_DESC)); df.Height = 25; // in logical units df.Width = 12; // in logical units df.Weight = 500; // boldness, range 0(light) - 1000(bold) df.Italic = false; df.CharSet = DEFAULT_CHARSET; df.OutputPrecision = 0; df.Quality = 0; df.PitchAndFamily = 0; strcpy(df.FaceName, "Times New Roman"); // font style // // Create an ID3DXFont based on 'lf'. // if(FAILED(D3DXCreateFontIndirect(Device, &df, &Font))) { }
二.使用ID3DXFont绘制文本
RECT rect = {0, 0, Width, Height}; Font->DrawText(NULL, FPSString, -1, // size of string or -1 indicates null terminating string &rect, // rectangle text is to be formatted to in windows coords DT_TOP | DT_LEFT, // draw in the top left corner of the viewport 0xffff0000); // black text
三.D3DXCreateText
Creates a mesh containing the specified text, using the font associated with the device context.// // Describe the font we want. // 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 // // Create the font and select it with the device context. // hFont = CreateFontIndirect(&lf); hFontOld = (HFONT)SelectObject(hdc, hFont); // // Create the text mesh based on the selected font in the HDC. // D3DXCreateText(Device, hdc, "Direct3D", 0.001f, 0.4f, &Text, 0, 0);
其会返回一个ID3DXMesh,然后调用DrawSubset方法
Device->SetMaterial(&d3d::BLUE_MTRL); Text->DrawSubset(0);
相关文章推荐
- Introduction to 3D Game Programming with DirectX 11学习笔记 6 Direct3D中的绘制(一)
- Introduction to 3D Game Programming with DirectX 11学习笔记 6 Direct3D中的绘制(三)像素着色器
- Direct3D 10学习笔记(三)——文本输出
- Direct3D 9学习笔记(3)基本顶点绘制
- DirectX 11游戏编程学习笔记之8: 第6章Drawing in Direct3D(在Direct3D中绘制)(习题解答)
- Introduction to 3D Game Programming with DirectX 11学习笔记 6 Direct3D中的绘制(四)渲染状态
- DirectX 11游戏编程学习笔记之7: 第6章Drawing in Direct3D(在Direct3D中绘制)(重点回顾+勘误)
- Direct3D 9学习笔记(4)基本顶点绘制呈现
- DirectX 11游戏编程学习笔记之8: 第6章Drawing in Direct3D(在Direct3D中绘制)(习题解答)
- Introduction to 3D Game Programming with DirectX 11学习笔记 6 Direct3D中的绘制(二)顶点着色器
- SED,AWK学习笔记Part 1-----利用正则表达式进行文本匹配[转]
- Perl语言学习笔记 9 正则表达式处理文本
- Python学习笔记——利用Python统计某目录下所有文本中内容行数
- cocos2d-x学习笔记03:绘制基本图元
- opencv 2.x学习笔记(十)随机数发生器、绘制文字
- HTML 学习笔记(四)HTML文本格式化
- Libgdx学习笔记:使用ShapeRenderer绘制贝塞尔曲线路线图
- caffe 学习笔记之ubuntu下绘制loss&accuracy 曲线
- 文本挖掘与分析第五周学习笔记3--意见挖掘和情感分析
- COCOS2d-x学习笔记(文本、XML读取TiXmlDocument解析)