1

I am new to OpenGLES coding. I am using ES2.0 version. I need to read from the framebuffer, for which I am using glReadPixels. But my filled buffer is having all zeros. I am using ti omapdrm for gl display and surface creation.

My rendering thread looks like this:

glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays ( GL_TRIANGLES, 0, 3 );
glReadPixels(0, 0, width,height, GL_RGB,GL_UNSIGNED_BYTE,pixels);
eglSwapBuffers(gl.display, gl.surface);

My Fragment shader :

void main()                                  
{                                            
    gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );

}

My vertex shader:

void main()                  
{                            
   gl_Position = vPosition;  
}

I am getting the proper output on display, but my glReadPixels is having some issue.

Instead of GL_RGB if I use GL_RGBA I am getting an error:

PVR:(Error): glReadPixels: Failed to get strided data

Any help would be greatly appreciated.

Regards Thushara.

samgak
  • 23,944
  • 4
  • 60
  • 82
  • How did you allocate memory for `pixels`? – elimad May 07 '15 at 06:28
  • Please see if this helps: `glReadPixels() data` argument usage:(http://stackoverflow.com/questions/8841422/glreadpixels-data-argument-usage) – elimad May 07 '15 at 06:43
  • Hi i am allocating like this: pixels = (GLubyte*)malloc(width * height*4); – THUSHARA JAYAKUMAR May 07 '15 at 07:03
  • One thing I observed is that the query for GL_IMPLEMENTATION_COLOR_READ_FORMAT is giving me some value which is not in the supported pixel format in Glut library. It is none of these values: GL_RGBA, GL_RGB, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_LUMINANCE, GL_DEPTH_COMPONENT – THUSHARA JAYAKUMAR May 07 '15 at 07:26
  • You should check GL_IMPLEMENTATION_COLOR_READ_TYPE_OES and GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES. For some implementations they could be GL_RGB and GL_UNSIGNED_SHORT_5_6_5 respectively (the 16 bits per pixel). – Dave May 11 '15 at 20:57

0 Answers0