I am currently developping quite a big project, and for simplicity I have chosen to use Processing as a graphical engine. I am coding with Eclipse Neon.
The issue is that I have developped GLSL Fragment shaders to accelerate image processing, and then apply them to a P2D PGraphics object (which works fine), the general PApplet is also P2D but there are a few in-between PGraphics objects that aren’t P2D and that I can’t make P2D since for some reason this messes up the whole look of the project (and this represent quite a substantial amount of time).
So basically, I run a shader onto a P2D PGraphics object and I then want to draw the resulting image onto a non OpenGL PGraphics object, and for some reason this doesn’t work, even though I assumed that after rendering the shader on the first PGraphics object, I would simply have an image I could render elsewhere…
Yeah you’re right. So basically the sketch runs as if the shader wasn’t applied (this shader doesn’t modify the current pixels array, but it actually draws over it, in this case a checkerboard pattern) and the result here is that it’s as if this image is transparent.
Oh I didn’t know that, I sometimes run into NullPointerExceptions when loadPixels() is called without beginDraw() before but I think that this is due to the fact there was actually nothing drawn onto the PGraphics beforehand.
This is also one of the things I tried before. This is why I tried recreating my issue on a simpler sketch :
I am writing this answer to close subject : apparently to apply a shader, something has to already have been drawn onto the PGraphics object, weither it is P2D or not. The simple fix was to apply a background color before applying the shader, weither it is a modifyer fragment shader or a “rendering” shader that draws “on top” of the previous pixels.