In fact,recently I’d ask a “what” question about it. After reading API documents,I thought it was easy to use. But, it’s not. My question is:“How to use glReadPixels to get color information of a pixel?”
I’ve written a simple test program.The following are parts of it:
…
…
…
glColor3f(1.0,0.0,0.0);
glBegin(GL_QUADS);
glVertex3f(50,50,0);
glVertex3f(100,50,0);
glVertex3f(100,100,0);
glVertex3f(50,100,0);
glEnd();
GLubyte p[3];
glReadPixels(60,
60,
1,
1,
GL_RGB,GL_UNSIGNED_BYTE,
p);
…
…
…
All I want to do is get the RGB value of the point (60,60).However,there is no any value assign to p array.
I’ve tried to search related topics,but,seems it’s too basic,I can’t find it.
Please someone tell me what’s wrong of it.
Thanks!