E0001: PGraphics needs to be a pointer

Compiler Error

What it means

A PGraphics buffer holds onto real graphics-card resources behind the scenes. Two copies of the same PGraphics could end up fighting over those resources, so copying isn't allowed.

How to fix it

Use PGraphics* instead of PGraphics.

Example

Before
PGraphics pg; pg = createGraphics(400, 300); pg.beginDraw(); pg.background(255); pg.endDraw();
After
PGraphics* pg; pg = createGraphics(400, 300); pg->beginDraw(); pg->background(255); pg->endDraw();

Notes

Once pg is a pointer, use -> instead of the dot you'd use in Java.