Why does my code give NullPointerException error?

Try using beginDraw() and endDraw(). Reference is here: https://processing.org/reference/PGraphics.html

Will also need a global variable: PGraphics tex;

Call the PGraphics in draw() with image(tex, 0, 0);

[Code removed]

2 Likes