I'm having problems with alpha/transparency using bgstaal's ofxShivaVG addon in 0.8.4. The examples compile fine and look great, but when I try to draw into an fbo, I lose transparency! I'm on OS X 10.10.3
Here's what my code looks like. I'm just trying to draw some stuff into an fbo and display that on top of an image:
setup(){
...
_shivaVGRenderer = ofPtr<ofxShivaVGRenderer>(new ofxShivaVGRenderer);
ofSetCurrentRenderer(_shivaVGRenderer);
_shivaVGRenderer->setLineJoinStyle(VG_JOIN_ROUND);
_shivaVGRenderer->setLineCapStyle(VG_CAP_ROUND);
ofEnableAlphaBlending();
...
fbo.allocate(1127,995,GL_RGBA,8);
fbo.begin();
fbo(255,0);
fbo.end();
...
}
draw(){
ofEnableAlphaBlending();
bgImage.draw(artCanvasX,artCanvasY,artCanvasWidth,artCanvasHeight);
fbo.begin();
ofClear(0, 0, 0, 0);
ofSetColor(255,0,0,255);
ofSetLineWidth(30.0f);
ofLine(10, 10, 500, 300);
ofSetLineWidth(1.0f);
ofSetColor(255);
fbo.end();
fbo.draw(artCanvasX,artCanvasY);
}
When I run that, I get a red line on a black background, with no image showing through. If I draw the image inside the fbo, before the line, it works fine. If I don't draw anything to the fbo, just leave it empty, it works fine (the empty fbo is drawn over the image, and I can see the image).
This happens if I try to draw anything into the fbo, even using the shiva renderer's built-in calls: ofGetCurrentRenderer()->drawCircle(30, 50, 0, 20);
I tried:
ofGetCurrentRenderer()->clearAlpha();
inside the fbo, with no luck. I also noticed that
ofGetCurrentRenderer()->clear()
only asks for three arguments...there doesn't seem to be a way to clear with 0 alpha.
The draw()
code aboce is actually inside a class, which then gets called in the main draw()
loop, that's why I'm trying to use ofGetCurrentRenderer()->xxxxx
instead of directly _shivaVGRenderer->xxxxx
Any help would be appreciated. I would like to keep this on 0.8.4 because it needs to be stable/run for a long time, but I'd consider moving to OF master.
Thanks!