1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
void COpenGLControl::OnLButtonDown(UINT nFlags, CPoint point)
{
// ...
GLuint selectBuf[BUFSIZE];
GLint hits;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFSIZE, selectBuf);
(void) glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
/* create 5x5 pixel picking region near cursor location */
gluPickMatrix((GLdouble) point.x, (GLdouble) (viewport[3] - point.y),
5.0, 5.0, viewport);
glOrtho(-10,10,-10,10,-10,10);
drawRects(GL_SELECT);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glFlush();
hits = glRenderMode(GL_RENDER);
processHits(hits, selectBuf);
//glutPostRedisplay();
CWnd::OnLButtonDown(nFlags, point);
} |
Partager