guju
06-04-2002, 09:56 PM
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
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