Login  Register

TextRenderer overlaped

Posted by elseine on Apr 26, 2016; 3:21pm
URL: https://forum.jogamp.org/TextRenderer-overlaped-tp4036666.html

Hello!.

I am using TextRenderer to render a text in my world.

This is my code:



if(r)
            {
            tr = new TextRenderer(new java.awt.Font("Calibri", java.awt.Font.BOLD, 16), true, false, null, false);
            tr.setColor(1,1,0,1);
            r = false;
            }
            ///
            tr.beginRendering(viewportMatrix[2], viewportMatrix[3]);
            tr.draw( nombreRepresentacion, ((Double)result[0]).intValue(), ((Double)result[1]).intValue());
            tr.endRendering();

ViewportMatrix has the viewportl given by my GL2 object. result contains the position in world space. The problem is when I execute my program, my text is behind my rectangle like this image:



This rectangle is created with this code:

 public void draw(GL2 gl) {
        //gl.glDisable(GL.GL_LIGHTING);
      //if (color!=null) gl.glColor3f(color.getRed(),color.getGreen(),color.getBlue());
           // gl.glEnable(GL.GL_LINE_STIPPLE);
        //gl.glLineStipple(1, (short) 255);
        if (fill) gl.glBegin(GL2.GL_POLYGON); else
            gl.glBegin(GL2.GL_LINE_LOOP);
        gl.glVertex3d(p1.x, p1.y, p1.z);
        gl.glVertex3d(p2.x, p1.y, p1.z);
        gl.glVertex3d(p2.x, p2.y, p2.z);
        gl.glVertex3d(p1.x, p2.y, p1.z);
      gl.glEnd();
         //gl.glDisable(GL.GL_LINE_STIPPLE);
    }

And in my code, I put the coordinates and calls to rect.render();

public void render(GL2 gl){
        gl.glDisable(GL2.GL_LIGHTING);

      if (isSelected()){
                        JSelectionModel.selectedColor.setColor(gl);

                      }
      if (isMouseOver()){
          JSelectionModel.mouseOverColor.setColor(gl);
                  } else
       if (!isSelected() && getColor()!=null ) getColor().setColor(gl);
       
       
      setStriple(gl);
      gl.glLineWidth(getWidth());
     
      gl.glPushMatrix();
          if (haveTransformation()) getTransformation().ApplyTransformation(gl);
             if (isPack)
                 gl.glCallList (this.hashCode()); //si esta empaquetado
             else {
                 draw(gl);   //si no esta empaquetado
             }
     
      gl.glPopMatrix();
    }


How can I make that the letters are in front on my rectangle instead of behind?

Thanks for your time!