怎么用glReadPixel读取颜色

来源:百度知道 编辑:UC知道 时间:2024/05/27 09:06:30
int color[3];

glReadPixels(x,y,1,1,GL_RGB,GL_INT,color);

为什么这样不行?
搞定,
不过还是谢谢你的回答

glReadPixels
The glReadPixels function reads a block of pixels from the framebuffer.

void glReadPixels(
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLvoid *pixels
);
Parameters
x, y
The window coordinates of the first pixel that is read from the framebuffer. This location is the lower-left corner of a rectangular block of pixels.
width, height
The dimensions of the pixel rectangle. The width and height parameters of one correspond to a single pixel.
format
The format of the pixel data. The following symbolic values are accepted:
GL_COLOR_INDEX
Color indexes are read from the color buffer selected by glReadBuffer. Each index is converted to fixed point, shifted left or right, depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. If GL_MAP_COLOR is GL_TRUE, indexes are replaced by their mappings in the tab