efficient way to blow up a video frame

Hi,
I’m playing a video and using a png-sequence as a stencil/mask for it. I’m using some code I found in the forum:

  
       
            glActiveTexture(GL_TEXTURE0);  
            video.getTextureReference().bind();  
            glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);  
            glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);  
              
            glActiveTexture(GL_TEXTURE1);  
            stencil.getTextureReference().bind();   
            glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);  
            glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_BLEND);  
  
            glBegin(GL_QUADS);  
            glMultiTexCoord2f(GL_TEXTURE0, 0.0f, HEIGHT);  
            glMultiTexCoord2f(GL_TEXTURE1, 0.0f, HEIGHT);  
            glVertex3f(0.0f, HEIGHT, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);  
            glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f);  
            glVertex3f(0.0f, 0.0f, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, WIDTH, 0.0f);  
            glMultiTexCoord2f(GL_TEXTURE1, WIDTH, 0.0f);  
            glVertex3f(WIDTH, 0.0f, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, WIDTH, HEIGHT);  
            glMultiTexCoord2f(GL_TEXTURE1, WIDTH, HEIGHT);  
            glVertex3f(WIDTH, HEIGHT, 0);  
            glEnd();  
  
            stencil.getTextureReference().unbind();  
            glActiveTexture(GL_TEXTURE0);  

Now I need to be able to blow up the video. My solution was to copy the video frame into an ofImage and resize it. Like this:

  
            bigVideoImage.setFromPixels(video.getPixelsRef());  
            bigVideoImage.resize(1920, 1080);  
  
            glActiveTexture(GL_TEXTURE0);  
            bigVideoImage.getTextureReference().bind();  
            glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);  
            glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);  
              
            glActiveTexture(GL_TEXTURE1);  
            stencil.getTextureReference().bind();   
            glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);  
            glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_BLEND);  
  
            glBegin(GL_QUADS);  
            glMultiTexCoord2f(GL_TEXTURE0, 0.0f, HEIGHT);  
            glMultiTexCoord2f(GL_TEXTURE1, 0.0f, HEIGHT);  
            glVertex3f(0.0f, HEIGHT, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);  
            glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f);  
            glVertex3f(0.0f, 0.0f, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, WIDTH, 0.0f);  
            glMultiTexCoord2f(GL_TEXTURE1, WIDTH, 0.0f);  
            glVertex3f(WIDTH, 0.0f, 0);  
            glMultiTexCoord2f(GL_TEXTURE0, WIDTH, HEIGHT);  
            glMultiTexCoord2f(GL_TEXTURE1, WIDTH, HEIGHT);  
            glVertex3f(WIDTH, HEIGHT, 0);  
            glEnd();  
  
            stencil.getTextureReference().unbind();  
            glActiveTexture(GL_TEXTURE0);  

It ‘works’ but the performance is pretty bad. Not usable in fact.
Do you guys have other suggestions?

Hi hrb

instead of multitexturing you could use glMask like so:

  
// make mask  
    glColorMask(false, false, false, true);  
    glBlendFunc(GL_SRC_ALPHA, GL_ZERO);  
    ofSetColor(0, 0, 0, 0);  
      
    myMask.draw();  
      
    glColorMask(true, true, true, true);  
    glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);  
      
    myContent.draw()  
      
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // normal  
  
  

problem with this technique is underlying alpha and blending stuff…

so… maybe it has to be rendered on a FBO…

ciao bis montag!

greetings ascorbin