Esempio n. 1
0
  //
  // Sets the frame rate text displayed in the lower left corner.
  //
  void setFrameRateText() {
    NumberFormat nf = NumberFormat.getInstance();

    nf.setMinimumFractionDigits(2);
    nf.setMaximumFractionDigits(2);

    frameRateText.text(
        "frames/sec = " + nf.format((double) frameCount / ((double) (time - lastTime) / 1000.0)));
  }
Esempio n. 2
0
  //
  // Interface render method.
  //
  public void render() {
    //
    // Calculate the frames per second.
    //

    frameCount++;

    time = getTimeMillis();

    if (secondsPassed != (time - startTime) / 1000) {
      setFrameRateText();
      lastTime = time;
      secondsPassed = (time - startTime) / 1000;
      frameCount = 0;
    }

    //
    // Clear the image.
    //
    go.clear(Go.IMAGE);

    //
    // Draw the teapot.
    //
    go.push(Go.MODELVIEW);
    go.translate(centerX, centerY, centerZ);
    go.rotate((time - startTime) / 1000.0 * 30.0, -0.4, -0.4, 1); // Rotate at 30 degrees/sec
    go.translate(-centerX, -centerY, -centerZ);
    go.render(data);
    go.pop(Go.MODELVIEW);

    //
    // Draw the frames/sec text.
    //
    go.push(Go.COLOR);
    go.color(1.0, 1.0, 0.0);
    frameRateText.render(go);
    go.pop(Go.COLOR);

    //
    // Display all that has been drawn, and do it again.
    //
    swap();
    if (doBenchmark) {
      rerender();
    }
  }