0

I was trying to use FBO and PBO together, read pixels from FBO to PBO, everyframe. Codes are below:

//at the beginning:
//fbo
glGenFramebuffers(1, &m_fBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_fBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0);
//pbo
glGenBuffersARB(1, &m_pbo);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_READ_ARB);

//at each frame:
glBindFramebuffer(GL_FRAMEBUFFER, m_fBO);
Draw_some_stuff();
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, 0);   //err occurs
Ptr = glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
Cpu_works_on_Ptr();
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);

It works fine on PC. But failed to running on my android phone, got an error 0x0502(GL_INVALID_OPERATION) right after glReadPixels.

I believe my codes are the same as the bottom answer at this link: Reading the pixels values from the Frame Buffer Object (FBO) using Pixel Buffer Object (PBO)

Has anyone got a clue? Where did I do it wrong?

alex
  • 11
  • 3
  • 2
    How did you get this to build on Android? I don't think it would have those ARB extensions defined. – Reto Koradi Nov 28 '14 at 16:26
  • 1
    Many of those functions might be extensions on Android (`glMapBuffer` and `glUnmapBuffer`, for example, which are part of [`GL_OES_mapbuffer`](https://www.khronos.org/registry/gles/extensions/OES/OES_mapbuffer.txt)), but they should have the **OES** suffix instead of **ARB**. _That is a mystery..._ – Andon M. Coleman Nov 28 '14 at 23:38

0 Answers0