开发者

Rotating text using Textrenderer

开发者 https://www.devze.com 2023-01-16 15:41 出处:网络
Hey, I\'d like to display text in a 2D szenario using JOGL. But I can\'t figure out开发者_如何学Python, how to rotate text using com.sun.opengl.util.j2d.TextRenderer. It does not have any methods conc

Hey, I'd like to display text in a 2D szenario using JOGL. But I can't figure out开发者_如何学Python, 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?


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.


Call glRotatef before you beginRendering() the text.


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

0

精彩评论

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