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