Bug 1222 : noFill() funtion affects fill in offscreen rendering
Last modified: 2009-07-31 10:51




Status:
RESOLVED
Resolution:
DUPLICATE of bug 1299
Priority:
P2
Severity:
normal

 

Reporter:
ac
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-03-30 10:40
Starting in version 1.0.2 (on Windows Vista at least, didn't test on OSX
nor Linux), calling noFill() from the main PApplet seems to affect the
normal behavior inside the GLGraphicsOffscreen renderer that comes with the
GLGraphics library (tested with latest release of GLGraphics, 0.8.9.5).
Once noFill() is called, any subsequent drawing operation in a
GLGraphicsOffscreen drawing surface will have fill disabled, even if
calling GLGraphicsOffScreen.fill()

See code example:

[code]
import processing.opengl.*;
import codeanticode.glgraphics.*;

GLGraphicsOffScreen offscreenCanvas;

void setup()
{
size(640, 480, GLConstants.GLGRAPHICS);

offscreenCanvas = new GLGraphicsOffScreen(this, 320, 240, true, 4);
}

void draw()
{
background(0);

offscreenCanvas.beginDraw();
offscreenCanvas.background(255, 0, 0);
offscreenCanvas.fill(0, 255, 0); // offscreenCanvas sets its own fill,
but it is affected by noFill() called in the parent renderer below.
offscreenCanvas.ellipse(map(mouseX, 0, width, 0, offscreenCanvas.width),
map(mouseY, 0, height, 0, offscreenCanvas.height), 50, 50);
offscreenCanvas.endDraw();

image(offscreenCanvas.getTexture(), 10, 10, width - 20, height - 20);

fill(0, 0, 0, 0); // Works ok.
//noFill(); // It doesn't work (offscreen image doesn't show up),
// unless it is coupled with the fill(0) below.
stroke(255);
rect(10, 10, width - 20, height - 20);

//fill(0); // This line should be uncommented to avoid the noFill() above
to affect offscreenCanvas.
}
[/code]

There are two workarounds:

1) if noFill() is replaced by a call to fill(0, 0, 0, 0)
2) after doing all the drawing operations in the main window that require
noFill, calling fill(0) restores the fill state in the GLGraphicsOffScreen
renderer.

Both workarounds are exemplified in the code above.
Additional Comment #1 From fry 2009-03-30 10:47
glgraphics is out of my control, please contact andres for glgraphics problems.
Additional Comment #2 From ac 2009-03-30 11:47
I'm Andres in fact :-) So I contacted Andres and after a brief discussion
we found the true source of the problem (we think).

(anyways... I wouldn't have posted this as a Processing bug if I weren't
suspected that it was actually such a thing)

It seems that noFill() function affects the behavior of image() (at first I
thought it was only when passing a GLTexture object, therefore revealing
some sort of conflict between the latest processing and the glraphics
renderer) but I tested again with an offscreen-rendering example that just
uses a PGraphics object and the P3D renderer, and the results are different
between 1.0.1 and 1.0.3

Take a look at this code:

[code]
PGraphics pg;

void setup()
{
size(640, 480, P3D);

pg = createGraphics(640, 480, P3D);
}

void draw()
{
// Offscreen drawing...
pg.beginDraw();
pg.background(255, 255, 0, 255);
pg.noFill();
pg.stroke(0, 0, 0, 255);


// Scaling screen coordinates to image coordinates.
float x = float(mouseX) / width * pg.width;
float y = float(mouseY) / height * pg.height;
pg.ellipse(x, y, 70, 70);

pg.fill(255, 0, 0, 255);
pg.endDraw();

noFill();
image(pg, 0, 0);
}

[/code]


If you try it on 1.0.1, it will display a yellow background with a small
(non-filled) ellipse following the mouse.

On 1.0.3, it just shows a gray screen (when you use the noFill() before
image(pg, 0, 0)). But if you change the renderer to JAVA2D, it works fine.
Additional Comment #3 From fry 2009-07-31 10:51


*** This bug has been marked as a duplicate of 1299 ***