We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › PGraphicsOpenGL save() transparent background
Page Index Toggle Pages: 1
PGraphicsOpenGL save() transparent background? (Read 2002 times)
PGraphicsOpenGL save() transparent background?
Oct 10th, 2009, 7:23pm
 
Is it possible using PGraphicsOpenGL to save .png images with a transparent background?

I know it can be done using the normal PGraphics, but when it comes to OpenGL...

Thanks,
Eric
Re: PGraphicsOpenGL save() transparent background?
Reply #1 - Oct 10th, 2009, 7:39pm
 
Re: PGraphicsOpenGL save() transparent background?
Reply #2 - Oct 10th, 2009, 7:58pm
 
The example you're showing me uses the conventional PGraphics.

frameToSave.save("Output.png"); where frameToSave is a PGraphics.

I would like to know if the same code works for PGraphicsOpenGL.

For example, my code starts with:
Code:
import processing.opengl.*;
import javax.media.opengl.*;
import com.sun.opengl.util.texture.*;
import damkjer.ocd.*;


PGraphicsOpenGL pgl;
GL gl;
Texture partTex;
Texture flashTex;


Can I make a transparent image with:
Code:
pgl.save("Output.png"); 

?

If not, is there a way to work around it?
Re: PGraphicsOpenGL save() transparent background?
Reply #3 - Oct 10th, 2009, 8:11pm
 
well, my workaround was to generate the graphics in an opengl window, and to copy the pixel[] array into a separate PGraphics object for saving.  If that doesn't work for you, maybe some more particulars would help?
Re: PGraphicsOpenGL save() transparent background?
Reply #4 - Oct 19th, 2009, 9:02pm
 
Alright, I'm just going to answer to myself in order to close this thread.

After trying a few things, including your trick BenHem from which I obtained non-transparent renders in tones of blue, I concluded that it's not realistically possible. OPENGL and transparent backgrounds don't get along very well, just google it.

Plus, there was always a blue line in the middle of the images. The blue is probably related to this : "Strictly speaking the "blue" value from the source image is used as the alpha color." (Found in the dev section about PGraphicsOpenGL).

In conclusion, since I only wanted to add an animation layer on a video sequence, it was MUCH simpler to use a black background and apply additive mode in Final Cut.
Re: PGraphicsOpenGL save() transparent background?
Reply #5 - Oct 19th, 2009, 10:45pm
 
This might not be helpful but I got around this by rendering the scene again on a black background with all fill turned to white. This dumped out an alpha frame for each RGB frame. Any RGBA textures were rendered as just the alpha channel.

Worked like a charm in the end. But it does take twice as long to output.
Page Index Toggle Pages: 1