PGraphics.image() not displayed with noSmooth() and P2D?

When running this sketch, press any key to cause the PGraphics to be displayed. When P2D and noSmooth() are used, the PGraphics is displayed only momentarily. Is there a logical reason for this?

PGraphics pg1;

void setup() {
  size(640, 480, P2D); // remove P2D's to allow pg1 to be displayed
  noSmooth(); // or remove this to allow pg1 to be displayed
  background(0);
  fill(0, 255, 0);
  rect(0, 0, 100, 200);

  pg1 = createGraphics(width, height, P2D);
  pg1.noSmooth();
  pg1.beginDraw();
  pg1.background(255);
  pg1.fill(0);
  pg1.rect(100, 100, 100, 50);
  pg1.endDraw();
}

void draw() {
}

void keyPressed() { 
  background(0);
  image(pg1, 0, 0, width, height);
}

Answers

Sign In or Register to comment.