Advertisement
Mr_jack

Processing framerate test

Apr 17th, 2024
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | Source Code | 0 0
  1. import processing.javafx.*;
  2.  
  3. //import java.awt.*;
  4. //import javax.media.opengl.glu.GLU;
  5.  
  6. void setup() {
  7.   // frameRate(-1) -> max rendering speed but high CPU usage
  8.   // - and as additional bonus we can't even limit this by ourselves
  9.   // - we can prevent doing anything more often than 60 HZ in draw
  10.   // - but it still renders what it has too often and consumes resources for no reason
  11.  
  12.   size(500, 500);
  13.   frameRate(60);
  14.  
  15.   //size(500, 500, P2D);
  16.   //frameRate(60);
  17.  
  18.   //size(500, 500, P2D);
  19.   //frameRate(60);
  20.   ////frameRate(-1);
  21.   //beginPGL();
  22.   //GLU.getCurrentGL().getGL2().setSwapInterval(1);
  23.   //endPGL();
  24.  
  25.  
  26.   //size(500, 500, P2D);
  27.   //frameRate(240);
  28.   //PJOGL pgl = (PJOGL) beginPGL();
  29.   //pgl.gl.setSwapInterval(0);
  30.   //endPGL();
  31. }
  32.  
  33. void draw() {
  34.   background(0);
  35.   float p = millis() / 1000.0 * 3.25;
  36.  
  37.   circle(cos(p) * 100 + 250, sin(p) * 100 + 250, cos(p) * 50 + 100);
  38.  
  39.   if (frameCount % 60 == 0) {
  40.     println("FPS: ", float(frameCount)/millis()*1000.0);
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement