3
我想弄清楚如何从所选像素中提取RGB值。每次点击它,它都会给我一个0的值,即使我点击一个彩色的三角形。查找像素颜色
void mouse(int button, int state, int x, int y) {
if(state == GLUT_DOWN) {
float mx = p2w_x(x); // pixel to world coordinates
float my = p2w_y(y);
float rgb[3];
glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, rgb);
std::cout << rgb[0] << std::endl; // prints 0 for red always
}
}
没错,使用屏幕缓冲区坐标。 – alxx 2010-10-07 09:46:26