开发者

how to pick up rgb color value of a pixel from a mouse click

It might be a very naive question but i am a bit stuck. I am writing my first opengl programme and I want to pick up the R value of a pixel, of a point that i got from mouse click. I am clueless about how to use glReadPixels function.

void myMouseFunc( int button, int state, int x, int y ) {
    if ( bu开发者_JS百科tton==GLUT_LEFT_BUTTON && state==GLUT_DOWN ) {

        glReadPixels(x,y,0.1,0.1,GL_RED,GL_INT, pixel);

        glutPostRedisplay();
    }
}


The documentation is pretty clear:

http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml

GLubyte pixel;
glReadPixels(x, windowHeight - y - 1, 1, 1, GL_RED, GL_UNSIGNED_BYTE, &pixel);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜