// draw objects
board->Draw(true);
// get matrices
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT, viewport);
// convert from windows coordinate system to ogl coordinate system
y = viewport[3] - y;
// convert x,y coordinates to GLfloat
ix = (GLfloat)x; iy = (GLfloat)y;
// read z coordinate
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &iz);
// unproject
gluUnProject(ix, iy, iz, modelview, projection, viewport, &ox, &oy, &oz);