【问题标题】:How to display text in OpenGL at specific coordinates?如何在特定坐标处显示 OpenGL 中的文本?
【发布时间】:2011-07-29 15:44:41
【问题描述】:

我想在 OpenGL 中特定坐标位置的游戏屏幕上显示文本。

例如,玩家在坐标(5,5) 得分"Player Score:" 10

我该怎么做?

【问题讨论】:

  • 您有纯 OpenGL 还是使用某种框架/引擎?

标签: opengl text-rendering


【解决方案1】:

在正交视图下使用名为 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");

【讨论】:

    猜你喜欢
    • 2021-10-15
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多