Reply – Re: Text without AWT?
Your Name
Subject
Message
or Cancel
In Reply To
Re: Text without AWT?
— by Xerxes Rånby Xerxes Rånby
I need a complete compilable example most preferable a git source tree in ordet to understand why the integration between the TextRegionUtil class and your code do mix well. Since OpenGL is a statemachine require me to look and test the complete code on order to help locate the issue.

Den 2 mar 2017 17:56 skrev "adi [via jogamp]" <[hidden email]>:
Hi Ranby

I use Shader (#version 450 core), Scenegraph and my own mathe library
so i can my scene change between a 3D and 2D environment with a simple key.

The TextRegionUtil doesn't work. (see nothing)
(The com.jogamp.opengl.util.awt.TextRenderer works correct)

What i want is using 'distance field fonts' with a shader, that relies not on 'libgdx environment'.
(I use the libgdx Hiero Bitmap converter to get distance field fonts)
I see, is must write my own *.fnt Reader class and a Textobject that can work without
fixed pipeline.

Here are a little code snipped from my Textrender class that doesn't work with TextRegionUtil :

......

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;

import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.util.PMVMatrix;
import com.lib.jengine.scene.animation.Positioner;
import com.lib.jengine.scene.animation.Transformer;
import com.lib.jengine.system.GlobalHelper;


public class TextRender3D implements Serializable
 {
  private static final long serialVersionUID = 863154778010270389L;
  private Font font = null;
  private float fontSize = 10.0f;
  private volatile float weight = 1.0f;
  private RenderState renderState = null;
  private float red = 1.0f;
  private float green = 0.0f;
  private float blue = 0.0f;
  private float alpha = 1.0f;
  private int[] sampleCount = new int[] { 4 };
  private int renderQuality = RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED;
  private RegionRenderer regionRenderer = null;
  private TextRegionUtil textRegionUtil = null;
  private int renderModes = Region.VARWEIGHT_RENDERING_BIT;
  // for own movings
  private int transformers[] = null;
  // for positioning
  private Positioner pos = new Positioner();
       
 
    public TextRender3D( String name ) throws Exception
     {
      renderState = RenderState.createRenderState(SVertex.factory());
      renderState.setColorStatic( red, green, blue, alpha);
      renderState.setHintMask( renderQuality );
      regionRenderer = RegionRenderer.create(renderState, RegionRenderer.defaultBlendEnable,     RegionRenderer.defaultBlendDisable);
      textRegionUtil = new TextRegionUtil(renderModes);
      InputStream stream = new FileInputStream( GlobalHelper.getInstance().getFontPath()+"/"+name );
      font = FontFactory.get ( stream,  true ) ;
     }
       
   
    public void init(GLAutoDrawable glDrawable)
     {
      final  GL4 gl = glDrawable.getGL().getGL4();
      regionRenderer.init(gl, renderModes);
          regionRenderer.enable(gl, false);
     }
       
    public void display(GLAutoDrawable glDrawable)
     {
      final  GL4 gl = glDrawable.getGL().getGL4();
      action( gl );
      if( weight != regionRenderer.getRenderState().getWeight() )
       regionRenderer.getRenderState().setWeight(weight);
     
      // That can be a problem in my environment
      final PMVMatrix Pmv = regionRenderer.getMatrix();
      Pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
      Pmv.glLoadIdentity();
      Pmv.glTranslatef( (float)pos.tX, (float)pos.tY, (float)pos.tZ);
      //Pmv.glRotatef((float)Math.PI, 0, 1, 0);
     
      regionRenderer.enable(gl, true);
      textRegionUtil.drawString3D(gl, regionRenderer, font, fontSize, "Hello", null, sampleCount);
      regionRenderer.enable(gl, false);
     }
   
    public void dispose(GLAutoDrawable glDrawable)
     {
      final  GL4 gl = glDrawable.getGL().getGL4();
      renderState.destroy(gl);
     }
...........................



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Text-without-AWT-tp4037684p4037722.html
To start a new topic under jogl, email [hidden email]
To unsubscribe from jogamp, click here.
NAML