Results 1 to 5 of 5

Thread: How to read Pixel data from the MultiSampled framebuffer ?

  1. #1

    How to read Pixel data from the MultiSampled framebuffer ?

    Hey
    Presently i am working on iphone app that includes OpenGl es 1.X and trying to read the pixel data from the frame Buffer in order to capture the screen in IOS. GlreadPixels command work fine when using the following code to setup frame buffer :-
    Code :
    //buffers
    // Create a depth buffer that has the same size as the color buffer.
    glGenRenderbuffersOES(1, &m_depthRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_depthRenderbuffer);
    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, width, height);
     
    // Create the framebuffer object.
     
    glGenFramebuffersOES(1, &framebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,
                                 GL_RENDERBUFFER_OES, m_colorRenderbuffer);
    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES,
                                 GL_RENDERBUFFER_OES, m_depthRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);

    but when i use depth buffer and colorbuffer for Multi-Sampling glreadpixels() dont capture any pixel data as with earlier code ....for multi-sampling i use following code :-
    Code :
    glGenFramebuffersOES(1, &sampleFramebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, sampleFramebuffer);
     
    //GLuint sampleColorRenderbuffer;
    glGenRenderbuffersOES(1, &sampleColorRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
    glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_RGBA8_OES, width, height);
    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
     
    //glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_RGBA8_OES, width, height);
    //glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
     
    GLuint sampleDepthRenderbuffer;
    glGenRenderbuffersOES(1, &sampleDepthRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
    glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_DEPTH_COMPONENT24_OES, width, height);
    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
    //glBindRenderbufferOES(GL_RENDERBUFFER_OES,sampleColorRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, sampleFramebuffer);

    i use the follwing code to read pixel data :-
    Code :
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
     
    int backingWidth = screenBounds.size.width;
    int backingHeight =screenBounds.size.height;
     
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
    NSInteger myDataLength = backingWidth * backingHeight * 4;
     
    buffer= (GLuint *) malloc(myDataLength);
    glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    Any idea how to capture correct pixel data with multi-Sampling technique....or Am i doing something wrong. Please guide me in right direction. Thanks

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: How to read Pixel data from the MultiSampled framebuffer

    You cannot read pixel data from a multisampled framebuffer, you need to blit it to a single-sampled framebuffer first.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3

    Re: How to read Pixel data from the MultiSampled framebuffer

    Quote Originally Posted by Xmas
    You cannot read pixel data from a multisampled framebuffer, you need to blit it to a single-sampled framebuffer first.
    Thanks for Replying...hmm k following blitting code is right or wrong ?
    Code :
    glBindFramebufferOES(GL_READ_FRAMEBUFFER_APPLE, sampleFramebuffer);
    	glBindFramebufferOES(GL_DRAW_FRAMEBUFFER_APPLE, framebuffer);
    	glResolveMultisampleFramebufferAPPLE();

  4. #4

    Re: How to read Pixel data from the MultiSampled framebuffer

    Hey all done.... got another issue regarding the performance while using glReadpixels() for reading the frame buffer ....the performance decreases unexpectedly.... without using glReadPixels() the FPS is around 30 and with glreadPixels the fps is 2-3 . is it normal or m lacking something ?

  5. #5

    Re: How to read Pixel data from the MultiSampled framebuffer

    Using glReadPixels is always expensive, how expensive depends on the platform. But most platforms need to stall rendering and wait for rendering to finish, with a possible resolve to another buffer, then an un-cached buffer generally needs to be read then the format needs to be converted. You should avoid glReadPixels at all cost for anything that you want to perform well. If you really need to use it, you might be able try various pixel format combinations, you can also try reading the target at the latest possible point in your frame.

Similar Threads

  1. Positional data in pixel shader
    By mrflibble in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 3
    Last Post: 01-20-2013, 02:30 PM
  2. How to remove pixel from the framebuffer?
    By pine in forum Developers Coding:Beginner
    Replies: 3
    Last Post: 02-13-2012, 02:54 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
  •