same shader on two quads at same depth

I am having a problem with my code.

I am trying to draw two quads. One with a background image and another with a foreground image.

The two quads have the same set of vertices, (x, y, z).

I had the code running with both images on a single quad and the mix function in the shader, but I need to modify the texture coordinates of the foreground image only.

I figured to just draw two quads and pass an alpha value to both for blending. My problem is that only the first texture is being drawn properly. The second texture is showing up as black.

I believe the texture updates are still working correctly. That thread has not changed.

Here is my init code:


                         // Positions         // Texture Coords
GLfloat vertices[20] = {  1.0f, -1.0f, 0.9f,   1.0f, 1.0f,   // Top Right
                          1.0f,  1.0f, 0.9f,   1.0f, 0.0f,   // Bottom Right
                         -1.0f,  1.0f, 0.9f,   0.0f, 0.0f,   // Bottom Left
                         -1.0f, -1.0f, 0.9f,   0.0f, 1.0f }; // Top Left 

GLuint indices[6] = { 0, 1, 3,  // First Triangle
                      1, 2, 3 };// Second Traingle

    /* Create the VBO and VAO and EBO for the background textures */
    glGenVertexArrays( Layer_Count, VAO[Output] );
    glGenBuffers( Layer_Count, VBO[Output] );
    glGenBuffers( Layer_Count, EBO[Output] );

    for( Layer = 0; Layer < Layer_Count; Layer++ )
    {
        glBindVertexArray( VAO[Output][Layer] );

        glBindBuffer( GL_ARRAY_BUFFER, VBO[Output][Layer] );
        glBufferData( GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STREAM_DRAW );

        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, EBO[Output][Layer] );
        glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW );

        glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0 );
        glEnableVertexAttribArray( 0 );

        glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)) );
        glEnableVertexAttribArray( 1 );
    }

    /* Un-bind the VAO */
    glBindVertexArray( 0 );

    /* create the PBOs */
    glGenBuffers( Layer_Count, PBO[Output] );

    /* Initialize all the PBOs */
    for( Layer = 0; Layer < Layer_Count; Layer++ )
    {
        /* bind the layers pbo */
        glBindBuffer( GL_PIXEL_UNPACK_BUFFER, PBO[Output][Layer] );

        /* set the pbo buffer parameters */
        glBufferData( GL_PIXEL_UNPACK_BUFFER, SOURCE_WIDTH*SOURCE_HEIGHT*sizeof(GLubyte)*COLOR_E  LEMENTS, 0, GL_STREAM_DRAW );
    }

    /* un-bind the pbo */
    glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );

    /* Generate the textures */
    glGenTextures( VID_Count, Capture_Texture[Output] );

    /* Loop across all the videos */
    for( Video = 0; Video < VID_Count; Video++ )
    {
        /* Bind the texture */
        glBindTexture( GL_TEXTURE_2D, Capture_Texture[Output][Video] );

        /* set the texture parameters */
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );

        /* Set the texture filtering */
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

        /* create and initialize texture */
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, SOURCE_WIDTH, SOURCE_HEIGHT, 0, GL_BGR, GL_UNSIGNED_BYTE, Cap_Blank );
    }

    /* Un-bind the texture */
    glBindTexture( GL_TEXTURE_2D, 0 );

the main render code looks like this:


void draw_video( VID_Inputs Video, int Layer, int Output, float Alpha )
{
    /* Install shader program */
    glUseProgram(Image_Program[Output]);

    /* Activate and bind the texture */
    glActiveTexture( GL_TEXTURE1+Layer );
    glBindTexture( GL_TEXTURE_2D, Capture_Texture[Output][Video] );

    /* set value of texture variable to Layer+1 */
    glUniform1i( TEX_LOC, Layer+1 );
    glUniform1f( ALPHA_LOC, Alpha );

    /* Bind VAO and draw background layer */
    glBindVertexArray(VAO[Output][Layer]);
    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

    /* un-bind VAO */
    glBindVertexArray(0);

    /* remove shader program */
    glUseProgram(0);
}

void Capture_Model( int Output )
{
...
                        case IR_EOWLL:
                        {
                            draw_video(  VID_IR, 0, Output, 0.5 );
                            draw_video( VID_EOW, 1, Output, 0.5 );
                            break;
                        }
...
}
 

Are the vertices being at the exact same depth causing a problem?

Any help would be appreciated.