New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

background(pImage) costs lots of fps with p3d #3012

Closed
mschi opened this Issue Dec 20, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@mschi

mschi commented Dec 20, 2014

hi,

the following programm runs with only 14 fps. when "background(0,0,0)" is used instead of the image i get 400 fps. dimensions of the image are 1680*1050px. processing 2.2.1 is used.

PImage bg;

void setup(){
size(1680, 1050, P3D);
smooth(8);
frameRate(30000);

bg = loadImage("bg.jpg");
}

void draw(){
frame.setTitle(int(frameRate) + " fps");
background(bg);
}

@mschi

This comment has been minimized.

Show comment
Hide comment

@codeanticode codeanticode self-assigned this Jan 15, 2015

@codeanticode codeanticode added the opengl label Jan 15, 2015

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Jun 3, 2015

Member

@mschi performance of the background(PImage) function in P2D/P3D will be much better in the next release after 3.0a9 due to #160. However, it will still be slower than using image() because background(PImage) also copies the pixels of the source image into the pixels of the screen, which can be an expensive operation if resolution is high.

A trick to use image() instead of background() is to disable depth mask, so no object occludes the background image (which is basically a textured quad at z=0):

PImage bg;

void setup() {
  size(displayWidth, displayHeight, P2D);
  smooth(8);
  frameRate(300);
  bg = loadImage("bg.jpg");
}

void draw(){
  hint(DISABLE_DEPTH_MASK);
  image(bg, 0, 0, width, height);
  hint(ENABLE_DEPTH_MASK);  

  println(frameRate);
}
Member

codeanticode commented Jun 3, 2015

@mschi performance of the background(PImage) function in P2D/P3D will be much better in the next release after 3.0a9 due to #160. However, it will still be slower than using image() because background(PImage) also copies the pixels of the source image into the pixels of the screen, which can be an expensive operation if resolution is high.

A trick to use image() instead of background() is to disable depth mask, so no object occludes the background image (which is basically a textured quad at z=0):

PImage bg;

void setup() {
  size(displayWidth, displayHeight, P2D);
  smooth(8);
  frameRate(300);
  bg = loadImage("bg.jpg");
}

void draw(){
  hint(DISABLE_DEPTH_MASK);
  image(bg, 0, 0, width, height);
  hint(ENABLE_DEPTH_MASK);  

  println(frameRate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment