How to use filter on PGraphics in thread?

How to use filter on PGraphics in thread?

void setup() {
  size(512, 512, P2D);
  thread("thread");
}
void thread() {
  PGraphics graphic = createGraphics(512, 512, P2D);
  PShader blur = loadShader("blur.glsl");
  graphic.beginDraw();
  graphic.background(200);
  graphic.ellipse(255, 255, 255, 255);
  graphic.filter(blur);
  graphic.endDraw();
}
2 Likes

Have you seen this:

2 Likes

It’s probably better to use the Java Thread API.
https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html

Why does this need to be in a separate Thread?
The shader will (hopefully) be computed by the GPU.

Why do you need to create a separate CPU Thread for it?

The P2D renderer is not necessarily faster than the default Java2D renderer.

Does your GPU driver support OpenGL?
(Only really valid for Linux)