Display frame rate in a 3D sketch?

Hello, I'm want to create a large 3D sketch, and keep track of the frameRate. The problem is that sometimes the 3D shapes overlap the frameRate text. I would like to display the frameRame always over the other shapes and objects, but I can find the best way to do it.

here is one example of a code with the text being overlapped:

PShape box;
float ry;

public void setup() {
  size(640, 360, P3D);
  box = createShape(BOX,200,400,5);
}

public void draw() {
  pushStyle();
  pushMatrix();
  background(0);
  lights();

  translate(width/8, 200 , 0);
  rotateZ(PI);
  rotateY(ry);
  shape(box);

  ry += 0.015;
  popStyle();
  popMatrix();

  fill(0,102,153);
  textAlign(LEFT, BASELINE);
  text(frameRate,50,30);
}

What is the best way to solve it?

Thanks

Answers

  • Answer ✓

    you can use this HUD-func

    void HUD_text (String a1) {
      // HUD text upper left corner 
    
      // this is a 2D HUD 
      camera();
      hint(DISABLE_DEPTH_TEST);
      noLights();
      // ------------------
      textSize(16);
      text (a1, 20, 20);
      // ------------------
      // reset all parameters to defaults
      textAlign(LEFT, BASELINE);
      rectMode(CORNER);
      textSize(32);
      hint(ENABLE_DEPTH_TEST); // no HUD anymore
      lights();
    }
    
    // =====================================================
    
Sign In or Register to comment.