Displaying Text is slow

edited March 2016 in Programming Questions

I'm trying to display numbers (that will increment throughout my program) but when I try to do so there is a significant lag between when I press run and when the number finally appears on the screen. Why is this? Is there a way to fix this? Thanks!

my code is just:

int x = 5;

void setup(){ size(300, 300); }

void draw(){ background(128); text(x, 20, 20); x++; }


  • A program needs some time to load, as any other programm actually.

  • Yeah, but this doesn't happen with my other programs where I don't include text and I simply draw shapes. I am trying to coordinate it so it is somewhat of a counter -- so when a shape appears, the number increments. So the timing needs to be precise, but the lag makes it difficult to do this.

  • So, if you combine text and shapes you receive something you're not expecting? Please, show it.

  • I ran into the same problem. The answer is quite simple. On the first text(), the font has to be loaded. If you do that manually, you will not encounter the lag anymore:

    PFont myFont = createFont("Arial", 10); textFont(myFont);

Sign In or Register to comment.