John Katsantas
John Katsantas

Reputation: 593

Can't read texture values using PBO and glReadPixels

I created a texture by rendering to an FBO and I've been trying to read the texture with no success for quite some time. After my failed attempts with glReadPixels() and glGetTexImage()(access violation errors) I decided to try with a PBO.

Here is the code I use immediately after rendering to the framebuffer and creating the texture successfully:

    glReadBuffer(GL_FRONT);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, PBO);
    glReadPixels(0, 0, 1024, 768, GL_RGB, GL_UNSIGNED_BYTE, 0);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, PBO);
    GLubyte* ptr = (GLubyte*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
    if (ptr)
    {
        //processPixels(ptr, ...);
        glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
    }
    glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

However, I'm never entering the loop, meaning no values are read. Am I forgetting something?

Upvotes: 0

Views: 334

Answers (0)

Related Questions