Log in or register to post comments

what's the difference between setVideoBackgroundTextureID and bindVideoBackground

January 7, 2013 - 12:52am #1

Hi

    I tried to display the camera video with  a simple texture, in a simple draw function(not renderFrameQCAR), using the code below:

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();
    
    GLuint texName;
    glGenTextures(1, &texName);
    glBindTexture(GL_TEXTURE_2D, texName);
    ////////////////////////////////////////////////////////////////////////////
    // This section renders the video background with a
    // custom shader defined in Shaders.h
    if (!QCAR::Renderer::getInstance().setVideoBackgroundTextureID(texName))    //maybe bindVideoBackground(texName) ? which should I use?
    {
        // No video frame available, take no further action
        CCLog(" No video frame available, take no further action");
        QCAR::Renderer::getInstance().end();
        return;
    }
    
    ccVertex3F vertices[4];
    ccVertex2F uv[4];
    
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertices);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uv);

    vertices[0] = vertex3(0,0,0);
    vertices[1] = vertex3(0,screenSize.height,0);
    vertices[2] = vertex3(screenSize.width,0,0);
    vertices[3] = vertex3(screenSize.width,screenSize.height,0);
    
    uv[0] = vertex2(0, 1);
    uv[1] = vertex2(0, 0);
    uv[2] = vertex2(1, 1);
    uv[3] = vertex2(1, 0);
    
    glDisable(GL_BLEND);
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

I have tried both, but none of them work, any help? Thank you very much!

Hi, the renderFrameQCAR

January 7, 2013 - 1:04am #2

Hi, the renderFrameQCAR ensures that the rendering occurs in the proper OpenGL thread/context;

if you make OpenGL calls outside of that, it is expected that these won't work.

If you need an example of how to bind the video to a texture, you can have a look at the BackgroundTextureAccess sample (bundled in your samples distribution).

 

Log in or register to post comments