Reading RGB8 buffer from OpenGL ES 3.0 on iOS?

I really need to get RGB 8 bytes per channel for a GPU buffer. I need him to go to a trained convolutional neural network, and he only accepts data in this format. I cannot convert it to a CPU, as I am very attached to the processor, and it is rather slow.

Currently, I have a FBO with the renderbuffer application, which is defined using: glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8_OES, bufferWidth, bufferHeight); There are no errors when linking, defining, and rendering in the buffer.

But when I use glReadPixels(0, 0, bufferWidth, bufferHeight, GL_RGB, GL_UNSIGNED_BYTE, rgbBufferRawName); it gives an incorrect enumeration error (0x0500). It works fine when transferring GL_RED_EXTor GL_RGBAand creates the correct buffers (I checked it by loading these buffers into the texture and executing them, and they looked correct).

I tried to install glPixelStorei(GL_PACK_ALIGNMENT, 1);, but that didn't matter.

I'm on iOS10 and iPhone 6. I did ES2.0, but now tried to switch to ES3.0 in the hope that this would help me solve the problem. This is not true.

I am very grateful for the help in creating the RGB8 buffer, Thank you.

+4
source share
1 answer

According to the OpenGL 3.0 specification, GL_RGB is not a valid value for the format.

https://www.khronos.org/opengles/sdk/docs/man3/html/glReadPixels.xhtml

You may want to either convert it to RGB after retrieving a buffer in GL_RGBA format, or configure your algorithm to compensate for RGBA.

+1
source

Source: https://habr.com/ru/post/1663040/


All Articles