我想在 OpenGL 中特定坐标位置的游戏屏幕上显示文本。
例如,一名球员"Player Score:" 10
在坐标处得分(5,5)
。
我怎么做?
在正交视图下使用名为 GLFont 的工具,您可以输出如下文本
glFontBegin(&font);
glScalef(8.0, 8.0, 8.0);
glTranslatef(30, 30, 0);
glFontTextOut("Test", 5, 5, 0);
glFontEnd();
glFlush();
你可以在这里找到它http://students.cs.byu.edu/~bfish/glfontdl.php
我记得opengl下也有可以在屏幕上显示文字的功能。检查这个: http ://www.opengl.org/resources/features/fontsurvey/
编辑:也检查此链接http://mycodelog.com/2010/03/23/printw/
用法就像调用 printf 一样简单:
printf( "char: %c, decimal: %d, float: %f, string: %s", 'X', 1618, 1.618, "text");
printw(x, y, z, "char: %c, decimal: %d, float: %f, string: %s", 'X', 1618, 1.618, "text");