Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: Calling multiple glReadPixels & glDrawArrays on a FBO, in Opengl ES

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    11

    Calling multiple glReadPixels & glDrawArrays on a FBO, in Opengl ES

    Hello. In Opengl ES, is it possible to call glReadPixels & glDrawArrayson a FBO several times one after the other?
    The issue I'm facing is that I'm getting the image all garbled.

    Sample Code:

    Code :
    // Activate Off-Screen FBO
    glBindFramebuffer(GL_FRAMEBUFFER, fboHandle);
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, textureHandle);
    glViewport(0, 0, 640, 480);
     
    // 1st Render
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glUseProgram(filter_A);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, in_pixels_A);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glReadPixels(0, 0, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, out_pixels_A);
     
    // 2st Render
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glUseProgram(filter_B);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, in_pixels_B);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glReadPixels(0, 0, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, out_pixels_B);
     
    // Back to the screen FB
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glActiveTexture(GL_TEXTURE0);
    Last edited by sanchiski; 02-17-2014 at 05:52 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •