Delphi+OpenGL怎样输出汉字

YourPeople 2006-06-01 06:40:59
我按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的就不能输出不知道是为什么?
哪位高手可以指点一二啊?
谢谢你们了.
...全文
603 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdyxl 2006-09-13
  • 打赏
  • 举报
回复
可以输出汉字啊!
chenfeng3000 2006-07-11
  • 打赏
  • 举报
回复
很好的网站,应该收藏
天涯倦客 2006-07-07
  • 打赏
  • 举报
回复
opengl 的例子
还是看nehe的教程
推荐个站点 http://www.gameres.com/ 有中文的 nehe教程
loujing 2006-07-07
  • 打赏
  • 举报
回复
我网站上有几个用C++ Builder写的OpenGL输出中文的例子:
http://www.loujing.com/article/ShowClass2.asp?ClassID=32
看看能不能用。
terence4444 2006-06-02
  • 打赏
  • 举报
回复
nChar := (A shl 8) + 256 + ord(s[i + 1]);
在这句前加一句 nChar="我",试一下

另外Delphi中的shl是循环左移的,不知道和上边C语言的代码是否相同
深宇 2006-06-02
  • 打赏
  • 举报
回复
你那个s变成widestring类型试试
taxi 2006-06-02
  • 打赏
  • 举报
回复
建立一張位圖,在位圖上寫字,然後將位圖作為紋理貼到屏幕上。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧