使用 Textrenderer 旋转文本

发布于 2024-09-24 01:12:01 字数 393 浏览 9 评论 0原文

嘿,我想使用 JOGL 在 2D szenario 中显示文本。但我不知道如何使用 com.sun.opengl.util.j2d.TextRenderer 旋转文本。它没有任何有关旋转的方法。所以我期望模型视图矩阵对旋转产生影响。

val renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36))

[...]

renderer.beginRendering(drawable.getWidth(), drawable.getHeight())
  gl.glRotatef(90,0,0,1)
  renderer.draw(content, 0, 0)
renderer.endRendering()

你知道有什么帮助吗?

Hey, I'd like to display text in a 2D szenario using JOGL. But I can't figure out, how to rotate text using com.sun.opengl.util.j2d.TextRenderer. It does not have any methods concerning the rotation. So I was expecting the modelview matrix to have an effect on the rotation.

val renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36))

[...]

renderer.beginRendering(drawable.getWidth(), drawable.getHeight())
  gl.glRotatef(90,0,0,1)
  renderer.draw(content, 0, 0)
renderer.endRendering()

Do you know any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赠我空喜 2024-10-01 01:12:01

对我来说,以下顺序 - 并且只有以下顺序 - 有效:

renderer.beginRendering(...)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()

glRotatef(...)
renderer.draw(...)

renderer.endRendering()
glPopMatrix()

如果我改变最后两行的顺序,它就会停止工作。不知道为什么。

For me, the following order -- and only the following order -- works:

renderer.beginRendering(...)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()

glRotatef(...)
renderer.draw(...)

renderer.endRendering()
glPopMatrix()

If I so much as switch the order of the last two lines, it stops working. Don't know why.

渡你暖光 2024-10-01 01:12:01

在 beginRendering() 文本之前调用 glRotatef。

Call glRotatef before you beginRendering() the text.

献世佛 2024-10-01 01:12:01

确保在调用 glRotatef 之前使用 glMatrixMode(GL_MODELVIEW)。您不知道 beginRendering 方法使 OpenGL 处于哪种矩阵模式。

Make sure to glMatrixMode(GL_MODELVIEW) just before calling glRotatef. You don't know what matrix mode the beginRendering method leaves OpenGL in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文