Hi!
I want to do picking with color! I did the following code:
GLint pixel[3];
(void) glRenderMode(GL_SELECT);
glBegin(GL_POINTS);
glPointSize(1);
for(int i=0;i<numVertices;i++){
glColor3ub( i&0xff, (i>>8)&0xff, (i>>16)&0xff );
glVertex3f(vertices[i*3],vertices[i*3+1],vertices[i*3+2]);
}
glEnd();
glReadPixels( xRot_old, yRot_old,1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel );
int t = pixel[0] + pixel[1]*256 + pixel[2]*65536;
But it does not really work! Whats wrong??
Juergen
But it does not really work
Now that was a detailed description of your problem.
A problem I can see is that you pass an array of three integers, but you tell OpenGL that it’s an array of unsigned chars. OpenGL will then store the three components as unsigned characters in the first three bytes of the first integer in the array.
Well, don’t change to GL_SELECT render mode and put glPointsize outside glBegin glEnd.
kon