急!!!哪位大侠告诉我关于opengl的一个问题? 怎么在用opengl画的背景上输出文字?有没有函数?用textout函数在上面输出的时候只闪了一下就消失了请帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 怎么能用TextOut呢??在OpenGL中显示文字,如果简单的话一般使用自定义的图片,转换成Texture,然后贴出来。或者使用Windows内带的TrueType字体。1. 首先要建立需要调用的Font Function CreateFont( fontname : PChar, int Size): Shortint;var hFont : THFONT; base : integer;begin base := glGenLists(255); // 能接受的最大值 if stricmp( fontName, 'symbol') =0 then begin hFont := CreateFont( Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName); end else begin hFont := CreateFont(Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName); end; if not hFont then result :=0 else begin SelectObject(g_HDC, hFont); wglUseFontBitmaps(g_HDC, 32, 96, base); result := base; end;end;在建立的时候调用 -> listBase = CreateFont("Arial", 24);2. 在DrawFrame 的时候调用, 记得Text不要太长了。procedure PrintText( base : ShortInt, str : PChar);begin if base = 0 then exit; glPushAttrib( GL_LIST_BIT ); glListBase( base - 32 ); glCallLists( strlen(str), GL_UNSIGNED_BYTE, str ); glPopAttrib();end;3. 最后退出时记得删除建立的东东.procedure ClearGLFont( base : shortint);begin if base <> 0 then glDeleteLists( base, 255 ); // 最大值必须和建立时一样.end; 上的代码是没有经过测试,不过应该问题不大. 自己调试一下吧。不要再尝试使用Textout了。^_^ procedure DrawNormalText;var str:PChar;begin str:='OpenGL Test!'; glRasterPos2f(-0.3, 0.3); wglUseFontBitmaps(h_DC,0,256,1000); glListBase(1000); glCallLists(strLen(str),GL_UNSIGNED_BYTE,str);end;procedure Draw3DText;var str:PChar; base:GLuint; x:array[0..255] of GLYPHMETRICSFLOAT; len:integer;begin str:='ABCD'; len:=strlen(str); base:=glGenLists(len); glRasterPos2f(-5, -8); glTranslatef(-1.0,0.0,-2.0); wglUseFontOutlines(h_DC,0,255,base,0.8,0.1,WGL_FONT_POLYGONS,@x); glListBase(base); glCallLists(strlen(str),GL_UNSIGNED_BYTE,str);end;delphi6+win2000调试通过,注释每写了,自己去查资料吧,中国游戏开发资源网上有 正版XE2多少钱? 在国外或香港买呢(让国内的破产吧!)? 如何在dll中加入WebBrowser2 关于把一串字符做为条件语句的问题? MIDForm问题 020-61087071 请问delphi调用vc的dll如何声明呀.在那块.多谢了 如何将以下文本中的数据存入两维数组中。UP有分!! [email protected]我是西安的一名程序员(Delphi数据库开发)愿意交流者将我加入联系人 再问两个小问题。 中文字符串比较的问题,大神请进啊! 急求COM口通讯控件 关于最小化的小问题...(求助!)
在OpenGL中显示文字,如果简单的话一般使用自定义的图片,转换成Texture,然后贴出来。或者使用Windows内带的TrueType字体。
1. 首先要建立需要调用的Font
Function CreateFont( fontname : PChar, int Size): Shortint;
var hFont : THFONT;
base : integer;
begin
base := glGenLists(255); // 能接受的最大值 if stricmp( fontName, 'symbol') =0 then
begin
hFont := CreateFont( Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName);
end
else begin
hFont := CreateFont(Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName);
end; if not hFont then result :=0
else begin
SelectObject(g_HDC, hFont);
wglUseFontBitmaps(g_HDC, 32, 96, base);
result := base;
end;
end;在建立的时候调用 -> listBase = CreateFont("Arial", 24);2. 在DrawFrame 的时候调用, 记得Text不要太长了。
procedure PrintText( base : ShortInt, str : PChar);
begin
if base = 0 then exit; glPushAttrib( GL_LIST_BIT );
glListBase( base - 32 );
glCallLists( strlen(str), GL_UNSIGNED_BYTE, str );
glPopAttrib();
end;3. 最后退出时记得删除建立的东东.
procedure ClearGLFont( base : shortint);
begin
if base <> 0 then glDeleteLists( base, 255 ); // 最大值必须和建立时一样.
end;
var
str:PChar;
begin
str:='OpenGL Test!';
glRasterPos2f(-0.3, 0.3);
wglUseFontBitmaps(h_DC,0,256,1000);
glListBase(1000);
glCallLists(strLen(str),GL_UNSIGNED_BYTE,str);
end;procedure Draw3DText;
var
str:PChar;
base:GLuint;
x:array[0..255] of GLYPHMETRICSFLOAT;
len:integer;
begin
str:='ABCD';
len:=strlen(str);
base:=glGenLists(len);
glRasterPos2f(-5, -8);
glTranslatef(-1.0,0.0,-2.0);
wglUseFontOutlines(h_DC,0,255,base,0.8,0.1,WGL_FONT_POLYGONS,@x);
glListBase(base);
glCallLists(strlen(str),GL_UNSIGNED_BYTE,str);
end;
delphi6+win2000调试通过,注释每写了,自己去查资料吧,中国游戏开发资源网上有