我使用这两个函数绘制文本:https ://pastebin.com/JVc5xFFT
我绘制文本 - GlText(dc, "Test", ERGB{ 155, 179, 0 }, 5, 220);
我用这个函数构建了一个字体
GLvoid BuildFont(HDC hDC, UINT* FontBase, int PointerWidth)
{
HFONT font;
HFONT oldfont;
*FontBase = glGenLists(96);
font = CreateFontW(-MulDiv(PointerWidth, GetDeviceCaps(hDC, LOGPIXELSY), 72),
0,
0,
0,
FW_BOLD,
FALSE,
FALSE,
FALSE,
ANSI_CHARSET,
OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
VARIABLE_PITCH | FF_SWISS,
L"Trebuchet MS");
oldfont = (HFONT)SelectObject(hDC, font);
wglUseFontBitmaps(hDC, 32, 96, *FontBase);
SelectObject(hDC, oldfont);
DeleteObject(font);
}
如何找出给定文本的高度和宽度?