error 0x0502 when reading pixels to PBO from FBO

307 views Asked by At

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?

0

There are 0 answers