My goal is to have an offscreen buffer with a 2D 80% alpha rectangle background and some 3D items while making use of the Proscene library. Problem is, there's a bug which I cannot seem to fix. And while I was researching the cause of it, I noticed the
BasicUseOffscreen example has that bug too.
Simply, when the example starts up, the behavior is as expected and wanted. But there are two (or three) problems. Once you zoom in, the filled rectangle actually disappears (possibly in negative z-space) which makes the grid, axis and box become uncleared and thus "redrawn". Zooming back out redraws the rectangle, but zooming too far out makes the 3D scene (box, grid, axis, ...) being split by the rectangle (clearly showing the rectangle here). Zooming any further out, again, makes the rectangle disappear and everything pile up.
My guess is that the rectangle is being drawn in 3D, while it should be 2D. Using background() instead clears the issue, but defies the use of an offscreen buffer (and using it as an alpha fill).
An ideal situation would be, in the draw function:
- canvas.beginDraw(); // GLGraphicsOffscreen
- // Begin 2D drawing // Even using beginScreenDrawing() does not work
- canvas.fill(0xFFFF0000, 204); // 80% alpha
- canvas.rect(0, 0, canvas.width, canvas.height); // Not applet.rect() or just rect(), but using the canvas, although this seems to work just fine too
- // Begin 3D drawing
- scene.beginDraw();
- canvas.fill(204, 102, 0);
- canvas.box(20, 30, 50);
- scene.endDraw();
- canvas.endDraw();
- image(canvas.getTexture(), 0, 0, canvas.width / 2, canvas.height / 2);
Any help / pointers?
1