开发者

How to display text in OpenGL at specific coordinates?

I want to dis开发者_Go百科play text on game screen on specific co-ordinate position in OpenGL.

For example a players score "Player Score:" 10 at coordinates (5,5).

How do I do that?


Use a tool called GLFont under ortho view you can output text like

  glFontBegin(&font);
  glScalef(8.0, 8.0, 8.0);
  glTranslatef(30, 30, 0);
  glFontTextOut("Test", 5, 5, 0);
  glFontEnd();
  glFlush();

you can find it here http://students.cs.byu.edu/~bfish/glfontdl.php

i remember there is function under opengl that can put text on screen too. Check this: http://www.opengl.org/resources/features/fontsurvey/

EDIT: check this link out too http://mycodelog.com/2010/03/23/printw/

Usage is as simple as calling 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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜