Results 1 to 5 of 5

Thread: Fail to read the frame buffer using PBO

  1. #1
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Fail to read the frame buffer using PBO

    Hi,

    I try to follow the tutorial to read the frame buffer using PBO. When I want to read out the value in the frame buffer, it prints zeros only.
    Code :
    /*Read values back*/
    /*Set the target framebuffer to read*/
    glReadBuffer(GL_FRONT);
    /*Read pixels from framebuffer to PBO*/
    glReadPixels(0,0,size,noOfpacket,GL_RGBA,GL_UNSIGNED_BYTE,(void*)0);
    checkError("glReadPixels error!");
    /*Map the PBO to process its data by CPU*/
    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,pboread);
    result =
    (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,GL_READ_ONLY_ARB);
    printf("Data in frame buffer:\n");
    for (i=0;i<noOfpacket*size;i++)
            printf("%d",result[i]);
    printf("\n\n");
    glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,0);

    I follow exactly the same. But still cannot read the frame buffer. Is it the frame buffer really empty or cant read it? I think there should not be zeros in my frame buffer as I have output colors in my shader.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Fail to read the frame buffer using PBO

    Well. I change the code like this:

    Code :
    /*Read values back*/
    /*Set the target framebuffer to read*/
    glReadBuffer(GL_FRONT);
     
    /*Read pixels from framebuffer to PBO*/
    glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboread);	glReadPixels(0,0,size,noOfpacket,GL_RGBA,GL_UNSIGNED_BYTE,(void*)0);
    checkError("glReadPixels error!");
    /*Map the PBO to process its data by CPU*/
    glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboread);
    result = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,GL_READ_ONLY_ARB);
    printf("Data in frame buffer:\n");
    checkError("Segmentation error!");
    for (i=0;i<noOfpacket*size;i++)
            printf("%d",result[i]);
    printf("\n\n");

    But segmentation fault occurs.The error is comes from this part:

    Code :
    printf("Data in frame buffer:\n");
    for (i=0;i<noOfpacket*size;i++)
            printf("%d",result[i]);
    printf("\n\n");

    Seems like cannot access the value of result here. But how comes like that?

  3. #3
    V-man
    Guest

    Re: Fail to read the frame buffer using PBO

    You need to use GL_PIXEL_PACK_BUFFER because you are transfer from the server (OpenGL) to the client (you).
    You can look at the example in the spec file for GL_ARB_pixel_buffer_object.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Fail to read the frame buffer using PBO

    Sry...is a mistake. Now I get the value. But all are zeros.

    Why? Are the values in the frame buffer really zeros or it read from the wrong place?

  5. #5
    V-man
    Guest

    Re: Fail to read the frame buffer using PBO

    I wouldn't know.
    Then render the scene to the backbuffer and read from the back.
    glReadBuffer(GL_BACK)

Similar Threads

  1. Replies: 2
    Last Post: 01-06-2019, 09:49 PM
  2. Re-create FBO (frame buffer object) each frame
    By Yossi Koren in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-15-2017, 03:25 PM
  3. Fail to Read From FrameBuffer
    By JohnHutch in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-11-2014, 11:54 AM
  4. Replies: 7
    Last Post: 07-02-2014, 12:41 PM
  5. read frame buffer from frag shader?
    By shiprat in forum OpenGL: GLSL
    Replies: 6
    Last Post: 07-28-2009, 07:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean