|
void CGLChineseFont::drawCNString(const char *str)
{
int len, i;
wchar_t* wstring;
HDC hDC = wglGetCurrentDC();
GLuint list = glGenLists(1);
//glNewList( list, GL_COMPILE_AND_EXECUTE );
len = 0;
for(i=0; str[i]!='\0'; ++i)
{
if( IsDBCSLeadByte(str[i]) )
++i;
++len;
}
wstring = (wchar_t*)malloc((len+1) * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, wstring, len);
wstring[len] = L'\0';
for(i=0; i<len; ++i)
{
wchar_t wstring1 = wstring[i];
wglUseFontBitmapsW(hDC, wstring[i], 1, list);
glCallList(list);
}
free(wstring);
glDeleteLists(list, 1);
}
比如我传过来的是“我爱我的祖国”在窗口中只能显示一个“我”字。为什么?请指出我存在什么问题?是我还需要在哪里指定一个宽度么? |
|