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 › Video with alpha channel
Page Index Toggle Pages: 1
Video with alpha channel (Read 2194 times)
Video with alpha channel
Jun 9th, 2010, 4:25am
 
Hi!

I'm trying to draw a video (.mov) with alpha channel as a opengl texture. I'm using jmcvideo library.

I create my JMCMovieGL with ARGB pixelformat:

myMovie = new JMCMovieGL(this,"movie_w_alpha.mov",PImage.ARGB);

and draw in OpenGL mode. In this code i draw two movies to check if alpha channel is working or not:

 PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;

 GL gl = pgl.beginGL();  
 {
   myMovie.image(gl, 0, 0, myMovie.width, myMovie.height);
   myMovie.image(gl, width/2, 0, myMovie.width, myMovie.height);
 }
 pgl.endGL();


But this doesn't work.

Any idea?

Thanks in advance!

Guillermo
Re: Video with alpha channel
Reply #1 - Jun 9th, 2010, 12:17pm
 
OK, i've got it.

One have to set the blending conditions. Just two lines:

  gl.glEnable (gl.GL_BLEND);
  gl.glBlendFunc (gl.GL_ONE, gl.GL_SRC_ALPHA);

(gl.glBlendFunc (gl.GL_ONE, gl.GL_ONE); works too)

This allow us to work with transparency in the next videos or images to draw.

So, final code is:

myMovie = new JMCMovieGL(this,"movie_w_alpha.mov",PImage.ARGB);

and draw in OpenGL mode. In this code i draw two movies to check if alpha channel is working or not:

PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;

GL gl = pgl.beginGL();  
{

  gl.glEnable (gl.GL_BLEND);
  gl.glBlendFunc (gl.GL_ONE, gl.GL_SRC_ALPHA);

  myMovie.image(gl, 0, 0, myMovie.width, myMovie.height);
  myMovie.image(gl, width/2, 0, myMovie.width, myMovie.height);
  // you can draw other videos with (or not) transparency)
  // mySecondMovie.image(gl, width/2, 0, myMovie.width, myMovie.height);
}
pgl.endGL();



I hope this will serve you!

Ciao!


Page Index Toggle Pages: 1