Delphi+OpenGL怎样输出汉字
我按VC++的方法转换成Delphi为什么不能输出汉字,但是VC++的就行,请合位高手们帮帮忙:
VC源码:
int i=0;
CFont* pOldFont=(CFont*)m_pdc->SelectObject(&fontOpenGL1);
unsigned int j=0;
DWORD nChar;
byte b;
CString m_theString = "电脑编程技巧";
BYTE FTextList[128];
GLYPHMETRICSFLOAT m_agmf1[128];
while(i< m_theString.GetLength())
{
b = m_theString[i];
if (IsDBCSLeadByte(b
{
nChar = (256 + b) * 256 + (256 + m_theString[i+1]);
i += 2;
}
else
{
nChar = b;
i++;
}
wglUseFontOutlines(m_pdc->m_hDC, nChar,
1,
1000+j,
0.0,
0.15f, WGL_FONT_POLYGONS,
&m_agmf1[j]);
FTextList[j]=j;
j++;
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslated(-3.10,0.9,-7.0 );
glPushMatrix();
glRotated(m_angle.cx, 1, 0, 0);
glColor3dv(purple) ;
glListBase(1000);
glCallLists(m_theString.GetLength(),GL_UNSIGNED_BYTE,&FTextList);
glPopMatrix();
将上边的VC代码大概译成Delphi代码:
s := '电脑编程技巧';
lf.lfHeight := 24;
lf.lfWidth := 0;
lf.lfEscapement := 5;
lf.lfWeight := 100;
lf.lfFaceName := '宋体';
newFont := CreateFontIndirect(lf);
oldFont := SelectObject(self.FDC, newFont);//FDC := GetDC(self.Handle);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
i := 0;
j := 0;
while(i<Length(s)) do
begin
A := ord(s[i]);
if (IsDBCSLeadByte(A)) then
begin
nChar := (A shl 8) + 256 + ord(s[i + 1]);
i := i + 2;
end else begin
nChar := A;
inc(i);
end;
wglUseFontOutlines(FDC,
1,
nChar,
1000 + j,
0.0,
0.15,
WGL_FONT_POLYGONS,
@m_agmf2[j]);
FTextList[j] := j;
Inc(j);
end;
SelectObject(FDC, oldFont);
Windows.DeleteObject(newFont);
glColor3f(1, 0, 1) ;
glListBase(1000);
glCallLists(Length(s),GL_UNSIGNED_BYTE,@FTextList);
SwapBuffers(wglGetCurrentDC);
VC的能输出Delphi的就不能输出不知道是为什么?
哪位高手可以指点一二啊?
谢谢你们了.