Low frameRate, my code gives 10 - 15 frames

Hello everyone. My code doesnt give me 30 frameRate even i dont do much thing there ! Help me please, thanks.

String s = "belli";
PFont font;
int tileCount = 25;
float tileWidth, tileHeight;

void setup() {
  size(800, 800);
  tileWidth = 25;
  tileHeight = 30;
  font = createFont("aktif.otf", 200);
  //textAlign(CENTER, CENTER);

void draw() {
  for (int gridY=0; gridY<tileCount-3; gridY++) {
    for (int gridX=0; gridX<tileCount; gridX++) {
      float posX = tileWidth*gridX+100;
      float posY = tileHeight*gridY+80;
      float angle = atan2(mouseY-posY, mouseX-posX) + radians(90);
      translate(posX, posY);
      rotate (angle);
      text(s.charAt((gridX+gridY)%5), 0, 0);
  fill(255, 0, 0);
  circle(mouseX, mouseY, 30);
  text(""+frameRate+"", 90, 20);

Your fonts are causing an issue.

The font issue is because I(and you probably too) haven’t installed the font.
For me it is running a pretty stable frameCount between 58 and 60.
Mybe try setting frameCount manually to 60 by using frameRate(60);, however is 60 the default frame rate set by processing, so if your processor isn’t fast enough 60fps can’t be achieved (see https://processing.org/reference/frameRate_.html).

I made the same observation…

A solid 60 fps commenting the fonts:

  //font = createFont("aktif.otf", 200);


@glv @Bobby54 @paulgoux I have to use that font. Do I have a chance to get 30fps ?

Try font = createFont("aktif.otf", 18); and remove textSize(18);.

If that doesn’t work, rasterise each character into a PImage and replace text() with image().

I don’t think that’s a good idea since loading and drawing images takes longer and has a bigger impact on the processor.

1st variant helped a little, now i got 20 - 22 fps… better) Thanks.

If I were you make a class Letter with position and char etc. and fill an 1D-array of Letter with the data (in setup())

Then in draw() you would have less calculating.

Still you would have 25x25 pushMatrix calls which is expensive.


Try it with another renderer and report (just curious) your frame rates:

  size(800, 800);
  //size(800, 800, FX2D);
  //size(800, 800, P2D);
  //size(800, 800, P3D);


I am getting solid frame rates while actively moving mouse with one of the other renderers.



Hello, thank u @glv!
size(800, 800, P2D) and size(800, 800, P3D) are helped ! 60 fps, wonderfull !