How to draw aplha texture from Video Capture.

Hi ,
Well , I want to paint video with little transparency applied. That’s something trivial like that ?

getImage from video (getPixels) ->allocate in new texture RBG, and then create a new texture with 4 channels like RGBA ,and reoorganize pixels (3 channels) inside new texture?

    int w = camWidth; int h = camHeight;  
    unsigned char * pixels = vidGrabber.getPixels();  
          colorAlphaPixels = new unsigned char [camWidth*camHeight*4];  
    // color alpha pixels, use w and h to control red and green  
    for (int i = 0; i < w; i++){  
        for (int j = 0; j < h; j++){  
            colorAlphaPixels[(j*w+i)*4 + 0] = pixels[(j*w+i)*3 + 0];      
            colorAlphaPixels[(j*w+i)*4 + 1] = pixels[(j*w+i)*3 + 1];  
            colorAlphaPixels[(j*w+i)*4 + 2] = pixels[(j*w+i)*3 + 2];  
            colorAlphaPixels[(j*w+i)*4 + 3] = i;     // alpha  

texColorAlpha.loadData(colorAlphaPixels, w,h, GL_RGBA);

At now, only draws white texture video… help?


looks ok on first glance,
can you post the whole code ? -

Hi Zach ,
link code:
is like Videograbber… thanks

don’t see anything like the code above in the code you posted.

there are two for loops in testApp.cpp:

for(int i=0; i<3;i++)  
for (int i=0;i<numCaras;i++)  

where is the code you are concerned with?

maybe you want to code a simple example to describe your problem – would definitely help


I’m sorry, I had uploaded the wrong file.



I think you are missing:



Yes ! you are right! Now It’s working