Package com.jogamp.opengl.util.awt

Examples of com.jogamp.opengl.util.awt.TextureRenderer


   * @param text text to paint.
   * @return
   */
  public static TextureRenderer makeText(String text) {
    // create texture for the text
    TextureRenderer textRenderer = new TextureRenderer(1, 3, false);
    Graphics2D g2d = textRenderer.createGraphics();
    FontRenderContext frc = g2d.getFontRenderContext();
    Font f = new Font("Arial", Font.BOLD, 18);
    String s = new String(text);
    TextLayout tl = new TextLayout(s, f, frc);
    // get the necessary size for the text to be rendered
    Rectangle2D bounds = tl.getBounds();
    // add some margin...
    int width = (int) bounds.getWidth() + 6;
    int height = (int) bounds.getHeight() + 6;
    // create a new texture renderer with the exact correct width and height.
    textRenderer = new TextureRenderer(width, height, true);
    textRenderer.setSmoothing(true);
    g2d = textRenderer.createGraphics();
    g2d.setColor(Color.white);
    //coordinate are inversed: 0:0 is top-left.
    tl.draw(g2d, 3, height - 3);

    textRenderer.markDirty(0, 0, width, height);
    return textRenderer;
  }
View Full Code Here


        renderer = null;
      }
    }
   
    if (renderer == null) {
      renderer = new TextureRenderer(width, height, true);
    }
  }
View Full Code Here

TOP

Related Classes of com.jogamp.opengl.util.awt.TextureRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.