Reputation: 21
I am new to JOGL/OpenGL. How do I draw labels on a 2D rendered image using JOGL? Like in Java2D/Swing we use jlabel, what is the way to do it here?
Upvotes: 2
Views: 5229
Reputation: 59
The TextRenderer
class renders 2D and 3D labels. Here's some reference to help you get going:
TextRenderer textRenderer = new TextRenderer(new Font("Verdana", Font.BOLD, 12));
textRenderer.beginRendering(900, 700);
textRenderer.setColor(Color.YELLOW);
textRenderer.setSmoothing(true);
DPoint pt = new DPoint(200, 200);
textRenderer.draw("Hello world!!", (int) (pt.x), (int) (pt.y));
textRenderer.endRendering();
Cheers!
Upvotes: 5
Reputation: 79013
OpenGL and specifically JOGL doesn't have a concept of labels. what you usually do is just freely render text in the JOGL window.
See this question for more details: How to use fonts in opengl in java?
Here's another demo from Nehe that uses text but in a different way: http://www.java-tips.org/other-api-tips/jogl/outline-fonts-nehe-tutorial-jogl-port.html
Upvotes: 2