1
votes

I looked at multiple tutorials about glReadPixels but I'm confused:

void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data)

The last argument is a void? I saw tutorials and they declared the argument as a vector, unsigned char, GLubyte,... But what does it really mean? And do you need to call glPixelStoref( , )?

1

1 Answers

3
votes

A void* is C/C++ speak for "pointer to block of memory". The purpose of glReadPixels is to take some part of the framebuffer and write that pixel data into your memory. The data parameter is the "your memory" that it writes into.

Exactly what it writes and how much depends on the pixel transfer parameters, format and type. That's why it takes a void*; because it could be writing an array of bytes, an array of ints, an array of floats, etc. It all depends on what those two parameters say.