Why is the frame rate difference between P2D and P3D?

a

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

void draw()
{
background(0);
text(frameRate, width/2, height/2);
}

b

void setup()
{
size(200, 200, P3D);
}

void draw()
{
background(0);
text(frameRate, width/2, height/2);
}

Tagged:

Answers

  • edited November 2016

    @smileblue --

    P3D uses OpenGL -- it requires more system resources. However, the difference will depend on your computer specs -- your graphics card -- and what else is running, etc.

    Also, note that the default renderer is JAVA2D, not P2D.

    On an old 2010 Mac Mini server 2.66 GHz Intel Core 2 Duo, these are the frame rates I get:

    1. default / JAVA2D: 60 avg
    2. P2D: 57 avg
    3. P3D: 57 avg

    Of course, those number will drop a lot in P3D if I start adding a bunch of objects to a scene.

    Test sketch:

    // Frame Rate Averager
    // 2016-11-10
    float avgRate;
    void setup() {
      size(200, 200, JAVA2D); // default
      // size(200, 200, P2D); 
      // size(200, 200, P3D); 
    }
    void draw() {
      avgRate = lerp(avgRate, frameRate, 0.01);
      background(0);
      text((int)avgRate, width/2, height/2);
    }
    
  • Thank you for your answer~~ :)

  • edited November 2016

    On much newer machines, however, this will be sort of reversed(after you add a lot more objects to draw). OpenGL is faster on Graphics Cards that support it than on integrated graphics, but JAVA2D does not get much of a boost.
    @jeremydouglass P2D and P3D always run at the similar framerates as long as the same objects are drawn, so it would slow down a lot even if you use P2D (so long as you draw the same objects). I have noticed that P3D can actually run quite fast even though 3D drawing is more intensive than 2D. Besides, on such an old device, it is not recommended to use OpenGL based renderers.

Sign In or Register to comment.